-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: address some golangci-lint issues #751
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for this awesome PR removing tech debt! Please check my comments when you have a chance.
func (c *Controller) updateSecret(ctx context.Context, newSecret *corev1.Secret) (*corev1.Secret, error) { | ||
existingSecret, err := c.sclient.Secrets(newSecret.GetObjectMeta().GetNamespace()).Get(ctx, newSecret.GetObjectMeta().GetName(), metav1.GetOptions{}) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to read existing secret: %s", err) | ||
} | ||
existingSecret = existingSecret.DeepCopy() | ||
existingSecret.Data = newSecret.Data | ||
|
||
c.updateOwnerReferences(existingSecret, newSecret) | ||
|
||
return existingSecret, nil | ||
} | ||
|
||
func (c *Controller) updateOwnerReferences(existing, new *corev1.Secret) { | ||
ownerRefs := existing.GetOwnerReferences() | ||
|
||
for _, newRef := range new.GetOwnerReferences() { | ||
found := false | ||
for _, ref := range ownerRefs { | ||
if newRef.UID == ref.UID { | ||
found = true | ||
break | ||
} | ||
} | ||
if !found { | ||
ownerRefs = append(ownerRefs, newRef) | ||
} | ||
} | ||
existing.SetOwnerReferences(ownerRefs) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkmik do you know why is this unused? Tech debt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a leftover from some refactoring, possibly when the k8s client API got updated.
it's dead code, let's remove it
…pkg/apis/sealed-secrets/v1alpha1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description of the change
Benefits
Possible drawbacks
Applicable issues
Additional information