diff --git a/internal/cmd/certificate/create.go b/internal/cmd/certificate/create.go index 0a63ac1e..10da3cee 100644 --- a/internal/cmd/certificate/create.go +++ b/internal/cmd/certificate/create.go @@ -13,7 +13,6 @@ import ( "github.com/hetznercloud/cli/internal/hcapi2" "github.com/hetznercloud/cli/internal/state" "github.com/hetznercloud/hcloud-go/v2/hcloud" - "github.com/hetznercloud/hcloud-go/v2/hcloud/schema" ) var CreateCmd = base.CreateCmd{ @@ -57,11 +56,7 @@ var CreateCmd = base.CreateCmd{ if err != nil { return nil, nil, err } - return cert, struct { - Certificate schema.Certificate `json:"certificate"` - }{ - Certificate: hcloud.SchemaFromCertificate(cert), - }, nil + return cert, util.WrapSchema("certificate", hcloud.SchemaFromCertificate(cert)), nil }, } diff --git a/internal/cmd/util/util.go b/internal/cmd/util/util.go index 8662b5dd..1407feb2 100644 --- a/internal/cmd/util/util.go +++ b/internal/cmd/util/util.go @@ -165,6 +165,13 @@ func DescribeYAML(object interface{}) error { return enc.Encode(object) } +// WrapSchema return a map wrapping the schema (value) in a dict (`{ key: value }`). +// +// Used to reduce boilerplate. +func WrapSchema(key string, value any) map[string]any { + return map[string]any{key: value} +} + // ValidateRequiredFlags ensures that flags has values for all flags with // the passed names. //