Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/uselagoon/lagoon-cli into r…
Browse files Browse the repository at this point in the history
…efactor_get_project
  • Loading branch information
CGoodwin90 committed Nov 28, 2023
2 parents 4f8777a + 5ce8a2a commit 36b8f2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,10 @@ var listVariablesCmd = &cobra.Command{
env = append(env, returnNonEmptyString(fmt.Sprintf("%v", envvar.Scope)))
env = append(env, returnNonEmptyString(fmt.Sprintf("%v", envvar.Name)))
if reveal {
env = append(env, returnNonEmptyString(fmt.Sprintf("%v", envvar.Value)))
env = append(env, fmt.Sprintf("%v", envvar.Value))
}
data = append(data, env)
}
if len(data) == 0 {
if cmdProjectEnvironment != "" {
return fmt.Errorf("There are no variables for environment '%s' in project '%s'", cmdProjectEnvironment, cmdProjectName)
} else {
return fmt.Errorf("There are no variables for project '%s'", cmdProjectName)
}
}
header := []string{
"ID",
"Project",
Expand All @@ -309,6 +302,13 @@ var listVariablesCmd = &cobra.Command{
if reveal {
header = append(header, "Value")
}
if len(data) == 0 {
if cmdProjectEnvironment != "" {
outputOptions.Error = fmt.Sprintf("There are no variables for environment '%s' in project '%s'", cmdProjectEnvironment, cmdProjectName)
} else {
outputOptions.Error = fmt.Sprintf("There are no variables for project '%s'\n", cmdProjectName)
}
}
output.RenderOutput(output.Table{
Header: header,
Data: data,
Expand Down
4 changes: 4 additions & 0 deletions pkg/output/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type Options struct {
JSON bool
Pretty bool
Debug bool
Error string
}

// Result .
Expand Down Expand Up @@ -125,6 +126,9 @@ func RenderOutput(data Table, opts Options) {
RenderJSON(returnedData, opts)
} else {
// otherwise render a table
if opts.Error != "" {
os.Stderr.WriteString(opts.Error)
}
table := tablewriter.NewWriter(os.Stdout)
opts.Header = !opts.Header
if opts.Header {
Expand Down

0 comments on commit 36b8f2d

Please sign in to comment.