in teamcity/user.go [233:272]
func (r *userResource) update(plan userResourceModel) client.User {
user := client.User{
Username: plan.Username.ValueString(),
}
if plan.Password.IsNull() != true {
password := plan.Password.ValueString()
user.Password = &password
}
if plan.Github.IsNull() != true {
user.Properties = &models.Properties{
Property: []models.Property{
{
Name: "plugin:auth:GitHubApp-oauth:userName",
Value: plan.Github.ValueString(),
},
},
}
}
user.Roles = &client.RoleAssignments{
RoleAssignment: []client.RoleAssignment{},
}
if plan.Roles != nil {
for _, role := range plan.Roles {
assignment := client.RoleAssignment{
Id: role.Id.ValueString(),
}
if role.Global.ValueBool() {
assignment.Scope = "g"
} else {
assignment.Scope = "p:" + role.Project.ValueString()
}
user.Roles.RoleAssignment = append(user.Roles.RoleAssignment, assignment)
}
}
return user
}