Skip to content

Commit

Permalink
fixes #447 : robot account read name
Browse files Browse the repository at this point in the history
Signed-off-by: flbla <[email protected]>
  • Loading branch information
flbla committed Jun 21, 2024
1 parent 19b61ac commit a0a3218
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions provider/resource_robot_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,19 @@ 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)

d.Set("name", shortName)
d.Set("robot_id", strconv.Itoa(robot.ID))
d.Set("full_name", robot.Name)
d.Set("description", robot.Description)
Expand Down

0 comments on commit a0a3218

Please sign in to comment.