Skip to content

Commit

Permalink
Fix linter findings
Browse files Browse the repository at this point in the history
  • Loading branch information
dimityrmirchev committed Jan 15, 2025
1 parent c70d894 commit b616ceb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions pkg/webhook/cloudprovider/ensurer.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ type ensurer struct {

// EnsureCloudProviderSecret ensures that cloudprovider secret
// contains the proper credential source.
func (e *ensurer) EnsureCloudProviderSecret(_ context.Context, _ gcontext.GardenContext, new, _ *corev1.Secret) error {
if new.ObjectMeta.Labels == nil || new.ObjectMeta.Labels[securityv1alpha1constants.LabelWorkloadIdentityProvider] != "gcp" {
func (e *ensurer) EnsureCloudProviderSecret(_ context.Context, _ gcontext.GardenContext, newSecret, _ *corev1.Secret) error {
if newSecret.ObjectMeta.Labels == nil || newSecret.ObjectMeta.Labels[securityv1alpha1constants.LabelWorkloadIdentityProvider] != "gcp" {
return nil
}

if _, ok := new.Data[securityv1alpha1constants.DataKeyConfig]; !ok {
if _, ok := newSecret.Data[securityv1alpha1constants.DataKeyConfig]; !ok {
return errors.New("cloudprovider secret is missing a 'config' data key")
}
workloadIdentityConfig := &apisgcp.WorkloadIdentityConfig{}
if err := util.Decode(e.decoder, new.Data[securityv1alpha1constants.DataKeyConfig], workloadIdentityConfig); err != nil {
if err := util.Decode(e.decoder, newSecret.Data[securityv1alpha1constants.DataKeyConfig], workloadIdentityConfig); err != nil {
return fmt.Errorf("could not decode 'config' as WorkloadIdentityConfig: %w", err)
}

Expand All @@ -83,8 +83,8 @@ func (e *ensurer) EnsureCloudProviderSecret(_ context.Context, _ gcontext.Garden
if err != nil {
return fmt.Errorf("could not marshal new config: %w", err)
}
new.Data["credentialsConfig"] = newConfig
new.Data["projectID"] = []byte(workloadIdentityConfig.ProjectID)
newSecret.Data["credentialsConfig"] = newConfig
newSecret.Data["projectID"] = []byte(workloadIdentityConfig.ProjectID)

return nil
}
6 changes: 3 additions & 3 deletions pkg/webhook/terraformer/mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ func New(c client.Client, logger logr.Logger) extensionswebhook.Mutator {
}

// Mutate mutates the pod attaches the workload identity token to it.
func (m *mutator) Mutate(ctx context.Context, new, old client.Object) error {
if old != nil || new.GetDeletionTimestamp() != nil {
func (m *mutator) Mutate(ctx context.Context, newObj, oldObj client.Object) error {
if oldObj != nil || newObj.GetDeletionTimestamp() != nil {
return nil
}

pod, ok := new.(*corev1.Pod)
pod, ok := newObj.(*corev1.Pod)
if !ok {
return errors.New("object is not of type corev1.Pod")
}
Expand Down

0 comments on commit b616ceb

Please sign in to comment.