func()

in teamcity/user.go [296:324]


func (r *userResource) readState(actual *client.User) userResourceModel {
	var newState userResourceModel
	newState.Id = types.StringValue(strconv.FormatInt(*actual.Id, 10))
	newState.Username = types.StringValue(actual.Username)

	for _, p := range actual.Properties.Property {
		if p.Name == "plugin:auth:GitHubApp-oauth:userName" {
			newState.Github = types.StringValue(p.Value)
			break
		}
	}

	if actual.Roles != nil && len(actual.Roles.RoleAssignment) > 0 {
		newState.Roles = []roleAssignment{}
		for _, role := range actual.Roles.RoleAssignment {
			assignment := roleAssignment{
				Id: types.StringValue(role.Id),
			}
			if role.Scope == "g" {
				assignment.Global = types.BoolValue(role.Scope == "g")
			} else {
				assignment.Project = types.StringValue(role.Scope[2:])
			}
			newState.Roles = append(newState.Roles, assignment)
		}
	}

	return newState
}