Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd: rename gateway client variable. #435

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/agola/cmd/directrunstart.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func parseVariable(variable string) (string, string, error) {
}

func directRunStart(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

for _, res := range directRunStartOpts.prRefRegexes {
if _, err := regexp.Compile(res); err != nil {
Expand Down Expand Up @@ -126,7 +126,7 @@ func directRunStart(cmd *cobra.Command, args []string) error {
return errors.Errorf(`only one of "--branch", "--tag" or "--ref" can be provided`)
}

user, _, err := gwclient.GetCurrentUser(context.TODO())
user, _, err := gwClient.GetCurrentUser(context.TODO())
if err != nil {
return errors.WithStack(err)
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func directRunStart(cmd *cobra.Command, args []string) error {
PullRequestRefRegexes: directRunStartOpts.prRefRegexes,
Variables: variables,
}
if _, err := gwclient.UserCreateRun(context.TODO(), req); err != nil {
if _, err := gwClient.UserCreateRun(context.TODO(), req); err != nil {
return errors.WithStack(err)
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/agola/cmd/logdelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func logDelete(cmd *cobra.Command, args []string) error {
return errors.Errorf("%d is an invalid step number, it must be equal or greater than zero", logDeleteOpts.step)
}

gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

isProject := !flags.Changed("username")

Expand All @@ -103,9 +103,9 @@ func logDelete(cmd *cobra.Command, args []string) error {
var run *gwapitypes.RunResponse
var err error
if isProject {
run, _, err = gwclient.GetProjectRun(context.TODO(), logDeleteOpts.projectRef, logDeleteOpts.runNumber)
run, _, err = gwClient.GetProjectRun(context.TODO(), logDeleteOpts.projectRef, logDeleteOpts.runNumber)
} else {
run, _, err = gwclient.GetUserRun(context.TODO(), logDeleteOpts.username, logDeleteOpts.runNumber)
run, _, err = gwClient.GetUserRun(context.TODO(), logDeleteOpts.username, logDeleteOpts.runNumber)
}
if err != nil {
return errors.WithStack(err)
Expand All @@ -127,9 +127,9 @@ func logDelete(cmd *cobra.Command, args []string) error {

var err error
if isProject {
_, err = gwclient.DeleteProjectLogs(context.TODO(), logDeleteOpts.projectRef, logDeleteOpts.runNumber, taskid, logDeleteOpts.setup, logDeleteOpts.step)
_, err = gwClient.DeleteProjectLogs(context.TODO(), logDeleteOpts.projectRef, logDeleteOpts.runNumber, taskid, logDeleteOpts.setup, logDeleteOpts.step)
} else {
_, err = gwclient.DeleteUserLogs(context.TODO(), logDeleteOpts.username, logDeleteOpts.runNumber, taskid, logDeleteOpts.setup, logDeleteOpts.step)
_, err = gwClient.DeleteUserLogs(context.TODO(), logDeleteOpts.username, logDeleteOpts.runNumber, taskid, logDeleteOpts.setup, logDeleteOpts.step)
}

if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions cmd/agola/cmd/logget.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func logGet(cmd *cobra.Command, args []string) error {
return errors.Errorf(`only one of "--follow" or "--output" can be provided`)
}

gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

isProject := !flags.Changed("username")

Expand All @@ -113,9 +113,9 @@ func logGet(cmd *cobra.Command, args []string) error {
var run *gwapitypes.RunResponse
var err error
if isProject {
run, _, err = gwclient.GetProjectRun(context.TODO(), logGetOpts.projectRef, logGetOpts.runNumber)
run, _, err = gwClient.GetProjectRun(context.TODO(), logGetOpts.projectRef, logGetOpts.runNumber)
} else {
run, _, err = gwclient.GetUserRun(context.TODO(), logGetOpts.username, logGetOpts.runNumber)
run, _, err = gwClient.GetUserRun(context.TODO(), logGetOpts.username, logGetOpts.runNumber)
}
if err != nil {
return errors.WithStack(err)
Expand All @@ -139,9 +139,9 @@ func logGet(cmd *cobra.Command, args []string) error {
var resp *http.Response
var err error
if isProject {
resp, err = gwclient.GetProjectLogs(context.TODO(), logGetOpts.projectRef, logGetOpts.runNumber, taskid, logGetOpts.setup, logGetOpts.step, logGetOpts.follow)
resp, err = gwClient.GetProjectLogs(context.TODO(), logGetOpts.projectRef, logGetOpts.runNumber, taskid, logGetOpts.setup, logGetOpts.step, logGetOpts.follow)
} else {
resp, err = gwclient.GetUserLogs(context.TODO(), logGetOpts.username, logGetOpts.runNumber, taskid, logGetOpts.setup, logGetOpts.step, logGetOpts.follow)
resp, err = gwClient.GetUserLogs(context.TODO(), logGetOpts.username, logGetOpts.runNumber, taskid, logGetOpts.setup, logGetOpts.step, logGetOpts.follow)
}
if err != nil {
return errors.Wrapf(err, "failed to get log")
Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/orgcreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func init() {
}

func orgCreate(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

// TODO(sgotti) make this a custom pflag Value?
if !IsValidVisibility(orgCreateOpts.visibility) {
Expand All @@ -69,7 +69,7 @@ func orgCreate(cmd *cobra.Command, args []string) error {
}

log.Info().Msgf("creating org")
org, _, err := gwclient.CreateOrg(context.TODO(), req)
org, _, err := gwClient.CreateOrg(context.TODO(), req)
if err != nil {
return errors.Wrapf(err, "failed to create org")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/orgdelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ func init() {
}

func orgDelete(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

log.Info().Msgf("deleting organization %q", orgDeleteOpts.name)
if _, err := gwclient.DeleteOrg(context.TODO(), orgDeleteOpts.name); err != nil {
if _, err := gwClient.DeleteOrg(context.TODO(), orgDeleteOpts.name); err != nil {
return errors.Wrapf(err, "failed to delete organization")
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/orgmemberadd.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ func init() {
}

func orgMemberAdd(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

log.Info().Msgf("adding/updating member %q to organization %q with role %q", orgMemberAddOpts.username, orgMemberAddOpts.orgname, orgMemberAddOpts.role)
_, _, err := gwclient.AddOrgMember(context.TODO(), orgMemberAddOpts.orgname, orgMemberAddOpts.username, gwapitypes.MemberRole(orgMemberAddOpts.role))
_, _, err := gwClient.AddOrgMember(context.TODO(), orgMemberAddOpts.orgname, orgMemberAddOpts.username, gwapitypes.MemberRole(orgMemberAddOpts.role))
if err != nil {
return errors.Wrapf(err, "failed to add/update organization member")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/orgmemberlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ func init() {
}

func orgMemberList(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

orgMembers, _, err := gwclient.GetOrgMembers(context.TODO(), orgMemberListOpts.orgname)
orgMembers, _, err := gwClient.GetOrgMembers(context.TODO(), orgMemberListOpts.orgname)
if err != nil {
return errors.Wrapf(err, "failed to get organization member")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/orgmemberremove.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ func init() {
}

func orgMemberRemove(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

log.Info().Msgf("removing member %q from organization %q", orgMemberRemoveOpts.username, orgMemberRemoveOpts.orgname)
_, err := gwclient.RemoveOrgMember(context.TODO(), orgMemberRemoveOpts.orgname, orgMemberRemoveOpts.username)
_, err := gwClient.RemoveOrgMember(context.TODO(), orgMemberRemoveOpts.orgname, orgMemberRemoveOpts.username)
if err != nil {
return errors.Wrapf(err, "failed to remove organization member")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/projectcreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func IsValidVisibility(v string) bool {
}

func projectCreate(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

// TODO(sgotti) make this a custom pflag Value?
if !IsValidVisibility(projectCreateOpts.visibility) {
Expand All @@ -104,7 +104,7 @@ func projectCreate(cmd *cobra.Command, args []string) error {

log.Info().Msgf("creating project")

project, _, err := gwclient.CreateProject(context.TODO(), req)
project, _, err := gwClient.CreateProject(context.TODO(), req)
if err != nil {
return errors.Wrapf(err, "failed to create project")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/projectdelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ func init() {
}

func projectDelete(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

log.Info().Msgf("deleting project")

if _, err := gwclient.DeleteProject(context.TODO(), projectDeleteOpts.ref); err != nil {
if _, err := gwClient.DeleteProject(context.TODO(), projectDeleteOpts.ref); err != nil {
return errors.Wrapf(err, "failed to delete project")
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/projectgroupcreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func init() {
}

func projectGroupCreate(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

// TODO(sgotti) make this a custom pflag Value?
if !IsValidVisibility(projectGroupCreateOpts.visibility) {
Expand All @@ -76,7 +76,7 @@ func projectGroupCreate(cmd *cobra.Command, args []string) error {

log.Info().Msgf("creating project group")

projectGroup, _, err := gwclient.CreateProjectGroup(context.TODO(), req)
projectGroup, _, err := gwClient.CreateProjectGroup(context.TODO(), req)
if err != nil {
return errors.Wrapf(err, "failed to create project group")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/projectgroupdelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ func init() {
}

func projectGroupDelete(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

log.Info().Msgf("deleting project group")

if _, err := gwclient.DeleteProjectGroup(context.TODO(), projectGroupDeleteOpts.ref); err != nil {
if _, err := gwClient.DeleteProjectGroup(context.TODO(), projectGroupDeleteOpts.ref); err != nil {
return errors.Wrapf(err, "failed to delete project group")
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/projectgroupupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func init() {
}

func projectGroupUpdate(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

req := &gwapitypes.UpdateProjectGroupRequest{}

Expand All @@ -80,7 +80,7 @@ func projectGroupUpdate(cmd *cobra.Command, args []string) error {
}

log.Info().Msgf("updating project group")
projectGroup, _, err := gwclient.UpdateProjectGroup(context.TODO(), projectGroupUpdateOpts.ref, req)
projectGroup, _, err := gwClient.UpdateProjectGroup(context.TODO(), projectGroupUpdateOpts.ref, req)
if err != nil {
return errors.Wrapf(err, "failed to update project group")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/projectlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ func printProjects(projects []*gwapitypes.ProjectResponse) {
}

func projectList(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

projects, _, err := gwclient.GetProjectGroupProjects(context.TODO(), projectListOpts.parentPath)
projects, _, err := gwClient.GetProjectGroupProjects(context.TODO(), projectListOpts.parentPath)
if err != nil {
return errors.WithStack(err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/projectreconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ func init() {
}

func projectReconfig(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

log.Info().Msgf("reconfiguring remote project")
if _, err := gwclient.ReconfigProject(context.TODO(), projectReconfigOpts.name); err != nil {
if _, err := gwClient.ReconfigProject(context.TODO(), projectReconfigOpts.name); err != nil {
return errors.Wrapf(err, "failed to reconfigure remote project")
}
log.Info().Msgf("project reconfigured")
Expand Down
6 changes: 3 additions & 3 deletions cmd/agola/cmd/projectsecretcreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func init() {
}

func secretCreate(cmd *cobra.Command, ownertype string, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

// "github.com/ghodss/yaml" doesn't provide a streaming decoder
var data []byte
Expand Down Expand Up @@ -104,14 +104,14 @@ func secretCreate(cmd *cobra.Command, ownertype string, args []string) error {
switch ownertype {
case "project":
log.Info().Msgf("creating project secret")
secret, _, err := gwclient.CreateProjectSecret(context.TODO(), secretCreateOpts.parentRef, req)
secret, _, err := gwClient.CreateProjectSecret(context.TODO(), secretCreateOpts.parentRef, req)
if err != nil {
return errors.Wrapf(err, "failed to create project secret")
}
log.Info().Msgf("project secret %q created, ID: %q", secret.Name, secret.ID)
case "projectgroup":
log.Info().Msgf("creating project group secret")
secret, _, err := gwclient.CreateProjectGroupSecret(context.TODO(), secretCreateOpts.parentRef, req)
secret, _, err := gwClient.CreateProjectGroupSecret(context.TODO(), secretCreateOpts.parentRef, req)
if err != nil {
return errors.Wrapf(err, "failed to create project group secret")
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/agola/cmd/projectsecretdelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,19 @@ func init() {
}

func secretDelete(cmd *cobra.Command, ownertype string, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

switch ownertype {
case "project":
log.Info().Msgf("deleting project secret")
_, err := gwclient.DeleteProjectSecret(context.TODO(), secretDeleteOpts.parentRef, secretDeleteOpts.name)
_, err := gwClient.DeleteProjectSecret(context.TODO(), secretDeleteOpts.parentRef, secretDeleteOpts.name)
if err != nil {
return errors.Wrapf(err, "failed to delete project secret")
}
log.Info().Msgf("project secret deleted")
case "projectgroup":
log.Info().Msgf("deleting project group secret")
_, err := gwclient.DeleteProjectGroupSecret(context.TODO(), secretDeleteOpts.parentRef, secretDeleteOpts.name)
_, err := gwClient.DeleteProjectGroupSecret(context.TODO(), secretDeleteOpts.parentRef, secretDeleteOpts.name)
if err != nil {
return errors.Wrapf(err, "failed to delete project group secret")
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/agola/cmd/projectsecretlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ func printSecrets(ownertype, description string, tree, removeoverridden bool) er
var err error
var secrets []*gwapitypes.SecretResponse

gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

switch ownertype {
case "project":
secrets, _, err = gwclient.GetProjectSecrets(context.TODO(), secretListOpts.parentRef, tree, removeoverridden)
secrets, _, err = gwClient.GetProjectSecrets(context.TODO(), secretListOpts.parentRef, tree, removeoverridden)
case "projectgroup":
secrets, _, err = gwclient.GetProjectGroupSecrets(context.TODO(), secretListOpts.parentRef, tree, removeoverridden)
secrets, _, err = gwClient.GetProjectGroupSecrets(context.TODO(), secretListOpts.parentRef, tree, removeoverridden)
}
if err != nil {
return errors.Wrapf(err, "failed to list %s secrets", ownertype)
Expand Down
6 changes: 3 additions & 3 deletions cmd/agola/cmd/projectsecretupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func init() {
}

func secretUpdate(cmd *cobra.Command, ownertype string, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

// "github.com/ghodss/yaml" doesn't provide a streaming decoder
var data []byte
Expand Down Expand Up @@ -111,14 +111,14 @@ func secretUpdate(cmd *cobra.Command, ownertype string, args []string) error {
switch ownertype {
case "project":
log.Info().Msgf("creating project secret")
secret, _, err := gwclient.UpdateProjectSecret(context.TODO(), secretUpdateOpts.parentRef, secretUpdateOpts.name, req)
secret, _, err := gwClient.UpdateProjectSecret(context.TODO(), secretUpdateOpts.parentRef, secretUpdateOpts.name, req)
if err != nil {
return errors.Wrapf(err, "failed to update project secret")
}
log.Info().Msgf("project secret %q updated, ID: %q", secret.Name, secret.ID)
case "projectgroup":
log.Info().Msgf("creating project group secret")
secret, _, err := gwclient.UpdateProjectGroupSecret(context.TODO(), secretUpdateOpts.parentRef, secretUpdateOpts.name, req)
secret, _, err := gwClient.UpdateProjectGroupSecret(context.TODO(), secretUpdateOpts.parentRef, secretUpdateOpts.name, req)
if err != nil {
return errors.Wrapf(err, "failed to update project group secret")
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/agola/cmd/projectupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func init() {
}

func projectUpdate(cmd *cobra.Command, args []string) error {
gwclient := gwclient.NewClient(gatewayURL, token)
gwClient := gwclient.NewClient(gatewayURL, token)

req := &gwapitypes.UpdateProjectRequest{}

Expand All @@ -86,7 +86,7 @@ func projectUpdate(cmd *cobra.Command, args []string) error {
}

log.Info().Msgf("updating project")
project, _, err := gwclient.UpdateProject(context.TODO(), projectUpdateOpts.ref, req)
project, _, err := gwClient.UpdateProject(context.TODO(), projectUpdateOpts.ref, req)
if err != nil {
return errors.Wrapf(err, "failed to update project")
}
Expand Down
Loading