diff --git a/CHANGELOG.md b/CHANGELOG.md index 764ba69d..b695396c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Storage: handle errors in batch objects delete action #627 - Instance: Fix instance protection flag update zone context #648 +- Anti-affinity group: fix show command to print all the attached instances from different zones #649 ## 1.80.0 diff --git a/cmd/anti_affinity_group_show.go b/cmd/anti_affinity_group_show.go index b43964d8..88423557 100644 --- a/cmd/anti_affinity_group_show.go +++ b/cmd/anti_affinity_group_show.go @@ -2,13 +2,11 @@ package cmd import ( "fmt" - "strings" - - "github.com/spf13/cobra" - "github.com/exoscale/cli/pkg/globalstate" "github.com/exoscale/cli/pkg/output" v3 "github.com/exoscale/egoscale/v3" + "github.com/spf13/cobra" + "strings" ) type antiAffinityGroupShowOutput struct { @@ -52,27 +50,29 @@ func (c *antiAffinityGroupShowCmd) cmdRun(_ *cobra.Command, _ []string) error { antiAffinityGroupsResp, err := globalstate.EgoscaleV3Client.ListAntiAffinityGroups(ctx) if err != nil { - return err + return fmt.Errorf("unable to retrieve list of anti-affinity groups: %w", err) } antiAffinityGroup, err := antiAffinityGroupsResp.FindAntiAffinityGroup(c.AntiAffinityGroup) if err != nil { - return err + return fmt.Errorf("unable to find anti-affinity group %q: %w", c.AntiAffinityGroup, err) } - out := antiAffinityGroupShowOutput{ ID: antiAffinityGroup.ID, Name: antiAffinityGroup.Name, Description: antiAffinityGroup.Description, } - if antiAffinityGroup.Instances != nil { - out.Instances = make([]string, len(antiAffinityGroup.Instances)) - for i, instance := range antiAffinityGroup.Instances { - out.Instances[i] = instance.Name + antiAffinityGroupWithInstanceDetails, err := globalstate.EgoscaleV3Client.GetAntiAffinityGroup(ctx, antiAffinityGroup.ID) + if err != nil { + return fmt.Errorf("unable to retrieve anti-affinity group with instance details %q: %w", c.AntiAffinityGroup, err) + } + if antiAffinityGroupWithInstanceDetails.Instances != nil { + out.Instances = make([]string, len(antiAffinityGroupWithInstanceDetails.Instances)) + for i, instance := range antiAffinityGroupWithInstanceDetails.Instances { + out.Instances[i] = instance.ID.String() } } - return c.outputFunc(&out, nil) } diff --git a/cmd/iam_api_key_create.go b/cmd/iam_api_key_create.go index 8165651f..81c18e30 100644 --- a/cmd/iam_api_key_create.go +++ b/cmd/iam_api_key_create.go @@ -12,9 +12,9 @@ import ( ) type iamAPIKeyShowOutput struct { - Name string `json:"name"` - Key string `json:"key"` - Secret string `json:"secret"` + Name string `json:"name"` + Key string `json:"key"` + Secret string `json:"secret"` Role v3.UUID `json:"role-id"` }