Skip to content

Commit

Permalink
update upsert function
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Oct 2, 2024
1 parent bdc1d5f commit 8ec5af5
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions pkg/controller/stacks/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,17 @@ func (r *StackReconciler) hasRunSecretData(data map[string][]byte, runID string)

func (r *StackReconciler) upsertRunSecret(ctx context.Context, name, namespace, runID string) (*corev1.Secret, error) {
logger := log.FromContext(ctx)
secret := &corev1.Secret{}

secret := &corev1.Secret{}
if err := r.k8sClient.Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, secret); err != nil {
if !apierrs.IsNotFound(err) {
return nil, err
}

logger.V(2).Info("generating run job secret", "namespace", namespace, "name", name)
secret = &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: namespace},
StringData: r.getRunSecretData(runID),
}

logger.V(2).Info("creating secret", "namespace", secret.Namespace, "name", secret.Name)
if err := r.k8sClient.Create(ctx, secret); err != nil {
logger.Error(err, "unable to create secret")
Expand Down

0 comments on commit 8ec5af5

Please sign in to comment.