@@ -24,6 +24,8 @@ var CreateCmd = base.CreateCmd{
24
24
cmd .Flags ().String ("name" , "" , "Certificate name (required)" )
25
25
_ = cmd .MarkFlagRequired ("name" )
26
26
27
+ cmd .Flags ().StringToString ("label" , nil , "User-defined labels ('key=value') (can be specified multiple times)" )
28
+
27
29
cmd .Flags ().StringP ("type" , "t" , string (hcloud .CertificateTypeUploaded ),
28
30
fmt .Sprintf ("Type of certificate to create. Valid choices: %v, %v" ,
29
31
hcloud .CertificateTypeUploaded , hcloud .CertificateTypeManaged ))
@@ -61,6 +63,7 @@ var CreateCmd = base.CreateCmd{
61
63
func createUploaded (s state.State , cmd * cobra.Command ) (* hcloud.Certificate , error ) {
62
64
var (
63
65
name string
66
+ labels map [string ]string
64
67
certFile , keyFile string
65
68
certPEM , keyPEM []byte
66
69
cert * hcloud.Certificate
@@ -74,6 +77,9 @@ func createUploaded(s state.State, cmd *cobra.Command) (*hcloud.Certificate, err
74
77
if name , err = cmd .Flags ().GetString ("name" ); err != nil {
75
78
return nil , err
76
79
}
80
+ if labels , err = cmd .Flags ().GetStringToString ("label" ); err != nil {
81
+ return nil , err
82
+ }
77
83
if certFile , err = cmd .Flags ().GetString ("cert-file" ); err != nil {
78
84
return nil , err
79
85
}
@@ -90,6 +96,7 @@ func createUploaded(s state.State, cmd *cobra.Command) (*hcloud.Certificate, err
90
96
91
97
createOpts := hcloud.CertificateCreateOpts {
92
98
Name : name ,
99
+ Labels : labels ,
93
100
Type : hcloud .CertificateTypeUploaded ,
94
101
Certificate : string (certPEM ),
95
102
PrivateKey : string (keyPEM ),
@@ -105,6 +112,7 @@ func createUploaded(s state.State, cmd *cobra.Command) (*hcloud.Certificate, err
105
112
func createManaged (s state.State , cmd * cobra.Command ) (* hcloud.Certificate , error ) {
106
113
var (
107
114
name string
115
+ labels map [string ]string
108
116
domains []string
109
117
res hcloud.CertificateCreateResult
110
118
err error
@@ -119,9 +127,13 @@ func createManaged(s state.State, cmd *cobra.Command) (*hcloud.Certificate, erro
119
127
if domains , err = cmd .Flags ().GetStringSlice ("domain" ); err != nil {
120
128
return nil , nil
121
129
}
130
+ if labels , err = cmd .Flags ().GetStringToString ("label" ); err != nil {
131
+ return nil , err
132
+ }
122
133
123
134
createOpts := hcloud.CertificateCreateOpts {
124
135
Name : name ,
136
+ Labels : labels ,
125
137
Type : hcloud .CertificateTypeManaged ,
126
138
DomainNames : domains ,
127
139
}
0 commit comments