Skip to content

Conversation

@phm07
Copy link
Contributor

@phm07 phm07 commented Oct 30, 2025

This PR makes the spacing used in describe commands consistent by utilizing Go's tabwriter.

@phm07 phm07 self-assigned this Oct 30, 2025
@apricote
Copy link
Member

apricote commented Oct 30, 2025

I like that its way less manual work to align the fields.

Just playing around with the output, I find it easier to understand if each "sub-object" would have its own indent level, and there are new lines between the different "sub-objects".

Output from this PR
$ hcloud storage-box describe test-sizes
ID:                          469232
Name:                        test-sizes
Created:                     Wed Aug 20 11:53:51 CEST 2025 (2 months ago)
Status:                      active
Username:                    u486114
Server:                      u486114.your-storagebox.de
System:                      FSN1-BX380
Snapshot Plan:               No snapshot plan active
Protection:                  
  Delete:                    false
Stats:                       
  Size:                      1000 MiB
  Size Data:                 0 B
  Size Snapshots:            1000 MiB
Labels:                      No labels
Access Settings:             
  Reachable Externally:      true
  Samba Enabled:             false
  SSH Enabled:               true
  WebDAV Enabled:            false
  ZFS Enabled:               true
Storage Box Type:            
  ID:                        1333
  Name:                      bx11
  Description:               BX11
  Size:                      1.0 TiB
  Snapshot Limit:            10
  Automatic Snapshot Limit:  10
  Subaccounts Limit:         100
Location:                    
  Location ID:               1
  Name:                      fsn1
  Description:               Falkenstein DC Park 1
  Network Zone:              eu-central
  Country:                   DE
  City:                      Falkenstein
  Latitude:                  50.476119
  Longitude:                 12.370071

Output for my suggestion
$ hcloud storage-box describe test-sizes
ID:        469232
Name:      test-sizes
Created:   Wed Aug 20 11:53:51 CEST 2025 (2 months ago)
Status:    active
Username:  u486114
Server:    u486114.your-storagebox.de
System:    FSN1-BX380

Snapshot Plan:  No snapshot plan active

Protection:
  Delete:  false

Stats:
  Size:            1000 MiB
  Size Data:       0 B
  Size Snapshots:  1000 MiB

Labels:  No labels

Access Settings:
  Reachable Externally:  true
  Samba Enabled:         false
  SSH Enabled:           true
  WebDAV Enabled:        false
  ZFS Enabled:           true

Storage Box Type:
  ID:                        1333
  Name:                      bx11
  Description:               BX11
  Size:                      1.0 TiB
  Snapshot Limit:            10
  Automatic Snapshot Limit:  10
  Subaccounts Limit:         100

Location:
  Location ID:   1
  Name:          fsn1
  Description:   Falkenstein DC Park 1
  Network Zone:  eu-central
  Country:       DE
  City:          Falkenstein
  Latitude:      50.476119
  Longitude:     12.370071
