Skip to content

Commit cc5d3c3

Browse files
authored
Merge pull request #84 from DopplerHQ/nic/labels-and-annotations
Add support for labels and annotations in managed secrets
2 parents c9a3a89 + cbca9cb commit cc5d3c3

File tree

8 files changed

+167
-73
lines changed

8 files changed

+167
-73
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ controller-gen: ## Download controller-gen locally if necessary.
146146

147147
KUSTOMIZE = $(shell pwd)/bin/kustomize
148148
kustomize: ## Download kustomize locally if necessary.
149-
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5@v5.0.3)
149+
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5@v5.6.0)
150150

151151
YQ = $(shell pwd)/bin/yq
152152
yq: ## Download yq locally if necessary.

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,28 @@ spec:
305305

306306
If this property is omitted all secrets are synced.
307307

308+
## Specifying Labels and Annotations on a Managed Secret
309+
310+
You can specify labels and annotations that the operator should add to the managed Kubernetes `Secret` resource. To do this, specify them in the `managedSecret.labels` and `managedSecret.annotations` spec properties.
311+
312+
```yaml
313+
apiVersion: secrets.doppler.com/v1alpha1
314+
kind: DopplerSecret
315+
metadata:
316+
name: dopplersecret-test
317+
namespace: doppler-operator-system
318+
spec:
319+
tokenSecret:
320+
name: doppler-token-secret
321+
managedSecret:
322+
name: doppler-test-secret
323+
namespace: default
324+
labels:
325+
doppler-secret-label: test
326+
annotations:
327+
doppler-secret-annotation: test
328+
```
329+
308330
## Kubernetes Secret Types and Value Encoding
309331

