Merge pull request #112024 from cndoit18/remove-redundant-judgment

style: remove redundant judgment
This commit is contained in:
Kubernetes Prow Robot
2022-08-25 07:28:18 -07:00
committed by GitHub
26 changed files with 26 additions and 112 deletions

View File

@@ -240,11 +240,7 @@ func runPreflightChecks(client clientset.Interface, ignorePreflightErrors sets.S
if err != nil {
return err
}
err = upgrade.RunCoreDNSMigrationCheck(client, ignorePreflightErrors)
if err != nil {
return err
}
return nil
return upgrade.RunCoreDNSMigrationCheck(client, ignorePreflightErrors)
}
// getClient gets a real or fake client depending on whether the user is dry-running or not

View File

@@ -471,11 +471,7 @@ func createKeyAndCSR(kubeadmConfig *kubeadmapi.InitConfiguration, cert *KubeadmC
if err != nil {
return err
}
err = pkiutil.WriteCSR(certDir, name, csr)
if err != nil {
return err
}
return nil
return pkiutil.WriteCSR(certDir, name, csr)
}
// CreateDefaultKeysAndCSRFiles is used in ExternalCA mode to create key files

View File

@@ -486,10 +486,7 @@ func validateSignedCertWithCA(l certKeyLocation, caCert *x509.Certificate) error
func validatePrivatePublicKey(l certKeyLocation) error {
// Try to load key
_, _, err := pkiutil.TryLoadPrivatePublicKeyFromDisk(l.pkiDir, l.baseName)
if err != nil {
return errors.Wrapf(err, "failure loading key for %s", l.uxName)
}
return nil
return errors.Wrapf(err, "failure loading key for %s", l.uxName)
}
// validateCertificateWithConfig makes sure that a given certificate is valid at

View File

@@ -281,10 +281,7 @@ func createKubeConfigFileIfNotExists(outDir, filename string, config *clientcmda
}
fmt.Printf("[kubeconfig] Writing %q kubeconfig file\n", filename)
err = kubeconfigutil.WriteToDisk(kubeConfigFilePath, config)
if err != nil {
return errors.Wrapf(err, "failed to save kubeconfig file %q on disk", kubeConfigFilePath)
}
return nil
return errors.Wrapf(err, "failed to save kubeconfig file %q on disk", kubeConfigFilePath)
}
// kubeadm doesn't validate the existing kubeconfig file more than this (kubeadm trusts the client certs to be valid)
// Basically, if we find a kubeconfig file with the same path; the same CA cert and the same server URL;

View File

@@ -110,8 +110,5 @@ func checkMigration(client clientset.Interface) error {
currentInstalledCoreDNSversion = strings.TrimLeft(currentInstalledCoreDNSversion, "v")
_, err = migration.Migrate(currentInstalledCoreDNSversion, strings.TrimLeft(kubeadmconstants.CoreDNSVersion, "v"), corefile, false)
if err != nil {
return errors.Wrap(err, "CoreDNS will not be upgraded")
}
return nil
return errors.Wrap(err, "CoreDNS will not be upgraded")
}

View File

@@ -249,10 +249,7 @@ func (w *KubeWaiter) WaitForStaticPodHashChange(nodeName, component, previousHas
if lastErr != nil {
return lastErr
}
if err != nil {
return errors.Wrapf(err, "static Pod hash for component %s on Node %s did not change after %v", component, nodeName, w.timeout)
}
return nil
return errors.Wrapf(err, "static Pod hash for component %s on Node %s did not change after %v", component, nodeName, w.timeout)
}
// getStaticPodSingleHash computes hashes for a single Static Pod resource

View File

@@ -23,9 +23,5 @@ import (
// CopyDir copies the content of a folder
func CopyDir(src string, dst string) error {
cmd := exec.Command("cp", "-r", src, dst)
err := cmd.Run()
if err != nil {
return err
}
return nil
return cmd.Run()
}