diff --git a/cmd/add.go b/cmd/add.go index 6ea38fef..fd74a218 100644 --- a/cmd/add.go +++ b/cmd/add.go @@ -22,15 +22,6 @@ var addNotificationCmd = &cobra.Command{ }, } -var addOrganizationCmd = &cobra.Command{ - Use: "organization", - Aliases: []string{"o"}, - Short: "Add an organization, or add a group/project to an organization", - PersistentPreRun: func(cmd *cobra.Command, args []string) { - validateToken(lagoonCLIConfig.Current) // get a new token if the current one is invalid - }, -} - func init() { addCmd.AddCommand(addDeployTargetCmd) addCmd.AddCommand(addGroupCmd) @@ -43,4 +34,6 @@ func init() { addCmd.AddCommand(addUserSSHKeyCmd) addCmd.AddCommand(addVariableCmd) addCmd.AddCommand(addDeployTargetConfigCmd) + addCmd.AddCommand(addDeployTargetToOrganizationCmd) + addCmd.AddCommand(addAdministratorToOrganizationCmd) } diff --git a/cmd/delete.go b/cmd/delete.go index d2e07788..85dea02b 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -22,15 +22,6 @@ var deleteNotificationCmd = &cobra.Command{ }, } -var deleteOrganizationCmd = &cobra.Command{ - Use: "organization", - Aliases: []string{"o"}, - Short: "Add an organization, or add a group/project to an organization", - PersistentPreRun: func(cmd *cobra.Command, args []string) { - validateToken(lagoonCLIConfig.Current) // get a new token if the current one is invalid - }, -} - func init() { deleteCmd.AddCommand(deleteEnvCmd) deleteCmd.AddCommand(deleteGroupCmd) @@ -44,4 +35,7 @@ func init() { deleteCmd.AddCommand(deleteVariableCmd) deleteCmd.AddCommand(deleteDeployTargetConfigCmd) deleteCmd.AddCommand(deleteOrganizationCmd) + deleteCmd.AddCommand(removeDeployTargetFromOrganizationCmd) + deleteCmd.AddCommand(removeAdministratorFromOrganizationCmd) + deleteCmd.AddCommand(removeProjectFromOrganizationCmd) } diff --git a/cmd/deploytarget.go b/cmd/deploytarget.go index dc7fad9d..b2b7892e 100644 --- a/cmd/deploytarget.go +++ b/cmd/deploytarget.go @@ -324,28 +324,27 @@ var deleteDeployTargetCmd = &cobra.Command{ } var addDeployTargetToOrganizationCmd = &cobra.Command{ - Use: "deploytarget", - Aliases: []string{"dt"}, + Use: "organization-deploytarget", + Aliases: []string{"org-dt"}, Short: "Add a deploy target to an Organization", PreRunE: func(_ *cobra.Command, _ []string) error { return validateTokenE(lagoonCLIConfig.Current) }, RunE: func(cmd *cobra.Command, args []string) error { debug, err := cmd.Flags().GetBool("debug") - handleError(err) - - organizationName, err := cmd.Flags().GetString("name") if err != nil { return err } - if err := requiredInputCheck("Organization name", organizationName); err != nil { + organizationName, err := cmd.Flags().GetString("organization-name") + if err != nil { return err } - deployTarget, err := cmd.Flags().GetUint("deploy-target") + deploytarget, err := cmd.Flags().GetUint("deploytarget") if err != nil { return err } - if err := requiredInputCheck("Deploy Target", strconv.Itoa(int(deployTarget))); err != nil { + + if err := requiredInputCheck("Organization name", organizationName, "Deploy Target", strconv.Itoa(int(deploytarget))); err != nil { return err } @@ -359,21 +358,24 @@ var addDeployTargetToOrganizationCmd = &cobra.Command{ debug) organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) - handleError(err) + if err != nil { + return err + } deployTargetInput := s.AddDeployTargetToOrganizationInput{ - DeployTarget: deployTarget, + DeployTarget: deploytarget, Organization: organization.ID, } deployTargetResponse, err := l.AddDeployTargetToOrganization(context.TODO(), &deployTargetInput, lc) - handleError(err) - + if err != nil { + return err + } resultData := output.Result{ Result: "success", ResultData: map[string]interface{}{ - "Deploy Target": deployTargetResponse.Name, - "Organization Name": organizationName, + "Deploy Target": deploytarget, + "Organization Name": deployTargetResponse.Name, }, } output.RenderResult(resultData, outputOptions) @@ -381,29 +383,28 @@ var addDeployTargetToOrganizationCmd = &cobra.Command{ }, } -var RemoveDeployTargetFromOrganizationCmd = &cobra.Command{ - Use: "deploytarget", - Aliases: []string{"dt"}, +var removeDeployTargetFromOrganizationCmd = &cobra.Command{ + Use: "organization-deploytarget", + Aliases: []string{"org-dt"}, Short: "Remove a deploy target from an Organization", PreRunE: func(_ *cobra.Command, _ []string) error { return validateTokenE(lagoonCLIConfig.Current) }, RunE: func(cmd *cobra.Command, args []string) error { debug, err := cmd.Flags().GetBool("debug") - handleError(err) - - organizationName, err := cmd.Flags().GetString("name") if err != nil { return err } - if err := requiredInputCheck("Organization name", organizationName); err != nil { + + organizationName, err := cmd.Flags().GetString("organization-name") + if err != nil { return err } - deployTarget, err := cmd.Flags().GetUint("deploy-target") + deploytarget, err := cmd.Flags().GetUint("deploytarget") if err != nil { return err } - if err := requiredInputCheck("Deploy Target", strconv.Itoa(int(deployTarget))); err != nil { + if err := requiredInputCheck("Organization name", organizationName, "Deploy Target", strconv.Itoa(int(deploytarget))); err != nil { return err } @@ -417,20 +418,24 @@ var RemoveDeployTargetFromOrganizationCmd = &cobra.Command{ debug) organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) - handleError(err) + if err != nil { + return err + } deployTargetInput := s.RemoveDeployTargetFromOrganizationInput{ - DeployTarget: deployTarget, + 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)) { + 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) - handleError(err) + if err != nil { + return err + } resultData := output.Result{ Result: "success", ResultData: map[string]interface{}{ - "Deploy Target": deployTarget, + "Deploy Target": deploytarget, "Organization Name": organizationName, }, } @@ -453,14 +458,14 @@ func init() { addDeployTargetCmd.Flags().StringP("ssh-port", "", "", "DeployTarget ssh port") addDeployTargetCmd.Flags().StringP("build-image", "", "", "DeployTarget build image to use (if different to the default)") - addDeployTargetToOrganizationCmd.Flags().StringP("name", "O", "", "Name of Organization") - addDeployTargetToOrganizationCmd.Flags().UintP("deploy-target", "D", 0, "ID of DeployTarget") + addDeployTargetToOrganizationCmd.Flags().StringP("organization-name", "O", "", "Name of Organization") + addDeployTargetToOrganizationCmd.Flags().UintP("deploytarget", "D", 0, "ID of DeployTarget") deleteDeployTargetCmd.Flags().UintP("id", "", 0, "ID of the DeployTarget") deleteDeployTargetCmd.Flags().StringP("name", "", "", "Name of DeployTarget") - RemoveDeployTargetFromOrganizationCmd.Flags().StringP("name", "O", "", "Name of Organization") - RemoveDeployTargetFromOrganizationCmd.Flags().UintP("deploy-target", "D", 0, "ID of DeployTarget") + removeDeployTargetFromOrganizationCmd.Flags().StringP("organization-name", "O", "", "Name of Organization") + removeDeployTargetFromOrganizationCmd.Flags().UintP("deploytarget", "D", 0, "ID of DeployTarget") updateDeployTargetCmd.Flags().UintP("id", "", 0, "ID of the DeployTarget") updateDeployTargetCmd.Flags().StringP("console-url", "", "", "DeployTarget console URL") diff --git a/cmd/environment.go b/cmd/environment.go index 1625380a..3d1aab96 100644 --- a/cmd/environment.go +++ b/cmd/environment.go @@ -83,7 +83,7 @@ var updateEnvironmentCmd = &cobra.Command{ if err != nil { return err } - openShift, err := cmd.Flags().GetUint("deploy-target") + openShift, err := cmd.Flags().GetUint("deploytarget") if err != nil { return err } @@ -290,7 +290,7 @@ func init() { updateEnvironmentCmd.Flags().String("route", "", "Update the route for the selected environment") updateEnvironmentCmd.Flags().String("routes", "", "Update the routes for the selected environment") updateEnvironmentCmd.Flags().UintVarP(&environmentAutoIdle, "auto-idle", "a", 1, "Auto idle setting of the environment") - updateEnvironmentCmd.Flags().UintP("deploy-target", "d", 0, "Reference to OpenShift Object this Environment should be deployed to") + updateEnvironmentCmd.Flags().UintP("deploytarget", "d", 0, "Reference to OpenShift Object this Environment should be deployed to") updateEnvironmentCmd.Flags().String("environment-type", "", "Update the environment type - production | development") updateEnvironmentCmd.Flags().String("deploy-type", "", "Update the deploy type - branch | pullrequest | promote") } diff --git a/cmd/get.go b/cmd/get.go index 6f067d99..d4f38264 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -268,7 +268,7 @@ var getOrganizationCmd = &cobra.Command{ if err != nil { return err } - organizationName, err := cmd.Flags().GetString("name") + organizationName, err := cmd.Flags().GetString("organization-name") if err != nil { return err } @@ -285,7 +285,9 @@ var getOrganizationCmd = &cobra.Command{ &token, debug) organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) - handleError(err) + if err != nil { + return err + } if organization.Name == "" { output.RenderInfo(fmt.Sprintf("No organization found for '%s'", organizationName), outputOptions) @@ -327,5 +329,5 @@ func init() { getProjectKeyCmd.Flags().BoolVarP(&revealValue, "reveal", "", false, "Reveal the variable values") getDeploymentByNameCmd.Flags().StringP("name", "N", "", "The name of the deployment (eg, lagoon-build-abcdef)") getDeploymentByNameCmd.Flags().BoolP("logs", "L", false, "Show the build logs if available") - getOrganizationCmd.Flags().StringP("name", "O", "", "Name of the organization") + getOrganizationCmd.Flags().StringP("organization-name", "O", "", "Name of the organization") } diff --git a/cmd/groups.go b/cmd/groups.go index 617c1fe3..6a1c0622 100644 --- a/cmd/groups.go +++ b/cmd/groups.go @@ -33,26 +33,76 @@ func parseGroup(flags pflag.FlagSet) api.Group { var addGroupCmd = &cobra.Command{ Use: "group", Aliases: []string{"g"}, - Short: "Add a group to lagoon", - Run: func(cmd *cobra.Command, args []string) { - groupFlags := parseGroup(*cmd.Flags()) - if groupFlags.Name == "" { - fmt.Println("Missing arguments: Group name is not defined") - cmd.Help() - os.Exit(1) + Short: "Add a group to Lagoon, or add a group to an organization", + Long: "To add a group to an organization, you'll need to include the `organization` flag and provide the name of the organization. You need to be an owner of this organization to do this.\nIf you're the organization owner and want to grant yourself ownership to this group to be able to deploy projects that may be added to it, specify the `owner` flag, otherwise you will still be able to add and remove users without being an owner", + PreRunE: func(_ *cobra.Command, _ []string) error { + return validateTokenE(lagoonCLIConfig.Current) + }, + RunE: func(cmd *cobra.Command, args []string) error { + debug, err := cmd.Flags().GetBool("debug") + if err != nil { + return err } - var customReqResult []byte - var err error - customReqResult, err = uClient.AddGroup(groupFlags) - handleError(err) - returnResultData := map[string]interface{}{} - err = json.Unmarshal([]byte(customReqResult), &returnResultData) - handleError(err) + groupName, err := cmd.Flags().GetString("name") + if err != nil { + return err + } + if err := requiredInputCheck("Group name", groupName); err != nil { + return err + } + orgOwner, err := cmd.Flags().GetBool("owner") + if err != nil { + return err + } + organizationName, err := cmd.Flags().GetString("organization-name") + if err != nil { + return err + } + + current := lagoonCLIConfig.Current + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( + lagoonCLIConfig.Lagoons[current].GraphQL, + lagoonCLIVersion, + lagoonCLIConfig.Lagoons[current].Version, + &token, + debug) + + if organizationName != "" { + organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + if err != nil { + return err + } + groupInput := s.AddGroupToOrganizationInput{ + Name: groupName, + Organization: organization.ID, + AddOrgOwner: orgOwner, + } + _, err = l.AddGroupToOrganization(context.TODO(), &groupInput, lc) + if err != nil { + return err + } + } else { + groupInput := s.AddGroupInput{ + Name: groupName, + } + _, err = l.AddGroup(context.TODO(), &groupInput, lc) + if err != nil { + return err + } + } + resultData := output.Result{ - Result: "success", - ResultData: returnResultData, + Result: "success", + ResultData: map[string]interface{}{ + "Group Name": groupName, + }, + } + if organizationName != "" { + resultData.ResultData["Organization"] = organizationName } output.RenderResult(resultData, outputOptions) + return nil }, } @@ -236,70 +286,10 @@ var deleteGroupCmd = &cobra.Command{ }, } -var addGroupToOrganizationCmd = &cobra.Command{ - Use: "group", - Aliases: []string{"g"}, - Short: "Add a group to an Organization", - PreRunE: func(_ *cobra.Command, _ []string) error { - return validateTokenE(lagoonCLIConfig.Current) - }, - RunE: func(cmd *cobra.Command, args []string) error { - debug, err := cmd.Flags().GetBool("debug") - handleError(err) - orgOwner, err := cmd.Flags().GetBool("org-owner") - if err != nil { - return err - } - organizationName, err := cmd.Flags().GetString("name") - if err != nil { - return err - } - if err := requiredInputCheck("Organization name", organizationName); err != nil { - return err - } - groupName, err := cmd.Flags().GetString("group") - if err != nil { - return err - } - if err := requiredInputCheck("Group name", groupName); err != nil { - return err - } - - current := lagoonCLIConfig.Current - token := lagoonCLIConfig.Lagoons[current].Token - lc := lclient.New( - lagoonCLIConfig.Lagoons[current].GraphQL, - lagoonCLIVersion, - lagoonCLIConfig.Lagoons[current].Version, - &token, - debug) - - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) - handleError(err) - - groupInput := s.AddGroupToOrganizationInput{ - Name: groupName, - Organization: organization.ID, - AddOrgOwner: orgOwner, - } - group := s.OrgGroup{} - err = lc.AddGroupToOrganization(context.TODO(), &groupInput, &group) - handleError(err) - - resultData := output.Result{ - Result: "success", - ResultData: map[string]interface{}{ - "Group Name": group.Name, - "Organization Name": organizationName, - }, - } - output.RenderResult(resultData, outputOptions) - return nil - }, -} - func init() { - addGroupCmd.Flags().StringVarP(&groupName, "name", "N", "", "Name of the group") + addGroupCmd.Flags().StringP("name", "N", "", "Name of the group") + addGroupCmd.Flags().StringP("organization-name", "O", "", "Name of the organization") + addGroupCmd.Flags().Bool("owner", false, "Organization owner only: Flag to grant yourself ownership of this group") addUserToGroupCmd.Flags().StringVarP(&groupName, "name", "N", "", "Name of the group") addUserToGroupCmd.Flags().StringP("role", "R", "", "Role in the group [owner, maintainer, developer, reporter, guest]") addUserToGroupCmd.Flags().StringVarP(&userEmail, "email", "E", "", "Email address of the user") @@ -308,7 +298,5 @@ func init() { deleteUserFromGroupCmd.Flags().StringVarP(&userEmail, "email", "E", "", "Email address of the user") deleteProjectFromGroupCmd.Flags().StringVarP(&groupName, "name", "N", "", "Name of the group") deleteGroupCmd.Flags().StringVarP(&groupName, "name", "N", "", "Name of the group") - addGroupToOrganizationCmd.Flags().StringP("name", "O", "", "Name of the organization") - addGroupToOrganizationCmd.Flags().StringP("group", "G", "", "Name of the group") - addGroupToOrganizationCmd.Flags().Bool("org-owner", false, "Flag to add the user to the group as an owner") + } diff --git a/cmd/list.go b/cmd/list.go index bd729ec4..46695b51 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -628,18 +628,9 @@ var listProjectGroupsCmd = &cobra.Command{ }, } -var listOrganizationCmd = &cobra.Command{ - Use: "organization", - Aliases: []string{"o"}, - Short: "List all organizations projects, groups, deploy targets or users", - PersistentPreRun: func(cmd *cobra.Command, args []string) { - validateToken(lagoonCLIConfig.Current) - }, -} - var listOrganizationProjectsCmd = &cobra.Command{ - Use: "projects", - Aliases: []string{"p"}, + Use: "organization-projects", + Aliases: []string{"org-p"}, Short: "List projects in an organization", PreRunE: func(_ *cobra.Command, _ []string) error { return validateTokenE(cmdLagoon) @@ -649,7 +640,7 @@ var listOrganizationProjectsCmd = &cobra.Command{ if err != nil { return err } - organizationName, err := cmd.Flags().GetString("name") + organizationName, err := cmd.Flags().GetString("organization-name") if err != nil { return err } @@ -697,8 +688,8 @@ var listOrganizationProjectsCmd = &cobra.Command{ } var listOrganizationGroupsCmd = &cobra.Command{ - Use: "groups", - Aliases: []string{"g"}, + Use: "organization-groups", + Aliases: []string{"org-g"}, Short: "List groups in an organization", PreRunE: func(_ *cobra.Command, _ []string) error { return validateTokenE(cmdLagoon) @@ -708,7 +699,7 @@ var listOrganizationGroupsCmd = &cobra.Command{ if err != nil { return err } - organizationName, err := cmd.Flags().GetString("name") + organizationName, err := cmd.Flags().GetString("organization-name") if err != nil { return err } @@ -756,8 +747,8 @@ var listOrganizationGroupsCmd = &cobra.Command{ } var listOrganizationDeployTargetsCmd = &cobra.Command{ - Use: "deploytargets", - Aliases: []string{"d"}, + Use: "organization-deploytargets", + Aliases: []string{"org-dt"}, Short: "List deploy targets in an organization", PreRunE: func(_ *cobra.Command, _ []string) error { return validateTokenE(cmdLagoon) @@ -767,7 +758,7 @@ var listOrganizationDeployTargetsCmd = &cobra.Command{ if err != nil { return err } - organizationName, err := cmd.Flags().GetString("name") + organizationName, err := cmd.Flags().GetString("organization-name") if err != nil { return err } @@ -775,10 +766,8 @@ var listOrganizationDeployTargetsCmd = &cobra.Command{ if err != nil { return err } - if err := requiredInputCheck("Organization name", organizationName); err != nil { - if err := requiredInputCheck("Organization ID", strconv.Itoa(int(organizationID))); err != nil { - return err - } + if organizationName == "" && organizationID == 0 { + return fmt.Errorf("missing arguments: Organization name or ID is not defined") } current := lagoonCLIConfig.Current @@ -790,8 +779,9 @@ var listOrganizationDeployTargetsCmd = &cobra.Command{ &token, debug) deployTargets, err := l.ListDeployTargetsByOrganizationNameOrID(context.TODO(), nullStrCheck(organizationName), nullUintCheck(organizationID), lc) - handleError(err) - + if err != nil { + return err + } if len(*deployTargets) == 0 { outputOptions.Error = fmt.Sprintf("No associated deploy targets found for organization '%s'\n", organizationName) } @@ -818,8 +808,8 @@ var listOrganizationDeployTargetsCmd = &cobra.Command{ } var ListOrganizationUsersCmd = &cobra.Command{ - Use: "users", - Aliases: []string{"u"}, + Use: "organization-users", + Aliases: []string{"org-u"}, Short: "List users in an organization", PreRunE: func(_ *cobra.Command, _ []string) error { return validateTokenE(cmdLagoon) @@ -829,7 +819,7 @@ var ListOrganizationUsersCmd = &cobra.Command{ if err != nil { return err } - organizationName, err := cmd.Flags().GetString("name") + organizationName, err := cmd.Flags().GetString("organization-name") if err != nil { return err } @@ -846,9 +836,13 @@ var ListOrganizationUsersCmd = &cobra.Command{ &token, debug) organization, err := l.GetOrganizationByName(context.Background(), organizationName, lc) - handleError(err) + if err != nil { + return err + } users, err := l.UsersByOrganization(context.TODO(), organization.ID, lc) - handleError(err) + if err != nil { + return err + } data := []output.Data{} for _, user := range *users { @@ -936,21 +930,20 @@ func init() { listCmd.AddCommand(listDeployTargetConfigsCmd) listCmd.AddCommand(listAllUsersCmd) listCmd.AddCommand(listUsersGroupsCmd) + listCmd.AddCommand(listOrganizationProjectsCmd) + listCmd.AddCommand(ListOrganizationUsersCmd) + listCmd.AddCommand(listOrganizationGroupsCmd) + listCmd.AddCommand(listOrganizationDeployTargetsCmd) + listCmd.AddCommand(listOrganizationsCmd) listAllUsersCmd.Flags().StringP("email-address", "E", "", "The email address of a user") listUsersGroupsCmd.Flags().StringP("email-address", "E", "", "The email address of a user") - listCmd.AddCommand(listOrganizationCmd) - listOrganizationCmd.AddCommand(listOrganizationProjectsCmd) - listOrganizationCmd.AddCommand(ListOrganizationUsersCmd) - listOrganizationCmd.AddCommand(listOrganizationGroupsCmd) - listOrganizationCmd.AddCommand(listOrganizationDeployTargetsCmd) - listOrganizationCmd.AddCommand(listOrganizationsCmd) listCmd.Flags().BoolVarP(&listAllProjects, "all-projects", "", false, "All projects (if supported)") listUsersCmd.Flags().StringVarP(&groupName, "name", "N", "", "Name of the group to list users in") listGroupProjectsCmd.Flags().StringVarP(&groupName, "name", "N", "", "Name of the group to list projects in") listVariablesCmd.Flags().BoolP("reveal", "", false, "Reveal the variable values") - listOrganizationProjectsCmd.Flags().StringP("name", "O", "", "Name of the organization to list associated projects for") - ListOrganizationUsersCmd.Flags().StringP("name", "O", "", "Name of the organization to list associated users for") - listOrganizationGroupsCmd.Flags().StringP("name", "O", "", "Name of the organization to list associated groups for") - listOrganizationDeployTargetsCmd.Flags().StringP("name", "O", "", "Name of the organization to list associated deploy targets for") + listOrganizationProjectsCmd.Flags().StringP("organization-name", "O", "", "Name of the organization to list associated projects for") + ListOrganizationUsersCmd.Flags().StringP("organization-name", "O", "", "Name of the organization to list associated users for") + listOrganizationGroupsCmd.Flags().StringP("organization-name", "O", "", "Name of the organization to list associated groups for") + listOrganizationDeployTargetsCmd.Flags().StringP("organization-name", "O", "", "Name of the organization to list associated deploy targets for") listOrganizationDeployTargetsCmd.Flags().Uint("id", 0, "ID of the organization to list associated deploy targets for") } diff --git a/cmd/organization.go b/cmd/organization.go index 2956273a..7df40439 100644 --- a/cmd/organization.go +++ b/cmd/organization.go @@ -11,7 +11,7 @@ import ( s "github.com/uselagoon/machinery/api/schema" ) -var addOrgCmd = &cobra.Command{ +var addOrganizationCmd = &cobra.Command{ Use: "organization", Aliases: []string{"o"}, Short: "Add a new organization to Lagoon", @@ -23,7 +23,7 @@ var addOrgCmd = &cobra.Command{ if err != nil { return err } - organizationName, err := cmd.Flags().GetString("name") + organizationName, err := cmd.Flags().GetString("organization-name") if err != nil { return err } @@ -80,7 +80,9 @@ var addOrgCmd = &cobra.Command{ } org := s.Organization{} err = lc.AddOrganization(context.TODO(), &organizationInput, &org) - handleError(err) + if err != nil { + return err + } resultData := output.Result{ Result: "success", @@ -93,7 +95,7 @@ var addOrgCmd = &cobra.Command{ }, } -var deleteOrgCmd = &cobra.Command{ +var deleteOrganizationCmd = &cobra.Command{ Use: "organization", Aliases: []string{"o"}, Short: "Delete an organization", @@ -105,7 +107,7 @@ var deleteOrgCmd = &cobra.Command{ if err != nil { return err } - organizationName, err := cmd.Flags().GetString("name") + organizationName, err := cmd.Flags().GetString("organization-name") if err != nil { return err } @@ -123,10 +125,14 @@ var deleteOrgCmd = &cobra.Command{ debug) organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) - handleError(err) + if err != nil { + return err + } if yesNo(fmt.Sprintf("You are attempting to delete organization '%s', are you sure?", organization.Name)) { _, err := l.DeleteOrganization(context.TODO(), organization.ID, lc) - handleError(err) + if err != nil { + return err + } resultData := output.Result{ Result: organization.Name, } @@ -148,7 +154,7 @@ var updateOrganizationCmd = &cobra.Command{ if err != nil { return err } - organizationName, err := cmd.Flags().GetString("name") + organizationName, err := cmd.Flags().GetString("organization-name") if err != nil { return err } @@ -226,27 +232,16 @@ var updateOrganizationCmd = &cobra.Command{ } func init() { - addOrganizationCmd.AddCommand(addOrgCmd) - addOrganizationCmd.AddCommand(addGroupToOrganizationCmd) - addOrganizationCmd.AddCommand(addProjectToOrganizationCmd) - addOrganizationCmd.AddCommand(addDeployTargetToOrganizationCmd) - addOrganizationCmd.AddCommand(addUserToOrganizationCmd) - - deleteOrganizationCmd.AddCommand(deleteOrgCmd) - deleteOrganizationCmd.AddCommand(RemoveDeployTargetFromOrganizationCmd) - deleteOrganizationCmd.AddCommand(RemoveProjectFromOrganizationCmd) - deleteOrganizationCmd.AddCommand(RemoveUserFromOrganization) - - addOrgCmd.Flags().StringP("name", "O", "", "Name of the organization") - addOrgCmd.Flags().String("friendly-name", "", "Friendly name of the organization") - addOrgCmd.Flags().String("description", "", "Description of the organization") - addOrgCmd.Flags().Int("project-quota", 0, "Project quota for the organization") - addOrgCmd.Flags().Int("group-quota", 0, "Group quota for the organization") - addOrgCmd.Flags().Int("notification-quota", 0, "Notification quota for the organization") - addOrgCmd.Flags().Int("environment-quota", 0, "Environment quota for the organization") - addOrgCmd.Flags().Int("route-quota", 0, "Route quota for the organization") - - updateOrganizationCmd.Flags().StringP("name", "O", "", "Name of the organization to update") + addOrganizationCmd.Flags().StringP("organization-name", "O", "", "Name of the organization") + addOrganizationCmd.Flags().String("friendly-name", "", "Friendly name of the organization") + addOrganizationCmd.Flags().String("description", "", "Description of the organization") + addOrganizationCmd.Flags().Int("project-quota", 0, "Project quota for the organization") + addOrganizationCmd.Flags().Int("group-quota", 0, "Group quota for the organization") + addOrganizationCmd.Flags().Int("notification-quota", 0, "Notification quota for the organization") + addOrganizationCmd.Flags().Int("environment-quota", 0, "Environment quota for the organization") + addOrganizationCmd.Flags().Int("route-quota", 0, "Route quota for the organization") + + updateOrganizationCmd.Flags().StringP("organization-name", "O", "", "Name of the organization to update") updateOrganizationCmd.Flags().String("friendly-name", "", "Friendly name of the organization") updateOrganizationCmd.Flags().String("description", "", "Description of the organization") updateOrganizationCmd.Flags().Int("project-quota", 0, "Project quota for the organization") @@ -255,5 +250,5 @@ func init() { updateOrganizationCmd.Flags().Int("environment-quota", 0, "Environment quota for the organization") updateOrganizationCmd.Flags().Int("route-quota", 0, "Route quota for the organization") - deleteOrgCmd.Flags().StringP("name", "O", "", "Name of the organization to delete") + deleteOrganizationCmd.Flags().StringP("organization-name", "O", "", "Name of the organization to delete") } diff --git a/cmd/project.go b/cmd/project.go index 2ff15bcb..45702d1b 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -66,34 +66,134 @@ var deleteProjectCmd = &cobra.Command{ var addProjectCmd = &cobra.Command{ Use: "project", Aliases: []string{"p"}, - Short: "Add a new project to Lagoon", - Run: func(cmd *cobra.Command, args []string) { - projectFlags := parseProjectFlags(*cmd.Flags()) - if cmdProjectName == "" { - fmt.Println("Missing arguments: Project name is not defined") - cmd.Help() - os.Exit(1) + Short: "Add a new project to Lagoon, or add a project to an organization", + Long: "To add a project to an organization, you'll need to include the `organization` flag and provide the name of the organization. You need to be an owner of this organization to do this.\nIf you're the organization owner and want to grant yourself ownership to this project to be able to deploy environments, specify the `owner` flag.", + PreRunE: func(_ *cobra.Command, _ []string) error { + return validateTokenE(lagoonCLIConfig.Current) + }, + RunE: func(cmd *cobra.Command, args []string) error { + debug, err := cmd.Flags().GetBool("debug") + if err != nil { + return err } - jsonPatch, _ := json.Marshal(projectFlags) - addResult, err := pClient.AddProject(cmdProjectName, string(jsonPatch)) - handleError(err) - var addedProject api.Project - err = json.Unmarshal([]byte(addResult), &addedProject) - handleError(err) - + organizationName, err := cmd.Flags().GetString("organization-name") if err != nil { - output.RenderError(err.Error(), outputOptions) - } else { - resultData := output.Result{ - Result: "success", - ResultData: map[string]interface{}{ - "Project Name": addedProject.Name, - "GitURL": addedProject.GitURL, - }, + return err + } + gitUrl, err := cmd.Flags().GetString("gitUrl") + if err != nil { + return err + } + productionEnvironment, err := cmd.Flags().GetString("productionEnvironment") + if err != nil { + return err + } + openshift, err := cmd.Flags().GetUint("openshift") + if err != nil { + return err + } + standbyProductionEnvironment, err := cmd.Flags().GetString("standbyProductionEnvironment") + if err != nil { + return err + } + branches, err := cmd.Flags().GetString("branches") + if err != nil { + return err + } + pullrequests, err := cmd.Flags().GetString("pullrequests") + if err != nil { + return err + } + openshiftProjectPattern, err := cmd.Flags().GetString("openshiftProjectPattern") + if err != nil { + return err + } + developmentEnvironmentsLimit, err := cmd.Flags().GetUint("developmentEnvironmentsLimit") + if err != nil { + return err + } + storageCalc, err := cmd.Flags().GetUint("storageCalc") + if err != nil { + return err + } + autoIdle, err := cmd.Flags().GetUint("autoIdle") + if err != nil { + return err + } + subfolder, err := cmd.Flags().GetString("subfolder") + if err != nil { + return err + } + privateKey, err := cmd.Flags().GetString("privateKey") + if err != nil { + return err + } + orgOwner, err := cmd.Flags().GetBool("owner") + if err != nil { + return err + } + routerPattern, err := cmd.Flags().GetString("routerPattern") + if err != nil { + return err + } + + if err := requiredInputCheck("Project name", cmdProjectName, "GitURL", gitUrl, "Production environment", productionEnvironment, "Openshift", strconv.Itoa(int(openshift))); err != nil { + return err + } + + current := lagoonCLIConfig.Current + token := lagoonCLIConfig.Lagoons[current].Token + lc := lclient.New( + lagoonCLIConfig.Lagoons[current].GraphQL, + lagoonCLIVersion, + lagoonCLIConfig.Lagoons[current].Version, + &token, + debug) + + projectInput := s.AddProjectInput{ + Name: cmdProjectName, + AddOrgOwner: orgOwner, + GitURL: gitUrl, + ProductionEnvironment: productionEnvironment, + StandbyProductionEnvironment: standbyProductionEnvironment, + Branches: branches, + PullRequests: pullrequests, + OpenshiftProjectPattern: openshiftProjectPattern, + Openshift: openshift, + DevelopmentEnvironmentsLimit: developmentEnvironmentsLimit, + StorageCalc: storageCalc, + AutoIdle: autoIdle, + Subfolder: subfolder, + PrivateKey: privateKey, + RouterPattern: routerPattern, + } + + if organizationName != "" { + organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + if err != nil { + return err } - output.RenderResult(resultData, outputOptions) + projectInput.Organization = organization.ID } + + project := s.Project{} + err = lc.AddProject(context.TODO(), &projectInput, &project) + if err != nil { + return err + } + resultData := output.Result{ + Result: "success", + ResultData: map[string]interface{}{ + "Project Name": project.Name, + "GitURL": gitUrl, + }, + } + if organizationName != "" { + resultData.ResultData["Organization"] = organizationName + } + output.RenderResult(resultData, outputOptions) + return nil }, } @@ -371,118 +471,25 @@ var deleteProjectMetadataByKey = &cobra.Command{ }, } -var addProjectToOrganizationCmd = &cobra.Command{ - Use: "project", - Aliases: []string{"p"}, - Short: "Add a project to an Organization", +var removeProjectFromOrganizationCmd = &cobra.Command{ + Use: "organization-project", + Aliases: []string{"org-p"}, + Short: "Remove a project from an Organization", + Long: "Removes a project from an Organization, but does not delete the project.\nThis is used by platform administrators to be able to reset a project.", PreRunE: func(_ *cobra.Command, _ []string) error { return validateTokenE(lagoonCLIConfig.Current) }, RunE: func(cmd *cobra.Command, args []string) error { debug, err := cmd.Flags().GetBool("debug") - handleError(err) - - if err := requiredInputCheck("Project name", cmdProjectName); err != nil { - return err - } - organizationName, err := cmd.Flags().GetString("name") - if err != nil { - return err - } - if err := requiredInputCheck("Organization name", organizationName); err != nil { - return err - } - gitUrl, err := cmd.Flags().GetString("git-url") - if err != nil { - return err - } - if err := requiredInputCheck("gitUrl", gitUrl); err != nil { - return err - } - productionEnvironment, err := cmd.Flags().GetString("production-environment") - if err != nil { - return err - } - if err := requiredInputCheck("Production Environment", productionEnvironment); err != nil { - return err - } - openshift, err := cmd.Flags().GetUint("openshift") - if err != nil { - return err - } - if err := requiredInputCheck("openshift", strconv.Itoa(int(openshift))); err != nil { - return err - } - standbyProductionEnvironment, err := cmd.Flags().GetString("standby-production-environment") - if err != nil { - return err - } - branches, err := cmd.Flags().GetString("branches") - if err != nil { - return err - } - pullrequests, err := cmd.Flags().GetString("pullrequests") - if err != nil { - return err - } - openshiftProjectPattern, err := cmd.Flags().GetString("openshift-project-pattern") - if err != nil { - return err - } - developmentEnvironmentsLimit, err := cmd.Flags().GetUint("development-environments-limit") - if err != nil { - return err - } - storageCalc, err := cmd.Flags().GetUint("storage-calc") - if err != nil { - return err - } - autoIdle, err := cmd.Flags().GetUint("auto-idle") if err != nil { return err } - subfolder, err := cmd.Flags().GetString("subfolder") - if err != nil { - return err - } - privateKey, err := cmd.Flags().GetString("private-key") - if err != nil { - return err - } - orgOwner, err := cmd.Flags().GetBool("org-owner") - if err != nil { - return err - } - buildImage, err := cmd.Flags().GetString("build-image") - if err != nil { - return err - } - availability, err := cmd.Flags().GetString("availability") - if err != nil { - return err - } - factsUi, err := cmd.Flags().GetUint("facts-ui") - if err != nil { - return err - } - problemsUi, err := cmd.Flags().GetUint("problems-ui") - if err != nil { - return err - } - routerPattern, err := cmd.Flags().GetString("router-pattern") - if err != nil { - return err - } - deploymentsDisabled, err := cmd.Flags().GetUint("deployments-disabled") - if err != nil { - return err - } - ProductionBuildPriority, err := cmd.Flags().GetUint("production-build-priority") + + organizationName, err := cmd.Flags().GetString("organization-name") if err != nil { return err } - DevelopmentBuildPriority, err := cmd.Flags().GetUint("development-build-priority") - if err != nil { + if err := requiredInputCheck("Project name", cmdProjectName, "Organization name", organizationName); err != nil { return err } @@ -495,86 +502,15 @@ var addProjectToOrganizationCmd = &cobra.Command{ &token, debug) - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) - handleError(err) - - projectInput := s.AddProjectInput{ - Name: cmdProjectName, - Organization: organization.ID, - AddOrgOwner: orgOwner, - BuildImage: buildImage, - Availability: s.ProjectAvailability(availability), - GitURL: gitUrl, - ProductionEnvironment: productionEnvironment, - StandbyProductionEnvironment: standbyProductionEnvironment, - Branches: branches, - PullRequests: pullrequests, - OpenshiftProjectPattern: openshiftProjectPattern, - Openshift: openshift, - DevelopmentEnvironmentsLimit: developmentEnvironmentsLimit, - StorageCalc: storageCalc, - AutoIdle: autoIdle, - Subfolder: subfolder, - PrivateKey: privateKey, - RouterPattern: routerPattern, - ProblemsUI: problemsUi, - FactsUI: factsUi, - ProductionBuildPriority: ProductionBuildPriority, - DevelopmentBuildPriority: DevelopmentBuildPriority, - DeploymentsDisabled: deploymentsDisabled, - } - project := s.Project{} - err = lc.AddProject(context.TODO(), &projectInput, &project) - handleError(err) - - resultData := output.Result{ - Result: "success", - ResultData: map[string]interface{}{ - "Project Name": project.Name, - "Organization Name": organizationName, - }, - } - output.RenderResult(resultData, outputOptions) - return nil - }, -} - -var RemoveProjectFromOrganizationCmd = &cobra.Command{ - Use: "project", - Aliases: []string{"p"}, - Short: "Remove a project from an Organization", - PreRunE: func(_ *cobra.Command, _ []string) error { - return validateTokenE(lagoonCLIConfig.Current) - }, - RunE: func(cmd *cobra.Command, args []string) error { - debug, err := cmd.Flags().GetBool("debug") - handleError(err) - - if err := requiredInputCheck("Project name", cmdProjectName); err != nil { - return err - } - organizationName, err := cmd.Flags().GetString("name") + project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) if err != nil { return err } - if err := requiredInputCheck("Organization name", organizationName); err != nil { + organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) + if err != nil { return err } - current := lagoonCLIConfig.Current - token := lagoonCLIConfig.Lagoons[current].Token - lc := lclient.New( - lagoonCLIConfig.Lagoons[current].GraphQL, - lagoonCLIVersion, - lagoonCLIConfig.Lagoons[current].Version, - &token, - debug) - - project, err := l.GetMinimalProjectByName(context.TODO(), cmdProjectName, lc) - handleError(err) - organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) - handleError(err) - projectInput := s.RemoveProjectFromOrganizationInput{ Project: project.ID, Organization: organization.ID, @@ -582,7 +518,9 @@ var RemoveProjectFromOrganizationCmd = &cobra.Command{ 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) - handleError(err) + if err != nil { + return err + } resultData := output.Result{ Result: "success", ResultData: map[string]interface{}{ @@ -620,22 +558,24 @@ func init() { updateProjectCmd.Flags().IntVarP(&factsUi, "factsUi", "", 0, "Enables the Lagoon insights Facts tab in the UI. Set to 1 to enable, 0 to disable") updateProjectCmd.Flags().IntVarP(&problemsUi, "problemsUi", "", 0, "Enables the Lagoon insights Problems tab in the UI. Set to 1 to enable, 0 to disable") - addProjectCmd.Flags().StringVarP(&jsonPatch, "json", "j", "", "JSON string to patch") - - addProjectCmd.Flags().StringVarP(&projectPatch.GitURL, "gitUrl", "g", "", "GitURL of the project") - addProjectCmd.Flags().StringVarP(&projectPatch.PrivateKey, "privateKey", "I", "", "Private key to use for the project") - addProjectCmd.Flags().StringVarP(&projectPatch.Subfolder, "subfolder", "s", "", "Set if the .lagoon.yml should be found in a subfolder useful if you have multiple Lagoon projects per Git Repository") - addProjectCmd.Flags().StringVarP(&projectPatch.RouterPattern, "routerPattern", "Z", "", "Router pattern of the project, e.g. '${service}-${environment}-${project}.lagoon.example.com'") - addProjectCmd.Flags().StringVarP(&projectPatch.Branches, "branches", "b", "", "Which branches should be deployed") - addProjectCmd.Flags().StringVarP(&projectPatch.Pullrequests, "pullrequests", "m", "", "Which Pull Requests should be deployed") - addProjectCmd.Flags().StringVarP(&projectPatch.ProductionEnvironment, "productionEnvironment", "E", "", "Which environment(the name) should be marked as the production environment") - addProjectCmd.Flags().StringVar(&projectPatch.StandbyProductionEnvironment, "standbyProductionEnvironment", "", "Which environment(the name) should be marked as the standby production environment") - addProjectCmd.Flags().StringVarP(&projectPatch.OpenshiftProjectPattern, "openshiftProjectPattern", "o", "", "Pattern of OpenShift Project/Namespace that should be generated") - - addProjectCmd.Flags().IntVarP(&projectAutoIdle, "autoIdle", "a", 0, "Auto idle setting of the project") - addProjectCmd.Flags().IntVarP(&projectStorageCalc, "storageCalc", "C", 0, "Should storage for this environment be calculated") - addProjectCmd.Flags().IntVarP(&projectDevelopmentEnvironmentsLimit, "developmentEnvironmentsLimit", "L", 0, "How many environments can be deployed at one time") - addProjectCmd.Flags().IntVarP(&projectOpenshift, "openshift", "S", 0, "Reference to OpenShift Object this Project should be deployed to") + addProjectCmd.Flags().StringP("json", "j", "", "JSON string to patch") + + addProjectCmd.Flags().StringP("gitUrl", "g", "", "GitURL of the project") + addProjectCmd.Flags().StringP("privateKey", "I", "", "Private key to use for the project") + addProjectCmd.Flags().StringP("subfolder", "s", "", "Set if the .lagoon.yml should be found in a subfolder useful if you have multiple Lagoon projects per Git Repository") + addProjectCmd.Flags().StringP("routerPattern", "Z", "", "Router pattern of the project, e.g. '${service}-${environment}-${project}.lagoon.example.com'") + addProjectCmd.Flags().StringP("branches", "b", "", "Which branches should be deployed") + addProjectCmd.Flags().StringP("pullrequests", "m", "", "Which Pull Requests should be deployed") + addProjectCmd.Flags().StringP("productionEnvironment", "E", "", "Which environment(the name) should be marked as the production environment") + addProjectCmd.Flags().String("standbyProductionEnvironment", "", "Which environment(the name) should be marked as the standby production environment") + addProjectCmd.Flags().StringP("openshiftProjectPattern", "o", "", "Pattern of OpenShift Project/Namespace that should be generated") + + addProjectCmd.Flags().UintP("autoIdle", "a", 0, "Auto idle setting of the project") + addProjectCmd.Flags().UintP("storageCalc", "C", 0, "Should storage for this environment be calculated") + addProjectCmd.Flags().UintP("developmentEnvironmentsLimit", "L", 0, "How many environments can be deployed at one time") + addProjectCmd.Flags().UintP("openshift", "S", 0, "Reference to OpenShift Object this Project should be deployed to") + addProjectCmd.Flags().Bool("owner", false, "Add the user as an owner of the project") + addProjectCmd.Flags().StringP("organization-name", "O", "", "Name of the Organization to add the project to") listCmd.AddCommand(listProjectByMetadata) listProjectByMetadata.Flags().StringP("key", "K", "", "The key name of the metadata value you are querying on") @@ -651,30 +591,5 @@ func init() { getCmd.AddCommand(getProjectMetadata) - addProjectToOrganizationCmd.Flags().String("build-image", "", "Build Image for the project") - addProjectToOrganizationCmd.Flags().String("availability", "", "Availability of the project") - addProjectToOrganizationCmd.Flags().String("git-url", "", "GitURL of the project") - addProjectToOrganizationCmd.Flags().String("production-environment", "", "Production Environment for the project") - addProjectToOrganizationCmd.Flags().String("standby-production-environment", "", "Standby Production Environment for the project") - addProjectToOrganizationCmd.Flags().String("subfolder", "", "Set if the .lagoon.yml should be found in a subfolder useful if you have multiple Lagoon projects per Git Repository") - addProjectToOrganizationCmd.Flags().String("private-key", "", "Private key to use for the project") - addProjectToOrganizationCmd.Flags().String("branches", "", "branches") - addProjectToOrganizationCmd.Flags().String("pullrequests", "", "Which Pull Requests should be deployed") - addProjectToOrganizationCmd.Flags().StringP("name", "O", "", "Name of the Organization to add the project to") - addProjectToOrganizationCmd.Flags().String("openshift-project-pattern", "", "Pattern of OpenShift Project/Namespace that should be generated") - addProjectToOrganizationCmd.Flags().String("router-pattern", "", "Router pattern of the project, e.g. '${service}-${environment}-${project}.lagoon.example.com'") - - addProjectToOrganizationCmd.Flags().Uint("openshift", 0, "Reference to OpenShift Object this Project should be deployed to") - addProjectToOrganizationCmd.Flags().Uint("auto-idle", 0, "Auto idle setting of the project") - addProjectToOrganizationCmd.Flags().Uint("storage-calc", 0, "Should storage for this environment be calculated") - addProjectToOrganizationCmd.Flags().Uint("development-environments-limit", 0, "How many environments can be deployed at one time") - addProjectToOrganizationCmd.Flags().Uint("facts-ui", 0, "Enables the Lagoon insights Facts tab in the UI. Set to 1 to enable, 0 to disable") - addProjectToOrganizationCmd.Flags().Uint("problems-ui", 0, "Enables the Lagoon insights Problems tab in the UI. Set to 1 to enable, 0 to disable") - addProjectToOrganizationCmd.Flags().Uint("deployments-disabled", 0, "Admin only flag for disabling deployments on a project, 1 to disable deployments, 0 to enable") - addProjectToOrganizationCmd.Flags().Uint("production-build-priority", 0, "Set the priority of the production build") - addProjectToOrganizationCmd.Flags().Uint("development-build-priority", 0, "Set the priority of the development build") - - addProjectToOrganizationCmd.Flags().Bool("org-owner", false, "Add the user as an owner of the project") - - RemoveProjectFromOrganizationCmd.Flags().StringP("name", "O", "", "Name of the Organization to remove the project from") + removeProjectFromOrganizationCmd.Flags().StringP("organization-name", "O", "", "Name of the Organization to remove the project from") } diff --git a/cmd/shared.go b/cmd/shared.go index 020c74b1..1d28cbc3 100644 --- a/cmd/shared.go +++ b/cmd/shared.go @@ -93,9 +93,15 @@ func nullIntCheck(i int) *int { return &i } -func requiredInputCheck(field string, value string) error { - if value == "" || value == "0" { - return fmt.Errorf(fmt.Sprintf("Missing argument: %s is not defined", field)) +// Specify the fields and values to check for required input e.g. requiredInputCheck("field1", value1, "field2", value2) +func requiredInputCheck(fieldsAndValues ...string) error { + for i := 0; i < len(fieldsAndValues); i += 2 { + field := fieldsAndValues[i] + value := fieldsAndValues[i+1] + + if value == "" || value == "0" { + return fmt.Errorf("missing argument: %s is not defined", field) + } } return nil } diff --git a/cmd/users.go b/cmd/users.go index 615828d4..29294a52 100644 --- a/cmd/users.go +++ b/cmd/users.go @@ -366,29 +366,29 @@ var getAllUserKeysCmd = &cobra.Command{ }, } -var addUserToOrganizationCmd = &cobra.Command{ - Use: "user", - Aliases: []string{"u"}, - Short: "Add a user to an Organization", +var addAdministratorToOrganizationCmd = &cobra.Command{ + Use: "organization-administrator", + Aliases: []string{"org-admin"}, + Short: "Add an administrator to an Organization", + Long: "Add an administrator to an Organization. If the owner flag is not provided users will be added as viewers", PreRunE: func(_ *cobra.Command, _ []string) error { return validateTokenE(lagoonCLIConfig.Current) }, RunE: func(cmd *cobra.Command, args []string) error { debug, err := cmd.Flags().GetBool("debug") - handleError(err) - - organizationName, err := cmd.Flags().GetString("name") if err != nil { return err } - if err := requiredInputCheck("Organization name", organizationName); err != nil { + + organizationName, err := cmd.Flags().GetString("organization-name") + if err != nil { return err } userEmail, err := cmd.Flags().GetString("email") if err != nil { return err } - if err := requiredInputCheck("User email", userEmail); err != nil { + if err := requiredInputCheck("Organization name", organizationName, "User email", userEmail); err != nil { return err } owner, err := cmd.Flags().GetBool("owner") @@ -406,7 +406,9 @@ var addUserToOrganizationCmd = &cobra.Command{ debug) organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) - handleError(err) + if err != nil { + return err + } userInput := s.AddUserToOrganizationInput{ User: s.UserInput{Email: userEmail}, @@ -416,7 +418,9 @@ var addUserToOrganizationCmd = &cobra.Command{ orgUser := s.Organization{} err = lc.AddUserToOrganization(context.TODO(), &userInput, &orgUser) - handleError(err) + if err != nil { + return err + } resultData := output.Result{ Result: "success", @@ -430,18 +434,20 @@ var addUserToOrganizationCmd = &cobra.Command{ }, } -var RemoveUserFromOrganization = &cobra.Command{ - Use: "user", - Aliases: []string{"u"}, - Short: "Remove a user to an Organization", +var removeAdministratorFromOrganizationCmd = &cobra.Command{ + Use: "organization-administrator", + Aliases: []string{"org-admin"}, + Short: "Remove an administrator from an Organization", PreRunE: func(_ *cobra.Command, _ []string) error { return validateTokenE(lagoonCLIConfig.Current) }, RunE: func(cmd *cobra.Command, args []string) error { debug, err := cmd.Flags().GetBool("debug") - handleError(err) + if err != nil { + return err + } - organizationName, err := cmd.Flags().GetString("name") + organizationName, err := cmd.Flags().GetString("organization-name") if err != nil { return err } @@ -470,7 +476,9 @@ var RemoveUserFromOrganization = &cobra.Command{ debug) organization, err := l.GetOrganizationByName(context.TODO(), organizationName, lc) - handleError(err) + if err != nil { + return err + } userInput := s.AddUserToOrganizationInput{ User: s.UserInput{Email: userEmail}, @@ -482,7 +490,9 @@ var RemoveUserFromOrganization = &cobra.Command{ 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) - handleError(err) + if err != nil { + return err + } resultData := output.Result{ Result: "success", ResultData: map[string]interface{}{ @@ -540,11 +550,11 @@ func init() { updateUserCmd.Flags().StringVarP(¤tUserEmail, "current-email", "C", "", "Current email address of the user") getUserKeysCmd.Flags().StringP("email", "E", "", "New email address of the user") getAllUserKeysCmd.Flags().StringP("name", "N", "", "Name of the group to list users in (if not specified, will default to all groups)") - addUserToOrganizationCmd.Flags().StringP("name", "O", "", "Name of the organization") - addUserToOrganizationCmd.Flags().StringP("email", "E", "", "Email address of the user") - addUserToOrganizationCmd.Flags().Bool("owner", false, "Set the user as an owner of the organization") - RemoveUserFromOrganization.Flags().StringP("name", "O", "", "Name of the organization") - RemoveUserFromOrganization.Flags().StringP("email", "E", "", "Email address of the user") - RemoveUserFromOrganization.Flags().Bool("owner", false, "Set the user as an owner of the organization") + addAdministratorToOrganizationCmd.Flags().StringP("organization-name", "O", "", "Name of the organization") + addAdministratorToOrganizationCmd.Flags().StringP("email", "E", "", "Email address of the user") + addAdministratorToOrganizationCmd.Flags().Bool("owner", false, "Set the user as an owner of the organization") + removeAdministratorFromOrganizationCmd.Flags().StringP("organization-name", "O", "", "Name of the organization") + removeAdministratorFromOrganizationCmd.Flags().StringP("email", "E", "", "Email address of the user") + removeAdministratorFromOrganizationCmd.Flags().Bool("owner", false, "Set the user as an administrator of the organization") resetPasswordCmd.Flags().StringVarP(&userEmail, "email", "E", "", "Email address of the user") } diff --git a/docs/commands/lagoon_add.md b/docs/commands/lagoon_add.md index b2a9a9f0..e600bac5 100644 --- a/docs/commands/lagoon_add.md +++ b/docs/commands/lagoon_add.md @@ -30,10 +30,12 @@ Add a project, or add notifications and variables to projects or environments * [lagoon](lagoon.md) - Command line integration for Lagoon * [lagoon add deploytarget](lagoon_add_deploytarget.md) - Add a DeployTarget to lagoon * [lagoon add deploytarget-config](lagoon_add_deploytarget-config.md) - Add deploytarget config to a project -* [lagoon add group](lagoon_add_group.md) - Add a group to lagoon +* [lagoon add group](lagoon_add_group.md) - Add a group to Lagoon, or add a group to an organization * [lagoon add notification](lagoon_add_notification.md) - Add notifications or add notifications to projects -* [lagoon add organization](lagoon_add_organization.md) - Add an organization, or add a group/project to an organization -* [lagoon add project](lagoon_add_project.md) - Add a new project to Lagoon +* [lagoon add organization](lagoon_add_organization.md) - Add a new organization to Lagoon +* [lagoon add organization-administrator](lagoon_add_organization-administrator.md) - Add an administrator to an Organization +* [lagoon add organization-deploytarget](lagoon_add_organization-deploytarget.md) - Add a deploy target to an Organization +* [lagoon add project](lagoon_add_project.md) - Add a new project to Lagoon, or add a project to an organization * [lagoon add project-group](lagoon_add_project-group.md) - Add a project to a group in lagoon * [lagoon add user](lagoon_add_user.md) - Add a user to lagoon * [lagoon add user-group](lagoon_add_user-group.md) - Add a user to a group in lagoon diff --git a/docs/commands/lagoon_add_group.md b/docs/commands/lagoon_add_group.md index 25a290be..71b6aef2 100644 --- a/docs/commands/lagoon_add_group.md +++ b/docs/commands/lagoon_add_group.md @@ -1,6 +1,11 @@ ## lagoon add group -Add a group to lagoon +Add a group to Lagoon, or add a group to an organization + +### Synopsis + +To add a group to an organization, you'll need to include the `organization` flag and provide the name of the organization. You need to be an owner of this organization to do this. +If you're the organization owner and want to grant yourself ownership to this group to be able to deploy projects that may be added to it, specify the `owner` flag, otherwise you will still be able to add and remove users without being an owner ``` lagoon add group [flags] @@ -9,8 +14,10 @@ lagoon add group [flags] ### Options ``` - -h, --help help for group - -N, --name string Name of the group + -h, --help help for group + -N, --name string Name of the group + -O, --organization-name string Name of the organization + --owner Organization owner only: Flag to grant yourself ownership of this group ``` ### Options inherited from parent commands diff --git a/docs/commands/lagoon_add_organization_user.md b/docs/commands/lagoon_add_organization-administrator.md similarity index 58% rename from docs/commands/lagoon_add_organization_user.md rename to docs/commands/lagoon_add_organization-administrator.md index e4c3c674..038a2f5a 100644 --- a/docs/commands/lagoon_add_organization_user.md +++ b/docs/commands/lagoon_add_organization-administrator.md @@ -1,18 +1,22 @@ -## lagoon add organization user +## lagoon add organization-administrator -Add a user to an Organization +Add an administrator to an Organization + +### Synopsis + +Add an administrator to an Organization. If the owner flag is not provided users will be added as viewers ``` -lagoon add organization user [flags] +lagoon add organization-administrator [flags] ``` ### Options ``` - -E, --email string Email address of the user - -h, --help help for user - -O, --name string Name of the organization - --owner Set the user as an owner of the organization + -E, --email string Email address of the user + -h, --help help for organization-administrator + -O, --organization-name string Name of the organization + --owner Set the user as an owner of the organization ``` ### Options inherited from parent commands @@ -34,5 +38,5 @@ lagoon add organization user [flags] ### SEE ALSO -* [lagoon add organization](lagoon_add_organization.md) - Add an organization, or add a group/project to an organization +* [lagoon add](lagoon_add.md) - Add a project, or add notifications and variables to projects or environments diff --git a/docs/commands/lagoon_add_organization_deploytarget.md b/docs/commands/lagoon_add_organization-deploytarget.md similarity index 71% rename from docs/commands/lagoon_add_organization_deploytarget.md rename to docs/commands/lagoon_add_organization-deploytarget.md index 12baa1b9..34ce6973 100644 --- a/docs/commands/lagoon_add_organization_deploytarget.md +++ b/docs/commands/lagoon_add_organization-deploytarget.md @@ -1,17 +1,17 @@ -## lagoon add organization deploytarget +## lagoon add organization-deploytarget Add a deploy target to an Organization ``` -lagoon add organization deploytarget [flags] +lagoon add organization-deploytarget [flags] ``` ### Options ``` - -D, --deploy-target uint ID of DeployTarget - -h, --help help for deploytarget - -O, --name string Name of Organization + -D, --deploytarget uint ID of DeployTarget + -h, --help help for organization-deploytarget + -O, --organization-name string Name of Organization ``` ### Options inherited from parent commands @@ -33,5 +33,5 @@ lagoon add organization deploytarget [flags] ### SEE ALSO -* [lagoon add organization](lagoon_add_organization.md) - Add an organization, or add a group/project to an organization +* [lagoon add](lagoon_add.md) - Add a project, or add notifications and variables to projects or environments diff --git a/docs/commands/lagoon_add_organization.md b/docs/commands/lagoon_add_organization.md index db7c2765..b7faf987 100644 --- a/docs/commands/lagoon_add_organization.md +++ b/docs/commands/lagoon_add_organization.md @@ -1,11 +1,23 @@ ## lagoon add organization -Add an organization, or add a group/project to an organization +Add a new organization to Lagoon + +``` +lagoon add organization [flags] +``` ### Options ``` - -h, --help help for organization + --description string Description of the organization + --environment-quota int Environment quota for the organization + --friendly-name string Friendly name of the organization + --group-quota int Group quota for the organization + -h, --help help for organization + --notification-quota int Notification quota for the organization + -O, --organization-name string Name of the organization + --project-quota int Project quota for the organization + --route-quota int Route quota for the organization ``` ### Options inherited from parent commands @@ -28,9 +40,4 @@ Add an organization, or add a group/project to an organization ### SEE ALSO * [lagoon add](lagoon_add.md) - Add a project, or add notifications and variables to projects or environments -* [lagoon add organization deploytarget](lagoon_add_organization_deploytarget.md) - Add a deploy target to an Organization -* [lagoon add organization group](lagoon_add_organization_group.md) - Add a group to an Organization -* [lagoon add organization organization](lagoon_add_organization_organization.md) - Add a new organization to Lagoon -* [lagoon add organization project](lagoon_add_organization_project.md) - Add a project to an Organization -* [lagoon add organization user](lagoon_add_organization_user.md) - Add a user to an Organization diff --git a/docs/commands/lagoon_add_organization_organization.md b/docs/commands/lagoon_add_organization_organization.md deleted file mode 100644 index ce70a134..00000000 --- a/docs/commands/lagoon_add_organization_organization.md +++ /dev/null @@ -1,43 +0,0 @@ -## lagoon add organization organization - -Add a new organization to Lagoon - -``` -lagoon add organization organization [flags] -``` - -### Options - -``` - --description string Description of the organization - --environment-quota int Environment quota for the organization - --friendly-name string Friendly name of the organization - --group-quota int Group quota for the organization - -h, --help help for organization - -O, --name string Name of the organization - --notification-quota int Notification quota for the organization - --project-quota int Project quota for the organization - --route-quota int Route quota for the organization -``` - -### Options inherited from parent commands - -``` - --config-file string Path to the config file to use (must be *.yml or *.yaml) - --debug Enable debugging output (if supported) - -e, --environment string Specify an environment to use - --force Force yes on prompts (if supported) - -l, --lagoon string The Lagoon instance to interact with - --no-header No header on table (if supported) - --output-csv Output as CSV (if supported) - --output-json Output as JSON (if supported) - --pretty Make JSON pretty (if supported) - -p, --project string Specify a project to use - --skip-update-check Skip checking for updates - -i, --ssh-key string Specify path to a specific SSH key to use for lagoon authentication -``` - -### SEE ALSO - -* [lagoon add organization](lagoon_add_organization.md) - Add an organization, or add a group/project to an organization - diff --git a/docs/commands/lagoon_add_organization_project.md b/docs/commands/lagoon_add_organization_project.md deleted file mode 100644 index 1b7815d5..00000000 --- a/docs/commands/lagoon_add_organization_project.md +++ /dev/null @@ -1,57 +0,0 @@ -## lagoon add organization project - -Add a project to an Organization - -``` -lagoon add organization project [flags] -``` - -### Options - -``` - --auto-idle uint Auto idle setting of the project - --availability string Availability of the project - --branches string branches - --build-image string Build Image for the project - --deployments-disabled uint Admin only flag for disabling deployments on a project, 1 to disable deployments, 0 to enable - --development-build-priority uint Set the priority of the development build - --development-environments-limit uint How many environments can be deployed at one time - --facts-ui uint Enables the Lagoon insights Facts tab in the UI. Set to 1 to enable, 0 to disable - --git-url string GitURL of the project - -h, --help help for project - -O, --name string Name of the Organization to add the project to - --openshift uint Reference to OpenShift Object this Project should be deployed to - --openshift-project-pattern string Pattern of OpenShift Project/Namespace that should be generated - --org-owner Add the user as an owner of the project - --private-key string Private key to use for the project - --problems-ui uint Enables the Lagoon insights Problems tab in the UI. Set to 1 to enable, 0 to disable - --production-build-priority uint Set the priority of the production build - --production-environment string Production Environment for the project - --pullrequests string Which Pull Requests should be deployed - --router-pattern string Router pattern of the project, e.g. '${service}-${environment}-${project}.lagoon.example.com' - --standby-production-environment string Standby Production Environment for the project - --storage-calc uint Should storage for this environment be calculated - --subfolder string Set if the .lagoon.yml should be found in a subfolder useful if you have multiple Lagoon projects per Git Repository -``` - -### Options inherited from parent commands - -``` - --config-file string Path to the config file to use (must be *.yml or *.yaml) - --debug Enable debugging output (if supported) - -e, --environment string Specify an environment to use - --force Force yes on prompts (if supported) - -l, --lagoon string The Lagoon instance to interact with - --no-header No header on table (if supported) - --output-csv Output as CSV (if supported) - --output-json Output as JSON (if supported) - --pretty Make JSON pretty (if supported) - -p, --project string Specify a project to use - --skip-update-check Skip checking for updates - -i, --ssh-key string Specify path to a specific SSH key to use for lagoon authentication -``` - -### SEE ALSO - -* [lagoon add organization](lagoon_add_organization.md) - Add an organization, or add a group/project to an organization - diff --git a/docs/commands/lagoon_add_project.md b/docs/commands/lagoon_add_project.md index f10da958..31699314 100644 --- a/docs/commands/lagoon_add_project.md +++ b/docs/commands/lagoon_add_project.md @@ -1,6 +1,11 @@ ## lagoon add project -Add a new project to Lagoon +Add a new project to Lagoon, or add a project to an organization + +### Synopsis + +To add a project to an organization, you'll need to include the `organization` flag and provide the name of the organization. You need to be an owner of this organization to do this. +If you're the organization owner and want to grant yourself ownership to this project to be able to deploy environments, specify the `owner` flag. ``` lagoon add project [flags] @@ -9,20 +14,22 @@ lagoon add project [flags] ### Options ``` - -a, --autoIdle int Auto idle setting of the project + -a, --autoIdle uint Auto idle setting of the project -b, --branches string Which branches should be deployed - -L, --developmentEnvironmentsLimit int How many environments can be deployed at one time + -L, --developmentEnvironmentsLimit uint How many environments can be deployed at one time -g, --gitUrl string GitURL of the project -h, --help help for project -j, --json string JSON string to patch - -S, --openshift int Reference to OpenShift Object this Project should be deployed to + -S, --openshift uint Reference to OpenShift Object this Project should be deployed to -o, --openshiftProjectPattern string Pattern of OpenShift Project/Namespace that should be generated + -O, --organization-name string Name of the Organization to add the project to + --owner Add the user as an owner of the project -I, --privateKey string Private key to use for the project -E, --productionEnvironment string Which environment(the name) should be marked as the production environment -m, --pullrequests string Which Pull Requests should be deployed -Z, --routerPattern string Router pattern of the project, e.g. '${service}-${environment}-${project}.lagoon.example.com' --standbyProductionEnvironment string Which environment(the name) should be marked as the standby production environment - -C, --storageCalc int Should storage for this environment be calculated + -C, --storageCalc uint Should storage for this environment be calculated -s, --subfolder string Set if the .lagoon.yml should be found in a subfolder useful if you have multiple Lagoon projects per Git Repository ``` diff --git a/docs/commands/lagoon_delete.md b/docs/commands/lagoon_delete.md index 6204e2bc..90ac6221 100644 --- a/docs/commands/lagoon_delete.md +++ b/docs/commands/lagoon_delete.md @@ -33,7 +33,10 @@ Delete a project, or delete notifications and variables from projects or environ * [lagoon delete environment](lagoon_delete_environment.md) - Delete an environment * [lagoon delete group](lagoon_delete_group.md) - Delete a group from lagoon * [lagoon delete notification](lagoon_delete_notification.md) - Delete notifications or delete notifications from projects -* [lagoon delete organization](lagoon_delete_organization.md) - Add an organization, or add a group/project to an organization +* [lagoon delete organization](lagoon_delete_organization.md) - Delete an organization +* [lagoon delete organization-administrator](lagoon_delete_organization-administrator.md) - Remove an administrator from an Organization +* [lagoon delete organization-deploytarget](lagoon_delete_organization-deploytarget.md) - Remove a deploy target from an Organization +* [lagoon delete organization-project](lagoon_delete_organization-project.md) - Remove a project from an Organization * [lagoon delete project](lagoon_delete_project.md) - Delete a project * [lagoon delete project-group](lagoon_delete_project-group.md) - Delete a project from a group in lagoon * [lagoon delete project-metadata](lagoon_delete_project-metadata.md) - Delete a key from a projects metadata diff --git a/docs/commands/lagoon_add_organization_group.md b/docs/commands/lagoon_delete_organization-administrator.md similarity index 62% rename from docs/commands/lagoon_add_organization_group.md rename to docs/commands/lagoon_delete_organization-administrator.md index ed5fbffc..abf01997 100644 --- a/docs/commands/lagoon_add_organization_group.md +++ b/docs/commands/lagoon_delete_organization-administrator.md @@ -1,18 +1,18 @@ -## lagoon add organization group +## lagoon delete organization-administrator -Add a group to an Organization +Remove an administrator from an Organization ``` -lagoon add organization group [flags] +lagoon delete organization-administrator [flags] ``` ### Options ``` - -G, --group string Name of the group - -h, --help help for group - -O, --name string Name of the organization - --org-owner Flag to add the user to the group as an owner + -E, --email string Email address of the user + -h, --help help for organization-administrator + -O, --organization-name string Name of the organization + --owner Set the user as an administrator of the organization ``` ### Options inherited from parent commands @@ -34,5 +34,5 @@ lagoon add organization group [flags] ### SEE ALSO -* [lagoon add organization](lagoon_add_organization.md) - Add an organization, or add a group/project to an organization +* [lagoon delete](lagoon_delete.md) - Delete a project, or delete notifications and variables from projects or environments diff --git a/docs/commands/lagoon_delete_organization_deploytarget.md b/docs/commands/lagoon_delete_organization-deploytarget.md similarity index 70% rename from docs/commands/lagoon_delete_organization_deploytarget.md rename to docs/commands/lagoon_delete_organization-deploytarget.md index d0e2f6a6..6a7e2fe9 100644 --- a/docs/commands/lagoon_delete_organization_deploytarget.md +++ b/docs/commands/lagoon_delete_organization-deploytarget.md @@ -1,17 +1,17 @@ -## lagoon delete organization deploytarget +## lagoon delete organization-deploytarget Remove a deploy target from an Organization ``` -lagoon delete organization deploytarget [flags] +lagoon delete organization-deploytarget [flags] ``` ### Options ``` - -D, --deploy-target uint ID of DeployTarget - -h, --help help for deploytarget - -O, --name string Name of Organization + -D, --deploytarget uint ID of DeployTarget + -h, --help help for organization-deploytarget + -O, --organization-name string Name of Organization ``` ### Options inherited from parent commands @@ -33,5 +33,5 @@ lagoon delete organization deploytarget [flags] ### SEE ALSO -* [lagoon delete organization](lagoon_delete_organization.md) - Add an organization, or add a group/project to an organization +* [lagoon delete](lagoon_delete.md) - Delete a project, or delete notifications and variables from projects or environments diff --git a/docs/commands/lagoon_delete_organization_project.md b/docs/commands/lagoon_delete_organization-project.md similarity index 64% rename from docs/commands/lagoon_delete_organization_project.md rename to docs/commands/lagoon_delete_organization-project.md index 91a9385f..440bc5f2 100644 --- a/docs/commands/lagoon_delete_organization_project.md +++ b/docs/commands/lagoon_delete_organization-project.md @@ -1,16 +1,21 @@ -## lagoon delete organization project +## lagoon delete organization-project Remove a project from an Organization +### Synopsis + +Removes a project from an Organization, but does not delete the project. +This is used by platform administrators to be able to reset a project. + ``` -lagoon delete organization project [flags] +lagoon delete organization-project [flags] ``` ### Options ``` - -h, --help help for project - -O, --name string Name of the Organization to remove the project from + -h, --help help for organization-project + -O, --organization-name string Name of the Organization to remove the project from ``` ### Options inherited from parent commands @@ -32,5 +37,5 @@ lagoon delete organization project [flags] ### SEE ALSO -* [lagoon delete organization](lagoon_delete_organization.md) - Add an organization, or add a group/project to an organization +* [lagoon delete](lagoon_delete.md) - Delete a project, or delete notifications and variables from projects or environments diff --git a/docs/commands/lagoon_delete_organization.md b/docs/commands/lagoon_delete_organization.md index be5c5566..92d88b2c 100644 --- a/docs/commands/lagoon_delete_organization.md +++ b/docs/commands/lagoon_delete_organization.md @@ -1,11 +1,16 @@ ## lagoon delete organization -Add an organization, or add a group/project to an organization +Delete an organization + +``` +lagoon delete organization [flags] +``` ### Options ``` - -h, --help help for organization + -h, --help help for organization + -O, --organization-name string Name of the organization to delete ``` ### Options inherited from parent commands @@ -28,8 +33,4 @@ Add an organization, or add a group/project to an organization ### SEE ALSO * [lagoon delete](lagoon_delete.md) - Delete a project, or delete notifications and variables from projects or environments -* [lagoon delete organization deploytarget](lagoon_delete_organization_deploytarget.md) - Remove a deploy target from an Organization -* [lagoon delete organization organization](lagoon_delete_organization_organization.md) - Delete an organization -* [lagoon delete organization project](lagoon_delete_organization_project.md) - Remove a project from an Organization -* [lagoon delete organization user](lagoon_delete_organization_user.md) - Remove a user to an Organization diff --git a/docs/commands/lagoon_delete_organization_organization.md b/docs/commands/lagoon_delete_organization_organization.md deleted file mode 100644 index 350a8f44..00000000 --- a/docs/commands/lagoon_delete_organization_organization.md +++ /dev/null @@ -1,36 +0,0 @@ -## lagoon delete organization organization - -Delete an organization - -``` -lagoon delete organization organization [flags] -``` - -### Options - -``` - -h, --help help for organization - -O, --name string Name of the organization to delete -``` - -### Options inherited from parent commands - -``` - --config-file string Path to the config file to use (must be *.yml or *.yaml) - --debug Enable debugging output (if supported) - -e, --environment string Specify an environment to use - --force Force yes on prompts (if supported) - -l, --lagoon string The Lagoon instance to interact with - --no-header No header on table (if supported) - --output-csv Output as CSV (if supported) - --output-json Output as JSON (if supported) - --pretty Make JSON pretty (if supported) - -p, --project string Specify a project to use - --skip-update-check Skip checking for updates - -i, --ssh-key string Specify path to a specific SSH key to use for lagoon authentication -``` - -### SEE ALSO - -* [lagoon delete organization](lagoon_delete_organization.md) - Add an organization, or add a group/project to an organization - diff --git a/docs/commands/lagoon_delete_organization_user.md b/docs/commands/lagoon_delete_organization_user.md deleted file mode 100644 index d7ebd6df..00000000 --- a/docs/commands/lagoon_delete_organization_user.md +++ /dev/null @@ -1,38 +0,0 @@ -## lagoon delete organization user - -Remove a user to an Organization - -``` -lagoon delete organization user [flags] -``` - -### Options - -``` - -E, --email string Email address of the user - -h, --help help for user - -O, --name string Name of the organization - --owner Set the user as an owner of the organization -``` - -### Options inherited from parent commands - -``` - --config-file string Path to the config file to use (must be *.yml or *.yaml) - --debug Enable debugging output (if supported) - -e, --environment string Specify an environment to use - --force Force yes on prompts (if supported) - -l, --lagoon string The Lagoon instance to interact with - --no-header No header on table (if supported) - --output-csv Output as CSV (if supported) - --output-json Output as JSON (if supported) - --pretty Make JSON pretty (if supported) - -p, --project string Specify a project to use - --skip-update-check Skip checking for updates - -i, --ssh-key string Specify path to a specific SSH key to use for lagoon authentication -``` - -### SEE ALSO - -* [lagoon delete organization](lagoon_delete_organization.md) - Add an organization, or add a group/project to an organization - diff --git a/docs/commands/lagoon_get_organization.md b/docs/commands/lagoon_get_organization.md index b75e28aa..291004de 100644 --- a/docs/commands/lagoon_get_organization.md +++ b/docs/commands/lagoon_get_organization.md @@ -9,8 +9,8 @@ lagoon get organization [flags] ### Options ``` - -h, --help help for organization - -O, --name string Name of the organization + -h, --help help for organization + -O, --organization-name string Name of the organization ``` ### Options inherited from parent commands diff --git a/docs/commands/lagoon_list.md b/docs/commands/lagoon_list.md index 784a07a4..fbf25ee9 100644 --- a/docs/commands/lagoon_list.md +++ b/docs/commands/lagoon_list.md @@ -40,7 +40,11 @@ List projects, environments, deployments, variables or notifications * [lagoon list groups](lagoon_list_groups.md) - List groups you have access to (alias: g) * [lagoon list invokable-tasks](lagoon_list_invokable-tasks.md) - Print a list of invokable tasks * [lagoon list notification](lagoon_list_notification.md) - List all notifications or notifications on projects -* [lagoon list organization](lagoon_list_organization.md) - List all organizations projects, groups, deploy targets or users +* [lagoon list organization-deploytargets](lagoon_list_organization-deploytargets.md) - List deploy targets in an organization +* [lagoon list organization-groups](lagoon_list_organization-groups.md) - List groups in an organization +* [lagoon list organization-projects](lagoon_list_organization-projects.md) - List projects in an organization +* [lagoon list organization-users](lagoon_list_organization-users.md) - List users in an organization +* [lagoon list organizations](lagoon_list_organizations.md) - List all organizations * [lagoon list project-groups](lagoon_list_project-groups.md) - List groups in a project (alias: pg) * [lagoon list projects](lagoon_list_projects.md) - List all projects you have access to (alias: p) * [lagoon list projects-by-metadata](lagoon_list_projects-by-metadata.md) - List projects by a given metadata key or key:value diff --git a/docs/commands/lagoon_list_organization_deploytargets.md b/docs/commands/lagoon_list_organization-deploytargets.md similarity index 67% rename from docs/commands/lagoon_list_organization_deploytargets.md rename to docs/commands/lagoon_list_organization-deploytargets.md index d887ed11..cf41d429 100644 --- a/docs/commands/lagoon_list_organization_deploytargets.md +++ b/docs/commands/lagoon_list_organization-deploytargets.md @@ -1,17 +1,17 @@ -## lagoon list organization deploytargets +## lagoon list organization-deploytargets List deploy targets in an organization ``` -lagoon list organization deploytargets [flags] +lagoon list organization-deploytargets [flags] ``` ### Options ``` - -h, --help help for deploytargets - --id uint ID of the organization to list associated deploy targets for - -O, --name string Name of the organization to list associated deploy targets for + -h, --help help for organization-deploytargets + --id uint ID of the organization to list associated deploy targets for + -O, --organization-name string Name of the organization to list associated deploy targets for ``` ### Options inherited from parent commands @@ -33,5 +33,5 @@ lagoon list organization deploytargets [flags] ### SEE ALSO -* [lagoon list organization](lagoon_list_organization.md) - List all organizations projects, groups, deploy targets or users +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_organization_groups.md b/docs/commands/lagoon_list_organization-groups.md similarity index 73% rename from docs/commands/lagoon_list_organization_groups.md rename to docs/commands/lagoon_list_organization-groups.md index a0899f67..3fbea4f8 100644 --- a/docs/commands/lagoon_list_organization_groups.md +++ b/docs/commands/lagoon_list_organization-groups.md @@ -1,16 +1,16 @@ -## lagoon list organization groups +## lagoon list organization-groups List groups in an organization ``` -lagoon list organization groups [flags] +lagoon list organization-groups [flags] ``` ### Options ``` - -h, --help help for groups - -O, --name string Name of the organization to list associated groups for + -h, --help help for organization-groups + -O, --organization-name string Name of the organization to list associated groups for ``` ### Options inherited from parent commands @@ -32,5 +32,5 @@ lagoon list organization groups [flags] ### SEE ALSO -* [lagoon list organization](lagoon_list_organization.md) - List all organizations projects, groups, deploy targets or users +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_organization_projects.md b/docs/commands/lagoon_list_organization-projects.md similarity index 73% rename from docs/commands/lagoon_list_organization_projects.md rename to docs/commands/lagoon_list_organization-projects.md index 1747bd3a..1cae1f5c 100644 --- a/docs/commands/lagoon_list_organization_projects.md +++ b/docs/commands/lagoon_list_organization-projects.md @@ -1,16 +1,16 @@ -## lagoon list organization projects +## lagoon list organization-projects List projects in an organization ``` -lagoon list organization projects [flags] +lagoon list organization-projects [flags] ``` ### Options ``` - -h, --help help for projects - -O, --name string Name of the organization to list associated projects for + -h, --help help for organization-projects + -O, --organization-name string Name of the organization to list associated projects for ``` ### Options inherited from parent commands @@ -32,5 +32,5 @@ lagoon list organization projects [flags] ### SEE ALSO -* [lagoon list organization](lagoon_list_organization.md) - List all organizations projects, groups, deploy targets or users +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_organization_users.md b/docs/commands/lagoon_list_organization-users.md similarity index 73% rename from docs/commands/lagoon_list_organization_users.md rename to docs/commands/lagoon_list_organization-users.md index 54087da5..98139840 100644 --- a/docs/commands/lagoon_list_organization_users.md +++ b/docs/commands/lagoon_list_organization-users.md @@ -1,16 +1,16 @@ -## lagoon list organization users +## lagoon list organization-users List users in an organization ``` -lagoon list organization users [flags] +lagoon list organization-users [flags] ``` ### Options ``` - -h, --help help for users - -O, --name string Name of the organization to list associated users for + -h, --help help for organization-users + -O, --organization-name string Name of the organization to list associated users for ``` ### Options inherited from parent commands @@ -32,5 +32,5 @@ lagoon list organization users [flags] ### SEE ALSO -* [lagoon list organization](lagoon_list_organization.md) - List all organizations projects, groups, deploy targets or users +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_list_organization.md b/docs/commands/lagoon_list_organization.md deleted file mode 100644 index 3fd69460..00000000 --- a/docs/commands/lagoon_list_organization.md +++ /dev/null @@ -1,36 +0,0 @@ -## lagoon list organization - -List all organizations projects, groups, deploy targets or users - -### Options - -``` - -h, --help help for organization -``` - -### Options inherited from parent commands - -``` - --config-file string Path to the config file to use (must be *.yml or *.yaml) - --debug Enable debugging output (if supported) - -e, --environment string Specify an environment to use - --force Force yes on prompts (if supported) - -l, --lagoon string The Lagoon instance to interact with - --no-header No header on table (if supported) - --output-csv Output as CSV (if supported) - --output-json Output as JSON (if supported) - --pretty Make JSON pretty (if supported) - -p, --project string Specify a project to use - --skip-update-check Skip checking for updates - -i, --ssh-key string Specify path to a specific SSH key to use for lagoon authentication -``` - -### SEE ALSO - -* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications -* [lagoon list organization deploytargets](lagoon_list_organization_deploytargets.md) - List deploy targets in an organization -* [lagoon list organization groups](lagoon_list_organization_groups.md) - List groups in an organization -* [lagoon list organization organizations](lagoon_list_organization_organizations.md) - List all organizations -* [lagoon list organization projects](lagoon_list_organization_projects.md) - List projects in an organization -* [lagoon list organization users](lagoon_list_organization_users.md) - List users in an organization - diff --git a/docs/commands/lagoon_list_organization_organizations.md b/docs/commands/lagoon_list_organizations.md similarity index 81% rename from docs/commands/lagoon_list_organization_organizations.md rename to docs/commands/lagoon_list_organizations.md index 05c8beb2..f2bc051a 100644 --- a/docs/commands/lagoon_list_organization_organizations.md +++ b/docs/commands/lagoon_list_organizations.md @@ -1,9 +1,9 @@ -## lagoon list organization organizations +## lagoon list organizations List all organizations ``` -lagoon list organization organizations [flags] +lagoon list organizations [flags] ``` ### Options @@ -31,5 +31,5 @@ lagoon list organization organizations [flags] ### SEE ALSO -* [lagoon list organization](lagoon_list_organization.md) - List all organizations projects, groups, deploy targets or users +* [lagoon list](lagoon_list.md) - List projects, environments, deployments, variables or notifications diff --git a/docs/commands/lagoon_update_environment.md b/docs/commands/lagoon_update_environment.md index 4c204f12..eec81629 100644 --- a/docs/commands/lagoon_update_environment.md +++ b/docs/commands/lagoon_update_environment.md @@ -12,9 +12,9 @@ lagoon update environment [flags] -a, --auto-idle uint Auto idle setting of the environment (default 1) --deploy-base-ref string Updates the deploy base ref for the selected environment --deploy-head-ref string Updates the deploy head ref for the selected environment - -d, --deploy-target uint Reference to OpenShift Object this Environment should be deployed to --deploy-title string Updates the deploy title for the selected environment --deploy-type string Update the deploy type - branch | pullrequest | promote + -d, --deploytarget uint Reference to OpenShift Object this Environment should be deployed to --environment-type string Update the environment type - production | development -h, --help help for environment --namespace string Update the namespace for the selected environment diff --git a/docs/commands/lagoon_update_organization.md b/docs/commands/lagoon_update_organization.md index 5563ecf3..00d77203 100644 --- a/docs/commands/lagoon_update_organization.md +++ b/docs/commands/lagoon_update_organization.md @@ -9,15 +9,15 @@ lagoon update organization [flags] ### Options ``` - --description string Description of the organization - --environment-quota int Environment quota for the organization - --friendly-name string Friendly name of the organization - --group-quota int Group quota for the organization - -h, --help help for organization - -O, --name string Name of the organization to update - --notification-quota int Notification quota for the organization - --project-quota int Project quota for the organization - --route-quota int Route quota for the organization + --description string Description of the organization + --environment-quota int Environment quota for the organization + --friendly-name string Friendly name of the organization + --group-quota int Group quota for the organization + -h, --help help for organization + --notification-quota int Notification quota for the organization + -O, --organization-name string Name of the organization to update + --project-quota int Project quota for the organization + --route-quota int Route quota for the organization ``` ### Options inherited from parent commands