310332
By default, the operator syncs secret values as they are in Doppler to an [`Opaque` Kubernetes secret](https://kubernetes.io/docs/concepts/configuration/secret/) as Key / Value pairs.

api/v1alpha1/dopplersecret_types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ type ManagedSecretReference struct {
4949
// +kubebuilder:default=Opaque
5050
// +optional
5151
Type string `json:"type,omitempty"`
52+
53+
// Labels to add or update on the managed secret
54+
// +optional
55+
Labels map[string]string `json:"labels,omitempty"`
56+
57+
// Annotations to add or update on the managed secret
58+
// +optional
59+
Annotations map[string]string `json:"annotations,omitempty"`
5260
}
5361

5462
type SecretProcessor struct {

api/v1alpha1/zz_generated.deepcopy.go

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

config/crd/bases/secrets.doppler.com_dopplersecrets.yaml

Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
21
---
32
apiVersion: apiextensions.k8s.io/v1
43
kind: CustomResourceDefinition
54
metadata:
65
annotations:
7-
controller-gen.kubebuilder.io/version: v0.4.1
8-
creationTimestamp: null
6+
controller-gen.kubebuilder.io/version: v0.17.1
97
name: dopplersecrets.secrets.doppler.com
108
spec:
119
group: secrets.doppler.com
@@ -22,14 +20,19 @@ spec:
2220
description: DopplerSecret is the Schema for the dopplersecrets API
2321
properties:
2422
apiVersion:
25-
description: 'APIVersion defines the versioned schema of this representation
26-
of an object. Servers should convert recognized schemas to the latest
27-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
23+
description: |-
24+
APIVersion defines the versioned schema of this representation of an object.
25+
Servers should convert recognized schemas to the latest internal value, and
26+
may reject unrecognized values.
27+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
2828
type: string
2929
kind:
30-
description: 'Kind is a string value representing the REST resource this
31-
object represents. Servers may infer this from the endpoint the client
32-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
30+
description: |-
31+
Kind is a string value representing the REST resource this object represents.
32+
Servers may infer this from the endpoint the client submits requests to.
33+
Cannot be updated.
34+
In CamelCase.
35+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
3336
type: string
3437
metadata:
3538
type: object
@@ -56,6 +59,16 @@ spec:
5659
description: The Kubernetes secret where the operator will store and
5760
sync the fetched secrets
5861
properties:
62+
annotations:
63+
additionalProperties:
64+
type: string
65+
description: Annotations to add or update on the managed secret
66+
type: object
67+
labels:
68+
additionalProperties:
69+
type: string
70+
description: Labels to add or update on the managed secret
71+
type: object
5972
name:
6073
description: The name of the Secret resource
6174
type: string
@@ -108,6 +121,7 @@ spec:
108121
- base64
109122
type: string
110123
type: object
124+
default: {}
111125
description: A list of processors to transform the data during ingestion
112126
type: object
113127
project:
@@ -147,45 +161,35 @@ spec:
147161
properties:
148162
conditions:
149163
items:
150-
description: "Condition contains details for one aspect of the current
151-
state of this API Resource. --- This struct is intended for direct
152-
use as an array at the field path .status.conditions. For example,
153-
\n \ttype FooStatus struct{ \t // Represents the observations
154-
of a foo's current state. \t // Known .status.conditions.type
155-
are: \"Available\", \"Progressing\", and \"Degraded\" \t //
156-
+patchMergeKey=type \t // +patchStrategy=merge \t // +listType=map
157-
\t // +listMapKey=type \t Conditions []metav1.Condition
158-
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
159-
protobuf:\"bytes,1,rep,name=conditions\"` \n \t // other fields
160-
\t}"
164+
description: Condition contains details for one aspect of the current
165+
state of this API Resource.
161166
properties:
162167
lastTransitionTime:
163-
description: lastTransitionTime is the last time the condition
164-
transitioned from one status to another. This should be when
165-
the underlying condition changed. If that is not known, then
166-
using the time when the API field changed is acceptable.
168+
description: |-
169+
lastTransitionTime is the last time the condition transitioned from one status to another.
170+
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
167171
format: date-time
168172
type: string
169173
message:
170-
description: message is a human readable message indicating
171-
details about the transition. This may be an empty string.
174+
description: |-
175+
message is a human readable message indicating details about the transition.
176+
This may be an empty string.
172177
maxLength: 32768
173178
type: string
174179
observedGeneration:
175-
description: observedGeneration represents the .metadata.generation
176-
that the condition was set based upon. For instance, if .metadata.generation
177-
is currently 12, but the .status.conditions[x].observedGeneration
178-
is 9, the condition is out of date with respect to the current
179-
state of the instance.
180+
description: |-
181+
observedGeneration represents the .metadata.generation that the condition was set based upon.
182+
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
183+
with respect to the current state of the instance.
180184
format: int64
181185
minimum: 0
182186
type: integer
183187
reason:
184-
description: reason contains a programmatic identifier indicating
185-
the reason for the condition's last transition. Producers
186-
of specific condition types may define expected values and
187-
meanings for this field, and whether the values are considered
188-
a guaranteed API. The value should be a CamelCase string.
188+
description: |-
189+
reason contains a programmatic identifier indicating the reason for the condition's last transition.
190+
Producers of specific condition types may define expected values and meanings for this field,
191+
and whether the values are considered a guaranteed API.
192+
The value should be a CamelCase string.
189193
This field may not be empty.
190194
maxLength: 1024
191195
minLength: 1
@@ -200,10 +204,6 @@ spec:
200204
type: string
201205
type:
202206
description: type of condition in CamelCase or in foo.example.com/CamelCase.
203-
--- Many .condition.type values are consistent across resources
204-
like Available, but because arbitrary conditions can be useful
205-
(see .node.status.conditions), the ability to deconflict is
206-
important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
207207
maxLength: 316
208208
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
209209
type: string
@@ -223,9 +223,3 @@ spec:
223223
storage: true
224224
subresources:
225225
status: {}
226-
status:
227-
acceptedNames:
228-
kind: ""
229-
plural: ""
230-
conditions: []
231-
storedVersions: []

config/rbac/role.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
21
---
32
apiVersion: rbac.authorization.k8s.io/v1
43
kind: ClusterRole
54
metadata:
6-
creationTimestamp: null
75
name: manager-role
86
rules:
97
- apiGroups:

0 commit comments

Comments
 (0)