Skip to content

Commit 112f88f

Browse files
committed
Use utl output function
1 parent 8feacb2 commit 112f88f

1 file changed

Lines changed: 1 addition & 33 deletions

File tree

pkg/cmd/ephemeralenvironment/deprovision-project/deprovision_project.go

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package deprovision_project
22

33
import (
4-
"encoding/json"
54
"fmt"
65
"slices"
76

@@ -11,7 +10,6 @@ import (
1110
"github.com/OctopusDeploy/cli/pkg/cmd/runbook/shared"
1211
"github.com/OctopusDeploy/cli/pkg/constants"
1312
"github.com/OctopusDeploy/cli/pkg/factory"
14-
"github.com/OctopusDeploy/cli/pkg/output"
1513
"github.com/OctopusDeploy/cli/pkg/question/selectors"
1614
"github.com/OctopusDeploy/cli/pkg/util/flag"
1715
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels"
@@ -165,41 +163,11 @@ func DeprovisionEphemeralEnvironmentProject(cmd *cobra.Command, opts *Deprovisio
165163

166164
cmd.Printf("\nSuccessfully deprovisioned ephemeral environment for project '%s' with id '%s'.\n", opts.Project.Value, environmentId)
167165

168-
outputResult(opts, cmd, deprovisionedEnv)
166+
util.OutPutDeprovisionResult(opts.Name.Value, cmd, []ephemeralenvironments.DeprovisioningRunbookRun{deprovisionedEnv.DeprovisioningRun})
169167

170168
return nil
171169
}
172170

173-
func outputResult(deprovisionEnvironmentOptions *DeprovisionProjectOptions, command *cobra.Command, response *ephemeralenvironments.DeprovisionEphemeralEnvironmentProjectResponse) {
174-
outputFormat, err := command.Flags().GetString(constants.FlagOutputFormat)
175-
176-
if err != nil {
177-
outputFormat = constants.OutputFormatTable
178-
}
179-
180-
switch outputFormat {
181-
case constants.OutputFormatBasic:
182-
command.Printf("%s \t %s \n", response.DeprovisioningRun.RunbookRunID, response.DeprovisioningRun.TaskId)
183-
case constants.OutputFormatJson:
184-
data, err := json.Marshal(response)
185-
if err != nil { // shouldn't happen but fallback in case
186-
command.PrintErrln(err)
187-
} else {
188-
_, _ = command.OutOrStdout().Write(data)
189-
command.Println()
190-
}
191-
default: // table
192-
t := output.NewTable(command.OutOrStdout())
193-
t.AddRow(output.Bold("Runbook Run ID"), output.Bold("Server Task ID"))
194-
t.AddRow(response.DeprovisioningRun.RunbookRunID, response.DeprovisioningRun.TaskId)
195-
196-
err := t.Print()
197-
if err != nil {
198-
command.PrintErrln(err)
199-
}
200-
}
201-
}
202-
203171
func PromptMissing(opts *DeprovisionProjectOptions) error {
204172
if opts.Project.Value == "" {
205173
opts.Cmd.Printf(" Choose from projects configured with an ephemeral environment channel.\n")

0 commit comments

Comments
 (0)