|
@@ -50,7 +50,7 @@ var (
|
|
|
fakeProvider *fake.Client
|
|
fakeProvider *fake.Client
|
|
|
metric dto.Metric
|
|
metric dto.Metric
|
|
|
metricDuration dto.Metric
|
|
metricDuration dto.Metric
|
|
|
- timeout = time.Second * 10
|
|
|
|
|
|
|
+ timeout = time.Second * 20
|
|
|
interval = time.Millisecond * 250
|
|
interval = time.Millisecond * 250
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -468,6 +468,39 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ mergeWithSecretUpdate := func(tc *testCase) {
|
|
|
|
|
+ const secretVal = "someValue"
|
|
|
|
|
+ tc.externalSecret.Spec.Target.CreationPolicy = esv1beta1.CreatePolicyMerge
|
|
|
|
|
+ tc.externalSecret.Spec.RefreshInterval = &metav1.Duration{Duration: time.Hour}
|
|
|
|
|
+
|
|
|
|
|
+ Expect(k8sClient.Create(context.Background(), &v1.Secret{
|
|
|
|
|
+ ObjectMeta: metav1.ObjectMeta{
|
|
|
|
|
+ Name: ExternalSecretTargetSecretName,
|
|
|
|
|
+ Namespace: ExternalSecretNamespace,
|
|
|
|
|
+ },
|
|
|
|
|
+ Data: map[string][]byte{
|
|
|
|
|
+ existingKey: []byte(existingVal),
|
|
|
|
|
+ },
|
|
|
|
|
+ }, client.FieldOwner(FakeManager))).To(Succeed())
|
|
|
|
|
+
|
|
|
|
|
+ fakeProvider.WithGetSecret([]byte(secretVal), nil)
|
|
|
|
|
+ tc.checkSecret = func(es *esv1beta1.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{
|
|
|
|
|
+ Name: ExternalSecretTargetSecretName,
|
|
|
|
|
+ Namespace: ExternalSecretNamespace,
|
|
|
|
|
+ },
|
|
|
|
|
+ Data: map[string][]byte{
|
|
|
|
|
+ existingKey: []byte("differentValue"),
|
|
|
|
|
+ },
|
|
|
|
|
+ }, client.FieldOwner(FakeManager))).To(Succeed())
|
|
|
|
|
+
|
|
|
|
|
+ Expect(string(secret.Data[existingKey])).To(Equal(existingVal))
|
|
|
|
|
+ Expect(string(secret.Data[targetProp])).To(Equal(secretVal))
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// should not update if no changes
|
|
// should not update if no changes
|
|
|
mergeWithSecretNoChange := func(tc *testCase) {
|
|
mergeWithSecretNoChange := func(tc *testCase) {
|
|
|
tc.externalSecret.Spec.Target.CreationPolicy = esv1beta1.CreatePolicyMerge
|
|
tc.externalSecret.Spec.Target.CreationPolicy = esv1beta1.CreatePolicyMerge
|
|
@@ -2226,6 +2259,7 @@ var _ = Describe("ExternalSecret controller", Serial, func() {
|
|
|
Entry("should removed outdated labels and annotations", removeOutdatedLabelsAnnotations),
|
|
Entry("should removed outdated labels and annotations", removeOutdatedLabelsAnnotations),
|
|
|
Entry("should set prometheus counters", checkPrometheusCounters),
|
|
Entry("should set prometheus counters", checkPrometheusCounters),
|
|
|
Entry("should merge with existing secret using creationPolicy=Merge", mergeWithSecret),
|
|
Entry("should merge with existing secret using creationPolicy=Merge", mergeWithSecret),
|
|
|
|
|
+ Entry("should kick reconciliation when secret changes using creationPolicy=Merge", mergeWithSecretUpdate),
|
|
|
Entry("should error if secret doesn't exist when using creationPolicy=Merge", mergeWithSecretErr),
|
|
Entry("should error if secret doesn't exist when using creationPolicy=Merge", mergeWithSecretErr),
|
|
|
Entry("should not resolve conflicts with creationPolicy=Merge", mergeWithConflict),
|
|
Entry("should not resolve conflicts with creationPolicy=Merge", mergeWithConflict),
|
|
|
Entry("should not update unchanged secret using creationPolicy=Merge", mergeWithSecretNoChange),
|
|
Entry("should not update unchanged secret using creationPolicy=Merge", mergeWithSecretNoChange),
|