|
|
@@ -44,8 +44,8 @@ import (
|
|
|
"github.com/external-secrets/external-secrets/pkg/controllers/externalsecret/esmetrics"
|
|
|
ctrlmetrics "github.com/external-secrets/external-secrets/pkg/controllers/metrics"
|
|
|
"github.com/external-secrets/external-secrets/pkg/controllers/util"
|
|
|
+ "github.com/external-secrets/external-secrets/pkg/esutils"
|
|
|
"github.com/external-secrets/external-secrets/pkg/provider/testing/fake"
|
|
|
- "github.com/external-secrets/external-secrets/pkg/utils"
|
|
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
|
. "github.com/onsi/gomega"
|
|
|
@@ -162,7 +162,7 @@ var _ = Describe("Kind=secret existence logic", func() {
|
|
|
esv1.LabelManaged: esv1.LabelManagedValue,
|
|
|
},
|
|
|
Annotations: map[string]string{
|
|
|
- esv1.AnnotationDataHash: utils.ObjectHash(validData),
|
|
|
+ esv1.AnnotationDataHash: esutils.ObjectHash(validData),
|
|
|
},
|
|
|
},
|
|
|
Data: validData,
|
|
|
@@ -286,7 +286,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
|
return true
|
|
|
},
|
|
|
- checkExternalSecret: func(es *esv1.ExternalSecret) {
|
|
|
+ checkExternalSecret: func(_ *esv1.ExternalSecret) {
|
|
|
// noop by default
|
|
|
},
|
|
|
secretStore: &esv1.SecretStore{
|
|
|
@@ -343,7 +343,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
syncBigNames := func(tc *testCase) {
|
|
|
tc.targetSecretName = "this-is-a-very-big-secret-name-that-wouldnt-be-generated-due-to-label-limits"
|
|
|
tc.externalSecret.Spec.Target.Name = "this-is-a-very-big-secret-name-that-wouldnt-be-generated-due-to-label-limits"
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(es *esv1.ExternalSecret, _ *v1.Secret) {
|
|
|
// check binding secret on external secret
|
|
|
Expect(es.Status.Binding.Name).To(Equal(tc.externalSecret.Spec.Target.Name))
|
|
|
}
|
|
|
@@ -376,7 +376,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(secret.ObjectMeta.Labels).To(HaveKeyWithValue(labelKey, labelValue))
|
|
|
Expect(secret.ObjectMeta.Annotations).To(HaveKeyWithValue(annotationKey, annotationValue))
|
|
|
|
|
|
@@ -409,7 +409,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}, client.FieldOwner(FakeManager))).To(Succeed())
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(secret.ObjectMeta.Labels).To(HaveKeyWithValue(labelKey, labelValue))
|
|
|
Expect(secret.ObjectMeta.Labels).To(HaveKeyWithValue(existingLabelKey, existingLabelValue))
|
|
|
Expect(secret.ObjectMeta.Annotations).To(HaveKeyWithValue(annotationKey, annotationValue))
|
|
|
@@ -439,7 +439,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}, client.FieldOwner(ExternalSecretFQDN))).To(Succeed())
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(secret.ObjectMeta.Labels).To(HaveKeyWithValue(labelKey, labelValue))
|
|
|
Expect(secret.ObjectMeta.Labels).NotTo(HaveKeyWithValue(existingLabelKey, existingLabelValue))
|
|
|
Expect(secret.ObjectMeta.Annotations).To(HaveKeyWithValue(annotationKey, annotationValue))
|
|
|
@@ -450,7 +450,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
checkPrometheusCounters := func(tc *testCase) {
|
|
|
const secretVal = "someValue"
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, _ *v1.Secret) {
|
|
|
Expect(externalSecretConditionShouldBe(ExternalSecretName, ExternalSecretNamespace, esv1.ExternalSecretReady, v1.ConditionFalse, 0.0)).To(BeTrue())
|
|
|
Expect(externalSecretConditionShouldBe(ExternalSecretName, ExternalSecretNamespace, esv1.ExternalSecretReady, v1.ConditionTrue, 1.0)).To(BeTrue())
|
|
|
Eventually(func() bool {
|
|
|
@@ -493,7 +493,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}, client.FieldOwner(FakeManager))).To(Succeed())
|
|
|
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check value
|
|
|
Expect(string(secret.Data[existingKey])).To(Equal(existingVal))
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
@@ -538,7 +538,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}, client.FieldOwner(FakeManager))).To(Succeed())
|
|
|
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// Overwrite the secret value to check if the change kicks reconciliation and overwrites it again
|
|
|
Expect(k8sClient.Update(context.Background(), &v1.Secret{
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
@@ -570,7 +570,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}, client.FieldOwner(FakeManager))).To(Succeed())
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
oldResourceVersion := secret.ResourceVersion
|
|
|
|
|
|
cleanSecret := secret.DeepCopy()
|
|
|
@@ -617,7 +617,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
|
return true
|
|
|
}
|
|
|
- tc.checkExternalSecret = func(es *esv1.ExternalSecret) {
|
|
|
+ tc.checkExternalSecret = func(_ *esv1.ExternalSecret) {
|
|
|
Eventually(func() bool {
|
|
|
Expect(testSyncCallsError.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
|
|
|
Expect(testExternalSecretReconcileDuration.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metricDuration)).To(Succeed())
|
|
|
@@ -647,7 +647,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}, client.FieldOwner(FakeManager))).To(Succeed())
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check that value stays the same
|
|
|
Expect(string(secret.Data[existingKey])).To(Equal(secretVal))
|
|
|
|
|
|
@@ -694,7 +694,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data[secretKey])).To(Equal(secretVal))
|
|
|
}
|
|
|
@@ -733,7 +733,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data[secretKey])).To(Equal(secretVal))
|
|
|
}
|
|
|
@@ -769,7 +769,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- ignoreMismatchControllerForGeneratorRef := func(tc *testCase) {
|
|
|
+ ignoreMismatchControllerForGeneratorRef := func(_ *testCase) {
|
|
|
const secretKey = "somekey"
|
|
|
const secretVal = "someValue"
|
|
|
|
|
|
@@ -862,7 +862,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data["foo"])).To(Equal("bar"))
|
|
|
Expect(string(secret.Data["foo2"])).To(Equal("bar2"))
|
|
|
@@ -934,7 +934,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(expectedSecretVal))
|
|
|
}
|
|
|
@@ -1019,7 +1019,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
"targetProperty": []byte(FooValue),
|
|
|
"bar": []byte(BarValue),
|
|
|
}, nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(expectedSecretVal))
|
|
|
Expect(string(secret.Data[tplStaticKey])).To(Equal(tplStaticVal))
|
|
|
@@ -1092,7 +1092,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
"targetKey": []byte(FooValue),
|
|
|
"targetValue": []byte(BarValue),
|
|
|
}, nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data["map-foo-value-cm"])).To(Equal(BarValue))
|
|
|
Expect(string(secret.Data["map-foo-value-sec"])).To(Equal(BarValue))
|
|
|
@@ -1140,7 +1140,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
"targetValue": []byte(BarValue),
|
|
|
"complex": []byte("{\"nested\":\"json\",\"can\":\"be\",\"templated\":\"successfully\"}"),
|
|
|
}, nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data["map-foo-value-literal"])).To(Equal(BarValue))
|
|
|
Expect(string(secret.Data["nested"])).To(Equal("json"))
|
|
|
@@ -1261,7 +1261,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
const secretVal = "someValue"
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
tc.externalSecret.Spec.RefreshInterval = &metav1.Duration{Duration: time.Second}
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
|
|
|
@@ -1300,7 +1300,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}
|
|
|
tc.externalSecret.Spec.RefreshInterval = &metav1.Duration{Duration: time.Second}
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data["foo"])).To(Equal("1111"))
|
|
|
Expect(string(secret.Data["bar"])).To(Equal("2222"))
|
|
|
@@ -1342,7 +1342,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}
|
|
|
tc.externalSecret.Spec.RefreshInterval = &metav1.Duration{Duration: time.Second}
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data["foo"])).To(Equal("1111"))
|
|
|
Expect(string(secret.Data["bar"])).To(Equal("2222"))
|
|
|
@@ -1372,7 +1372,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
const secretVal = "someValue"
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
tc.externalSecret.Spec.RefreshInterval = &metav1.Duration{Duration: 0}
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
|
|
|
@@ -1412,7 +1412,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
|
tc.externalSecret.Spec.Target.DeletionPolicy = esv1.DeletionPolicyDelete
|
|
|
tc.externalSecret.Spec.RefreshInterval = &metav1.Duration{Duration: time.Second}
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(secret.Data["foo"]).To(Equal(expVal))
|
|
|
|
|
|
// update provider secret
|
|
|
@@ -1459,7 +1459,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
|
tc.externalSecret.Spec.Target.DeletionPolicy = esv1.DeletionPolicyRetain
|
|
|
tc.externalSecret.Spec.RefreshInterval = &metav1.Duration{Duration: time.Second}
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(secret.Data["foo"]).To(Equal(expVal))
|
|
|
|
|
|
sec := &v1.Secret{}
|
|
|
@@ -1540,7 +1540,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}, client.FieldOwner(FakeManager))).To(Succeed())
|
|
|
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check value
|
|
|
Expect(string(secret.Data[existingKey])).To(Equal(existingVal))
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
@@ -1572,7 +1572,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
tc.externalSecret.Spec.Target.CreationPolicy = esv1.CreatePolicyOrphan
|
|
|
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check value
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
|
|
|
@@ -1623,7 +1623,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
"foo": []byte(FooValue),
|
|
|
"bar": []byte(BarValue),
|
|
|
}, nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data["new-foo"])).To(Equal(FooValue))
|
|
|
Expect(string(secret.Data["new-bar"])).To(Equal(BarValue))
|
|
|
@@ -1666,7 +1666,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
|
return true
|
|
|
}
|
|
|
- tc.checkExternalSecret = func(es *esv1.ExternalSecret) {
|
|
|
+ tc.checkExternalSecret = func(_ *esv1.ExternalSecret) {
|
|
|
Eventually(func() bool {
|
|
|
Expect(testSyncCallsError.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
|
|
|
Expect(testExternalSecretReconcileDuration.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metricDuration)).To(Succeed())
|
|
|
@@ -1715,7 +1715,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
|
return true
|
|
|
}
|
|
|
- tc.checkExternalSecret = func(es *esv1.ExternalSecret) {
|
|
|
+ tc.checkExternalSecret = func(_ *esv1.ExternalSecret) {
|
|
|
Eventually(func() bool {
|
|
|
Expect(testSyncCallsError.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
|
|
|
Expect(testExternalSecretReconcileDuration.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metricDuration)).To(Succeed())
|
|
|
@@ -1742,7 +1742,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
"foo": []byte(FooValue),
|
|
|
"bar": []byte(BarValue),
|
|
|
}, nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data["foo"])).To(Equal(FooValue))
|
|
|
Expect(string(secret.Data["bar"])).To(Equal(BarValue))
|
|
|
@@ -1773,7 +1773,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
"foo": []byte(FooValue),
|
|
|
"bar": []byte(BarValue),
|
|
|
}, nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data["new-foo"])).To(Equal(FooValue))
|
|
|
Expect(string(secret.Data["new-bar"])).To(Equal(BarValue))
|
|
|
@@ -1797,7 +1797,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
"foo": []byte(FooValue),
|
|
|
"bar": []byte(BarValue),
|
|
|
}, nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
// check values
|
|
|
Expect(string(secret.Data["foo"])).To(Equal(FooValue))
|
|
|
Expect(string(secret.Data["bar"])).To(Equal(BarValue))
|
|
|
@@ -1826,7 +1826,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
"tls.crt": []byte(FooValue),
|
|
|
"tls.key": []byte(BarValue),
|
|
|
}, nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(secret.Type).To(Equal(v1.SecretTypeTLS))
|
|
|
// check values
|
|
|
Expect(string(secret.Data["tls.crt"])).To(Equal(FooValue))
|
|
|
@@ -1885,7 +1885,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
|
return true
|
|
|
}
|
|
|
- tc.checkExternalSecret = func(es *esv1.ExternalSecret) {
|
|
|
+ tc.checkExternalSecret = func(_ *esv1.ExternalSecret) {
|
|
|
Eventually(func() bool {
|
|
|
Expect(testSyncCallsError.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
|
|
|
Expect(testExternalSecretReconcileDuration.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metricDuration)).To(Succeed())
|
|
|
@@ -1911,7 +1911,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
|
return true
|
|
|
}
|
|
|
- tc.checkExternalSecret = func(es *esv1.ExternalSecret) {
|
|
|
+ tc.checkExternalSecret = func(_ *esv1.ExternalSecret) {
|
|
|
Eventually(func() bool {
|
|
|
Expect(testSyncCallsError.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metric)).To(Succeed())
|
|
|
Expect(testExternalSecretReconcileDuration.WithLabelValues(ExternalSecretName, ExternalSecretNamespace).Write(&metricDuration)).To(Succeed())
|
|
|
@@ -1930,7 +1930,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
cond := GetExternalSecretCondition(es.Status, esv1.ExternalSecretReady)
|
|
|
return cond == nil
|
|
|
}
|
|
|
- tc.checkExternalSecret = func(es *esv1.ExternalSecret) {
|
|
|
+ tc.checkExternalSecret = func(_ *esv1.ExternalSecret) {
|
|
|
// Condition True and False should be 0, since the Condition was not created
|
|
|
Eventually(func() float64 {
|
|
|
Expect(testExternalSecretCondition.WithLabelValues(ExternalSecretName, ExternalSecretNamespace, string(esv1.ExternalSecretReady), string(v1.ConditionTrue)).Write(&metric)).To(Succeed())
|
|
|
@@ -1969,7 +1969,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
const secretVal = "someValue"
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
tc.externalSecret.Spec.RefreshInterval = &metav1.Duration{Duration: time.Minute * 10}
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
|
|
|
// check values
|
|
|
oldUID := secret.UID
|
|
|
@@ -1998,8 +1998,8 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
checkSecretDataHashAnnotation := func(tc *testCase) {
|
|
|
const secretVal = "someValue"
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
- expectedHash := utils.ObjectHash(map[string][]byte{
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ expectedHash := esutils.ObjectHash(map[string][]byte{
|
|
|
targetProp: []byte(secretVal),
|
|
|
})
|
|
|
Expect(secret.Annotations[esv1.AnnotationDataHash]).To(Equal(expectedHash))
|
|
|
@@ -2023,8 +2023,8 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}, client.FieldOwner(FakeManager))).To(Succeed())
|
|
|
|
|
|
fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
- expectedHash := utils.ObjectHash(map[string][]byte{
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ expectedHash := esutils.ObjectHash(map[string][]byte{
|
|
|
existingKey: []byte(existingVal),
|
|
|
targetProp: []byte(secretVal),
|
|
|
})
|
|
|
@@ -2039,7 +2039,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
|
fakeProvider.WithGetSecretMap(fakeData, nil)
|
|
|
tc.externalSecret.Spec.RefreshInterval = &metav1.Duration{Duration: time.Minute * 10}
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
oldHash := secret.Annotations[esv1.AnnotationDataHash]
|
|
|
oldResourceVersion := secret.ResourceVersion
|
|
|
Expect(oldHash).NotTo(BeEmpty())
|
|
|
@@ -2094,9 +2094,9 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
if err != nil {
|
|
|
return false
|
|
|
}
|
|
|
- _, ok := refreshedSecret.Data["key"]
|
|
|
- return !ok && bytes.Equal(refreshedSecret.Data["new"], []byte("foo"))
|
|
|
- }, timeout, interval).Should(BeTrue())
|
|
|
+ // ensure new data value exist
|
|
|
+ return string(refreshedSecret.Data["new"]) == "foo"
|
|
|
+ }, time.Second*10, time.Millisecond*200).Should(BeTrue())
|
|
|
}
|
|
|
}
|
|
|
// When we update the template, remaining keys should not be preserved
|
|
|
@@ -2110,7 +2110,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
"key": `{{.targetProperty}}-foo`,
|
|
|
},
|
|
|
}
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(secret.Data["key"]).To(Equal([]byte("someValue-foo")))
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
}
|
|
|
@@ -2134,7 +2134,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
|
|
|
// Secret is created when ClusterSecretStore has no conditions
|
|
|
noConditionsSecretCreated := func(tc *testCase) {
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
}
|
|
|
}
|
|
|
@@ -2201,7 +2201,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
}
|
|
|
}
|
|
|
@@ -2213,7 +2213,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
}
|
|
|
}
|
|
|
@@ -2243,7 +2243,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
}
|
|
|
}
|
|
|
@@ -2276,7 +2276,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
}
|
|
|
}
|
|
|
@@ -2292,7 +2292,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
- tc.checkSecret = func(es *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
+ tc.checkSecret = func(_ *esv1.ExternalSecret, secret *v1.Secret) {
|
|
|
Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
}
|
|
|
}
|
|
|
@@ -2453,7 +2453,7 @@ var _ = Describe("ExternalSecret refresh logic", func() {
|
|
|
RefreshTime: metav1.Now(),
|
|
|
},
|
|
|
}
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
// this should not refresh, rv matches object
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
|
|
|
@@ -2477,7 +2477,7 @@ var _ = Describe("ExternalSecret refresh logic", func() {
|
|
|
RefreshTime: metav1.Now(),
|
|
|
},
|
|
|
}
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
// this should not refresh, rv matches object
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
|
|
|
@@ -2498,7 +2498,7 @@ var _ = Describe("ExternalSecret refresh logic", func() {
|
|
|
RefreshTime: metav1.Now(),
|
|
|
},
|
|
|
}
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
|
|
|
// update gen -> refresh
|
|
|
@@ -2517,7 +2517,7 @@ var _ = Describe("ExternalSecret refresh logic", func() {
|
|
|
Status: esv1.ExternalSecretStatus{},
|
|
|
}
|
|
|
// resource version matches
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
})
|
|
|
|
|
|
@@ -2534,7 +2534,7 @@ var _ = Describe("ExternalSecret refresh logic", func() {
|
|
|
},
|
|
|
}
|
|
|
// resource version matches
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeTrue())
|
|
|
})
|
|
|
|
|
|
@@ -2549,20 +2549,20 @@ var _ = Describe("ExternalSecret refresh logic", func() {
|
|
|
Status: esv1.ExternalSecretStatus{},
|
|
|
}
|
|
|
// resource version matches
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeTrue())
|
|
|
})
|
|
|
|
|
|
})
|
|
|
Context("objectmeta hash", func() {
|
|
|
It("should produce different hashes for different k/v pairs", func() {
|
|
|
- h1 := util.HashMeta(metav1.ObjectMeta{
|
|
|
+ h1 := ctrlutil.HashMeta(metav1.ObjectMeta{
|
|
|
Generation: 1,
|
|
|
Annotations: map[string]string{
|
|
|
"foo": "bar",
|
|
|
},
|
|
|
})
|
|
|
- h2 := util.HashMeta(metav1.ObjectMeta{
|
|
|
+ h2 := ctrlutil.HashMeta(metav1.ObjectMeta{
|
|
|
Generation: 1,
|
|
|
Annotations: map[string]string{
|
|
|
"foo": "bing",
|
|
|
@@ -2572,7 +2572,7 @@ var _ = Describe("ExternalSecret refresh logic", func() {
|
|
|
})
|
|
|
|
|
|
It("should produce different hashes for different generations but same label/annotations", func() {
|
|
|
- h1 := util.HashMeta(metav1.ObjectMeta{
|
|
|
+ h1 := ctrlutil.HashMeta(metav1.ObjectMeta{
|
|
|
Generation: 1,
|
|
|
Annotations: map[string]string{
|
|
|
"foo": "bar",
|
|
|
@@ -2581,7 +2581,7 @@ var _ = Describe("ExternalSecret refresh logic", func() {
|
|
|
"foo": "bar",
|
|
|
},
|
|
|
})
|
|
|
- h2 := util.HashMeta(metav1.ObjectMeta{
|
|
|
+ h2 := ctrlutil.HashMeta(metav1.ObjectMeta{
|
|
|
Generation: 2,
|
|
|
Annotations: map[string]string{
|
|
|
"foo": "bar",
|
|
|
@@ -2594,21 +2594,21 @@ var _ = Describe("ExternalSecret refresh logic", func() {
|
|
|
})
|
|
|
|
|
|
It("should produce the same hash for the same k/v pairs", func() {
|
|
|
- h1 := util.HashMeta(metav1.ObjectMeta{
|
|
|
+ h1 := ctrlutil.HashMeta(metav1.ObjectMeta{
|
|
|
Generation: 1,
|
|
|
})
|
|
|
- h2 := util.HashMeta(metav1.ObjectMeta{
|
|
|
+ h2 := ctrlutil.HashMeta(metav1.ObjectMeta{
|
|
|
Generation: 1,
|
|
|
})
|
|
|
Expect(h1).To(Equal(h2))
|
|
|
|
|
|
- h1 = util.HashMeta(metav1.ObjectMeta{
|
|
|
+ h1 = ctrlutil.HashMeta(metav1.ObjectMeta{
|
|
|
Generation: 1,
|
|
|
Annotations: map[string]string{
|
|
|
"foo": "bar",
|
|
|
},
|
|
|
})
|
|
|
- h2 = util.HashMeta(metav1.ObjectMeta{
|
|
|
+ h2 = ctrlutil.HashMeta(metav1.ObjectMeta{
|
|
|
Generation: 1,
|
|
|
Annotations: map[string]string{
|
|
|
"foo": "bar",
|
|
|
@@ -2718,7 +2718,7 @@ var _ = Describe("ExternalSecret refresh policy", func() {
|
|
|
},
|
|
|
}
|
|
|
// Set the synced resource version to match the current resource version
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
})
|
|
|
|
|
|
@@ -2738,7 +2738,7 @@ var _ = Describe("ExternalSecret refresh policy", func() {
|
|
|
},
|
|
|
}
|
|
|
// Set the synced resource version to match the current resource version
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
|
|
|
es.Annotations["foo"] = "bar1"
|
|
|
@@ -2766,7 +2766,7 @@ var _ = Describe("ExternalSecret refresh policy", func() {
|
|
|
},
|
|
|
}
|
|
|
// Set the synced resource version to match the current resource version
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
|
|
|
// Initially should not refresh
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
@@ -2799,7 +2799,7 @@ var _ = Describe("ExternalSecret refresh policy", func() {
|
|
|
RefreshTime: metav1.Now(),
|
|
|
},
|
|
|
}
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
|
|
|
// When refresh interval has passed
|
|
|
@@ -2823,7 +2823,7 @@ var _ = Describe("ExternalSecret refresh policy", func() {
|
|
|
},
|
|
|
}
|
|
|
// Set the synced resource version to match the current resource version
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
})
|
|
|
|
|
|
@@ -2858,7 +2858,7 @@ var _ = Describe("ExternalSecret refresh policy", func() {
|
|
|
},
|
|
|
}
|
|
|
// Resource version matches
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeTrue())
|
|
|
})
|
|
|
|
|
|
@@ -2874,7 +2874,7 @@ var _ = Describe("ExternalSecret refresh policy", func() {
|
|
|
Status: esv1.ExternalSecretStatus{},
|
|
|
}
|
|
|
// Resource version matches
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeTrue())
|
|
|
})
|
|
|
|
|
|
@@ -2892,7 +2892,7 @@ var _ = Describe("ExternalSecret refresh policy", func() {
|
|
|
},
|
|
|
}
|
|
|
// Resource version matches
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeTrue())
|
|
|
})
|
|
|
|
|
|
@@ -2918,9 +2918,10 @@ var _ = Describe("ExternalSecret refresh policy", func() {
|
|
|
RefreshTime: metav1.NewTime(metav1.Now().Add(-time.Second * 5)),
|
|
|
},
|
|
|
}
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
|
|
|
+ // Update the spec by adding a new data item
|
|
|
es.ObjectMeta.Generation = 2
|
|
|
es.Spec.Data = append(es.Spec.Data, esv1.ExternalSecretData{
|
|
|
SecretKey: "key2",
|
|
|
@@ -2955,7 +2956,7 @@ var _ = Describe("ExternalSecret refresh policy", func() {
|
|
|
},
|
|
|
}
|
|
|
// Set the synced resource version to match the current resource version
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
|
|
|
// Update the spec by adding a new data item
|
|
|
@@ -2992,7 +2993,7 @@ var _ = Describe("ExternalSecret refresh policy", func() {
|
|
|
},
|
|
|
}
|
|
|
// Set the synced resource version to match the current resource version
|
|
|
- es.Status.SyncedResourceVersion = util.GetResourceVersion(es.ObjectMeta)
|
|
|
+ es.Status.SyncedResourceVersion = ctrlutil.GetResourceVersion(es.ObjectMeta)
|
|
|
Expect(shouldRefresh(es)).To(BeFalse())
|
|
|
|
|
|
// Update labels and annotations
|