Skip to content

Commit

Permalink
Merge branch 'master' into feat/config-rework
Browse files Browse the repository at this point in the history
  • Loading branch information
avirtopeanu-ionos authored Oct 9, 2023
2 parents 37ad183 + 1253919 commit e87b5e8
Show file tree
Hide file tree
Showing 47 changed files with 177 additions and 171 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
### Fixed
* Fixed #297: `ionosctl login` not clearing previous credentials
* The command will ask for confirmation if a config file already exists at the set path. The user can skip this check by using `--force`
* Fixed 404, 405 status codes on firewallrule delete command


## [v6.6.10] (September 2023)
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ test:
.PHONY: mocks
mocks:
@echo "--- Update mocks ---"
@echo "--- Ensure gomock is up to date. Run: 'go install github.com/golang/mock/[email protected]' ---"
@tools/mocks.sh && echo "DONE"

.PHONY: docs generate-docs
Expand Down
6 changes: 3 additions & 3 deletions commands/cloudapi-v6/applicationloadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ func DeleteAllApplicationLoadBalancer(c *core.CommandConfig) error {

queryParams := listQueryParams.QueryParams

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Getting Application Load Balancers..."))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("Getting Application Load Balancers..."))

applicationLoadBalancers, resp, err := c.CloudApiV6Services.ApplicationLoadBalancers().List(
viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgDataCenterId)), cloudapiv6.ParentResourceListQueryParams)
Expand Down Expand Up @@ -582,7 +582,7 @@ func DeleteAllApplicationLoadBalancer(c *core.CommandConfig) error {
}
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(delIdAndName))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(delIdAndName))
}

if !confirm.FAsk(c.Command.Command.InOrStdin(), "delete all the Application Load Balancers", viper.GetBool(constants.ArgForce)) {
Expand Down Expand Up @@ -611,7 +611,7 @@ func DeleteAllApplicationLoadBalancer(c *core.CommandConfig) error {
continue
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))

if err = utils.WaitForRequest(c, waiter.RequestInterrogator, utils.GetId(resp)); err != nil {
multiErr = errors.Join(multiErr, fmt.Errorf(constants.ErrDeleteAll, c.Resource, *id, err))
Expand Down
6 changes: 3 additions & 3 deletions commands/cloudapi-v6/applicationloadbalancer_flowlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ func DeleteAllApplicationLoadBalancerFlowLog(c *core.CommandConfig) error {

queryParams := listQueryParams.QueryParams

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Getting Application Load Balancer FlowLogs..."))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("Getting Application Load Balancer FlowLogs..."))

applicationLoadBalancerFlowlogs, resp, err := c.CloudApiV6Services.ApplicationLoadBalancers().ListFlowLogs(
viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgDataCenterId)),
Expand Down Expand Up @@ -565,7 +565,7 @@ func DeleteAllApplicationLoadBalancerFlowLog(c *core.CommandConfig) error {
}
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(delIdAndName))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(delIdAndName))
}

if !confirm.FAsk(c.Command.Command.InOrStdin(), "delete all the Application Load Balancer FlowLogs", viper.GetBool(constants.ArgForce)) {
Expand Down Expand Up @@ -597,7 +597,7 @@ func DeleteAllApplicationLoadBalancerFlowLog(c *core.CommandConfig) error {
continue
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))

if err = utils.WaitForRequest(c, waiter.RequestInterrogator, utils.GetId(resp)); err != nil {
multiErr = errors.Join(multiErr, fmt.Errorf(constants.ErrDeleteAll, c.Resource, *id, err))
Expand Down
6 changes: 3 additions & 3 deletions commands/cloudapi-v6/applicationloadbalancer_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ func DeleteAllApplicationLoadBalancerForwardingRule(c *core.CommandConfig) error

queryParams := listQueryParams.QueryParams

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Getting Application Load Balancer Forwarding Rules..."))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("Getting Application Load Balancer Forwarding Rules..."))

applicationLoadBalancerRules, resp, err := c.CloudApiV6Services.ApplicationLoadBalancers().ListForwardingRules(
viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgDataCenterId)),
Expand Down Expand Up @@ -573,7 +573,7 @@ func DeleteAllApplicationLoadBalancerForwardingRule(c *core.CommandConfig) error
}
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(delIdAndName))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(delIdAndName))
}

