Skip to content

Commit 0720bf9

Browse files
committed
feat: include buildstep in deployment get, list
1 parent 67e51b9 commit 0720bf9

4 files changed

Lines changed: 61 additions & 25 deletions

File tree

cmd/get.go

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ This returns information about a deployment, the logs of this build can also be
149149
if err != nil {
150150
return err
151151
}
152+
wide, err := cmd.Flags().GetBool("wide")
153+
if err != nil {
154+
return err
155+
}
152156
showLogs, err := cmd.Flags().GetBool("logs")
153157
if err != nil {
154158
return err
@@ -184,27 +188,35 @@ This returns information about a deployment, the logs of this build can also be
184188
fmt.Fprintf(cmd.OutOrStdout(), "%s", r)
185189
return nil
186190
}
191+
data := []output.Data{}
192+
dep := []string{
193+
returnNonEmptyString(fmt.Sprintf("%v", deployment.ID)),
194+
returnNonEmptyString(fmt.Sprintf("%v", deployment.Name)),
195+
returnNonEmptyString(fmt.Sprintf("%v", deployment.Status)),
196+
returnNonEmptyString(fmt.Sprintf("%v", deployment.BuildStep)),
197+
returnNonEmptyString(fmt.Sprintf("%v", deployment.Started)),
198+
returnNonEmptyString(fmt.Sprintf("%v", deployment.Completed)),
199+
}
200+
if wide {
201+
dep = append(dep, returnNonEmptyString(fmt.Sprintf("%v", deployment.Created)))
202+
dep = append(dep, returnNonEmptyString(fmt.Sprintf("%v", deployment.RemoteID)))
203+
}
204+
data = append(data, dep)
205+
header := []string{
206+
"ID",
207+
"Name",
208+
"Status",
209+
"BuildStep",
210+
"Started",
211+
"Completed",
212+
}
213+
if wide {
214+
header = append(header, "Created")
215+
header = append(header, "RemoteID")
216+
}
187217
dataMain := output.Table{
188-
Header: []string{
189-
"ID",
190-
"RemoteID",
191-
"Name",
192-
"Status",
193-
"Created",
194-
"Started",
195-
"Completed",
196-
},
197-
Data: []output.Data{
198-
{
199-
returnNonEmptyString(fmt.Sprintf("%v", deployment.ID)),
200-
returnNonEmptyString(fmt.Sprintf("%v", deployment.RemoteID)),
201-
returnNonEmptyString(fmt.Sprintf("%v", deployment.Name)),
202-
returnNonEmptyString(fmt.Sprintf("%v", deployment.Status)),
203-
returnNonEmptyString(fmt.Sprintf("%v", deployment.Created)),
204-
returnNonEmptyString(fmt.Sprintf("%v", deployment.Started)),
205-
returnNonEmptyString(fmt.Sprintf("%v", deployment.Completed)),
206-
},
207-
},
218+
Header: header,
219+
Data: data,
208220
}
209221
r := output.RenderOutput(dataMain, outputOptions)
210222
fmt.Fprintf(cmd.OutOrStdout(), "%s", r)
@@ -447,6 +459,7 @@ func init() {
447459
getProjectKeyCmd.Flags().BoolVarP(&revealValue, "reveal", "", false, "Reveal the variable values")
448460
getDeploymentByNameCmd.Flags().StringP("name", "N", "", "The name of the deployment (eg, lagoon-build-abcdef)")
449461
getDeploymentByNameCmd.Flags().BoolP("logs", "L", false, "Show the build logs if available")
462+
getDeploymentByNameCmd.Flags().Bool("wide", false, "Display additional information about deployments")
450463
getOrganizationCmd.Flags().StringP("organization-name", "O", "", "Name of the organization")
451464
getEnvironmentCmd.Flags().Bool("wide", false, "Display additional information about the environment")
452465
getProjectCmd.Flags().Bool("wide", false, "Display additional information about the project")

cmd/list.go

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,10 @@ var listDeploymentsCmd = &cobra.Command{
481481
if err != nil {
482482
return err
483483
}
484+
wide, err := cmd.Flags().GetBool("wide")
485+
if err != nil {
486+
return err
487+
}
484488
if err := requiredInputCheck("Project name", cmdProjectName, "Environment name", cmdProjectEnvironment); err != nil {
485489
return err
486490
}
@@ -501,22 +505,38 @@ var listDeploymentsCmd = &cobra.Command{
501505

502506
data := []output.Data{}
503507
for _, deployment := range deployments.Deployments {
504-
data = append(data, []string{
508+
dep := []string{
505509
returnNonEmptyString(fmt.Sprintf("%d", deployment.ID)),
506-
returnNonEmptyString(fmt.Sprintf("%v", deployment.RemoteID)),
507510
returnNonEmptyString(fmt.Sprintf("%v", deployment.Name)),
508511
returnNonEmptyString(fmt.Sprintf("%v", deployment.Status)),
509-
returnNonEmptyString(fmt.Sprintf("%v", deployment.Created)),
512+
returnNonEmptyString(fmt.Sprintf("%v", deployment.BuildStep)),
510513
returnNonEmptyString(fmt.Sprintf("%v", deployment.Started)),
511514
returnNonEmptyString(fmt.Sprintf("%v", deployment.Completed)),
512-
})
515+
}
516+
if wide {
517+
dep = append(dep, returnNonEmptyString(fmt.Sprintf("%v", deployment.Created)))
518+
dep = append(dep, returnNonEmptyString(fmt.Sprintf("%v", deployment.RemoteID)))
519+
}
520+
data = append(data, dep)
513521
}
514522

515523
if len(data) == 0 {
516524
return handleNilResults("There are no deployments for environment '%s' in project '%s'\n", cmd, cmdProjectEnvironment, cmdProjectName)
517525
}
526+
header := []string{
527+
"ID",
528+
"Name",
529+
"Status",
530+
"BuildStep",
531+
"Started",
532+
"Completed",
533+
}
534+
if wide {
535+
header = append(header, "Created")
536+
header = append(header, "RemoteID")
537+
}
518538
dataMain := output.Table{
519-
Header: []string{"ID", "RemoteID", "Name", "Status", "Created", "Started", "Completed"},
539+
Header: header,
520540
Data: data,
521541
}
522542
r := output.RenderOutput(dataMain, outputOptions)
@@ -1226,6 +1246,7 @@ var listOrganizationsCmd = &cobra.Command{
12261246
func init() {
12271247
listCmd.AddCommand(listDeployTargetsCmd)
12281248
listCmd.AddCommand(listDeploymentsCmd)
1249+
listDeploymentsCmd.Flags().Bool("wide", false, "Display additional information about deployments")
12291250
listCmd.AddCommand(listGroupsCmd)
12301251
listCmd.AddCommand(listGroupProjectsCmd)
12311252
listCmd.AddCommand(listProjectGroupsCmd)

docs/commands/lagoon_get_deployment.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ lagoon get deployment [flags]
1717
-h, --help help for deployment
1818
-L, --logs Show the build logs if available
1919
-N, --name string The name of the deployment (eg, lagoon-build-abcdef)
20+
--wide Display additional information about deployments
2021
```
2122

2223
### Options inherited from parent commands

docs/commands/lagoon_list_deployments.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ lagoon list deployments [flags]
1010

1111
```
1212
-h, --help help for deployments
13+
--wide Display additional information about deployments
1314
```
1415

1516
### Options inherited from parent commands

0 commit comments

Comments
 (0)