Skip to content

Commit

Permalink
Updated add project cmd + various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CGoodwin90 committed Oct 23, 2023
1 parent 55fdf00 commit 86e5fb4
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 135 deletions.
38 changes: 26 additions & 12 deletions cmd/deploytarget.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,20 @@ var addDeployTargetToOrganizationCmd = &cobra.Command{
debug, err := cmd.Flags().GetBool("debug")
handleError(err)

organizationName, err := cmd.Flags().GetString("organization")
requiredInputCheck("Organization name", organizationName)
deployTarget, err := cmd.Flags().GetUint("deployTarget")
requiredInputCheck("Deploy Target", strconv.Itoa(int(deployTarget)))
organizationName, err := cmd.Flags().GetString("name")
if err != nil {
return err
}
if err := requiredInputCheck("Organization name", organizationName); err != nil {
return err
}
deployTarget, err := cmd.Flags().GetUint("deploy-target")
if err != nil {
return err
}
if err := requiredInputCheck("Deploy Target", strconv.Itoa(int(deployTarget))); err != nil {
return err
}

current := lagoonCLIConfig.Current
token := lagoonCLIConfig.Lagoons[current].Token
Expand Down Expand Up @@ -383,13 +390,20 @@ var RemoveDeployTargetFromOrganizationCmd = &cobra.Command{
debug, err := cmd.Flags().GetBool("debug")
handleError(err)

organizationName, err := cmd.Flags().GetString("organization")
requiredInputCheck("Organization name", organizationName)
deployTarget, err := cmd.Flags().GetUint("deployTarget")
requiredInputCheck("Deploy Target", strconv.Itoa(int(deployTarget)))
organizationName, err := cmd.Flags().GetString("name")
if err != nil {
return err
}
if err := requiredInputCheck("Organization name", organizationName); err != nil {
return err
}
deployTarget, err := cmd.Flags().GetUint("deploy-target")
if err != nil {
return err
}
if err := requiredInputCheck("Deploy Target", strconv.Itoa(int(deployTarget))); err != nil {
return err
}

current := lagoonCLIConfig.Current
token := lagoonCLIConfig.Lagoons[current].Token
Expand Down Expand Up @@ -436,14 +450,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("organization", "O", "", "Name of Organization")
addDeployTargetToOrganizationCmd.Flags().UintP("deployTarget", "D", 0, "ID of DeployTarget")
addDeployTargetToOrganizationCmd.Flags().StringP("name", "O", "", "Name of Organization")
addDeployTargetToOrganizationCmd.Flags().UintP("deploy-target", "D", 0, "ID of DeployTarget")

deleteDeployTargetCmd.Flags().UintP("id", "", 0, "ID of the DeployTarget")
deleteDeployTargetCmd.Flags().StringP("name", "", "", "Name of DeployTarget")

RemoveDeployTargetFromOrganizationCmd.Flags().StringP("organization", "O", "", "Name of Organization")
RemoveDeployTargetFromOrganizationCmd.Flags().UintP("deployTarget", "D", 0, "ID of DeployTarget")
RemoveDeployTargetFromOrganizationCmd.Flags().StringP("name", "O", "", "Name of Organization")
RemoveDeployTargetFromOrganizationCmd.Flags().UintP("deploy-target", "D", 0, "ID of DeployTarget")

updateDeployTargetCmd.Flags().UintP("id", "", 0, "ID of the DeployTarget")
updateDeployTargetCmd.Flags().StringP("console-url", "", "", "DeployTarget console URL")
Expand Down
12 changes: 7 additions & 5 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,13 @@ var getOrganizationCmd = &cobra.Command{
if err != nil {
return err
}
organizationName, err := cmd.Flags().GetString("organization")
requiredInputCheck("Organization name", organizationName)
organizationName, err := cmd.Flags().GetString("name")
if err != nil {
return err
}
if err := requiredInputCheck("Organization name", organizationName); err != nil {
return err
}

current := lagoonCLIConfig.Current
token := lagoonCLIConfig.Lagoons[current].Token
Expand All @@ -199,7 +201,7 @@ var getOrganizationCmd = &cobra.Command{

if organization.Name == "" {
output.RenderInfo(fmt.Sprintf("No organization found for '%s'", organizationName), outputOptions)
os.Exit(0)
return nil
}

data := []output.Data{}
Expand All @@ -213,7 +215,7 @@ var getOrganizationCmd = &cobra.Command{
})

dataMain := output.Table{
Header: []string{"ID", "Name", "Description", "quotaProject", "quotaGroup", "quotaNotification"},
Header: []string{"ID", "Name", "Description", "Project Quota", "Group Quota", "Notification Quota"},
Data: data,
}

Expand All @@ -236,5 +238,5 @@ func init() {
getTaskByID.Flags().BoolP("logs", "L", false, "Show the task logs if available")
getProjectKeyCmd.Flags().BoolVarP(&revealValue, "reveal", "", false, "Reveal the variable values")
getDeploymentCmd.Flags().StringVarP(&remoteID, "remoteid", "R", "", "The remote ID of the deployment")
getOrganizationCmd.Flags().StringP("organization", "O", "", "Name of the organization")
getOrganizationCmd.Flags().StringP("name", "O", "", "Name of the organization")
}
19 changes: 13 additions & 6 deletions cmd/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,24 @@ var addGroupToOrganizationCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
debug, err := cmd.Flags().GetBool("debug")
handleError(err)
orgOwner, err := cmd.Flags().GetBool("orgOwner")
organizationName, err := cmd.Flags().GetString("organization")
requiredInputCheck("Organization name", organizationName)
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")
requiredInputCheck("Group name", groupName)
if err != nil {
return err
}
if err := requiredInputCheck("Group name", groupName); err != nil {
return err
}

current := lagoonCLIConfig.Current
token := lagoonCLIConfig.Lagoons[current].Token
Expand Down Expand Up @@ -296,7 +303,7 @@ 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("organization", "O", "", "Name of the organization")
addGroupToOrganizationCmd.Flags().StringP("name", "O", "", "Name of the organization")
addGroupToOrganizationCmd.Flags().StringP("group", "G", "", "Name of the group")
addGroupToOrganizationCmd.Flags().Bool("orgOwner", false, "Flag to add the user to the group as an owner")
addGroupToOrganizationCmd.Flags().Bool("org-owner", false, "Flag to add the user to the group as an owner")
}
50 changes: 35 additions & 15 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,13 @@ var listOrganizationProjectsCmd = &cobra.Command{
if err != nil {
return err
}
organizationName, err := cmd.Flags().GetString("organization")
requiredInputCheck("Organization name", organizationName)
organizationName, err := cmd.Flags().GetString("name")
if err != nil {
return err
}
if err := requiredInputCheck("Organization name", organizationName); err != nil {
return err
}

current := lagoonCLIConfig.Current
token := lagoonCLIConfig.Lagoons[current].Token
Expand All @@ -481,7 +486,7 @@ var listOrganizationProjectsCmd = &cobra.Command{
})
}
dataMain := output.Table{
Header: []string{"ID", "Name", "GroupCount"},
Header: []string{"ID", "Name", "Group Count"},
Data: data,
}
output.RenderOutput(dataMain, outputOptions)
Expand All @@ -501,8 +506,13 @@ var listOrganizationGroupsCmd = &cobra.Command{
if err != nil {
return err
}
organizationName, err := cmd.Flags().GetString("organization")
requiredInputCheck("Organization name", organizationName)
organizationName, err := cmd.Flags().GetString("name")
if err != nil {
return err
}
if err := requiredInputCheck("Organization name", organizationName); err != nil {
return err
}

current := lagoonCLIConfig.Current
token := lagoonCLIConfig.Lagoons[current].Token
Expand All @@ -526,7 +536,7 @@ var listOrganizationGroupsCmd = &cobra.Command{
})
}
dataMain := output.Table{
Header: []string{"ID", "Name", "Type", "MemberCount"},
Header: []string{"ID", "Name", "Type", "Member Count"},
Data: data,
}
output.RenderOutput(dataMain, outputOptions)
Expand All @@ -546,8 +556,13 @@ var listOrganizationDeployTargetsCmd = &cobra.Command{
if err != nil {
return err
}
organizationName, err := cmd.Flags().GetString("organization")
requiredInputCheck("Organization name", organizationName)
organizationName, err := cmd.Flags().GetString("name")
if err != nil {
return err
}
if err := requiredInputCheck("Organization name", organizationName); err != nil {
return err
}

current := lagoonCLIConfig.Current
token := lagoonCLIConfig.Lagoons[current].Token
Expand All @@ -573,7 +588,7 @@ var listOrganizationDeployTargetsCmd = &cobra.Command{
})
}
dataMain := output.Table{
Header: []string{"ID", "Name", "Router Pattern", "ConsoleURL", "Cloud Region", "Cloud Provider", "SSH Host", "SSH Port"},
Header: []string{"ID", "Name", "Router Pattern", "Console URL", "Cloud Region", "Cloud Provider", "SSH Host", "SSH Port"},
Data: data,
}
output.RenderOutput(dataMain, outputOptions)
Expand All @@ -593,8 +608,13 @@ var ListOrganizationUsersCmd = &cobra.Command{
if err != nil {
return err
}
organizationName, err := cmd.Flags().GetString("organization")
requiredInputCheck("Organization name", organizationName)
organizationName, err := cmd.Flags().GetString("name")
if err != nil {
return err
}
if err := requiredInputCheck("Organization name", organizationName); err != nil {
return err
}

current := lagoonCLIConfig.Current
token := lagoonCLIConfig.Lagoons[current].Token
Expand Down Expand Up @@ -651,8 +671,8 @@ func init() {
listUsersCmd.Flags().StringVarP(&groupName, "name", "N", "", "Name of the group to list users in (if not specified, will default to all groups)")
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("organization", "O", "", "Name of the organization to list associated projects for")
ListOrganizationUsersCmd.Flags().StringP("organization", "O", "", "Name of the organization to list associated users for")
listOrganizationGroupsCmd.Flags().StringP("organization", "O", "", "Name of the organization to list associated groups for")
listOrganizationDeployTargetsCmd.Flags().StringP("organization", "O", "", "Name of the organization to list associated deploy targets for")
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")
}
Loading

0 comments on commit 86e5fb4

Please sign in to comment.