mirror of https://github.com/k3s-io/k3s
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
commit
a1e786f138
|
@ -241,10 +241,7 @@ func PerformStaticPodUpgrade(client clientset.Interface, waiter apiclient.Waiter
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := upgrade.StaticPodControlPlane(waiter, pathManager, internalcfg); err != nil {
|
return upgrade.StaticPodControlPlane(waiter, pathManager, internalcfg)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DryRunStaticPodUpgrade fakes an upgrade of the control plane
|
// 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))
|
files = append(files, dryrunutil.NewFileToPrint(realPath, outputPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := dryrunutil.PrintDryRunFiles(files, os.Stdout); err != nil {
|
return dryrunutil.PrintDryRunFiles(files, os.Stdout)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,10 +99,7 @@ func CreateServiceAccount(client clientset.Interface) error {
|
||||||
|
|
||||||
// CreateRBACRules creates the essential RBAC rules for a minimally set-up cluster
|
// CreateRBACRules creates the essential RBAC rules for a minimally set-up cluster
|
||||||
func CreateRBACRules(client clientset.Interface) error {
|
func CreateRBACRules(client clientset.Interface) error {
|
||||||
if err := createClusterRoleBindings(client); err != nil {
|
return createClusterRoleBindings(client)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createKubeProxyAddon(configMapBytes, daemonSetbytes []byte, client clientset.Interface) error {
|
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
|
// Create the DaemonSet for kube-proxy or update it in case it already exists
|
||||||
if err := apiclient.CreateOrUpdateDaemonSet(client, kubeproxyDaemonSet); err != nil {
|
return apiclient.CreateOrUpdateDaemonSet(client, kubeproxyDaemonSet)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createClusterRoleBindings(client clientset.Interface) error {
|
func createClusterRoleBindings(client clientset.Interface) error {
|
||||||
|
|
|
@ -76,11 +76,7 @@ func WriteCertAndKey(pkiPath string, name string, cert *x509.Certificate, key *r
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := WriteCert(pkiPath, name, cert); err != nil {
|
return WriteCert(pkiPath, name, cert)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteCert stores the given certificate at the given location
|
// 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 {
|
if err := utilfiles.EnsureFile(s.fs, filepath.Join(s.checkpointsDir, curFile)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := utilfiles.EnsureFile(s.fs, filepath.Join(s.checkpointsDir, lkgFile)); err != nil {
|
return utilfiles.EnsureFile(s.fs, filepath.Join(s.checkpointsDir, lkgFile))
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *fsStore) Exists(uid string) (bool, error) {
|
func (s *fsStore) Exists(uid string) (bool, error) {
|
||||||
|
@ -77,10 +74,7 @@ func (s *fsStore) Save(c checkpoint.Checkpoint) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// save the file
|
// save the file
|
||||||
if err := utilfiles.ReplaceFile(s.fs, filepath.Join(s.checkpointsDir, c.UID()), data); err != nil {
|
return utilfiles.ReplaceFile(s.fs, filepath.Join(s.checkpointsDir, c.UID()), data)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *fsStore) Load(uid string) (checkpoint.Checkpoint, error) {
|
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 {
|
if err := utilfiles.EnsureDir(fs, filepath.Dir(path)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := utilfiles.ReplaceFile(fs, path, []byte(file)); err != nil {
|
return utilfiles.ReplaceFile(fs, path, []byte(file))
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoad(t *testing.T) {
|
func TestLoad(t *testing.T) {
|
||||||
|
|
|
@ -248,10 +248,7 @@ func (cc *Controller) StartSync(client clientset.Interface, nodeName string) {
|
||||||
func (cc *Controller) initialize() error {
|
func (cc *Controller) initialize() error {
|
||||||
utillog.Infof("ensuring filesystem is set up correctly")
|
utillog.Infof("ensuring filesystem is set up correctly")
|
||||||
// initialize local checkpoint storage location
|
// initialize local checkpoint storage location
|
||||||
if err := cc.checkpointStore.Initialize(); err != nil {
|
return cc.checkpointStore.Initialize()
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// localConfig returns the initConfig if it is loaded, otherwise returns the defaultConfig.
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
// rename over existing file
|
// rename over existing file
|
||||||
if err := fs.Rename(tmpPath, path); err != nil {
|
return fs.Rename(tmpPath, path)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DirExists returns true if a directory exists at `path`, false if `path` does not exist, otherwise an error
|
// 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
|
} // Assert: dir does not exist
|
||||||
|
|
||||||
// create the dir
|
// create the dir
|
||||||
if err := fs.MkdirAll(path, defaultPerm); err != nil {
|
return fs.MkdirAll(path, defaultPerm)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,10 +66,7 @@ func WriteCert(certPath string, data []byte) error {
|
||||||
if err := os.MkdirAll(filepath.Dir(certPath), os.FileMode(0755)); err != nil {
|
if err := os.MkdirAll(filepath.Dir(certPath), os.FileMode(0755)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(certPath, data, os.FileMode(0644)); err != nil {
|
return ioutil.WriteFile(certPath, data, os.FileMode(0644))
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteKey writes the pem-encoded key data to keyPath.
|
// 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 {
|
if err := os.MkdirAll(filepath.Dir(keyPath), os.FileMode(0755)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := ioutil.WriteFile(keyPath, data, os.FileMode(0600)); err != nil {
|
return ioutil.WriteFile(keyPath, data, os.FileMode(0600))
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadOrGenerateKeyFile looks for a key in the file at the given path. If it
|
// LoadOrGenerateKeyFile looks for a key in the file at the given path. If it
|
||||||
|
|
Loading…
Reference in New Issue