diff --git a/cmd/deploy.go b/cmd/deploy.go index 75e5cf96..75becd29 100644 --- a/cmd/deploy.go +++ b/cmd/deploy.go @@ -3,12 +3,13 @@ package cmd import ( "context" "fmt" - lclient "github.com/uselagoon/machinery/api/lagoon/client" "strconv" + lclient "github.com/uselagoon/machinery/api/lagoon/client" + "github.com/spf13/cobra" - l "github.com/uselagoon/machinery/api/lagoon" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/schema" ) var deployCmd = &cobra.Command{ @@ -66,7 +67,7 @@ use 'lagoon deploy latest' instead`, lagoonCLIConfig.Lagoons[current].Version, &token, debug) - depBranch := &ls.DeployEnvironmentBranchInput{ + depBranch := &schema.DeployEnvironmentBranchInput{ Branch: branch, Project: cmdProjectName, ReturnData: returnData, @@ -75,7 +76,7 @@ use 'lagoon deploy latest' instead`, if branchRef != "" { depBranch.BranchRef = branchRef } - result, err := l.DeployBranch(context.TODO(), depBranch, lc) + result, err := lagoon.DeployBranch(context.TODO(), depBranch, lc) if err != nil { return err } @@ -132,7 +133,7 @@ var deployPromoteCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.DeployPromote(context.TODO(), &ls.DeployEnvironmentPromoteInput{ + result, err := lagoon.DeployPromote(context.TODO(), &schema.DeployEnvironmentPromoteInput{ SourceEnvironment: sourceEnvironment, DestinationEnvironment: destinationEnvironment, Project: cmdProjectName, @@ -187,10 +188,10 @@ This environment should already exist in lagoon. It is analogous with the 'Deplo lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.DeployLatest(context.TODO(), &ls.DeployEnvironmentLatestInput{ - Environment: ls.EnvironmentInput{ + result, err := lagoon.DeployLatest(context.TODO(), &schema.DeployEnvironmentLatestInput{ + Environment: schema.EnvironmentInput{ Name: cmdProjectEnvironment, - Project: ls.ProjectInput{ + Project: schema.ProjectInput{ Name: cmdProjectName, }, }, @@ -271,8 +272,8 @@ This pullrequest may not already exist as an environment in lagoon.`, &token, debug) - result, err := l.DeployPullRequest(context.TODO(), &ls.DeployEnvironmentPullrequestInput{ - Project: ls.ProjectInput{ + result, err := lagoon.DeployPullRequest(context.TODO(), &schema.DeployEnvironmentPullrequestInput{ + Project: schema.ProjectInput{ Name: cmdProjectName, }, Title: prTitle, diff --git a/cmd/deploytarget.go b/cmd/deploytarget.go index d66eedbe..b4f9d27e 100644 --- a/cmd/deploytarget.go +++ b/cmd/deploytarget.go @@ -7,9 +7,9 @@ import ( "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" ) var addDeployTargetCmd = &cobra.Command{ @@ -66,7 +66,7 @@ var addDeployTargetCmd = &cobra.Command{ return err } - addDeployTarget := &ls.AddDeployTargetInput{ + addDeployTarget := &schema.AddDeployTargetInput{ Name: name, FriendlyName: friendlyName, CloudProvider: cloudProvider, @@ -99,7 +99,7 @@ var addDeployTargetCmd = &cobra.Command{ debug) if yesNo(fmt.Sprintf("You are attempting to add '%s' DeployTarget, are you sure?", addDeployTarget.Name)) { - addDeployTargetResponse, err := l.AddDeployTarget(context.TODO(), addDeployTarget, lc) + addDeployTargetResponse, err := lagoon.AddDeployTarget(context.TODO(), addDeployTarget, lc) if err != nil { return err } @@ -216,8 +216,8 @@ var updateDeployTargetCmd = &cobra.Command{ &lagoonToken, debug) - updateDeployTarget := &ls.UpdateDeployTargetInput{ - AddDeployTargetInput: ls.AddDeployTargetInput{ + updateDeployTarget := &schema.UpdateDeployTargetInput{ + AddDeployTargetInput: schema.AddDeployTargetInput{ ID: id, Token: token, FriendlyName: friendlyName, @@ -231,7 +231,7 @@ var updateDeployTargetCmd = &cobra.Command{ BuildImage: buildImage, } if yesNo(fmt.Sprintf("You are attempting to update '%d' DeployTarget, are you sure?", updateDeployTarget.ID)) { - updateDeployTargetResponse, err := l.UpdateDeployTarget(context.TODO(), updateDeployTarget, lc) + updateDeployTargetResponse, err := lagoon.UpdateDeployTarget(context.TODO(), updateDeployTarget, lc) if err != nil { return err } @@ -307,11 +307,11 @@ var deleteDeployTargetCmd = &cobra.Command{ &token, debug) - deleteDeployTarget := &ls.DeleteDeployTargetInput{ + deleteDeployTarget := &schema.DeleteDeployTargetInput{ Name: name, } if yesNo(fmt.Sprintf("You are attempting to delete DeployTarget '%s', are you sure?", deleteDeployTarget.Name)) { - deleteDeployTargetResponse, err := l.DeleteDeployTarget(context.TODO(), deleteDeployTarget, lc) + deleteDeployTargetResponse, err := lagoon.DeleteDeployTarget(context.TODO(), deleteDeployTarget, lc) if err != nil { return err } @@ -358,7 +358,7 @@ var addDeployTargetToOrganizationCmd = &cobra.Command{ &token, debug) - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } @@ -366,12 +366,12 @@ var addDeployTargetToOrganizationCmd = &cobra.Command{ return fmt.Errorf("error querying organization by name") } - deployTargetInput := ls.AddDeployTargetToOrganizationInput{ + deployTargetInput := schema.AddDeployTargetToOrganizationInput{ DeployTarget: deploytarget, Organization: organization.ID, } - deployTargetResponse, err := l.AddDeployTargetToOrganization(context.TODO(), &deployTargetInput, lc) + deployTargetResponse, err := lagoon.AddDeployTargetToOrganization(context.TODO(), &deployTargetInput, lc) if err != nil { return err } @@ -422,7 +422,7 @@ var removeDeployTargetFromOrganizationCmd = &cobra.Command{ &token, debug) - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } @@ -430,13 +430,13 @@ var removeDeployTargetFromOrganizationCmd = &cobra.Command{ return fmt.Errorf("error querying organization by name") } - deployTargetInput := ls.RemoveDeployTargetFromOrganizationInput{ + deployTargetInput := schema.RemoveDeployTargetFromOrganizationInput{ DeployTarget: deploytarget, Organization: organization.ID, } if yesNo(fmt.Sprintf("You are attempting to remove deploy target '%d' from organization '%s', are you sure?", deploytarget, organization.Name)) { - _, err := l.RemoveDeployTargetFromOrganization(context.TODO(), &deployTargetInput, lc) + _, err := lagoon.RemoveDeployTargetFromOrganization(context.TODO(), &deployTargetInput, lc) if err != nil { return err } diff --git a/cmd/deploytargetconfig.go b/cmd/deploytargetconfig.go index 9be9892c..cb4465f3 100644 --- a/cmd/deploytargetconfig.go +++ b/cmd/deploytargetconfig.go @@ -4,11 +4,12 @@ import ( "context" "fmt" - l "github.com/uselagoon/machinery/api/lagoon" - lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" "strconv" + "github.com/uselagoon/machinery/api/lagoon" + lclient "github.com/uselagoon/machinery/api/lagoon/client" + "github.com/uselagoon/machinery/api/schema" + "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" ) @@ -56,11 +57,11 @@ var addDeployTargetConfigCmd = &cobra.Command{ &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - addDeployTargetConfig := &ls.AddDeployTargetConfigInput{ + addDeployTargetConfig := &schema.AddDeployTargetConfigInput{ Project: project.ID, Weight: weight, } @@ -74,7 +75,7 @@ var addDeployTargetConfigCmd = &cobra.Command{ addDeployTargetConfig.DeployTarget = deploytarget } if yesNo(fmt.Sprintf("You are attempting to add a deploytarget configuration to project '%s', are you sure?", cmdProjectName)) { - deployTargetConfig, err := l.AddDeployTargetConfiguration(context.TODO(), addDeployTargetConfig, lc) + deployTargetConfig, err := lagoon.AddDeployTargetConfiguration(context.TODO(), addDeployTargetConfig, lc) if err != nil { return err } @@ -153,7 +154,7 @@ var updateDeployTargetConfigCmd = &cobra.Command{ &token, debug) - updateDeployTargetConfig := &ls.UpdateDeployTargetConfigInput{ + updateDeployTargetConfig := &schema.UpdateDeployTargetConfigInput{ ID: id, Weight: weight, } @@ -168,7 +169,7 @@ var updateDeployTargetConfigCmd = &cobra.Command{ } if yesNo(fmt.Sprintf("You are attempting to update a deploytarget configuration with id '%d', are you sure?", id)) { - deployTargetConfig, err := l.UpdateDeployTargetConfiguration(context.TODO(), updateDeployTargetConfig, lc) + deployTargetConfig, err := lagoon.UpdateDeployTargetConfiguration(context.TODO(), updateDeployTargetConfig, lc) if err != nil { return err } @@ -231,7 +232,7 @@ var deleteDeployTargetConfigCmd = &cobra.Command{ &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -242,7 +243,7 @@ var deleteDeployTargetConfigCmd = &cobra.Command{ } if yesNo(fmt.Sprintf("You are attempting to delete deploytarget configuration with id '%d' from project '%s', are you sure?", id, cmdProjectName)) { - result, err := l.DeleteDeployTargetConfiguration(context.TODO(), int(id), int(project.ID), lc) + result, err := lagoon.DeleteDeployTargetConfiguration(context.TODO(), int(id), int(project.ID), lc) if err != nil { return err } @@ -279,7 +280,7 @@ var listDeployTargetConfigsCmd = &cobra.Command{ &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -288,7 +289,7 @@ var listDeployTargetConfigsCmd = &cobra.Command{ output.RenderError(outputOptions.Error, outputOptions) return nil } - deployTargetConfigs, err := l.GetDeployTargetConfigs(context.TODO(), int(project.ID), lc) + deployTargetConfigs, err := lagoon.GetDeployTargetConfigs(context.TODO(), int(project.ID), lc) if err != nil { return err } diff --git a/cmd/environment.go b/cmd/environment.go index 1ae3530b..7875b94f 100644 --- a/cmd/environment.go +++ b/cmd/environment.go @@ -3,13 +3,14 @@ package cmd import ( "context" "fmt" - ls "github.com/uselagoon/machinery/api/schema" "strings" + "github.com/uselagoon/machinery/api/schema" + "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/uselagoon/lagoon-cli/pkg/output" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" ) @@ -42,7 +43,7 @@ var deleteEnvCmd = &cobra.Command{ &token, debug) if yesNo(fmt.Sprintf("You are attempting to delete environment '%s' from project '%s', are you sure?", cmdProjectEnvironment, cmdProjectName)) { - environment, err := l.DeleteEnvironment(context.TODO(), cmdProjectEnvironment, cmdProjectName, true, lc) + environment, err := lagoon.DeleteEnvironment(context.TODO(), cmdProjectEnvironment, cmdProjectName, true, lc) if err != nil { return err } @@ -118,14 +119,14 @@ var updateEnvironmentCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if project.Name == "" { err = fmt.Errorf("project not found") } if err != nil { return err } - environment, err := l.GetEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc) + environment, err := lagoon.GetEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc) if environment.Name == "" { err = fmt.Errorf("environment not found") } @@ -133,7 +134,7 @@ var updateEnvironmentCmd = &cobra.Command{ return err } - environmentFlags := ls.UpdateEnvironmentPatchInput{ + environmentFlags := schema.UpdateEnvironmentPatchInput{ DeployBaseRef: nullStrCheck(deployBaseRef), DeployHeadRef: nullStrCheck(deployHeadRef), OpenshiftProjectName: nullStrCheck(namespace), @@ -146,21 +147,21 @@ var updateEnvironmentCmd = &cobra.Command{ environmentFlags.AutoIdle = &environmentAutoIdle } if environmentType != "" { - envType := ls.EnvType(strings.ToUpper(environmentType)) - if validationErr := ls.ValidateType(envType); validationErr != nil { + envType := schema.EnvType(strings.ToUpper(environmentType)) + if validationErr := schema.ValidateType(envType); validationErr != nil { handleError(validationErr) } environmentFlags.EnvironmentType = &envType } if deployT != "" { - deployType := ls.DeployType(strings.ToUpper(deployT)) - if validationErr := ls.ValidateType(deployType); validationErr != nil { + deployType := schema.DeployType(strings.ToUpper(deployT)) + if validationErr := schema.ValidateType(deployType); validationErr != nil { handleError(validationErr) } environmentFlags.DeployType = &deployType } - result, err := l.UpdateEnvironment(context.TODO(), environment.ID, environmentFlags, lc) + result, err := lagoon.UpdateEnvironment(context.TODO(), environment.ID, environmentFlags, lc) if err != nil { return err } @@ -207,11 +208,11 @@ var listBackupsCmd = &cobra.Command{ &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - backupsResult, err := l.GetBackupsForEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc) + backupsResult, err := lagoon.GetBackupsForEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc) if err != nil { return err } @@ -277,11 +278,11 @@ This returns a direct URL to the backup, this is a signed download link with a l &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - backupsResult, err := l.GetBackupsForEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc) + backupsResult, err := lagoon.GetBackupsForEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc) if err != nil { return err } diff --git a/cmd/get.go b/cmd/get.go index 648b730b..d4b9d936 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -11,7 +11,7 @@ import ( "github.com/spf13/pflag" "github.com/uselagoon/lagoon-cli/pkg/output" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" ) @@ -68,7 +68,7 @@ var getProjectCmd = &cobra.Command{ &token, debug) - project, err := l.GetProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -163,7 +163,7 @@ This returns information about a deployment, the logs of this build can also be lagoonCLIConfig.Lagoons[current].Version, &token, debug) - deployment, err := l.GetDeploymentByName(context.TODO(), cmdProjectName, cmdProjectEnvironment, buildName, showLogs, lc) + deployment, err := lagoon.GetDeploymentByName(context.TODO(), cmdProjectName, cmdProjectEnvironment, buildName, showLogs, lc) if err != nil { return err } @@ -228,11 +228,11 @@ var getEnvironmentCmd = &cobra.Command{ &token, debug) - project, err := l.GetProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - environment, err := l.GetEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc) + environment, err := lagoon.GetEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc) if err != nil { return err } @@ -286,7 +286,7 @@ var getProjectKeyCmd = &cobra.Command{ &token, debug) - projectKey, err := l.GetProjectKeyByName(context.TODO(), cmdProjectName, revealValue, lc) + projectKey, err := lagoon.GetProjectKeyByName(context.TODO(), cmdProjectName, revealValue, lc) if err != nil { return err } @@ -360,7 +360,7 @@ var getOrganizationCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } diff --git a/cmd/groups.go b/cmd/groups.go index ff702f0f..57a5184a 100644 --- a/cmd/groups.go +++ b/cmd/groups.go @@ -7,9 +7,9 @@ import ( "slices" "strings" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -69,27 +69,27 @@ var addGroupCmd = &cobra.Command{ debug) if organizationName != "" { - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } if organization.Name == "" { return fmt.Errorf("error querying organization by name") } - groupInput := ls.AddGroupToOrganizationInput{ + groupInput := schema.AddGroupToOrganizationInput{ Name: groupName, Organization: organization.ID, AddOrgOwner: orgOwner, } - _, err = l.AddGroupToOrganization(context.TODO(), &groupInput, lc) + _, err = lagoon.AddGroupToOrganization(context.TODO(), &groupInput, lc) if err != nil { return err } } else { - groupInput := ls.AddGroupInput{ + groupInput := schema.AddGroupInput{ Name: groupName, } - _, err = l.AddGroup(context.TODO(), &groupInput, lc) + _, err = lagoon.AddGroup(context.TODO(), &groupInput, lc) if err != nil { return err } @@ -164,12 +164,12 @@ var addUserToGroupCmd = &cobra.Command{ &token, debug) - userGroupRole := &ls.UserGroupRoleInput{ + userGroupRole := &schema.UserGroupRoleInput{ UserEmail: userEmail, GroupName: groupName, - GroupRole: ls.GroupRole(groupRole), + GroupRole: schema.GroupRole(groupRole), } - _, err = l.AddUserToGroup(context.TODO(), userGroupRole, lc) + _, err = lagoon.AddUserToGroup(context.TODO(), userGroupRole, lc) if err != nil { return err } @@ -199,11 +199,11 @@ var addProjectToGroupCmd = &cobra.Command{ return err } - projectGroup := &ls.ProjectGroupsInput{ - Project: ls.ProjectInput{ + projectGroup := &schema.ProjectGroupsInput{ + Project: schema.ProjectInput{ Name: cmdProjectName, }, - Groups: []ls.GroupInput{ + Groups: []schema.GroupInput{ { Name: groupName, }, @@ -219,13 +219,13 @@ var addProjectToGroupCmd = &cobra.Command{ &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if len(project.Name) == 0 { outputOptions.Error = fmt.Sprintf("Project '%s' not found", cmdProjectName) output.RenderError(outputOptions.Error, outputOptions) return nil } - _, err = l.AddProjectToGroup(context.TODO(), projectGroup, lc) + _, err = lagoon.AddProjectToGroup(context.TODO(), projectGroup, lc) if err != nil { return err } @@ -260,7 +260,7 @@ var deleteUserFromGroupCmd = &cobra.Command{ return err } - user := &ls.UserGroupInput{ + user := &schema.UserGroupInput{ UserEmail: userEmail, GroupName: groupName, } @@ -275,7 +275,7 @@ var deleteUserFromGroupCmd = &cobra.Command{ debug) if yesNo(fmt.Sprintf("You are attempting to delete user '%s' from group '%s', are you sure?", userEmail, groupName)) { - result, err := l.RemoveUserFromGroup(context.TODO(), user, lc) + result, err := lagoon.RemoveUserFromGroup(context.TODO(), user, lc) if err != nil { return err } @@ -309,11 +309,11 @@ var deleteProjectFromGroupCmd = &cobra.Command{ return err } - projectGroup := &ls.ProjectGroupsInput{ - Project: ls.ProjectInput{ + projectGroup := &schema.ProjectGroupsInput{ + Project: schema.ProjectInput{ Name: cmdProjectName, }, - Groups: []ls.GroupInput{ + Groups: []schema.GroupInput{ { Name: groupName, }, @@ -329,7 +329,7 @@ var deleteProjectFromGroupCmd = &cobra.Command{ &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if len(project.Name) == 0 { outputOptions.Error = fmt.Sprintf("Project '%s' not found", cmdProjectName) output.RenderError(outputOptions.Error, outputOptions) @@ -337,7 +337,7 @@ var deleteProjectFromGroupCmd = &cobra.Command{ } if yesNo(fmt.Sprintf("You are attempting to delete project '%s' from group '%s', are you sure?", projectGroup.Project.Name, projectGroup.Groups[0].Name)) { - _, err = l.RemoveGroupsFromProject(context.TODO(), projectGroup, lc) + _, err = lagoon.RemoveGroupsFromProject(context.TODO(), projectGroup, lc) if err != nil { return err } @@ -374,7 +374,7 @@ var deleteGroupCmd = &cobra.Command{ debug) if yesNo(fmt.Sprintf("You are attempting to delete group '%s', are you sure?", groupName)) { - _, err := l.DeleteGroup(context.TODO(), groupName, lc) + _, err := lagoon.DeleteGroup(context.TODO(), groupName, lc) if err != nil { return err } diff --git a/cmd/list.go b/cmd/list.go index 48d93e18..11b94005 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -7,9 +7,9 @@ import ( "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" ) // ListFlags . @@ -48,7 +48,7 @@ var listProjectsCmd = &cobra.Command{ &token, debug) - projects, err := l.ListAllProjects(context.TODO(), lc) + projects, err := lagoon.ListAllProjects(context.TODO(), lc) if err != nil { return err } @@ -104,7 +104,7 @@ var listDeployTargetsCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - deploytargets, err := l.ListDeployTargets(context.TODO(), lc) + deploytargets, err := lagoon.ListDeployTargets(context.TODO(), lc) if err != nil { return err } @@ -169,7 +169,7 @@ var listGroupsCmd = &cobra.Command{ &token, debug) - groups, err := l.ListAllGroups(context.TODO(), lc) + groups, err := lagoon.ListAllGroups(context.TODO(), lc) if err != nil { return err } @@ -229,15 +229,15 @@ var listGroupProjectsCmd = &cobra.Command{ &token, debug) - var groupProjects *[]ls.Group + var groupProjects *[]schema.Group if listAllProjects { - groupProjects, err = l.GetGroupProjects(context.TODO(), "", lc) + groupProjects, err = lagoon.GetGroupProjects(context.TODO(), "", lc) if err != nil { return err } } else { - groupProjects, err = l.GetGroupProjects(context.TODO(), groupName, lc) + groupProjects, err = lagoon.GetGroupProjects(context.TODO(), groupName, lc) if err != nil { return err } @@ -300,7 +300,7 @@ var listEnvironmentsCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - environments, err := l.GetEnvironmentsByProjectName(context.TODO(), cmdProjectName, lc) + environments, err := lagoon.GetEnvironmentsByProjectName(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -361,11 +361,11 @@ var listVariablesCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - in := &ls.EnvVariableByProjectEnvironmentNameInput{ + in := &schema.EnvVariableByProjectEnvironmentNameInput{ Project: cmdProjectName, Environment: cmdProjectEnvironment, } - envvars, err := l.GetEnvVariablesByProjectEnvironmentName(context.TODO(), in, lc) + envvars, err := lagoon.GetEnvVariablesByProjectEnvironmentName(context.TODO(), in, lc) if err != nil { return err } @@ -437,12 +437,12 @@ var listDeploymentsCmd = &cobra.Command{ &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - deployments, err := l.GetDeploymentsByEnvironment(context.TODO(), project.ID, cmdProjectEnvironment, lc) + deployments, err := lagoon.GetDeploymentsByEnvironment(context.TODO(), project.ID, cmdProjectEnvironment, lc) if err != nil { return err } @@ -497,12 +497,12 @@ var listTasksCmd = &cobra.Command{ &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - tasks, err := l.GetTasksByEnvironment(context.TODO(), project.ID, cmdProjectEnvironment, lc) + tasks, err := lagoon.GetTasksByEnvironment(context.TODO(), project.ID, cmdProjectEnvironment, lc) if err != nil { return err } @@ -539,7 +539,7 @@ var listUsersCmd = &cobra.Command{ Short: "List all users in groups", Long: `List all users in groups in lagoon, this only shows users that are in groups. If no group name is provided, all groups are queried. -Without a group name, this query may time out in large Lagoon installs.`, +Without a group name, this query may time out in large Lagoon instalschema.`, PreRunE: func(_ *cobra.Command, _ []string) error { return validateTokenE(cmdLagoon) }, @@ -563,7 +563,7 @@ Without a group name, this query may time out in large Lagoon installs.`, data := []output.Data{} if groupName != "" { // if a groupName is provided, use the groupbyname resolver - groupMembers, err := l.ListGroupMembers(context.TODO(), groupName, lc) + groupMembers, err := lagoon.ListGroupMembers(context.TODO(), groupName, lc) if err != nil { return err } @@ -577,7 +577,7 @@ Without a group name, this query may time out in large Lagoon installs.`, } } else { // otherwise allgroups query - groupMembers, err := l.ListAllGroupMembers(context.TODO(), groupName, lc) + groupMembers, err := lagoon.ListAllGroupMembers(context.TODO(), groupName, lc) if err != nil { return err } @@ -627,7 +627,7 @@ This query can take a long time to run if there are a lot of users.`, lagoonCLIConfig.Lagoons[current].Version, &token, debug) - allUsers, err := l.AllUsers(context.TODO(), ls.AllUsersFilter{ + allUsers, err := lagoon.AllUsers(context.TODO(), schema.AllUsersFilter{ Email: emailAddress, }, lc) if err != nil { @@ -680,7 +680,7 @@ var listUsersGroupsCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - allUsers, err := l.GetUserByEmail(context.TODO(), emailAddress, lc) + allUsers, err := lagoon.GetUserByEmail(context.TODO(), emailAddress, lc) if err != nil { return err } @@ -728,11 +728,11 @@ var listInvokableTasks = &cobra.Command{ &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - tasks, err := l.GetInvokableAdvancedTaskDefinitionsByEnvironment(context.TODO(), project.ID, cmdProjectEnvironment, lc) + tasks, err := lagoon.GetInvokableAdvancedTaskDefinitionsByEnvironment(context.TODO(), project.ID, cmdProjectEnvironment, lc) if err != nil { return err } @@ -790,7 +790,7 @@ var listProjectGroupsCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - projectGroups, err := l.GetProjectGroups(context.TODO(), cmdProjectName, lc) + projectGroups, err := lagoon.GetProjectGroups(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -849,14 +849,14 @@ var listOrganizationProjectsCmd = &cobra.Command{ &token, debug) - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } if organization.Name == "" { return fmt.Errorf("error querying organization by name") } - orgProjects, err := l.ListProjectsByOrganizationID(context.TODO(), organization.ID, lc) + orgProjects, err := lagoon.ListProjectsByOrganizationID(context.TODO(), organization.ID, lc) if err != nil { return err } @@ -911,14 +911,14 @@ var listOrganizationGroupsCmd = &cobra.Command{ &token, debug) - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } if organization.Name == "" { return fmt.Errorf("error querying organization by name") } - orgGroups, err := l.ListGroupsByOrganizationID(context.TODO(), organization.ID, lc) + orgGroups, err := lagoon.ListGroupsByOrganizationID(context.TODO(), organization.ID, lc) if err != nil { return err } @@ -976,7 +976,7 @@ var listOrganizationDeployTargetsCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - deployTargets, err := l.ListDeployTargetsByOrganizationNameOrID(context.TODO(), nullStrCheck(organizationName), nullUintCheck(organizationID), lc) + deployTargets, err := lagoon.ListDeployTargetsByOrganizationNameOrID(context.TODO(), nullStrCheck(organizationName), nullUintCheck(organizationID), lc) if err != nil { return err } @@ -1033,14 +1033,14 @@ var ListOrganizationUsersCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - organization, err := l.GetOrganizationByName(context.Background(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.Background(), organizationName, lc) if err != nil { return err } if organization.Name == "" { return fmt.Errorf("error querying organization by name") } - users, err := l.UsersByOrganization(context.TODO(), organization.ID, lc) + users, err := lagoon.UsersByOrganization(context.TODO(), organization.ID, lc) if err != nil { return err } @@ -1087,7 +1087,7 @@ var listOrganizationsCmd = &cobra.Command{ &token, debug) - organizations, err := l.AllOrganizations(context.TODO(), lc) + organizations, err := lagoon.AllOrganizations(context.TODO(), lc) if err != nil { return err } diff --git a/cmd/notificationsemail.go b/cmd/notificationsemail.go index 399503ac..bdd62a1a 100644 --- a/cmd/notificationsemail.go +++ b/cmd/notificationsemail.go @@ -7,9 +7,9 @@ import ( "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" ) var addNotificationEmailCmd = &cobra.Command{ @@ -52,13 +52,13 @@ It does not configure a project to send notifications to email though, you need &token, debug) - notification := ls.AddNotificationEmailInput{ + notification := schema.AddNotificationEmailInput{ Name: name, EmailAddress: email, Organization: &organizationID, } - result, err := l.AddNotificationEmail(context.TODO(), ¬ification, lc) + result, err := lagoon.AddNotificationEmail(context.TODO(), ¬ification, lc) if err != nil { return err } @@ -69,7 +69,7 @@ It does not configure a project to send notifications to email though, you need returnNonEmptyString(fmt.Sprintf("%v", result.EmailAddress)), } if result.Organization != nil { - organization, err := l.GetOrganizationByID(context.TODO(), organizationID, lc) + organization, err := lagoon.GetOrganizationByID(context.TODO(), organizationID, lc) if err != nil { return err } @@ -123,12 +123,12 @@ This command is used to add an existing email notification in Lagoon to a projec lagoonCLIConfig.Lagoons[current].Version, &token, debug) - notification := &ls.AddNotificationToProjectInput{ - NotificationType: ls.EmailNotification, + notification := &schema.AddNotificationToProjectInput{ + NotificationType: schema.EmailNotification, NotificationName: name, Project: cmdProjectName, } - _, err := l.AddNotificationToProject(context.TODO(), notification, lc) + _, err := lagoon.AddNotificationToProject(context.TODO(), notification, lc) if err != nil { return err } @@ -166,7 +166,7 @@ var listProjectEmailsCmd = &cobra.Command{ &token, debug) - result, err := l.GetProjectNotificationEmail(context.TODO(), cmdProjectName, lc) + result, err := lagoon.GetProjectNotificationEmail(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -216,7 +216,7 @@ var listAllEmailsCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.GetAllNotificationEmail(context.TODO(), lc) + result, err := lagoon.GetAllNotificationEmail(context.TODO(), lc) if err != nil { return err } @@ -273,12 +273,12 @@ var deleteProjectEmailNotificationCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - notification := &ls.RemoveNotificationFromProjectInput{ - NotificationType: ls.EmailNotification, + notification := &schema.RemoveNotificationFromProjectInput{ + NotificationType: schema.EmailNotification, NotificationName: name, Project: cmdProjectName, } - _, err := l.RemoveNotificationFromProject(context.TODO(), notification, lc) + _, err := lagoon.RemoveNotificationFromProject(context.TODO(), notification, lc) if err != nil { return err } @@ -319,7 +319,7 @@ var deleteEmailNotificationCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.DeleteNotificationEmail(context.TODO(), name, lc) + result, err := lagoon.DeleteNotificationEmail(context.TODO(), name, lc) if err != nil { return err } @@ -359,11 +359,11 @@ var updateEmailNotificationCmd = &cobra.Command{ if err := requiredInputCheck("Notification name", name); err != nil { return err } - patch := ls.UpdateNotificationEmailPatchInput{ + patch := schema.UpdateNotificationEmailPatchInput{ Name: nullStrCheck(newname), EmailAddress: nullStrCheck(email), } - if patch == (ls.UpdateNotificationEmailPatchInput{}) { + if patch == (schema.UpdateNotificationEmailPatchInput{}) { return fmt.Errorf("missing arguments: either email or newname must be defined") } @@ -377,11 +377,11 @@ var updateEmailNotificationCmd = &cobra.Command{ &token, debug) - notification := &ls.UpdateNotificationEmailInput{ + notification := &schema.UpdateNotificationEmailInput{ Name: name, Patch: patch, } - result, err := l.UpdateNotificationEmail(context.TODO(), notification, lc) + result, err := lagoon.UpdateNotificationEmail(context.TODO(), notification, lc) if err != nil { return err } diff --git a/cmd/notificationsrocketchat.go b/cmd/notificationsrocketchat.go index 8a9d0630..f1130028 100644 --- a/cmd/notificationsrocketchat.go +++ b/cmd/notificationsrocketchat.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" @@ -57,14 +57,14 @@ It does not configure a project to send notifications to RocketChat though, you &token, debug) - notification := ls.AddNotificationRocketChatInput{ + notification := schema.AddNotificationRocketChatInput{ Name: name, Webhook: webhook, Channel: channel, Organization: &organizationID, } - result, err := l.AddNotificationRocketChat(context.TODO(), ¬ification, lc) + result, err := lagoon.AddNotificationRocketChat(context.TODO(), ¬ification, lc) if err != nil { return err } @@ -76,7 +76,7 @@ It does not configure a project to send notifications to RocketChat though, you returnNonEmptyString(fmt.Sprintf("%v", result.Channel)), } if result.Organization != nil { - organization, err := l.GetOrganizationByID(context.TODO(), organizationID, lc) + organization, err := lagoon.GetOrganizationByID(context.TODO(), organizationID, lc) if err != nil { return err } @@ -131,13 +131,13 @@ This command is used to add an existing RocketChat notification in Lagoon to a p &token, debug) - notification := &ls.AddNotificationToProjectInput{ - NotificationType: ls.RocketChatNotification, + notification := &schema.AddNotificationToProjectInput{ + NotificationType: schema.RocketChatNotification, NotificationName: name, Project: cmdProjectName, } - _, err := l.AddNotificationToProject(context.TODO(), notification, lc) + _, err := lagoon.AddNotificationToProject(context.TODO(), notification, lc) if err != nil { return err } @@ -175,7 +175,7 @@ var listProjectRocketChatsCmd = &cobra.Command{ &token, debug) - result, err := l.GetProjectNotificationRocketChat(context.TODO(), cmdProjectName, lc) + result, err := lagoon.GetProjectNotificationRocketChat(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -227,7 +227,7 @@ var listAllRocketChatsCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.GetAllNotificationRocketChat(context.TODO(), lc) + result, err := lagoon.GetAllNotificationRocketChat(context.TODO(), lc) if err != nil { return err } @@ -286,12 +286,12 @@ var deleteProjectRocketChatNotificationCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - notification := &ls.RemoveNotificationFromProjectInput{ - NotificationType: ls.RocketChatNotification, + notification := &schema.RemoveNotificationFromProjectInput{ + NotificationType: schema.RocketChatNotification, NotificationName: name, Project: cmdProjectName, } - _, err := l.RemoveNotificationFromProject(context.TODO(), notification, lc) + _, err := lagoon.RemoveNotificationFromProject(context.TODO(), notification, lc) if err != nil { return err } @@ -332,7 +332,7 @@ var deleteRocketChatNotificationCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.DeleteNotificationRocketChat(context.TODO(), name, lc) + result, err := lagoon.DeleteNotificationRocketChat(context.TODO(), name, lc) if err != nil { return err } @@ -376,12 +376,12 @@ var updateRocketChatNotificationCmd = &cobra.Command{ if err := requiredInputCheck("Notification name", name); err != nil { return err } - patch := ls.UpdateNotificationRocketChatPatchInput{ + patch := schema.UpdateNotificationRocketChatPatchInput{ Name: nullStrCheck(newname), Webhook: nullStrCheck(webhook), Channel: nullStrCheck(channel), } - if patch == (ls.UpdateNotificationRocketChatPatchInput{}) { + if patch == (schema.UpdateNotificationRocketChatPatchInput{}) { return fmt.Errorf("missing arguments: either channel, webhook, or newname must be defined") } @@ -395,11 +395,11 @@ var updateRocketChatNotificationCmd = &cobra.Command{ &token, debug) - notification := &ls.UpdateNotificationRocketChatInput{ + notification := &schema.UpdateNotificationRocketChatInput{ Name: name, Patch: patch, } - result, err := l.UpdateNotificationRocketChat(context.TODO(), notification, lc) + result, err := lagoon.UpdateNotificationRocketChat(context.TODO(), notification, lc) if err != nil { return err } diff --git a/cmd/notificationsslack.go b/cmd/notificationsslack.go index 63018638..7032f3a2 100644 --- a/cmd/notificationsslack.go +++ b/cmd/notificationsslack.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" @@ -57,14 +57,14 @@ It does not configure a project to send notifications to Slack though, you need &token, debug) - notification := ls.AddNotificationSlackInput{ + notification := schema.AddNotificationSlackInput{ Name: name, Webhook: webhook, Channel: channel, Organization: &organizationID, } - result, err := l.AddNotificationSlack(context.TODO(), ¬ification, lc) + result, err := lagoon.AddNotificationSlack(context.TODO(), ¬ification, lc) if err != nil { return err } @@ -76,7 +76,7 @@ It does not configure a project to send notifications to Slack though, you need returnNonEmptyString(fmt.Sprintf("%v", result.Channel)), } if result.Organization != nil { - organization, err := l.GetOrganizationByID(context.TODO(), organizationID, lc) + organization, err := lagoon.GetOrganizationByID(context.TODO(), organizationID, lc) if err != nil { return err } @@ -130,12 +130,12 @@ This command is used to add an existing Slack notification in Lagoon to a projec lagoonCLIConfig.Lagoons[current].Version, &token, debug) - notification := &ls.AddNotificationToProjectInput{ - NotificationType: ls.SlackNotification, + notification := &schema.AddNotificationToProjectInput{ + NotificationType: schema.SlackNotification, NotificationName: name, Project: cmdProjectName, } - _, err := l.AddNotificationToProject(context.TODO(), notification, lc) + _, err := lagoon.AddNotificationToProject(context.TODO(), notification, lc) if err != nil { return err } @@ -173,7 +173,7 @@ var listProjectSlacksCmd = &cobra.Command{ &token, debug) - result, err := l.GetProjectNotificationSlack(context.TODO(), cmdProjectName, lc) + result, err := lagoon.GetProjectNotificationSlack(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -225,7 +225,7 @@ var listAllSlacksCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.GetAllNotificationSlack(context.TODO(), lc) + result, err := lagoon.GetAllNotificationSlack(context.TODO(), lc) if err != nil { return err } @@ -284,12 +284,12 @@ var deleteProjectSlackNotificationCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - notification := &ls.RemoveNotificationFromProjectInput{ - NotificationType: ls.SlackNotification, + notification := &schema.RemoveNotificationFromProjectInput{ + NotificationType: schema.SlackNotification, NotificationName: name, Project: cmdProjectName, } - _, err := l.RemoveNotificationFromProject(context.TODO(), notification, lc) + _, err := lagoon.RemoveNotificationFromProject(context.TODO(), notification, lc) if err != nil { return err } @@ -330,7 +330,7 @@ var deleteSlackNotificationCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.DeleteNotificationSlack(context.TODO(), name, lc) + result, err := lagoon.DeleteNotificationSlack(context.TODO(), name, lc) if err != nil { return err } @@ -374,12 +374,12 @@ var updateSlackNotificationCmd = &cobra.Command{ if err := requiredInputCheck("Notification name", name); err != nil { return err } - patch := ls.UpdateNotificationSlackPatchInput{ + patch := schema.UpdateNotificationSlackPatchInput{ Name: nullStrCheck(newname), Webhook: nullStrCheck(webhook), Channel: nullStrCheck(channel), } - if patch == (ls.UpdateNotificationSlackPatchInput{}) { + if patch == (schema.UpdateNotificationSlackPatchInput{}) { return fmt.Errorf("missing arguments: either channel, webhook, or newname must be defined") } @@ -393,11 +393,11 @@ var updateSlackNotificationCmd = &cobra.Command{ &token, debug) - notification := &ls.UpdateNotificationSlackInput{ + notification := &schema.UpdateNotificationSlackInput{ Name: name, Patch: patch, } - result, err := l.UpdateNotificationSlack(context.TODO(), notification, lc) + result, err := lagoon.UpdateNotificationSlack(context.TODO(), notification, lc) if err != nil { return err } diff --git a/cmd/notificationsteams.go b/cmd/notificationsteams.go index 627e9756..d267fb66 100644 --- a/cmd/notificationsteams.go +++ b/cmd/notificationsteams.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" @@ -53,13 +53,13 @@ It does not configure a project to send notifications to Microsoft Teams though, &token, debug) - notification := ls.AddNotificationMicrosoftTeamsInput{ + notification := schema.AddNotificationMicrosoftTeamsInput{ Name: name, Webhook: webhook, Organization: &organizationID, } - result, err := l.AddNotificationMicrosoftTeams(context.TODO(), ¬ification, lc) + result, err := lagoon.AddNotificationMicrosoftTeams(context.TODO(), ¬ification, lc) if err != nil { return err } @@ -70,7 +70,7 @@ It does not configure a project to send notifications to Microsoft Teams though, returnNonEmptyString(fmt.Sprintf("%v", result.Webhook)), } if result.Organization != nil { - organization, err := l.GetOrganizationByID(context.TODO(), organizationID, lc) + organization, err := lagoon.GetOrganizationByID(context.TODO(), organizationID, lc) if err != nil { return err } @@ -123,12 +123,12 @@ This command is used to add an existing Microsoft Teams notification in Lagoon t lagoonCLIConfig.Lagoons[current].Version, &token, debug) - notification := &ls.AddNotificationToProjectInput{ - NotificationType: ls.MicrosoftTeamsNotification, + notification := &schema.AddNotificationToProjectInput{ + NotificationType: schema.MicrosoftTeamsNotification, NotificationName: name, Project: cmdProjectName, } - _, err := l.AddNotificationToProject(context.TODO(), notification, lc) + _, err := lagoon.AddNotificationToProject(context.TODO(), notification, lc) if err != nil { return err } @@ -166,7 +166,7 @@ var listProjectMicrosoftTeamsCmd = &cobra.Command{ &token, debug) - result, err := l.GetProjectNotificationMicrosoftTeams(context.TODO(), cmdProjectName, lc) + result, err := lagoon.GetProjectNotificationMicrosoftTeams(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -216,7 +216,7 @@ var listAllMicrosoftTeamsCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.GetAllNotificationMicrosoftTeams(context.TODO(), lc) + result, err := lagoon.GetAllNotificationMicrosoftTeams(context.TODO(), lc) if err != nil { return err } @@ -273,12 +273,12 @@ var deleteProjectMicrosoftTeamsNotificationCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - notification := &ls.RemoveNotificationFromProjectInput{ - NotificationType: ls.MicrosoftTeamsNotification, + notification := &schema.RemoveNotificationFromProjectInput{ + NotificationType: schema.MicrosoftTeamsNotification, NotificationName: name, Project: cmdProjectName, } - _, err := l.RemoveNotificationFromProject(context.TODO(), notification, lc) + _, err := lagoon.RemoveNotificationFromProject(context.TODO(), notification, lc) if err != nil { return err } @@ -319,7 +319,7 @@ var deleteMicrosoftTeamsNotificationCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.DeleteNotificationMicrosoftTeams(context.TODO(), name, lc) + result, err := lagoon.DeleteNotificationMicrosoftTeams(context.TODO(), name, lc) if err != nil { return err } @@ -359,11 +359,11 @@ var updateMicrosoftTeamsNotificationCmd = &cobra.Command{ if err := requiredInputCheck("Notification name", name); err != nil { return err } - patch := ls.UpdateNotificationMicrosoftTeamsPatchInput{ + patch := schema.UpdateNotificationMicrosoftTeamsPatchInput{ Name: nullStrCheck(newname), Webhook: nullStrCheck(webhook), } - if patch == (ls.UpdateNotificationMicrosoftTeamsPatchInput{}) { + if patch == (schema.UpdateNotificationMicrosoftTeamsPatchInput{}) { return fmt.Errorf("missing arguments: either webhook or newname must be defined") } @@ -377,11 +377,11 @@ var updateMicrosoftTeamsNotificationCmd = &cobra.Command{ &token, debug) - notification := &ls.UpdateNotificationMicrosoftTeamsInput{ + notification := &schema.UpdateNotificationMicrosoftTeamsInput{ Name: name, Patch: patch, } - result, err := l.UpdateNotificationMicrosoftTeams(context.TODO(), notification, lc) + result, err := lagoon.UpdateNotificationMicrosoftTeams(context.TODO(), notification, lc) if err != nil { return err } diff --git a/cmd/notificationswebhook.go b/cmd/notificationswebhook.go index 6601fbe8..58eee15a 100644 --- a/cmd/notificationswebhook.go +++ b/cmd/notificationswebhook.go @@ -5,9 +5,9 @@ import ( "encoding/json" "fmt" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" @@ -53,13 +53,13 @@ It does not configure a project to send notifications to webhook though, you nee &token, debug) - notification := ls.AddNotificationWebhookInput{ + notification := schema.AddNotificationWebhookInput{ Name: name, Webhook: webhook, Organization: &organizationID, } - result, err := l.AddNotificationWebhook(context.TODO(), ¬ification, lc) + result, err := lagoon.AddNotificationWebhook(context.TODO(), ¬ification, lc) if err != nil { return err } @@ -70,7 +70,7 @@ It does not configure a project to send notifications to webhook though, you nee returnNonEmptyString(fmt.Sprintf("%v", result.Webhook)), } if result.Organization != nil { - organization, err := l.GetOrganizationByID(context.TODO(), organizationID, lc) + organization, err := lagoon.GetOrganizationByID(context.TODO(), organizationID, lc) if err != nil { return err } @@ -123,12 +123,12 @@ This command is used to add an existing webhook notification in Lagoon to a proj lagoonCLIConfig.Lagoons[current].Version, &token, debug) - notification := &ls.AddNotificationToProjectInput{ - NotificationType: ls.WebhookNotification, + notification := &schema.AddNotificationToProjectInput{ + NotificationType: schema.WebhookNotification, NotificationName: name, Project: cmdProjectName, } - _, err := l.AddNotificationToProject(context.TODO(), notification, lc) + _, err := lagoon.AddNotificationToProject(context.TODO(), notification, lc) if err != nil { return err } @@ -166,7 +166,7 @@ var listProjectWebhooksCmd = &cobra.Command{ &token, debug) - result, err := l.GetProjectNotificationWebhook(context.TODO(), cmdProjectName, lc) + result, err := lagoon.GetProjectNotificationWebhook(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -216,7 +216,7 @@ var listAllWebhooksCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.GetAllNotificationWebhook(context.TODO(), lc) + result, err := lagoon.GetAllNotificationWebhook(context.TODO(), lc) if err != nil { return err } @@ -273,12 +273,12 @@ var deleteProjectWebhookNotificationCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - notification := &ls.RemoveNotificationFromProjectInput{ - NotificationType: ls.WebhookNotification, + notification := &schema.RemoveNotificationFromProjectInput{ + NotificationType: schema.WebhookNotification, NotificationName: name, Project: cmdProjectName, } - _, err := l.RemoveNotificationFromProject(context.TODO(), notification, lc) + _, err := lagoon.RemoveNotificationFromProject(context.TODO(), notification, lc) if err != nil { return err } @@ -319,7 +319,7 @@ var deleteWebhookNotificationCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.DeleteNotificationWebhook(context.TODO(), name, lc) + result, err := lagoon.DeleteNotificationWebhook(context.TODO(), name, lc) if err != nil { return err } @@ -359,11 +359,11 @@ var updateWebhookNotificationCmd = &cobra.Command{ if err := requiredInputCheck("Notification name", name); err != nil { return err } - patch := ls.UpdateNotificationWebhookPatchInput{ + patch := schema.UpdateNotificationWebhookPatchInput{ Name: nullStrCheck(newname), Webhook: nullStrCheck(webhook), } - if patch == (ls.UpdateNotificationWebhookPatchInput{}) { + if patch == (schema.UpdateNotificationWebhookPatchInput{}) { return fmt.Errorf("missing arguments: either webhook or newname must be defined") } @@ -377,11 +377,11 @@ var updateWebhookNotificationCmd = &cobra.Command{ &token, debug) - notification := &ls.UpdateNotificationWebhookInput{ + notification := &schema.UpdateNotificationWebhookInput{ Name: name, Patch: patch, } - result, err := l.UpdateNotificationWebhook(context.TODO(), notification, lc) + result, err := lagoon.UpdateNotificationWebhook(context.TODO(), notification, lc) if err != nil { return err } diff --git a/cmd/organization.go b/cmd/organization.go index b18b60ca..1685a2b9 100644 --- a/cmd/organization.go +++ b/cmd/organization.go @@ -6,9 +6,9 @@ import ( "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - s "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" ) var addOrganizationCmd = &cobra.Command{ @@ -68,7 +68,7 @@ var addOrganizationCmd = &cobra.Command{ &token, debug) - organizationInput := s.AddOrganizationInput{ + organizationInput := schema.AddOrganizationInput{ Name: organizationName, FriendlyName: organizationFriendlyName, Description: organizationDescription, @@ -78,7 +78,7 @@ var addOrganizationCmd = &cobra.Command{ QuotaEnvironment: organizationQuotaEnvironment, QuotaRoute: organizationQuotaRoute, } - org := s.Organization{} + org := schema.Organization{} err = lc.AddOrganization(context.TODO(), &organizationInput, &org) if err != nil { return err @@ -124,7 +124,7 @@ var deleteOrganizationCmd = &cobra.Command{ &token, debug) - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } @@ -132,7 +132,7 @@ var deleteOrganizationCmd = &cobra.Command{ return fmt.Errorf("error querying organization by name") } if yesNo(fmt.Sprintf("You are attempting to delete organization '%s', are you sure?", organization.Name)) { - _, err := l.DeleteOrganization(context.TODO(), organization.ID, lc) + _, err := lagoon.DeleteOrganization(context.TODO(), organization.ID, lc) if err != nil { return err } @@ -202,14 +202,14 @@ var updateOrganizationCmd = &cobra.Command{ &token, debug) - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } if organization.Name == "" { return fmt.Errorf("error querying organization by name") } - organizationInput := s.UpdateOrganizationPatchInput{ + organizationInput := schema.UpdateOrganizationPatchInput{ Description: nullStrCheck(organizationDescription), FriendlyName: nullStrCheck(organizationFriendlyName), QuotaProject: nullIntCheck(organizationQuotaProject), @@ -218,7 +218,7 @@ var updateOrganizationCmd = &cobra.Command{ QuotaEnvironment: nullIntCheck(organizationQuotaEnvironment), QuotaRoute: nullIntCheck(organizationQuotaRoute), } - result, err := l.UpdateOrganization(context.TODO(), organization.ID, organizationInput, lc) + result, err := lagoon.UpdateOrganization(context.TODO(), organization.ID, organizationInput, lc) if err != nil { return err } diff --git a/cmd/project.go b/cmd/project.go index ab5ccf0d..d4ef7079 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -8,9 +8,9 @@ import ( "strings" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" "github.com/guregu/null" "github.com/spf13/cobra" @@ -43,7 +43,7 @@ var deleteProjectCmd = &cobra.Command{ debug) if yesNo(fmt.Sprintf("You are attempting to delete project '%s', are you sure?", cmdProjectName)) { - _, err := l.DeleteProject(context.TODO(), cmdProjectName, lc) + _, err := lagoon.DeleteProject(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -152,7 +152,7 @@ var addProjectCmd = &cobra.Command{ &token, debug) - projectInput := ls.AddProjectInput{ + projectInput := schema.AddProjectInput{ Name: cmdProjectName, AddOrgOwner: orgOwner, GitURL: gitUrl, @@ -176,7 +176,7 @@ var addProjectCmd = &cobra.Command{ } // otherwise if name is provided use it if organizationName != "" && organizationID == 0 { - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } @@ -188,7 +188,7 @@ var addProjectCmd = &cobra.Command{ projectInput.Organization = organization.ID } - project := ls.Project{} + project := schema.Project{} err = lc.AddProject(context.TODO(), &projectInput, &project) if err != nil { return err @@ -323,7 +323,7 @@ var updateProjectCmd = &cobra.Command{ &token, debug) - projectPatch := ls.UpdateProjectPatchInput{ + projectPatch := schema.UpdateProjectPatchInput{ GitURL: nullStrCheck(gitUrl), ProductionEnvironment: nullStrCheck(productionEnvironment), Openshift: nullUintCheck(openshift), @@ -346,7 +346,7 @@ var updateProjectCmd = &cobra.Command{ } if availability != "" { - ProjectAvailability := ls.ProjectAvailability(strings.ToUpper(availability)) + ProjectAvailability := schema.ProjectAvailability(strings.ToUpper(availability)) projectPatch.Availability = &ProjectAvailability } if autoIdleProvided { @@ -371,7 +371,7 @@ var updateProjectCmd = &cobra.Command{ } } - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -380,7 +380,7 @@ var updateProjectCmd = &cobra.Command{ output.RenderError(outputOptions.Error, outputOptions) return nil } - projectUpdate, err := l.UpdateProject(context.TODO(), int(project.ID), projectPatch, lc) + projectUpdate, err := lagoon.UpdateProject(context.TODO(), int(project.ID), projectPatch, lc) if err != nil { return err } @@ -431,7 +431,7 @@ var listProjectByMetadata = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - projects, err := l.GetProjectsByMetadata(context.TODO(), key, value, lc) + projects, err := lagoon.GetProjectsByMetadata(context.TODO(), key, value, lc) if err != nil { return err } @@ -491,7 +491,7 @@ var getProjectMetadata = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - project, err := l.GetProjectMetadata(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetProjectMetadata(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -550,11 +550,11 @@ var updateProjectMetadata = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - projectResult, err := l.UpdateProjectMetadata(context.TODO(), int(project.ID), key, value, lc) + projectResult, err := lagoon.UpdateProjectMetadata(context.TODO(), int(project.ID), key, value, lc) if err != nil { return err } @@ -606,11 +606,11 @@ var deleteProjectMetadataByKey = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - projectResult, err := l.RemoveProjectMetadataByKey(context.TODO(), int(project.ID), key, lc) + projectResult, err := lagoon.RemoveProjectMetadataByKey(context.TODO(), int(project.ID), key, lc) if err != nil { return err } @@ -665,11 +665,11 @@ var removeProjectFromOrganizationCmd = &cobra.Command{ &token, debug) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } @@ -677,13 +677,13 @@ var removeProjectFromOrganizationCmd = &cobra.Command{ return fmt.Errorf("error querying organization by name") } - projectInput := ls.RemoveProjectFromOrganizationInput{ + projectInput := schema.RemoveProjectFromOrganizationInput{ Project: project.ID, Organization: organization.ID, } if yesNo(fmt.Sprintf("You are attempting to remove project '%s' from organization '%s'. This will return the project to a state where it has no groups or notifications associated, are you sure?", cmdProjectName, organization.Name)) { - _, err := l.RemoveProjectFromOrganization(context.TODO(), &projectInput, lc) + _, err := lagoon.RemoveProjectFromOrganization(context.TODO(), &projectInput, lc) if err != nil { return err } diff --git a/cmd/retrieve.go b/cmd/retrieve.go index 28bf738d..eec279bb 100644 --- a/cmd/retrieve.go +++ b/cmd/retrieve.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/spf13/cobra" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" ) @@ -51,7 +51,7 @@ You can check the status of the backup using the list backups or get backup comm lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.AddBackupRestore(context.TODO(), backupID, lc) + result, err := lagoon.AddBackupRestore(context.TODO(), backupID, lc) if err != nil { if strings.Contains(err.Error(), "Duplicate entry") { // this error reports a lot about the sql backup, need to fix that in Lagoon upstream diff --git a/cmd/ssh.go b/cmd/ssh.go index 35dc48c5..1a406a25 100644 --- a/cmd/ssh.go +++ b/cmd/ssh.go @@ -3,10 +3,11 @@ package cmd import ( "context" "fmt" - l "github.com/uselagoon/machinery/api/lagoon" - lclient "github.com/uselagoon/machinery/api/lagoon/client" "os" + "github.com/uselagoon/machinery/api/lagoon" + lclient "github.com/uselagoon/machinery/api/lagoon/client" + "github.com/spf13/cobra" lagoonssh "github.com/uselagoon/lagoon-cli/pkg/lagoon/ssh" "github.com/uselagoon/lagoon-cli/pkg/output" @@ -52,7 +53,7 @@ var sshEnvCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - project, err := l.GetSSHEndpointsByProject(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetSSHEndpointsByProject(context.TODO(), cmdProjectName, lc) if err != nil { return err } diff --git a/cmd/tasks.go b/cmd/tasks.go index 19dd6cb9..bd3b1053 100644 --- a/cmd/tasks.go +++ b/cmd/tasks.go @@ -13,9 +13,9 @@ import ( "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" ) var getTaskByID = &cobra.Command{ @@ -51,7 +51,7 @@ var getTaskByID = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.TaskByID(context.TODO(), taskID, lc) + result, err := lagoon.TaskByID(context.TODO(), taskID, lc) if err != nil { return err } @@ -111,7 +111,7 @@ If the task fails or fails to update, contact your Lagoon administrator for assi lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.ActiveStandbySwitch(context.TODO(), cmdProjectName, lc) + result, err := lagoon.ActiveStandbySwitch(context.TODO(), cmdProjectName, lc) if err != nil { return err } @@ -242,11 +242,11 @@ Direct: &token, debug) - project, err := l.GetProjectByName(context.TODO(), cmdProjectName, lc) + project, err := lagoon.GetProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - environment, err := l.GetAdvancedTasksByEnvironment(context.TODO(), project.ID, cmdProjectEnvironment, lc) + environment, err := lagoon.GetAdvancedTasksByEnvironment(context.TODO(), project.ID, cmdProjectEnvironment, lc) if err != nil { return err } @@ -258,7 +258,7 @@ Direct: } } - taskResult, err := l.InvokeAdvancedTaskDefinition(context.TODO(), environment.ID, taskId, lc) + taskResult, err := lagoon.InvokeAdvancedTaskDefinition(context.TODO(), environment.ID, taskId, lc) if err != nil { return err } @@ -349,15 +349,15 @@ Path: &token, debug) - task := ls.Task{ + task := schema.Task{ Name: taskName, Command: taskCommand, Service: taskService, } fmt.Println(task.Name) - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) - environment, err := l.GetEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc) - taskResult, err := l.AddTask(context.TODO(), environment.ID, task, lc) + project, err := lagoon.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) + environment, err := lagoon.GetEnvironmentByName(context.TODO(), cmdProjectEnvironment, project.ID, lc) + taskResult, err := lagoon.AddTask(context.TODO(), environment.ID, task, lc) if err != nil { return err } @@ -405,7 +405,7 @@ var uploadFilesToTask = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - result, err := l.UploadFilesForTask(context.TODO(), taskID, files, lc) + result, err := lagoon.UploadFilesForTask(context.TODO(), taskID, files, lc) if err != nil { return err } diff --git a/cmd/users.go b/cmd/users.go index 6054b3c6..588eedd5 100644 --- a/cmd/users.go +++ b/cmd/users.go @@ -8,9 +8,9 @@ import ( "strconv" "strings" - l "github.com/uselagoon/machinery/api/lagoon" + "github.com/uselagoon/machinery/api/lagoon" lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" + "github.com/uselagoon/machinery/api/schema" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -33,7 +33,7 @@ func parseUser(flags pflag.FlagSet) api.User { return parsedFlags } -func parseSSHKeyFile(sshPubKey string, keyName string, keyValue string, userEmail string) (ls.AddSSHKeyInput, error) { +func parseSSHKeyFile(sshPubKey string, keyName string, keyValue string, userEmail string) (schema.AddSSHKeyInput, error) { // if we haven't got a keyvalue if keyValue == "" { b, err := os.ReadFile(sshPubKey) // just pass the file name @@ -41,23 +41,23 @@ func parseSSHKeyFile(sshPubKey string, keyName string, keyValue string, userEmai keyValue = string(b) } splitKey := strings.Split(keyValue, " ") - var keyType ls.SSHKeyType + var keyType schema.SSHKeyType var err error // will fail if value is not right if strings.EqualFold(string(splitKey[0]), "ssh-rsa") { - keyType = ls.SSHRsa + keyType = schema.SSHRsa } else if strings.EqualFold(string(splitKey[0]), "ssh-ed25519") { - keyType = ls.SSHEd25519 + keyType = schema.SSHEd25519 } else if strings.EqualFold(string(splitKey[0]), "ecdsa-sha2-nistp256") { - keyType = ls.SSHECDSA256 + keyType = schema.SSHECDSA256 } else if strings.EqualFold(string(splitKey[0]), "ecdsa-sha2-nistp384") { - keyType = ls.SSHECDSA384 + keyType = schema.SSHECDSA384 } else if strings.EqualFold(string(splitKey[0]), "ecdsa-sha2-nistp521") { - keyType = ls.SSHECDSA521 + keyType = schema.SSHECDSA521 } else { // return error stating key type not supported - keyType = ls.SSHRsa + keyType = schema.SSHRsa err = fmt.Errorf(fmt.Sprintf("SSH key type %s not supported", splitKey[0])) } @@ -69,8 +69,8 @@ func parseSSHKeyFile(sshPubKey string, keyName string, keyValue string, userEmai keyName = userEmail output.RenderInfo("no name provided, using email address as key name", outputOptions) } - SSHKeyInput := ls.AddSSHKeyInput{ - SSHKey: ls.SSHKey{ + SSHKeyInput := schema.AddSSHKeyInput{ + SSHKey: schema.SSHKey{ KeyType: keyType, KeyValue: stripNewLines(splitKey[1]), Name: keyName, @@ -122,13 +122,13 @@ var addUserCmd = &cobra.Command{ &token, debug) - userInput := &ls.AddUserInput{ + userInput := &schema.AddUserInput{ FirstName: firstName, LastName: LastName, Email: email, ResetPassword: resetPassword, } - user, err := l.AddUser(context.TODO(), userInput, lc) + user, err := lagoon.AddUser(context.TODO(), userInput, lc) if err != nil { return err } @@ -206,7 +206,7 @@ Add key by defining key value, but not specifying a key name (will default to tr if err != nil { return err } - result, err := l.AddSSHKey(context.TODO(), &userSSHKey, lc) + result, err := lagoon.AddSSHKey(context.TODO(), &userSSHKey, lc) if err != nil { return err } @@ -252,7 +252,7 @@ var deleteSSHKeyCmd = &cobra.Command{ debug) if yesNo(fmt.Sprintf("You are attempting to delete SSH key ID:'%d', are you sure?", sshKeyID)) { - _, err := l.RemoveSSHKey(context.TODO(), sshKeyID, lc) + _, err := lagoon.RemoveSSHKey(context.TODO(), sshKeyID, lc) if err != nil { return err } @@ -294,11 +294,11 @@ var deleteUserCmd = &cobra.Command{ &token, debug) - deleteUserInput := &ls.DeleteUserInput{ - User: ls.UserInput{Email: emailAddress}, + deleteUserInput := &schema.DeleteUserInput{ + User: schema.UserInput{Email: emailAddress}, } if yesNo(fmt.Sprintf("You are attempting to delete user with email address '%s', are you sure?", emailAddress)) { - _, err := l.DeleteUser(context.TODO(), deleteUserInput, lc) + _, err := lagoon.DeleteUser(context.TODO(), deleteUserInput, lc) if err != nil { return err } @@ -358,18 +358,18 @@ var updateUserCmd = &cobra.Command{ &token, debug) - currentUser := &ls.UpdateUserInput{ - User: ls.UserInput{ + currentUser := &schema.UpdateUserInput{ + User: schema.UserInput{ Email: strings.ToLower(currentEmail), }, - Patch: ls.UpdateUserPatchInput{ + Patch: schema.UpdateUserPatchInput{ Email: nullStrCheck(strings.ToLower(emailAddress)), FirstName: nullStrCheck(firstName), LastName: nullStrCheck(lastName), }, } - user, err := l.UpdateUser(context.TODO(), currentUser, lc) + user, err := lagoon.UpdateUser(context.TODO(), currentUser, lc) if err != nil { return err } @@ -415,7 +415,7 @@ var getUserKeysCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - userKeys, err := l.GetUserSSHKeysByEmail(context.TODO(), userEmail, lc) + userKeys, err := lagoon.GetUserSSHKeysByEmail(context.TODO(), userEmail, lc) if err != nil { return err } @@ -472,16 +472,16 @@ var getAllUserKeysCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - groupMembers, err := l.ListAllGroupMembersWithKeys(context.TODO(), groupName, lc) + groupMembers, err := lagoon.ListAllGroupMembersWithKeys(context.TODO(), groupName, lc) if err != nil { return err } - var userGroups []ls.AddSSHKeyInput + var userGroups []schema.AddSSHKeyInput for _, group := range *groupMembers { for _, member := range group.Members { for _, key := range member.User.SSHKeys { - userGroups = append(userGroups, ls.AddSSHKeyInput{SSHKey: key, UserEmail: member.User.Email}) + userGroups = append(userGroups, schema.AddSSHKeyInput{SSHKey: key, UserEmail: member.User.Email}) } } } @@ -553,7 +553,7 @@ var addAdministratorToOrganizationCmd = &cobra.Command{ &token, debug) - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } @@ -561,13 +561,13 @@ var addAdministratorToOrganizationCmd = &cobra.Command{ return fmt.Errorf("error querying organization by name") } - userInput := ls.AddUserToOrganizationInput{ - User: ls.UserInput{Email: userEmail}, + userInput := schema.AddUserToOrganizationInput{ + User: schema.UserInput{Email: userEmail}, Organization: organization.ID, Owner: owner, } - orgUser := ls.Organization{} + orgUser := schema.Organization{} err = lc.AddUserToOrganization(context.TODO(), &userInput, &orgUser) if err != nil { return err @@ -626,7 +626,7 @@ var removeAdministratorFromOrganizationCmd = &cobra.Command{ &token, debug) - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + organization, err := lagoon.GetOrganizationByName(context.TODO(), organizationName, lc) if err != nil { return err } @@ -634,13 +634,13 @@ var removeAdministratorFromOrganizationCmd = &cobra.Command{ return fmt.Errorf("error querying organization by name") } - userInput := ls.AddUserToOrganizationInput{ - User: ls.UserInput{Email: userEmail}, + userInput := schema.AddUserToOrganizationInput{ + User: schema.UserInput{Email: userEmail}, Organization: organization.ID, Owner: owner, } - orgUser := ls.Organization{} + orgUser := schema.Organization{} if yesNo(fmt.Sprintf("You are attempting to remove user '%s' from organization '%s'. This removes the users ability to view or manage the organizations groups, projects, & notifications, are you sure?", userEmail, organization.Name)) { err = lc.RemoveUserFromOrganization(context.TODO(), &userInput, &orgUser) @@ -687,12 +687,12 @@ var resetPasswordCmd = &cobra.Command{ &token, debug) - resetPasswordInput := ls.ResetUserPasswordInput{ - User: ls.UserInput{Email: userEmail}, + resetPasswordInput := schema.ResetUserPasswordInput{ + User: schema.UserInput{Email: userEmail}, } if yesNo(fmt.Sprintf("You are attempting to send a password reset email to '%s', are you sure?", userEmail)) { - _, err := l.ResetUserPassword(context.TODO(), &resetPasswordInput, lc) + _, err := lagoon.ResetUserPassword(context.TODO(), &resetPasswordInput, lc) if err != nil { return err } diff --git a/cmd/variables.go b/cmd/variables.go index 4d410774..88e6bc5a 100644 --- a/cmd/variables.go +++ b/cmd/variables.go @@ -3,11 +3,12 @@ package cmd import ( "context" "fmt" - l "github.com/uselagoon/machinery/api/lagoon" - lclient "github.com/uselagoon/machinery/api/lagoon/client" - ls "github.com/uselagoon/machinery/api/schema" "strings" + "github.com/uselagoon/machinery/api/lagoon" + lclient "github.com/uselagoon/machinery/api/lagoon/client" + "github.com/uselagoon/machinery/api/schema" + "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" ) @@ -49,14 +50,14 @@ var addVariableCmd = &cobra.Command{ &token, debug) - in := &ls.EnvVariableByNameInput{ + in := &schema.EnvVariableByNameInput{ Project: cmdProjectName, Environment: cmdProjectEnvironment, - Scope: ls.EnvVariableScope(strings.ToUpper(varScope)), + Scope: schema.EnvVariableScope(strings.ToUpper(varScope)), Name: varName, Value: varValue, } - envvar, err := l.AddOrUpdateEnvVariableByName(context.TODO(), in, lc) + envvar, err := lagoon.AddOrUpdateEnvVariableByName(context.TODO(), in, lc) if err != nil { return err } @@ -129,12 +130,12 @@ var deleteVariableCmd = &cobra.Command{ lagoonCLIConfig.Lagoons[current].Version, &token, debug) - in := &ls.DeleteEnvVariableByNameInput{ + in := &schema.DeleteEnvVariableByNameInput{ Project: cmdProjectName, Environment: cmdProjectEnvironment, Name: varName, } - deleteResult, err := l.DeleteEnvVariableByName(context.TODO(), in, lc) + deleteResult, err := lagoon.DeleteEnvVariableByName(context.TODO(), in, lc) if err != nil { return err } diff --git a/cmd/whoami.go b/cmd/whoami.go index 6732b810..d8193548 100644 --- a/cmd/whoami.go +++ b/cmd/whoami.go @@ -3,10 +3,11 @@ package cmd import ( "context" "fmt" - l "github.com/uselagoon/machinery/api/lagoon" - lclient "github.com/uselagoon/machinery/api/lagoon/client" "strings" + "github.com/uselagoon/machinery/api/lagoon" + lclient "github.com/uselagoon/machinery/api/lagoon/client" + "github.com/spf13/cobra" "github.com/uselagoon/lagoon-cli/pkg/output" ) @@ -40,7 +41,7 @@ This is useful if you have multiple keys or accounts in multiple lagoons and nee &token, debug) - user, err := l.Me(context.TODO(), lc) + user, err := lagoon.Me(context.TODO(), lc) if err != nil { if strings.Contains(err.Error(), "Cannot read properties of null (reading 'access_token')") { return fmt.Errorf("unable to get user information, you may be using an administration token")