diff --git a/cmd/kms/key/key_show.go b/cmd/kms/key/key_show.go index 4755321e8..677ca6fff 100644 --- a/cmd/kms/key/key_show.go +++ b/cmd/kms/key/key_show.go @@ -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" } @@ -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) } diff --git a/pkg/output/outputter.go b/pkg/output/outputter.go index 683df1517..fe770dac3 100644 --- a/pkg/output/outputter.go +++ b/pkg/output/outputter.go @@ -8,6 +8,7 @@ import ( "reflect" "strings" "text/template" + "time" "github.com/exoscale/cli/table" v3 "github.com/exoscale/egoscale/v3" @@ -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.