if !confirm.FAsk(c.Command.Command.InOrStdin(), "delete all the Forwarding Rules", viper.GetBool(constants.ArgForce)) {
Expand Down Expand Up @@ -606,7 +606,7 @@ func DeleteAllApplicationLoadBalancerForwardingRule(c *core.CommandConfig) error
continue
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))

if err = utils.WaitForRequest(c, waiter.RequestInterrogator, utils.GetId(resp)); err != nil {
multiErr = errors.Join(multiErr, fmt.Errorf(constants.ErrDeleteAll, c.Resource, *id, err))
Expand Down
8 changes: 4 additions & 4 deletions commands/cloudapi-v6/applicationloadbalancer_rule_httprule.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func RunAlbRuleHttpRuleList(c *core.CommandConfig) error {
return errors.New("error getting rule http rules")
}

out, err := jsontabwriter.GenerateOutput("", allAlbHttpRuleJSONPaths, httpRules,
out, err := jsontabwriter.GenerateOutput("", allAlbHttpRuleJSONPaths, *httpRules,
tabheaders.GetHeaders(allAlbRuleHttpRuleCols, defaultAlbRuleHttpRuleCols, cols))
if err != nil {
return err
Expand Down Expand Up @@ -443,7 +443,7 @@ func RemoveAllHTTPRules(c *core.CommandConfig) (*resources.Response, error) {

queryParams := listQueryParams.QueryParams

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Forwarding Rule HTTP Rules to be deleted:"))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("Forwarding Rule HTTP Rules to be deleted:"))

applicationLoadBalancerRules, resp, err := c.CloudApiV6Services.ApplicationLoadBalancers().GetForwardingRule(
viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgDataCenterId)),
Expand Down Expand Up @@ -471,11 +471,11 @@ func RemoveAllHTTPRules(c *core.CommandConfig) (*resources.Response, error) {

for _, httpRuleOk := range *httpRulesOk {
if nameOk, ok := httpRuleOk.GetNameOk(); ok && nameOk != nil {
fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Forwarding Rule HTTP Rule Name: %v", *nameOk))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("Forwarding Rule HTTP Rule Name: %v", *nameOk))
}

if typeOk, ok := httpRuleOk.GetTypeOk(); ok && typeOk != nil {
fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Forwarding Rule HTTP Rule Type: %v", *typeOk))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("Forwarding Rule HTTP Rule Type: %v", *typeOk))
}
}

Expand Down
8 changes: 4 additions & 4 deletions commands/cloudapi-v6/backupunit.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ func DeleteAllBackupUnits(c *core.CommandConfig) error {
return fmt.Errorf("no Backup Units found")
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Backup Units to be deleted:"))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("Backup Units to be deleted:"))

for _, backupUnit := range *backupUnitsItems {
delIdAndName := ""
Expand All @@ -512,14 +512,14 @@ func DeleteAllBackupUnits(c *core.CommandConfig) error {
}
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(delIdAndName))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(delIdAndName))
}

if !confirm.FAsk(c.Command.Command.InOrStdin(), "delete all the Backup Units", viper.GetBool(constants.ArgForce)) {
return fmt.Errorf(confirm.UserDenied)
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Deleting all the BackupUnits..."))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateVerboseOutput("Deleting all the BackupUnits..."))

var multiErr error
for _, backupUnit := range *backupUnitsItems {
Expand All @@ -539,7 +539,7 @@ func DeleteAllBackupUnits(c *core.CommandConfig) error {
continue
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))

if err = utils.WaitForRequest(c, waiter.RequestInterrogator, utils.GetId(resp)); err != nil {
multiErr = errors.Join(multiErr, fmt.Errorf(constants.ErrWaitDeleteAll, c.Resource, *id, err))
Expand Down
6 changes: 3 additions & 3 deletions commands/cloudapi-v6/cdrom.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ func DetachAllCdRoms(c *core.CommandConfig) error {
return fmt.Errorf("no CD-ROMs found")
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("CD-ROMS to be detached:"))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("CD-ROMS to be detached:"))
delIdAndName := ""

for _, cdRom := range *cdRomsItems {
Expand All @@ -403,7 +403,7 @@ func DetachAllCdRoms(c *core.CommandConfig) error {
}
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(delIdAndName))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(delIdAndName))
}

if !confirm.FAsk(c.Command.Command.InOrStdin(), "detach all the CD-ROMS", viper.GetBool(constants.ArgForce)) {
Expand All @@ -430,7 +430,7 @@ func DetachAllCdRoms(c *core.CommandConfig) error {
continue
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))

if err = utils.WaitForRequest(c, waiter.RequestInterrogator, utils.GetId(resp)); err != nil {
multiErr = errors.Join(multiErr, fmt.Errorf(constants.ErrWaitDeleteAll, c.Resource, *id, err))
Expand Down
2 changes: 1 addition & 1 deletion commands/cloudapi-v6/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func RunLocationCpuList(c *core.CommandConfig) error {

cols := viper.GetStringSlice(core.GetFlagName(c.Resource, constants.ArgCols))

out, err := jsontabwriter.GenerateOutput("", allCpuJSONPaths, cpus, tabheaders.GetHeadersAllDefault(defaultCpuCols, cols))
out, err := jsontabwriter.GenerateOutput("", allCpuJSONPaths, *cpus, tabheaders.GetHeadersAllDefault(defaultCpuCols, cols))
if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions commands/cloudapi-v6/datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func DeleteAllDatacenters(c *core.CommandConfig) error {
return fmt.Errorf("no Datacenters found")
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Datacenters to be deleted:"))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("Datacenters to be deleted:"))

for _, dc := range *datacentersItems {
delIdAndName := ""
Expand All @@ -438,7 +438,7 @@ func DeleteAllDatacenters(c *core.CommandConfig) error {
}
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(delIdAndName))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(delIdAndName))
}

if !confirm.FAsk(c.Command.Command.InOrStdin(), "delete all the Datacenters", viper.IsSet(constants.ArgForce)) {
Expand All @@ -465,7 +465,7 @@ func DeleteAllDatacenters(c *core.CommandConfig) error {
continue
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))

if err = utils.WaitForRequest(c, waiter.RequestInterrogator, utils.GetId(resp)); err != nil {
multiErr = errors.Join(multiErr, fmt.Errorf(constants.ErrDeleteAll, c.Resource, *id, err))
Expand Down
28 changes: 14 additions & 14 deletions commands/cloudapi-v6/firewallrule.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ func PreRunDcServerNicIds(c *core.PreCommandConfig) error {

func PreRunFirewallDelete(c *core.PreCommandConfig) error {
return core.CheckRequiredFlagsSets(c.Command, c.NS,
[]string{cloudapiv6.ArgDataCenterId, cloudapiv6.ArgServerId, cloudapiv6.ArgNicId},
[]string{cloudapiv6.ArgDataCenterId, cloudapiv6.ArgServerId, cloudapiv6.ArgAll},
[]string{cloudapiv6.ArgDataCenterId, cloudapiv6.ArgServerId, cloudapiv6.ArgNicId, cloudapiv6.ArgFirewallRuleId},
[]string{cloudapiv6.ArgDataCenterId, cloudapiv6.ArgServerId, cloudapiv6.ArgNicId, cloudapiv6.ArgAll},
)
}

Expand Down Expand Up @@ -383,7 +383,7 @@ func RunFirewallRuleGet(c *core.CommandConfig) error {
queryParams := listQueryParams.QueryParams

fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateVerboseOutput(
"Firewall Rule with id: %v is getting... ", viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgFirewallRuleId))))
"Getting Firewall Rule with id: %v", viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgFirewallRuleId))))

