Skip to content
This repository was archived by the owner on Jul 26, 2022. It is now read-only.

feat: adding annotations support #139

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Daemon {
* @returns {Object} Poller descriptor.
*/
_createPollerDescriptor (externalSecret) {
const { uid, name, namespace } = externalSecret.metadata
const { uid, name, namespace, annotations = {} } = externalSecret.metadata
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, I worry about copying one object's annotations directly to another object. A more "kubernetes-like" approach would be to have a Secret template (analogous to the Pod template for Deployments) and set the annotation values there that you want the external secrets controller to apply to the corresponding Secret.

We've discussed this approach before, but had some concerns with reconciling in with other "frontends" that don't use Secret objects (see #46).

What's the use case for this? Maybe there's another way to support it?

// NOTE(jdaeli): hash this in case resource version becomes too long?
const secretDescriptor = { ...externalSecret.secretDescriptor, name }
const ownerReference = {
Expand All @@ -47,7 +47,7 @@ class Daemon {
uid
}

return { id: uid, namespace, secretDescriptor, ownerReference }
return { id: uid, namespace, secretDescriptor, ownerReference, annotations }
}

/**
Expand Down Expand Up @@ -75,6 +75,7 @@ class Daemon {
kubeClient: this._kubeClient,
logger: this._logger,
namespace: descriptor.namespace,
annotations: descriptor.annotations,
secretDescriptor: descriptor.secretDescriptor,
ownerReference: descriptor.ownerReference
})
Expand Down
3 changes: 3 additions & 0 deletions lib/poller.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Poller {
* @param {SecretDescriptor} secretDescriptor - Kubernetes secret descriptor.
*/
constructor ({
annotations = {},
backends,
intervalMilliseconds,
kubeClient,
Expand All @@ -32,6 +33,7 @@ class Poller {
secretDescriptor,
ownerReference
}) {
this._annotations = annotations
this._backends = backends
this._intervalMilliseconds = intervalMilliseconds
this._kubeClient = kubeClient
Expand All @@ -55,6 +57,7 @@ class Poller {
apiVersion: 'v1',
kind: 'Secret',
metadata: {
annotations: this._annotations,
name: secretDescriptor.name,
ownerReferences: [
this._ownerReference
Expand Down
5 changes: 5 additions & 0 deletions lib/poller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ describe('Poller', () => {
apiVersion: 'v1',
kind: 'Secret',
metadata: {
annotations: {},
name: 'fakeSecretName',
ownerReferences: [ownerReference]
},
Expand Down Expand Up @@ -134,6 +135,7 @@ describe('Poller', () => {
apiVersion: 'v1',
kind: 'Secret',
metadata: {
annotations: {},
name: 'fakeSecretName',
ownerReferences: [ownerReference]
},
Expand Down Expand Up @@ -194,6 +196,7 @@ describe('Poller', () => {
apiVersion: 'v1',
kind: 'Secret',
metadata: {
annotations: {},
name: 'fakeSecretName'
},
type: 'some-type',
Expand All @@ -213,6 +216,7 @@ describe('Poller', () => {
apiVersion: 'v1',
kind: 'Secret',
metadata: {
annotations: {},
name: 'fakeSecretName'
},
type: 'some-type',
Expand All @@ -238,6 +242,7 @@ describe('Poller', () => {
apiVersion: 'v1',
kind: 'Secret',
metadata: {
annotations: {},
name: 'fakeSecretName'
},
type: 'some-type',
Expand Down