Skip to content

Commit

Permalink
fix: make sure we only watch secret objects we're interested in that …
Browse files Browse the repository at this point in the history
…have the correct labels and add labels to said secrets (#48)

* fix: make sure we only watch secret objects we're interested in that have the correct labels and add labels to said secrets

* fix: check if the entire secret is different when deciding whether to update (from check if data has changed)
  • Loading branch information
givanov authored Feb 21, 2020
1 parent fb5f3f6 commit 6ad546f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions deploy/helm/credstash-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ spec:
args:
{{- if .Values.operatorInstance }}
- --selector-label={{ .Values.operatorInstance }}
{{- end }}
{{- if .Values.verboseLogging }}
- --zap-level 1
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
Expand Down
5 changes: 4 additions & 1 deletion deploy/helm/credstash-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ fullnameOverride: ""
namespaceToWatch:
# Specifies which operatorInstance to filter the CRDs - defaults to all CRDs.
# Use this if you wish to deploy multiple controllers, each using a different AWS config for example
operatorInstance:
operatorInstance:

# Specifies whether to turn on verbose logs
verboseLogging: false

awsCredentials:
create: false
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/credstashsecret/credstashsecret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
err = c.Watch(&source.Kind{Type: &corev1.Secret{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &credstashv1alpha1.CredstashSecret{},
})
}, pred)
if err != nil {
return err
}
Expand Down Expand Up @@ -197,7 +197,7 @@ func (r *ReconcileCredstashSecret) Reconcile(request reconcile.Request) (reconci
}

// Secret is out of date with credstash data
if !reflect.DeepEqual(secret.Data, found.Data) {
if !reflect.DeepEqual(secret, found) {
reqLogger.Info(
"Updating Secret because contents have changed",
"Secret.Namespace",
Expand Down Expand Up @@ -239,6 +239,7 @@ func (r *ReconcileCredstashSecret) secretForCR(cr *credstashv1alpha1.CredstashSe
ObjectMeta: metav1.ObjectMeta{
Name: secretName,
Namespace: cr.Namespace,
Labels: cr.GetLabels(),
},
Data: credstashSecretsValueMap,
}
Expand Down

0 comments on commit 6ad546f

Please sign in to comment.