firewallRule, resp, err := c.CloudApiV6Services.FirewallRules().Get(
viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgDataCenterId)),
Expand Down Expand Up @@ -511,13 +511,13 @@ func RunFirewallRuleDelete(c *core.CommandConfig) error {
}

queryParams := listQueryParams.QueryParams
datacenterId := viper.GetString(core.GetFlagName(c.Resource, cloudapiv6.ArgDataCenterId))
serverId := viper.GetString(core.GetFlagName(c.Resource, cloudapiv6.ArgServerId))
nicId := viper.GetString(core.GetFlagName(c.Resource, cloudapiv6.ArgNicId))
datacenterId := viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgDataCenterId))
serverId := viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgServerId))
nicId := viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgNicId))
fruleId := viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgFirewallRuleId))

if viper.GetBool(core.GetFlagName(c.NS, cloudapiv6.ArgAll)) {
if err := DeleteAllFirewallRuses(c); err != nil {
if err := DeleteAllFirewallRules(c); err != nil {
return err
}

Expand Down Expand Up @@ -625,16 +625,16 @@ func getFirewallRulePropertiesSet(c *core.CommandConfig) resources.FirewallRuleP
return properties
}

func DeleteAllFirewallRuses(c *core.CommandConfig) error {
func DeleteAllFirewallRules(c *core.CommandConfig) error {
listQueryParams, err := query.GetListQueryParams(c)
if err != nil {
return err
}

queryParams := listQueryParams.QueryParams
datacenterId := viper.GetString(core.GetFlagName(c.Resource, cloudapiv6.ArgDataCenterId))
serverId := viper.GetString(core.GetFlagName(c.Resource, cloudapiv6.ArgServerId))
nicId := viper.GetString(core.GetFlagName(c.Resource, cloudapiv6.ArgNicId))
datacenterId := viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgDataCenterId))
serverId := viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgServerId))
nicId := viper.GetString(core.GetFlagName(c.NS, cloudapiv6.ArgNicId))

fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateVerboseOutput(constants.DatacenterId, datacenterId))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateVerboseOutput("Server ID: %v", serverId))
Expand All @@ -655,7 +655,7 @@ func DeleteAllFirewallRuses(c *core.CommandConfig) error {
return fmt.Errorf("no Firewall Rule found")
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Firewall Rules to be deleted:"))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("Firewall Rules to be deleted:"))

for _, firewall := range *firewallRulesItems {
delIdAndName := ""
Expand All @@ -670,7 +670,7 @@ func DeleteAllFirewallRuses(c *core.CommandConfig) error {
}
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(delIdAndName))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(delIdAndName))
}

if !confirm.FAsk(c.Command.Command.InOrStdin(), "delete all the Firewall Rules", viper.GetBool(constants.ArgForce)) {
Expand All @@ -697,7 +697,7 @@ func DeleteAllFirewallRuses(c *core.CommandConfig) error {
continue
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))

if err = utils.WaitForRequest(c, waiter.RequestInterrogator, utils.GetId(resp)); err != nil {
multiErr = errors.Join(multiErr, fmt.Errorf(constants.ErrWaitDeleteAll, c.Resource, *id, err))
Expand Down
6 changes: 3 additions & 3 deletions commands/cloudapi-v6/flowlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ func DeleteAllFlowlogs(c *core.CommandConfig) error {
return errors.New("no Flowlogs found")
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Flowlogs to be deleted:"))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("Flowlogs to be deleted:"))

for _, backupUnit := range *flowlogsItems {
delIdAndName := ""
Expand All @@ -517,7 +517,7 @@ func DeleteAllFlowlogs(c *core.CommandConfig) error {
}
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(delIdAndName))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(delIdAndName))
}

if !confirm.FAsk(c.Command.Command.InOrStdin(), "delete all the flow logs", viper.GetBool(constants.ArgForce)) {
Expand All @@ -544,7 +544,7 @@ func DeleteAllFlowlogs(c *core.CommandConfig) error {
continue
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))

if err = utils.WaitForRequest(c, waiter.RequestInterrogator, utils.GetId(resp)); err != nil {
multiErr = errors.Join(multiErr, fmt.Errorf(constants.ErrDeleteAll, c.Resource, *id, err))
Expand Down
6 changes: 3 additions & 3 deletions commands/cloudapi-v6/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ func DeleteAllGroups(c *core.CommandConfig) error {
return fmt.Errorf("no Groups found")
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput("Groups to be deleted:"))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput("Groups to be deleted:"))

for _, group := range *groupsItems {
delIdAndName := ""
Expand All @@ -727,7 +727,7 @@ func DeleteAllGroups(c *core.CommandConfig) error {
}
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(delIdAndName))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(delIdAndName))
}

if !confirm.FAsk(c.Command.Command.InOrStdin(), "delete all the Groups", viper.GetBool(constants.ArgForce)) {
Expand All @@ -754,7 +754,7 @@ func DeleteAllGroups(c *core.CommandConfig) error {
continue
}

fmt.Fprintf(c.Command.Command.OutOrStdout(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))
fmt.Fprintf(c.Command.Command.ErrOrStderr(), jsontabwriter.GenerateLogOutput(constants.MessageDeletingAll, c.Resource, *id))

if err = utils.WaitForRequest(c, waiter.RequestInterrogator, utils.GetId(resp)); err != nil {
multiErr = errors.Join(multiErr, fmt.Errorf(constants.ErrWaitDeleteAll, c.Resource, *id, err))
Expand Down
Loading

0 comments on commit e87b5e8

Please sign in to comment.