Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for attached volumes in instance_show.go #476

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Volume IDs")
}

if common.OutputFormat == "json" || common.OutputFormat == "custom" {
ow.AppendDataWithLabel("public_ip", instance.PublicIP, "Public IP")
ow.AppendDataWithLabel("notes", instance.Notes, "notes")
Expand Down
Loading