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
```
pull/6/head
Kubernetes Submit Queue 2017-09-27 12:58:25 -07:00 committed by GitHub
commit b80b7b08c9
1 changed files with 2 additions and 1 deletions

View File

@ -68,7 +68,8 @@ func BuildClusterConfig(c *federation_v1beta1.Cluster) (*restclient.Config, erro
if c.Spec.SecretRef.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 {
return nil, err
}