diff --git a/cmd/get.go b/cmd/get.go index 0701bb31..54eb74fd 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -149,6 +149,10 @@ This returns information about a deployment, the logs of this build can also be if err != nil { return err } + wide, err := cmd.Flags().GetBool("wide") + if err != nil { + return err + } showLogs, err := cmd.Flags().GetBool("logs") if err != nil { return err @@ -184,27 +188,35 @@ This returns information about a deployment, the logs of this build can also be fmt.Fprintf(cmd.OutOrStdout(), "%s", r) return nil } + data := []output.Data{} + dep := []string{ + returnNonEmptyString(fmt.Sprintf("%v", deployment.ID)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.Name)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.Status)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.BuildStep)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.Started)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.Completed)), + } + if wide { + dep = append(dep, returnNonEmptyString(fmt.Sprintf("%v", deployment.Created))) + dep = append(dep, returnNonEmptyString(fmt.Sprintf("%v", deployment.RemoteID))) + } + data = append(data, dep) + header := []string{ + "ID", + "Name", + "Status", + "BuildStep", + "Started", + "Completed", + } + if wide { + header = append(header, "Created") + header = append(header, "RemoteID") + } dataMain := output.Table{ - Header: []string{ - "ID", - "RemoteID", - "Name", - "Status", - "Created", - "Started", - "Completed", - }, - Data: []output.Data{ - { - returnNonEmptyString(fmt.Sprintf("%v", deployment.ID)), - returnNonEmptyString(fmt.Sprintf("%v", deployment.RemoteID)), - returnNonEmptyString(fmt.Sprintf("%v", deployment.Name)), - returnNonEmptyString(fmt.Sprintf("%v", deployment.Status)), - returnNonEmptyString(fmt.Sprintf("%v", deployment.Created)), - returnNonEmptyString(fmt.Sprintf("%v", deployment.Started)), - returnNonEmptyString(fmt.Sprintf("%v", deployment.Completed)), - }, - }, + Header: header, + Data: data, } r := output.RenderOutput(dataMain, outputOptions) fmt.Fprintf(cmd.OutOrStdout(), "%s", r) @@ -447,6 +459,7 @@ 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") + getDeploymentByNameCmd.Flags().Bool("wide", false, "Display additional information about deployments") 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 388108c8..1345d8cf 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -481,6 +481,10 @@ var listDeploymentsCmd = &cobra.Command{ if err != nil { return err } + wide, err := cmd.Flags().GetBool("wide") + if err != nil { + return err + } if err := requiredInputCheck("Project name", cmdProjectName, "Environment name", cmdProjectEnvironment); err != nil { return err } @@ -501,22 +505,38 @@ var listDeploymentsCmd = &cobra.Command{ data := []output.Data{} for _, deployment := range deployments.Deployments { - data = append(data, []string{ + dep := []string{ returnNonEmptyString(fmt.Sprintf("%d", deployment.ID)), - returnNonEmptyString(fmt.Sprintf("%v", deployment.RemoteID)), returnNonEmptyString(fmt.Sprintf("%v", deployment.Name)), returnNonEmptyString(fmt.Sprintf("%v", deployment.Status)), - returnNonEmptyString(fmt.Sprintf("%v", deployment.Created)), + returnNonEmptyString(fmt.Sprintf("%v", deployment.BuildStep)), returnNonEmptyString(fmt.Sprintf("%v", deployment.Started)), returnNonEmptyString(fmt.Sprintf("%v", deployment.Completed)), - }) + } + if wide { + dep = append(dep, returnNonEmptyString(fmt.Sprintf("%v", deployment.Created))) + dep = append(dep, returnNonEmptyString(fmt.Sprintf("%v", deployment.RemoteID))) + } + data = append(data, dep) } if len(data) == 0 { return handleNilResults("There are no deployments for environment '%s' in project '%s'\n", cmd, cmdProjectEnvironment, cmdProjectName) } + header := []string{ + "ID", + "Name", + "Status", + "BuildStep", + "Started", + "Completed", + } + if wide { + header = append(header, "Created") + header = append(header, "RemoteID") + } dataMain := output.Table{ - Header: []string{"ID", "RemoteID", "Name", "Status", "Created", "Started", "Completed"}, + Header: header, Data: data, } r := output.RenderOutput(dataMain, outputOptions) @@ -1226,6 +1246,7 @@ var listOrganizationsCmd = &cobra.Command{ func init() { listCmd.AddCommand(listDeployTargetsCmd) listCmd.AddCommand(listDeploymentsCmd) + listDeploymentsCmd.Flags().Bool("wide", false, "Display additional information about deployments") listCmd.AddCommand(listGroupsCmd) listCmd.AddCommand(listGroupProjectsCmd) listCmd.AddCommand(listProjectGroupsCmd) diff --git a/docs/commands/lagoon_get_deployment.md b/docs/commands/lagoon_get_deployment.md index 456f5b01..8814b8e3 100644 --- a/docs/commands/lagoon_get_deployment.md +++ b/docs/commands/lagoon_get_deployment.md @@ -17,6 +17,7 @@ lagoon get deployment [flags] -h, --help help for deployment -L, --logs Show the build logs if available -N, --name string The name of the deployment (eg, lagoon-build-abcdef) + --wide Display additional information about deployments ``` ### Options inherited from parent commands diff --git a/docs/commands/lagoon_list_deployments.md b/docs/commands/lagoon_list_deployments.md index 12f0a028..df95e6b8 100644 --- a/docs/commands/lagoon_list_deployments.md +++ b/docs/commands/lagoon_list_deployments.md @@ -10,6 +10,7 @@ lagoon list deployments [flags] ``` -h, --help help for deployments + --wide Display additional information about deployments ``` ### Options inherited from parent commands