From 9d03e044aac002ec2ec4bfb738944cdba7a1814f Mon Sep 17 00:00:00 2001 From: elkezza Date: Mon, 11 Nov 2024 11:36:15 +0000 Subject: [PATCH 1/6] fixing the AAG show to print all instances name that attached to it. --- cmd/anti_affinity_group_show.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/anti_affinity_group_show.go b/cmd/anti_affinity_group_show.go index b43964d8..33b4a91d 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 %q: %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) } From 9904f2d49d83f3d352ca85cbb66d3737ce9196d8 Mon Sep 17 00:00:00 2001 From: elkezza Date: Mon, 11 Nov 2024 11:44:47 +0000 Subject: [PATCH 2/6] fix typo --- cmd/anti_affinity_group_show.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/anti_affinity_group_show.go b/cmd/anti_affinity_group_show.go index 33b4a91d..522e2f14 100644 --- a/cmd/anti_affinity_group_show.go +++ b/cmd/anti_affinity_group_show.go @@ -50,7 +50,7 @@ func (c *antiAffinityGroupShowCmd) cmdRun(_ *cobra.Command, _ []string) error { antiAffinityGroupsResp, err := globalstate.EgoscaleV3Client.ListAntiAffinityGroups(ctx) if err != nil { - return fmt.Errorf("unable to retrieve list of anti-affinity %q: %w", err) + return fmt.Errorf("unable to retrieve list of anti-affinity %w", err) } antiAffinityGroup, err := antiAffinityGroupsResp.FindAntiAffinityGroup(c.AntiAffinityGroup) From 88450429d728330f5a148fc9a9842e2db93d20cf Mon Sep 17 00:00:00 2001 From: elkezza Date: Mon, 11 Nov 2024 11:52:23 +0000 Subject: [PATCH 3/6] fixing gh-action error by running ` go fmt ./...` --- cmd/iam_api_key_create.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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"` } From a5cc7545f32645ee6af4b4d6df541e9e21c59b88 Mon Sep 17 00:00:00 2001 From: elkezza <47871727+elkezza@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:02:50 +0100 Subject: [PATCH 4/6] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 764ba69d..93f3d128 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 ## 1.80.0 From 9235479a6e8ae27ea3cdcf7f0c87d0f51386b774 Mon Sep 17 00:00:00 2001 From: elkezza <47871727+elkezza@users.noreply.github.com> Date: Mon, 11 Nov 2024 13:11:30 +0100 Subject: [PATCH 5/6] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93f3d128..b695396c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +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 +- Anti-affinity group: fix show command to print all the attached instances from different zones #649 ## 1.80.0 From a9463c6a69c97cb329c945ad50fca05cba1a2e7b Mon Sep 17 00:00:00 2001 From: elkezza <47871727+elkezza@users.noreply.github.com> Date: Mon, 11 Nov 2024 14:51:21 +0100 Subject: [PATCH 6/6] Update cmd/anti_affinity_group_show.go Co-authored-by: Philipp Sauter <46172817+sauterp@users.noreply.github.com> --- cmd/anti_affinity_group_show.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/anti_affinity_group_show.go b/cmd/anti_affinity_group_show.go index 522e2f14..88423557 100644 --- a/cmd/anti_affinity_group_show.go +++ b/cmd/anti_affinity_group_show.go @@ -50,7 +50,7 @@ func (c *antiAffinityGroupShowCmd) cmdRun(_ *cobra.Command, _ []string) error { antiAffinityGroupsResp, err := globalstate.EgoscaleV3Client.ListAntiAffinityGroups(ctx) if err != nil { - return fmt.Errorf("unable to retrieve list of anti-affinity %w", err) + return fmt.Errorf("unable to retrieve list of anti-affinity groups: %w", err) } antiAffinityGroup, err := antiAffinityGroupsResp.FindAntiAffinityGroup(c.AntiAffinityGroup)