Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: include buildstep in deployment get, list #388

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 33 additions & 20 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
31 changes: 26 additions & 5 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/commands/lagoon_get_deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/commands/lagoon_list_deployments.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lagoon list deployments [flags]

```
-h, --help help for deployments
--wide Display additional information about deployments
```

### Options inherited from parent commands
Expand Down