mirror of https://github.com/k3s-io/k3s
Fix lint warnings for useless err checks.
This check was recently added to golint.pull/6/head
parent
1d8f1e268f
commit
49553d4a7a
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue