From 7a5efeb86a377dd701632ab01714d9532b8e89f4 Mon Sep 17 00:00:00 2001 From: Uzair Ali <72073401+uzaxirr@users.noreply.github.com> Date: Wed, 9 Oct 2024 11:50:15 +0530 Subject: [PATCH 1/2] Add support for attached volumes in instance_show.go --- cmd/instance/instance_show.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cmd/instance/instance_show.go b/cmd/instance/instance_show.go index c8ba467..14d5df0 100644 --- a/cmd/instance/instance_show.go +++ b/cmd/instance/instance_show.go @@ -84,6 +84,19 @@ If you wish to use a custom format, the available fields are: ow.AppendDataWithLabel("created_at", instance.CreatedAt.Format(time.RFC1123), "Created At") ow.AppendDataWithLabel("private_ip", instance.PrivateIP, "Private IP") + if len(instance.AttachedVolumes) > 0 { + // Correctly declare the slice of strings for volume IDs + volumeIDs := []string{} + + // Iterate over attached volumes and collect their IDs + for _, volume := range instance.AttachedVolumes { + volumeIDs = append(volumeIDs, volume.ID) + } + + // Join the volume IDs into a single string with spaces separating them + ow.AppendDataWithLabel("attached_volumes", strings.Join(volumeIDs, ", "), "Attached Volumes") + } + if common.OutputFormat == "json" || common.OutputFormat == "custom" { ow.AppendDataWithLabel("public_ip", instance.PublicIP, "Public IP") ow.AppendDataWithLabel("notes", instance.Notes, "notes") From 4af5f33e398057783f9c249acdb3965f6f1e1f6b Mon Sep 17 00:00:00 2001 From: Uzair Ali <72073401+uzaxirr@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:13:50 +0530 Subject: [PATCH 2/2] Add support for attached volumes in instance_show.go --- cmd/instance/instance_show.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/instance/instance_show.go b/cmd/instance/instance_show.go index 14d5df0..78c8401 100644 --- a/cmd/instance/instance_show.go +++ b/cmd/instance/instance_show.go @@ -94,7 +94,7 @@ If you wish to use a custom format, the available fields are: } // Join the volume IDs into a single string with spaces separating them - ow.AppendDataWithLabel("attached_volumes", strings.Join(volumeIDs, ", "), "Attached Volumes") + ow.AppendDataWithLabel("attached_volumes", strings.Join(volumeIDs, ", "), "Attached Volume IDs") } if common.OutputFormat == "json" || common.OutputFormat == "custom" {