Skip to content

Commit 5af3051

Browse files
committed
improve annotations
1 parent c32cba7 commit 5af3051

File tree

14 files changed

+63
-49
lines changed

14 files changed

+63
-49
lines changed

apis/secretmanager/v1beta1/secret_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ type SecretManagerSecretSpec struct {
8484
// The total size of annotation keys and values must be less than 16KiB.
8585
Annotations map[string]string `json:"annotations,omitempty"`
8686

87+
// The labels assigned to this Secret.
88+
//
89+
// Label keys must be between 1 and 63 characters long, have a UTF-8 encoding
90+
// of maximum 128 bytes, and must conform to the following PCRE regular
91+
// expression: `[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}`
92+
//
93+
// Label values must be between 0 and 63 characters long, have a UTF-8
94+
// encoding of maximum 128 bytes, and must conform to the following PCRE
95+
// regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}`
96+
//
97+
// No more than 64 labels can be assigned to a given resource.
98+
Labels map[string]string `json:"labels,omitempty"`
99+
87100
/*NOTYET
88101
// Optional. Secret Version TTL after destruction request
89102
//

apis/secretmanager/v1beta1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crds/resources/apiextensions.k8s.io_v1_customresourcedefinition_secretmanagersecrets.secretmanager.cnrm.cloud.google.com.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,22 @@ spec:
8484
is scheduled to expire. This is always provided on output, regardless
8585
of what was sent on input.
8686
type: string
87+
labels:
88+
additionalProperties:
89+
type: string
90+
description: |-
91+
The labels assigned to this Secret.
92+
93+
Label keys must be between 1 and 63 characters long, have a UTF-8 encoding
94+
of maximum 128 bytes, and must conform to the following PCRE regular
95+
expression: `[\p{Ll}\p{Lo}][\p{Ll}\p{Lo}\p{N}_-]{0,62}`
96+
97+
Label values must be between 0 and 63 characters long, have a UTF-8
98+
encoding of maximum 128 bytes, and must conform to the following PCRE
99+
regular expression: `[\p{Ll}\p{Lo}\p{N}_-]{0,63}`
100+
101+
No more than 64 labels can be assigned to a given resource.
102+
type: object
87103
replication:
88104
description: |-
89105
Optional. Immutable. The replication policy of the secret data attached to

pkg/controller/direct/secretmanager/mapper.generated.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controller/direct/secretmanager/secret_mapping.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ func SecretManagerSecretSpec_ToProto(mapCtx *direct.MapContext, in *krm.SecretMa
9999
// MISSING: VersionAliases
100100
// out.VersionAliases = in.VersionAliases
101101
out.Annotations = in.Annotations
102+
out.Labels = in.Labels
102103
// MISSING: VersionDestroyTtl
103104
// MISSING: CustomerManagedEncryption
104105
return out

pkg/controller/direct/secretmanager/secretversion_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ func (a *SecretVersionAdapter) Create(ctx context.Context, createOp *directbase.
165165
log.V(2).Info("successfully created SecretVersion", "name", a.id)
166166

167167
// The default status for newly created resource is "enabled".
168+
// This saves the waiting time for the next reconciliation.
168169
if !*a.desired.Spec.Enabled {
169170
log.V(2).Info("disabling the secret version", "name", a.id)
170171
req := &pb.DisableSecretVersionRequest{

pkg/test/resourcefixture/testdata/basic/secretmanager/v1beta1/basicsecretmanagersecret/_generated_object_basicsecretmanagersecret.golden.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ metadata:
1010
generation: 1
1111
labels:
1212
cnrm-test: "true"
13-
label-one: value-one
1413
name: secretmanagersecret-${uniqueId}
1514
namespace: ${uniqueId}
1615
spec:
16+
labels:
17+
label-one: value-one
1718
replication:
1819
userManaged:
1920
replicas:

pkg/test/resourcefixture/testdata/basic/secretmanager/v1beta1/basicsecretmanagersecret/_http.log

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ x-goog-request-params: parent=projects%2F${projectId}
3131

3232
{
3333
"labels": {
34-
"cnrm-test": "true",
35-
"label-one": "value-one",
36-
"managed-by-cnrm": "true"
34+
"label-one": "value-one"
3735
},
3836
"replication": {
3937
"userManaged": {
@@ -61,9 +59,7 @@ X-Xss-Protection: 0
6159
"createTime": "2024-04-01T12:34:56.123456Z",
6260
"etag": "abcdef0123A=",
6361
"labels": {
64-
"cnrm-test": "true",
65-
"label-one": "value-one",
66-
"managed-by-cnrm": "true"
62+
"label-one": "value-one"
6763
},
6864
"name": "projects/${projectNumber}/secrets/secretmanagersecret-${uniqueId}",
6965
"replication": {
@@ -99,9 +95,7 @@ X-Xss-Protection: 0
9995
"createTime": "2024-04-01T12:34:56.123456Z",
10096
"etag": "abcdef0123A=",
10197
"labels": {
102-
"cnrm-test": "true",
103-
"label-one": "value-one",
104-
"managed-by-cnrm": "true"
98+
"label-one": "value-one"
10599
},
106100
"name": "projects/${projectNumber}/secrets/secretmanagersecret-${uniqueId}",
107101
"replication": {

pkg/test/resourcefixture/testdata/basic/secretmanager/v1beta1/basicsecretmanagersecret/create.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ metadata:
1818
annotations:
1919
cnrm.cloud.google.com/project-id: ${projectId}
2020
name: secretmanagersecret-${uniqueId}
21-
labels:
22-
label-one: value-one
2321
spec:
2422
replication:
2523
userManaged:
2624
replicas:
27-
- location: us-central1
25+
- location: us-central1
26+
labels:
27+
label-one: value-one

pkg/test/resourcefixture/testdata/basic/secretmanager/v1beta1/fullsecretmanagersecret/_generated_object_fullsecretmanagersecret.golden.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ metadata:
1010
generation: 2
1111
labels:
1212
cnrm-test: "true"
13-
label-one: value-one
1413
name: secretmanagersecret-${uniqueId}
1514
namespace: ${uniqueId}
1615
spec:
1716
annotations:
1817
bar: secretmanagersecret-bar
1918
foo: secretmanagersecret
2019
expireTime: "2025-10-03T15:01:23Z"
20+
labels:
21+
label-one: value-one
22+
label-two: value-two
2123
replication:
2224
auto:
2325
customerManagedEncryption:

0 commit comments

Comments
 (0)