diff --git a/cmd/get.go b/cmd/get.go index 7b0c8382..5d5ca03d 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -41,6 +41,10 @@ var getProjectCmd = &cobra.Command{ if err != nil { return err } + wide, err := cmd.Flags().GetBool("wide") + if err != nil { + return err + } if err := requiredInputCheck("Project name", cmdProjectName); err != nil { return err } @@ -65,7 +69,7 @@ var getProjectCmd = &cobra.Command{ } DevEnvironments := 0 - productionRoute := "none" + productionRoute := "" deploymentsDisabled, err := strconv.ParseBool(strconv.Itoa(int(project.DeploymentsDisabled))) if err != nil { return err @@ -91,25 +95,35 @@ var getProjectCmd = &cobra.Command{ } } - data := []output.Data{} - data = append(data, []string{ + projData := []string{ returnNonEmptyString(fmt.Sprintf("%d", project.ID)), returnNonEmptyString(fmt.Sprintf("%v", project.Name)), returnNonEmptyString(fmt.Sprintf("%v", project.GitURL)), - returnNonEmptyString(fmt.Sprintf("%v", project.Branches)), - returnNonEmptyString(fmt.Sprintf("%v", project.PullRequests)), + returnNonEmptyString(fmt.Sprintf("%v", project.ProductionEnvironment)), returnNonEmptyString(fmt.Sprintf("%v", productionRoute)), returnNonEmptyString(fmt.Sprintf("%v/%v", DevEnvironments, project.DevelopmentEnvironmentsLimit)), - returnNonEmptyString(fmt.Sprintf("%v", project.DevelopmentEnvironmentsLimit)), - returnNonEmptyString(fmt.Sprintf("%v", project.ProductionEnvironment)), - returnNonEmptyString(fmt.Sprintf("%v", project.RouterPattern)), - returnNonEmptyString(fmt.Sprintf("%v", autoIdle)), - returnNonEmptyString(fmt.Sprintf("%v", factsUI)), - returnNonEmptyString(fmt.Sprintf("%v", problemsUI)), - returnNonEmptyString(fmt.Sprintf("%v", deploymentsDisabled)), - }) + } + projHeader := []string{"ID", "ProjectName", "GitUrl", "ProductionEnvironment", "ProductionRoute", "DevEnvironments"} + if wide { + projHeader = append(projHeader, "AutoIdle") + projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v", autoIdle))) + projHeader = append(projHeader, "Branches") + projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v", project.Branches))) + projHeader = append(projHeader, "PullRequests") + projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v", project.PullRequests))) + projHeader = append(projHeader, "RouterPattern") + projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v", project.RouterPattern))) + projHeader = append(projHeader, "FactsUI") + projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v", factsUI))) + projHeader = append(projHeader, "ProblemsUI") + projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v", problemsUI))) + projHeader = append(projHeader, "DeploymentsDisabled") + projData = append(projData, returnNonEmptyString(fmt.Sprintf("%v", deploymentsDisabled))) + } + data := []output.Data{} + data = append(data, projData) dataMain := output.Table{ - Header: []string{"ID", "ProjectName", "GitURL", "Branches", "PullRequests", "ProductionRoute", "DevEnvironments", "DevEnvLimit", "ProductionEnv", "RouterPattern", "AutoIdle", "FactsUI", "ProblemsUI", "DeploymentsDisabled"}, + Header: projHeader, Data: data, } output.RenderOutput(dataMain, outputOptions) @@ -413,4 +427,5 @@ func init() { getDeploymentByNameCmd.Flags().BoolP("logs", "L", false, "Show the build logs if available") getOrganizationCmd.Flags().StringP("organization-name", "O", "", "Name of the organization") getEnvironmentCmd.Flags().Bool("wide", false, "Display additional information about the environment") + getProjectCmd.Flags().Bool("wide", false, "Display additional information about the project") } diff --git a/cmd/list.go b/cmd/list.go index 97df5e10..9483e882 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -56,10 +56,14 @@ var listProjectsCmd = &cobra.Command{ data := []output.Data{} for _, project := range *projects { var devEnvironments = 0 + productionRoute := "" for _, environment := range project.Environments { if environment.EnvironmentType == "development" { devEnvironments++ } + if environment.EnvironmentType == "production" { + productionRoute = environment.Route + } } data = append(data, []string{ @@ -67,6 +71,7 @@ var listProjectsCmd = &cobra.Command{ returnNonEmptyString(fmt.Sprintf("%v", project.Name)), returnNonEmptyString(fmt.Sprintf("%v", project.GitURL)), returnNonEmptyString(fmt.Sprintf("%v", project.ProductionEnvironment)), + returnNonEmptyString(fmt.Sprintf("%v", productionRoute)), returnNonEmptyString(fmt.Sprintf("%v/%v", devEnvironments, project.DevelopmentEnvironmentsLimit)), }) } @@ -74,7 +79,7 @@ var listProjectsCmd = &cobra.Command{ outputOptions.Error = "No access to any projects in Lagoon\n" } dataMain := output.Table{ - Header: []string{"ID", "ProjectName", "GitUrl", "ProductionEnvironment", "DevEnvironments"}, + Header: []string{"ID", "ProjectName", "GitUrl", "ProductionEnvironment", "ProductionRoute", "DevEnvironments"}, Data: data, } diff --git a/go.mod b/go.mod index 44896fcb..a1b46029 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.2 - github.com/uselagoon/machinery v0.0.24-0.20240722003955-19e63e32423a + github.com/uselagoon/machinery v0.0.24-0.20240722005832-5029bf3feafb golang.org/x/crypto v0.21.0 golang.org/x/term v0.18.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 0dcd1a67..eb577192 100644 --- a/go.sum +++ b/go.sum @@ -70,6 +70,8 @@ github.com/uselagoon/machinery v0.0.23 h1:8fRoVo3/dAByFQQH7Po35vEjFmtT4MmE326EuC github.com/uselagoon/machinery v0.0.23/go.mod h1:NbgtEofjK2XY0iUpk9aMYazIo+W/NI56+UF72jv8zVY= github.com/uselagoon/machinery v0.0.24-0.20240722003955-19e63e32423a h1:yQZRU4TORa4QYr5Mxuj7VSZN84Qo0b//asRQdNlhAbo= github.com/uselagoon/machinery v0.0.24-0.20240722003955-19e63e32423a/go.mod h1:NbgtEofjK2XY0iUpk9aMYazIo+W/NI56+UF72jv8zVY= +github.com/uselagoon/machinery v0.0.24-0.20240722005832-5029bf3feafb h1:wG4E7caTaB5p0CIrfpXLhmFQiucvav8fspAhE7XzSCQ= +github.com/uselagoon/machinery v0.0.24-0.20240722005832-5029bf3feafb/go.mod h1:NbgtEofjK2XY0iUpk9aMYazIo+W/NI56+UF72jv8zVY= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=