Skip to content

Commit

Permalink
Merge pull request #911 from equinor/68-reader-role
Browse files Browse the repository at this point in the history
68 reader role
  • Loading branch information
magnus-longva-bouvet authored Aug 23, 2023
2 parents db88651 + b91b49f commit b565437
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions charts/radix-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: radix-operator
version: 1.20.7
appVersion: 1.40.7
version: 1.20.8
appVersion: 1.40.8
kubeVersion: ">=1.24.0"
description: Radix Operator
keywords:
Expand Down
10 changes: 5 additions & 5 deletions pkg/apis/kube/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ func (kubeutil *Kube) ApplySecret(namespace string, secret *corev1.Secret) (save
savedSecret, err := kubeutil.kubeClient.CoreV1().Secrets(namespace).Create(context.TODO(), secret, metav1.CreateOptions{})
return savedSecret, err
} else if err != nil {
return nil, fmt.Errorf("failed to get Secret object: %v", err)
return nil, fmt.Errorf("failed to get Secret object: %w", err)
}

oldSecretJSON, err := json.Marshal(oldSecret)
if err != nil {
return nil, fmt.Errorf("failed to marshal old secret object: %v", err)
return nil, fmt.Errorf("failed to marshal old secret object: %w", err)
}

// Avoid unnecessary patching
Expand All @@ -71,19 +71,19 @@ func (kubeutil *Kube) ApplySecret(namespace string, secret *corev1.Secret) (save

newSecretJSON, err := json.Marshal(newSecret)
if err != nil {
return nil, fmt.Errorf("failed to marshal new secret object: %v", err)
return nil, fmt.Errorf("failed to marshal new secret object: %w", err)
}

patchBytes, err := strategicpatch.CreateTwoWayMergePatch(oldSecretJSON, newSecretJSON, corev1.Secret{})
if err != nil {
return nil, fmt.Errorf("failed to create two way merge patch secret objects: %v", err)
return nil, fmt.Errorf("failed to create two way merge patch secret objects: %w", err)
}

if !IsEmptyPatch(patchBytes) {
// Will perform update as patching not properly remove secret data entries
patchedSecret, err := kubeutil.kubeClient.CoreV1().Secrets(namespace).Update(context.TODO(), newSecret, metav1.UpdateOptions{})
if err != nil {
return nil, fmt.Errorf("failed to update secret object: %v", err)
return nil, fmt.Errorf("failed to update secret object: %w", err)
}

log.Debugf("Updated secret: %s ", patchedSecret.Name)
Expand Down

0 comments on commit b565437

Please sign in to comment.