mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
style: remove redundant judgment
Signed-off-by: cndoit18 <cndoit18@outlook.com>
This commit is contained in:
parent
26842bb0c8
commit
ec43037d0f
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
// validateCertificateWithConfig makes sure that a given certificate is valid at
|
||||
|
@ -281,11 +281,8 @@ 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
|
||||
}
|
||||
// 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;
|
||||
// kubeadm thinks those files are equal and doesn't bother writing a new 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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
// getStaticPodSingleHash computes hashes for a single Static Pod resource
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -87,11 +87,7 @@ func validateCSR(obj *certificates.CertificateSigningRequest) error {
|
||||
return err
|
||||
}
|
||||
// check that the signature is valid
|
||||
err = csr.CheckSignature()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return csr.CheckSignature()
|
||||
}
|
||||
|
||||
func validateCertificate(pemData []byte) error {
|
||||
|
@ -36,9 +36,5 @@ var SortingDeletionAgeRatio = metrics.NewHistogram(
|
||||
|
||||
// Register registers ReplicaSet controller metrics.
|
||||
func Register(registrationFunc func(metrics.Registerable) error) error {
|
||||
err := registrationFunc(SortingDeletionAgeRatio)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return registrationFunc(SortingDeletionAgeRatio)
|
||||
}
|
||||
|
@ -138,10 +138,7 @@ func (o *ConvertOptions) Complete(f cmdutil.Factory, cmd *cobra.Command) (err er
|
||||
|
||||
// build the printer
|
||||
o.Printer, err = o.PrintFlags.ToPrinter()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunConvert implements the generic Convert command
|
||||
|
@ -214,10 +214,7 @@ func (m *Stub) Register(kubeletEndpoint, resourceName string, pluginSockDir stri
|
||||
}
|
||||
|
||||
_, err = client.Register(context.Background(), reqt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetDevicePluginOptions returns DevicePluginOptions settings for the device plugin.
|
||||
|
6
pkg/kubelet/util/cache/object_cache.go
vendored
6
pkg/kubelet/util/cache/object_cache.go
vendored
@ -77,9 +77,5 @@ func (c *ObjectCache) Get(key string) (interface{}, error) {
|
||||
|
||||
// Add adds objectEntry by using a unique string as the key.
|
||||
func (c *ObjectCache) Add(key string, obj interface{}) error {
|
||||
err := c.cache.Add(objectEntry{key: key, obj: obj})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return c.cache.Add(objectEntry{key: key, obj: obj})
|
||||
}
|
||||
|
@ -524,11 +524,7 @@ func (ed *emptyDir) teardownDefault(dir string) error {
|
||||
}
|
||||
// Renaming the directory is not required anymore because the operation executor
|
||||
// now handles duplicate operations on the same volume
|
||||
err = os.RemoveAll(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
return os.RemoveAll(dir)
|
||||
}
|
||||
|
||||
func (ed *emptyDir) teardownTmpfsOrHugetlbfs(dir string) error {
|
||||
|
@ -63,10 +63,7 @@ func normalizeWebhookConfig(config *imagePolicyWebhookConfig) (err error) {
|
||||
return err
|
||||
}
|
||||
config.DenyTTL, err = normalizeConfigDuration("deny cache", time.Second, config.DenyTTL, minDenyTTL, maxDenyTTL, defaultDenyTTL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func normalizeConfigDuration(name string, scale, value, min, max, defaultValue time.Duration) (time.Duration, error) {
|
||||
|
@ -105,9 +105,5 @@ func (s *DryRunnableStorage) copyInto(in, out runtime.Object) error {
|
||||
return err
|
||||
}
|
||||
_, _, err = s.Codec.Decode(data, nil, out)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
@ -571,10 +571,7 @@ func LoadTLSFiles(c *Config) error {
|
||||
}
|
||||
|
||||
c.KeyData, err = dataFromSliceOrFile(c.KeyData, c.KeyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// dataFromSliceOrFile returns data from the slice (if non-empty), or from the file,
|
||||
|
@ -157,10 +157,7 @@ func loadTLSFiles(c *Config) error {
|
||||
}
|
||||
|
||||
c.TLS.KeyData, err = dataFromSliceOrFile(c.TLS.KeyData, c.TLS.KeyFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// dataFromSliceOrFile returns data from the slice (if non-empty), or from the file,
|
||||
|
@ -74,10 +74,7 @@ func (o *APIVersionsOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg
|
||||
}
|
||||
var err error
|
||||
o.discoveryClient, err = f.ToDiscoveryClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunAPIVersions does the work
|
||||
|
@ -211,10 +211,7 @@ func (o *CreateIngressOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, a
|
||||
}
|
||||
|
||||
o.ValidationDirective, err = cmdutil.GetValidationDirective(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Validate validates the Ingress object to be created
|
||||
|
@ -143,10 +143,7 @@ func (o *NamespaceOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
|
||||
}
|
||||
|
||||
o.ValidationDirective, err = cmdutil.GetValidationDirective(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Run calls the CreateSubcommandOptions.Run in NamespaceOpts instance
|
||||
|
@ -152,10 +152,7 @@ func (o *RoleBindingOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, arg
|
||||
}
|
||||
|
||||
o.ValidationDirective, err = cmdutil.GetValidationDirective(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Validate validates required fields are set
|
||||
|
@ -381,10 +381,7 @@ func (o *ExposeServiceOptions) RunExpose(cmd *cobra.Command, args []string) erro
|
||||
|
||||
return o.PrintObj(actualObject, o.Out)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *ExposeServiceOptions) createService() (*corev1.Service, error) {
|
||||
|
@ -199,10 +199,7 @@ func (o *SetResourcesOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, ar
|
||||
}
|
||||
|
||||
o.Infos, err = builder.Do().Infos()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Validate makes sure that provided values in ResourcesOptions are valid
|
||||
|
@ -174,10 +174,7 @@ func (o *SetServiceAccountOptions) Complete(f cmdutil.Factory, cmd *cobra.Comman
|
||||
Latest()
|
||||
}
|
||||
o.infos, err = builder.Do().Infos()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Run creates and applies the patch either locally or calling apiserver.
|
||||
|
@ -589,10 +589,7 @@ func (o *EditOptions) annotationPatch(update *resource.Info) error {
|
||||
WithFieldValidation(o.ValidationDirective).
|
||||
WithSubresource(o.Subresource)
|
||||
_, err = helper.Patch(o.CmdNamespace, update.Name, patchType, patch, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetApplyPatch is used to get and apply patches
|
||||
|
@ -104,10 +104,7 @@ func (g *Cloud) DeleteTPU(ctx context.Context, name, zone string) error {
|
||||
return err
|
||||
}
|
||||
err = getErrorFromTPUOp(op)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetTPU returns the Cloud TPU with the specified name in the specified zone.
|
||||
|
Loading…
Reference in New Issue
Block a user