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

Droplet: Add SizeSlug as format flag #1569

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

danaelhe
Copy link
Member

@danaelhe danaelhe commented Aug 13, 2024

Includes SizeSlug as a format flag in help docs:

go run cmd/doctl/main.go compute droplet list -h

....

Flags:
      --format ID         Columns for output in a comma-separated list. Possible values: ID, `Name`, `SizeSlug`, `PublicIPv4`, `PrivateIPv4`, `PublicIPv6`, `Memory`, `VCPUs`, `Disk`, `Region`, `Image`, `VPCUUID`, `Status`, `Tags`, `Features`, `Volumes`.
  -h, --help              help for list
      --no-header         Return raw data with no headers
      --region string     Retrieves a list of Droplets in a specified region
      --tag-name string   Retrieves a list of Droplets with the specified tag name

SizeSlug as a format flag was supported but wasn't documented.
@danaelhe
Copy link
Member Author

Ooop need to update some tests too, one sec

@danaelhe
Copy link
Member Author

danaelhe commented Aug 14, 2024

Tests are failing because it now includes SizeSlug in output by default:

               	Error:      	Not equal: 
                	            	expected: "ID      Name                 Public IPv4    Private IPv4    Public IPv6    Memory    VCPUs    Disk    Region              Image                          VPC UUID    Status    Tags    Features    Volumes\n5555    some-droplet-name                                                  0         0        0       some-region-slug    some-distro some-image-name                active    yes     remotes     some-volume-id"
                	            	actual  : "ID      Name                 Size Slug    Public IPv4    Private IPv4    Public IPv6    Memory    VCPUs    Disk    Region              Image                          VPC UUID    Status    Tags    Features    Volumes\n5555    some-droplet-name                                                               0         0        0       some-region-slug    some-distro some-image-name                active    yes     remotes     some-volume-id"
                	            	
                	            	Diff:
                	            	--- Expected
                	            	+++ Actual
                	            	@@ -1,2 +1,2 @@
                	            	-ID      Name                 Public IPv4    Private IPv4    Public IPv6    Memory    VCPUs    Disk    Region              Image                          VPC UUID    Status    Tags    Features    Volumes
                	            	-5555    some-droplet-name                                                  0         0        0       some-region-slug    some-distro some-image-name                active    yes     remotes     some-volume-id
                	            	+ID      Name                 Size Slug    Public IPv4    Private IPv4    Public IPv6    Memory    VCPUs    Disk    Region              Image                          VPC UUID    Status    Tags    Features    Volumes
                	            	+5555    some-droplet-name                                                               0         0        0       some-region-slug    some-distro some-image-name                active    yes     remotes     some-volume-id

I can update the tests if this is not considered a breaking change? @andrewsomething

@andrewsomething
Copy link
Member

Adding new columns isn't necessarily a breaking change. For scripting, we should be encouraging usage of the --format flag to pick the specific values the user cares about and provide a stable order. Though we also need to think about readability of the default output. Unfortunately, the output here is already too wide to fit on a single line in most cases. While the slug is useful, it does duplicate some of the info already shown.

I wonder if there is some more general solution for non-default columns? There are a lot of commands that could benefit.

The values shown in the help output come from here:

c.fmtCols = d.Cols()

It might be as simple as:

-               c.fmtCols = d.Cols()
+               c.fmtCols = maps.Keys(d.ColMap())

Though we need to check that the change doesn't have any undesired side effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants