Persist OwnerReferences when 1Password item is updated

This commit is contained in:
Joris Coenen
2022-04-11 12:10:22 +02:00
parent 58b4ff8ecf
commit ea68cfc2b4
2 changed files with 4 additions and 4 deletions

View File

@@ -8,7 +8,7 @@
## Fixes
- A user-friendly description of a fix. {issue-number}
- OwnerReferences on secrets are now persisted after an item is updated. {#101}
## Security

View File

@@ -140,9 +140,9 @@ func (h *SecretUpdateHandler) updateKubernetesSecrets() (map[string]map[string]*
log.Info(fmt.Sprintf("Updating kubernetes secret '%v'", secret.GetName()))
secret.Annotations[VersionAnnotation] = itemVersion
secret.Annotations[ItemPathAnnotation] = itemPathString
updatedSecret := kubeSecrets.BuildKubernetesSecretFromOnePasswordItem(secret.Name, secret.Namespace, secret.Annotations, secret.Labels, string(secret.Type), *item, nil)
log.Info(fmt.Sprintf("New secret path: %v and version: %v", updatedSecret.Annotations[ItemPathAnnotation], updatedSecret.Annotations[VersionAnnotation]))
h.client.Update(context.Background(), updatedSecret)
secret.Data = kubeSecrets.BuildKubernetesSecretData(item.Fields, item.Files)
log.Info(fmt.Sprintf("New secret path: %v and version: %v", secret.Annotations[ItemPathAnnotation], secret.Annotations[VersionAnnotation]))
h.client.Update(context.Background(), &secret)
if updatedSecrets[secret.Namespace] == nil {
updatedSecrets[secret.Namespace] = make(map[string]*corev1.Secret)
}