Skip to content

Commit

Permalink
fix errcheck linter
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Ramlot <[email protected]>
  • Loading branch information
inteon committed Mar 27, 2024
1 parent 1a532ef commit 8f71ae9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ issues:
- staticcheck
- prealloc
- gosec
- errcheck
text: ".*"
linters:
# Explicitly define all enabled linters
Expand Down
12 changes: 9 additions & 3 deletions cmd/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ func (o *Options) Prepare(cmd *cobra.Command) *Options {
func (o *Options) Complete() error {
klog.InitFlags(nil)
log := klogr.New()
flag.Set("v", o.logLevel)
if err := flag.Set("v", o.logLevel); err != nil {
return fmt.Errorf("failed to set log level: %s", err)
}
o.Logr = log

var err error
Expand All @@ -107,8 +109,6 @@ func (o *Options) addFlags(cmd *cobra.Command) {
o.addAppFlags(nfs.FlagSet("App"))
o.kubeConfigFlags = genericclioptions.NewConfigFlags(true)
o.kubeConfigFlags.AddFlags(nfs.FlagSet("Kubernetes"))
cmd.MarkPersistentFlagRequired("node-id")
cmd.MarkPersistentFlagRequired("endpoint")

usageFmt := "Usage:\n %s\n"
cmd.SetUsageFunc(func(cmd *cobra.Command) error {
Expand All @@ -135,9 +135,15 @@ func (o *Options) addAppFlags(fs *pflag.FlagSet) {

fs.StringVar(&o.NodeID, "node-id", "",
"The name of the node which is hosting this driver instance.")
if err := cobra.MarkFlagRequired(fs, "node-id"); err != nil {
panic(err)
}

fs.StringVar(&o.Endpoint, "endpoint", "",
"The endpoint that the driver will connect to the Kubelet.")
if err := cobra.MarkFlagRequired(fs, "endpoint"); err != nil {
panic(err)
}

fs.StringVar(&o.DriverName, "driver-name", "csi.cert-manager.io",
"The name of this CSI driver which will be shared with the Kubelet.")
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/framework/helper/certificaterequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ func (h *Helper) WaitForCertificateRequestDeletion(namespace, name string, timeo
return false, nil
})
if err != nil {
h.Kubectl(namespace).DescribeResource("certificaterequest", name)
if err := h.Kubectl(namespace).DescribeResource("certificaterequest", name); err != nil {
log.Logf("helper: failed to describe CertificateRequest %s/%s: %v", namespace, name, err)
}
return err
}

Expand Down
8 changes: 6 additions & 2 deletions test/e2e/framework/helper/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ func (h *Helper) WaitForPodReady(namespace, name string, timeout time.Duration)
return true, nil
})
if err != nil {
h.Kubectl(namespace).DescribeResource("pod", name)
if err := h.Kubectl(namespace).DescribeResource("pod", name); err != nil {
log.Logf("helper: failed to describe Pod %s/%s: %v", namespace, name, err)
}
return err
}

Expand All @@ -188,7 +190,9 @@ func (h *Helper) WaitForPodDeletion(namespace, name string, timeout time.Duratio
return false, nil
})
if err != nil {
h.Kubectl(namespace).DescribeResource("pod", name)
if err := h.Kubectl(namespace).DescribeResource("pod", name); err != nil {
log.Logf("helper: failed to describe Pod %s/%s: %v", namespace, name, err)
}
return err
}

Expand Down

0 comments on commit 8f71ae9

Please sign in to comment.