Skip to content

Commit

Permalink
fixes #464 : project robot account doesnt need admin rights (#466)
Browse files Browse the repository at this point in the history
Signed-off-by: flbla <[email protected]>
  • Loading branch information
flbla authored Oct 23, 2024
1 parent a82baa2 commit 8e20c50
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions provider/resource_robot_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,21 @@ func resourceRobotAccountRead(d *schema.ResourceData, m interface{}) error {
return nil
}

resp, _, respCode, err := apiClient.SendRequest("GET", models.PathConfig, nil, 200)
if respCode == 404 && err != nil {
d.SetId("")
return fmt.Errorf("error getting system configuration %s", err)
}
var systemConfig models.ConfigBodyResponse
err = json.Unmarshal([]byte(resp), &systemConfig)
if err != nil {
return fmt.Errorf("error getting system configuration %s", err)
}

shortName := strings.TrimPrefix(robot.Name, systemConfig.RobotNamePrefix.Value)
var shortName string
if robot.Level == "project" {
shortName = strings.Split(shortName, "+")[1]
shortName = strings.Split(robot.Name, "+")[1]
} else {
resp, _, respCode, err := apiClient.SendRequest("GET", models.PathConfig, nil, 200)
if respCode == 404 && err != nil {
d.SetId("")
return fmt.Errorf("error getting system configuration %s", err)
}
var systemConfig models.ConfigBodyResponse
err = json.Unmarshal([]byte(resp), &systemConfig)
if err != nil {
return fmt.Errorf("error getting system configuration %s", err)
}
shortName = strings.TrimPrefix(robot.Name, systemConfig.RobotNamePrefix.Value)
}

d.Set("name", shortName)
Expand Down

0 comments on commit 8e20c50

Please sign in to comment.