prow/cmd/peribolos/main.go
func configureTeam(client editTeamClient, orgName, teamName string, team org.Team, gt github.Team, parent *int) error {
	// Do we need to reconfigure any team settings?
	patch := false
	if gt.Name != teamName {
		patch = true
	}
	gt.Name = teamName
	if team.Description != nil && gt.Description != *team.Description {
		patch = true
		gt.Description = *team.Description
	} else {
		gt.Description = ""
	}
	// doesn't have parent in github, but has parent in config
	if gt.Parent == nil && parent != nil {
		patch = true
		gt.ParentTeamID = parent
	}
	if gt.Parent != nil { // has parent in github ...
		if parent == nil { // ... but doesn't need one
			patch = true
			gt.Parent = nil
			gt.ParentTeamID = parent
		} else if gt.Parent.ID != *parent { // but it's different than the config
			patch = true
			gt.Parent = nil
			gt.ParentTeamID = parent
		}
	}

	if team.Privacy != nil && gt.Privacy != string(*team.Privacy) {
		patch = true
		gt.Privacy = string(*team.Privacy)

	} else if team.Privacy == nil && (parent != nil || len(team.Children) > 0) && gt.Privacy != "closed" {
		patch = true
		gt.Privacy = github.PrivacyClosed // nested teams must be closed
	}

	if patch { // yes we need to patch
		if _, err := client.EditTeam(gt); err != nil {
			return fmt.Errorf("failed to edit %s team %d(%s): %v", orgName, gt.ID, gt.Name, err)
		}
	}
	return nil
}
func configureTeam(client editTeamClient, orgName, teamName string, team org.Team, gt github.Team, parent *int) error {
	// Do we need to reconfigure any team settings?
	patch := false
	if gt.Name != teamName {
		patch = true
	}
	gt.Name = teamName
	if team.Description != nil && gt.Description != *team.Description {
		patch = true
		gt.Description = *team.Description
	} else {
		gt.Description = ""
	}
	// doesn't have parent in github, but has parent in config
	if gt.Parent == nil && parent != nil {
		patch = true
		gt.ParentTeamID = parent
	}
	if gt.Parent != nil { // has parent in github ...
		if parent == nil { // ... but doesn't need one
			patch = true
			gt.Parent = nil
			gt.ParentTeamID = parent
		} else if gt.Parent.ID != *parent { // but it's different than the config
			patch = true
			gt.Parent = nil
			gt.ParentTeamID = parent
		}
	}

	if team.Privacy != nil && gt.Privacy != string(*team.Privacy) {
		patch = true
		gt.Privacy = string(*team.Privacy)

	} else if team.Privacy == nil && (parent != nil || len(team.Children) > 0) && gt.Privacy != "closed" {
		patch = true
		gt.Privacy = github.PrivacyClosed // nested teams must be closed
	}

	if patch { // yes we need to patch
		if _, err := client.EditTeam(gt); err != nil {
			return fmt.Errorf("failed to edit %s team %d(%s): %v", orgName, gt.ID, gt.Name, err)
		}
	}
	return nil
}
func configureTeam ( client editTeamClient , orgName , teamName string , team org . Team , gt github . Team , parent * int ) error { // Do we need to reconfigure any team settings? patch := false if gt . Name != teamName { patch = true } gt . Name = teamName if team . Description != nil && gt . Description != * team . Description { patch = true gt . Description = * team . Description } else { gt . Description = " " } // doesn't have parent in github, but has parent in config if gt . Parent == nil && parent != nil { patch = true gt . ParentTeamID = parent } if gt . Parent != nil { // has parent in github ... if parent == nil { // ... but doesn't need one patch = true gt . Parent = nil gt . ParentTeamID = parent } else if gt . Parent . ID != * parent { // but it's different than the config patch = true gt . Parent = nil gt . ParentTeamID = parent } } if team . Privacy != nil && gt . Privacy != string ( * team . Privacy ) { patch = true gt . Privacy = string ( * team . Privacy ) } else if team . Privacy == nil && ( parent != nil || len ( team . Children ) > 0 ) && gt . Privacy != " " { patch = true gt . Privacy = github . PrivacyClosed // nested teams must be closed } if patch { // yes we need to patch if _ , err := client . EditTeam ( gt ) ; err != nil { return fmt . Errorf ( " " , orgName , gt . ID , gt . Name , err ) } } return nil }
// configureTeam patches the team name/description/privacy when values differ
configureTeam patches the team name / description / privacy when values differ