Diff for my formatting
diff --git a/internal/cmd/storagebox/describe.go b/internal/cmd/storagebox/describe.go
index c09ea7d8..93c1a35f 100644
--- a/internal/cmd/storagebox/describe.go
+++ b/internal/cmd/storagebox/describe.go
@@ -38,11 +38,12 @@ var DescribeCmd = base.DescribeCmd[*hcloud.StorageBox]{
                fmt.Fprintf(out, "Server:\t%s\n", storageBox.Server)
                fmt.Fprintf(out, "System:\t%s\n", storageBox.System)
 
+               fmt.Fprintln(out)
                snapshotPlan := storageBox.SnapshotPlan
                if snapshotPlan == nil {
                        fmt.Fprintf(out, "Snapshot Plan:\tNo snapshot plan active\n")
                } else {
-                       fmt.Fprintf(out, "Snapshot Plan:\t\n")
+                       fmt.Fprintf(out, "Snapshot Plan:\n")
                        fmt.Fprintf(out, "  Max Snapshots:\t%d\n", snapshotPlan.MaxSnapshots)
                        fmt.Fprintf(out, "  Minute:\t%d\n", snapshotPlan.Minute)
                        fmt.Fprintf(out, "  Hour:\t%d\n", snapshotPlan.Hour)
@@ -55,31 +56,37 @@ var DescribeCmd = base.DescribeCmd[*hcloud.StorageBox]{
                        }
                }
 
+               fmt.Fprintln(out)
                protection := storageBox.Protection
-               fmt.Fprintf(out, "Protection:\t\n")
+               fmt.Fprintf(out, "Protection:\n")
                fmt.Fprintf(out, "  Delete:\t%t\n", protection.Delete)
 
+               fmt.Fprintln(out)
                stats := storageBox.Stats
-               fmt.Fprintf(out, "Stats:\t\n")
+               fmt.Fprintf(out, "Stats:\n")
                fmt.Fprintf(out, "  Size:\t%s\n", humanize.IBytes(stats.Size))
                fmt.Fprintf(out, "  Size Data:\t%s\n", humanize.IBytes(stats.SizeData))
                fmt.Fprintf(out, "  Size Snapshots:\t%s\n", humanize.IBytes(stats.SizeSnapshots))
 
+               fmt.Fprintln(out)
                util.DescribeLabels(out, storageBox.Labels, "")
 
+               fmt.Fprintln(out)
                accessSettings := storageBox.AccessSettings
-               fmt.Fprintf(out, "Access Settings:\t\n")
+               fmt.Fprintf(out, "Access Settings:\n")
                fmt.Fprintf(out, "  Reachable Externally:\t%t\n", accessSettings.ReachableExternally)
                fmt.Fprintf(out, "  Samba Enabled:\t%t\n", accessSettings.SambaEnabled)
                fmt.Fprintf(out, "  SSH Enabled:\t%t\n", accessSettings.SSHEnabled)
                fmt.Fprintf(out, "  WebDAV Enabled:\t%t\n", accessSettings.WebDAVEnabled)
                fmt.Fprintf(out, "  ZFS Enabled:\t%t\n", accessSettings.ZFSEnabled)
 
+               fmt.Fprintln(out)
                typeDescription, _ := storageboxtype.DescribeStorageBoxType(s, storageBox.StorageBoxType, true)
-               fmt.Fprintf(out, "Storage Box Type:\t\n")
+               fmt.Fprintf(out, "Storage Box Type:\n")
                fmt.Fprintf(out, "%s", util.PrefixLines(typeDescription, "  "))
 
-               fmt.Fprintf(out, "Location:\t\n")
+               fmt.Fprintln(out)
+               fmt.Fprintf(out, "Location:\n")
                fmt.Fprintf(out, "%s", util.PrefixLines(location.DescribeLocation(storageBox.Location), "  "))
 
                return nil
diff --git a/internal/cmd/util/util.go b/internal/cmd/util/util.go
index 486ee1c4..5febd8e6 100644
--- a/internal/cmd/util/util.go
+++ b/internal/cmd/util/util.go
@@ -448,7 +448,7 @@ func DescribeLabels(out io.Writer, labels map[string]string, prefix string) {
        if len(labels) == 0 {
                _, _ = fmt.Fprintf(out, "%sLabels:\tNo labels\n", prefix)
        } else {
-               _, _ = fmt.Fprintf(out, "%sLabels:\t\n", prefix)
+               _, _ = fmt.Fprintf(out, "%sLabels:\n", prefix)
                for key, value := range IterateInOrder(labels) {
                        _, _ = fmt.Fprintf(out, "%s  %s:\t%s\n", prefix, key, value)
                }

@phm07
Copy link
Contributor Author

phm07 commented Oct 30, 2025

Would be fine for me, looks a bit more organized

Copy link
Member

@apricote apricote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice already :) Found some minor formatting inconsistencies

fmt.Fprintf(out, "Fingerprint:\t%s\n", sshKey.Fingerprint)

fmt.Fprintln(out)
fmt.Fprintf(out, "Public Key:\n%s\n", strings.TrimSpace(sshKey.PublicKey))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe with some space infront of the string?

Suggested change
fmt.Fprintf(out, "Public Key:\n%s\n", strings.TrimSpace(sshKey.PublicKey))
fmt.Fprintf(out, "Public Key:\n %s\n", strings.TrimSpace(sshKey.PublicKey))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be annoying if the whitespace is included when copying the line

@phm07 phm07 marked this pull request as ready for review November 6, 2025 14:56
@phm07 phm07 requested a review from a team as a code owner November 6, 2025 14:56
@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 81.77843% with 125 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.47%. Comparing base (e1cbe03) to head (de603ed).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
internal/cmd/loadbalancer/describe.go 36.17% 59 Missing and 1 partial ⚠️
internal/cmd/server/describe.go 65.85% 28 Missing ⚠️
internal/cmd/image/describe.go 80.64% 4 Missing and 2 partials ⚠️
internal/cmd/zone/describe.go 79.31% 6 Missing ⚠️
internal/cmd/certificate/describe.go 88.88% 2 Missing and 1 partial ⚠️
internal/cmd/network/describe.go 88.88% 2 Missing and 1 partial ⚠️
internal/cmd/primaryip/describe.go 88.00% 3 Missing ⚠️
internal/cmd/servertype/describe.go 91.66% 2 Missing and 1 partial ⚠️
internal/cmd/storageboxtype/describe.go 90.90% 2 Missing and 1 partial ⚠️
internal/cmd/base/describe.go 60.00% 1 Missing and 1 partial ⚠️
... and 6 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1216      +/-   ##
==========================================
+ Coverage   72.28%   72.47%   +0.19%     
==========================================
  Files         311      311              
  Lines       11407    11413       +6     
==========================================
+ Hits         8245     8272      +27     
+ Misses       2216     2208       -8     
+ Partials      946      933      -13     
Flag Coverage Δ
e2e 51.94% <45.48%> (+0.46%) ⬆️
unit 67.43% <78.42%> (+0.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@phm07 phm07 requested a review from apricote November 7, 2025 12:58
@phm07 phm07 merged commit 5b70819 into main Nov 7, 2025
6 checks passed
@phm07 phm07 deleted the describe-fix branch November 7, 2025 13:27
jooola pushed a commit that referenced this pull request Nov 7, 2025
<!-- section-start changelog -->
### Features

- format user provided TXT records when not quoted (#1208)

### Bug Fixes

- more readable default time format (#1197)
- **iso**: broken `--type` flag in list command (#1221)
- Storage Boxes not listed in `hcloud all list` (#1222)
- consistent tab spacing in describe commands (#1216)
- filepaths not correctly resolved on Windows (#1229)

<!-- section-end changelog -->

---

<details>
<summary><h4>PR by <a
href="https://github.com/apricote/releaser-pleaser">releaser-pleaser</a>
🤖</h4></summary>

If you want to modify the proposed release, add you overrides here. You
can learn more about the options in the docs.

## Release Notes

### Prefix / Start

This will be added to the start of the release notes.

~~~~rp-prefix
~~~~

### Suffix / End

This will be added to the end of the release notes.

~~~~rp-suffix
~~~~

</details>

Co-authored-by: Hetzner Cloud Bot <>
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.

4 participants