diff --git a/main.go b/main.go index 5d16934..dccdfa4 100644 --- a/main.go +++ b/main.go @@ -27,6 +27,8 @@ import ( "github.com/gorilla/mux" ) +const DEFAULT_TEAM_NAME = "default" + type GiteaAccess struct { URL string Username string @@ -1967,8 +1969,7 @@ func handleCreateOrg(w http.ResponseWriter, r *http.Request) { log.Println("Received Org Data:", options) if err := createOrg(access.URL, access.Username, access.Password, options.OrgName); err == nil { - teamName := "default" // must be less than 30 chars - if err := createTeam(access.URL, access.Username, access.Password, options.OrgName, teamName, "Primary Team for "+options.OrgName); err == nil { + if err := createTeam(access.URL, access.Username, access.Password, options.OrgName, DEFAULT_TEAM_NAME, "Primary Team for "+options.OrgName); err == nil { w.WriteHeader(http.StatusCreated) w.Write([]byte("Org created successfully")) } else { @@ -1993,7 +1994,7 @@ func handleOrg(w http.ResponseWriter, r *http.Request) { } func getOrgMembers(giteaBaseURL, adminUsername, adminPassword, orgName string) ([]api.User, error) { - teamID, err := getTeamID(giteaBaseURL, adminUsername, adminPassword, orgName, orgName) + teamID, err := getTeamID(giteaBaseURL, adminUsername, adminPassword, orgName, DEFAULT_TEAM_NAME) if err != nil { return nil, err } @@ -2052,7 +2053,7 @@ func handleAddMember(w http.ResponseWriter, r *http.Request) { orgName := vars["orgName"] userName := vars["userName"] - if err := addUserToTeam(access.URL, access.Username, access.Password, orgName, orgName, userName); err == nil { + if err := addUserToTeam(access.URL, access.Username, access.Password, orgName, DEFAULT_TEAM_NAME, userName); err == nil { // Respond to the client w.WriteHeader(http.StatusCreated) w.Write([]byte("User added to organization"))