Skip to content

Commit

Permalink
Add support for attached volumes in instance_show.go
Browse files Browse the repository at this point in the history
  • Loading branch information
uzaxirr committed Oct 9, 2024
1 parent 837a5d8 commit 7a5efeb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/instance/instance_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 7a5efeb

Please sign in to comment.