Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions cmd/kms/key/key_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type KeyShowOutput struct {
Rotation string `json:"rotation" validate:"required"`
Usage string `json:"usage" validate:"required"`
Source v3.GetKmsKeyResponseSource `json:"source" validate:"required"`
Description string `json:"description" validate:"required"`
Description string `json:"description,omitempty"`
DeleteAt time.Time `json:"delete-at,omitempty"`
}

func (o *KeyShowOutput) Type() string { return "KMS key" }
Expand Down Expand Up @@ -77,10 +78,12 @@ func (c *KeyShowCmd) CmdRun(_ *cobra.Command, _ []string) error {
ReplicasStatus: formatReplicaStatus(resp.ReplicasStatus),
Material: formatKeyMaterial(resp.Material),
Rotation: formatKeyRotationConfig(resp.Rotation),
Usage: string(resp.Usage),
Usage: resp.Usage,
Source: resp.Source,
Description: resp.Description,
DeleteAt: resp.DeleteAT,
}

return c.OutputFunc(&out, nil)
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/output/outputter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"reflect"
"strings"
"text/template"
"time"

"github.com/exoscale/cli/table"
v3 "github.com/exoscale/egoscale/v3"
Expand Down Expand Up @@ -209,6 +210,12 @@ func Table(o interface{}) {
label = l
}

// If the field is a zero-value time.Time, print "n/a".
if ts, ok := v.Field(i).Interface().(time.Time); ok && ts.IsZero() {
tab.Append([]string{label, "n/a"})
continue
}

switch v.Field(i).Kind() {
case reflect.Slice:
// If the field value is a slice and is empty, print "n/a" instead of 0.
Expand Down
Loading