Commit b80b7b08 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #53075 from alrs/fix-federation-controller-swallowed-errors

Automatic merge from submit-queue (batch tested with PRs 52630, 53110, 53136, 53075). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. federation/pkg/federation-controller/util: fix swallowed errors **What this PR does / why we need it**: The re-declaration of `err` inside the `if` block causes it to be lost before the check on line 93, even though it is reassigned on lines 95 and 90. By declaring the secret variable on line 71 I was able to ditch the `:=` assignment on line 72, meaning we can keep the `err` variable previously defined before the block on line 47. ```release-note NONE ```
parents d44de7b7 097e0638
...@@ -68,7 +68,8 @@ func BuildClusterConfig(c *federation_v1beta1.Cluster) (*restclient.Config, erro ...@@ -68,7 +68,8 @@ func BuildClusterConfig(c *federation_v1beta1.Cluster) (*restclient.Config, erro
if c.Spec.SecretRef.Name == "" { if c.Spec.SecretRef.Name == "" {
return nil, fmt.Errorf("found secretRef but no secret name for cluster %s", c.Name) return nil, fmt.Errorf("found secretRef but no secret name for cluster %s", c.Name)
} }
secret, err := getSecret(c.Spec.SecretRef.Name) var secret *api.Secret
secret, err = getSecret(c.Spec.SecretRef.Name)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment