Merge pull request #54059 from porridge/fix-lint-err

Automatic merge from submit-queue (batch tested with PRs 53696, 54059). 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>.

Fix lint warnings for useless err checks.

**What this PR does / why we need it**:

This check was recently added to golint.

**Which issue this PR fixes**

Related to #37254

**Release note**:
```release-note
NONE
```
pull/6/head
Kubernetes Submit Queue 2017-10-18 00:58:59 -07:00 committed by GitHub
commit a1e786f138
8 changed files with 13 additions and 53 deletions

View File

@ -241,10 +241,7 @@ func PerformStaticPodUpgrade(client clientset.Interface, waiter apiclient.Waiter
return err
}
if err := upgrade.StaticPodControlPlane(waiter, pathManager, internalcfg); err != nil {
return err
}
return nil
return upgrade.StaticPodControlPlane(waiter, pathManager, internalcfg)
}
// DryRunStaticPodUpgrade fakes an upgrade of the control plane
@ -268,8 +265,5 @@ func DryRunStaticPodUpgrade(internalcfg *kubeadmapi.MasterConfiguration) error {
files = append(files, dryrunutil.NewFileToPrint(realPath, outputPath))
}
if err := dryrunutil.PrintDryRunFiles(files, os.Stdout); err != nil {
return err
}
return nil
return dryrunutil.PrintDryRunFiles(files, os.Stdout)
}

View File

@ -99,10 +99,7 @@ func CreateServiceAccount(client clientset.Interface) error {
// CreateRBACRules creates the essential RBAC rules for a minimally set-up cluster
func CreateRBACRules(client clientset.Interface) error {
if err := createClusterRoleBindings(client); err != nil {
return err
}
return nil
return createClusterRoleBindings(client)
}
func createKubeProxyAddon(configMapBytes, daemonSetbytes []byte, client clientset.Interface) error {
@ -122,10 +119,7 @@ func createKubeProxyAddon(configMapBytes, daemonSetbytes []byte, client clientse
}
// Create the DaemonSet for kube-proxy or update it in case it already exists
if err := apiclient.CreateOrUpdateDaemonSet(client, kubeproxyDaemonSet); err != nil {
return err
}
return nil
return apiclient.CreateOrUpdateDaemonSet(client, kubeproxyDaemonSet)
}
func createClusterRoleBindings(client clientset.Interface) error {

View File

@ -76,11 +76,7 @@ func WriteCertAndKey(pkiPath string, name string, cert *x509.Certificate, key *r
return err
}
if err := WriteCert(pkiPath, name, cert); err != nil {
return err
}
return nil
return WriteCert(pkiPath, name, cert)
}
// WriteCert stores the given certificate at the given location

View File

@ -56,10 +56,7 @@ func (s *fsStore) Initialize() error {
if err := utilfiles.EnsureFile(s.fs, filepath.Join(s.checkpointsDir, curFile)); err != nil {
return err
}
if err := utilfiles.EnsureFile(s.fs, filepath.Join(s.checkpointsDir, lkgFile)); err != nil {
return err
}
return nil
return utilfiles.EnsureFile(s.fs, filepath.Join(s.checkpointsDir, lkgFile))
}
func (s *fsStore) Exists(uid string) (bool, error) {
@ -77,10 +74,7 @@ func (s *fsStore) Save(c checkpoint.Checkpoint) error {
return err
}
// save the file
if err := utilfiles.ReplaceFile(s.fs, filepath.Join(s.checkpointsDir, c.UID()), data); err != nil {
return err
}
return nil
return utilfiles.ReplaceFile(s.fs, filepath.Join(s.checkpointsDir, c.UID()), data)
}
func (s *fsStore) Load(uid string) (checkpoint.Checkpoint, error) {

View File

@ -37,10 +37,7 @@ func addFile(fs utilfs.Filesystem, path string, file string) error {
if err := utilfiles.EnsureDir(fs, filepath.Dir(path)); err != nil {
return err
}
if err := utilfiles.ReplaceFile(fs, path, []byte(file)); err != nil {
return err
}
return nil
return utilfiles.ReplaceFile(fs, path, []byte(file))
}
func TestLoad(t *testing.T) {

View File

@ -248,10 +248,7 @@ func (cc *Controller) StartSync(client clientset.Interface, nodeName string) {
func (cc *Controller) initialize() error {
utillog.Infof("ensuring filesystem is set up correctly")
// initialize local checkpoint storage location
if err := cc.checkpointStore.Initialize(); err != nil {
return err
}
return nil
return cc.checkpointStore.Initialize()
}
// localConfig returns the initConfig if it is loaded, otherwise returns the defaultConfig.

View File

@ -109,10 +109,7 @@ func ReplaceFile(fs utilfs.Filesystem, path string, data []byte) error {
return err
}
// rename over existing file
if err := fs.Rename(tmpPath, path); err != nil {
return err
}
return nil
return fs.Rename(tmpPath, path)
}
// DirExists returns true if a directory exists at `path`, false if `path` does not exist, otherwise an error
@ -138,8 +135,5 @@ func EnsureDir(fs utilfs.Filesystem, path string) error {
} // Assert: dir does not exist
// create the dir
if err := fs.MkdirAll(path, defaultPerm); err != nil {
return err
}
return nil
return fs.MkdirAll(path, defaultPerm)
}

View File

@ -66,10 +66,7 @@ func WriteCert(certPath string, data []byte) error {
if err := os.MkdirAll(filepath.Dir(certPath), os.FileMode(0755)); err != nil {
return err
}
if err := ioutil.WriteFile(certPath, data, os.FileMode(0644)); err != nil {
return err
}
return nil
return ioutil.WriteFile(certPath, data, os.FileMode(0644))
}
// WriteKey writes the pem-encoded key data to keyPath.
@ -80,10 +77,7 @@ func WriteKey(keyPath string, data []byte) error {
if err := os.MkdirAll(filepath.Dir(keyPath), os.FileMode(0755)); err != nil {
return err
}
if err := ioutil.WriteFile(keyPath, data, os.FileMode(0600)); err != nil {
return err
}
return nil
return ioutil.WriteFile(keyPath, data, os.FileMode(0600))
}
// LoadOrGenerateKeyFile looks for a key in the file at the given path. If it