Skip to content

Commit ea98067

Browse files
Md. Emruz Hossaintamalsaha
authored andcommitted
Fix go_vet error (#440)
1 parent 9d626eb commit ea98067

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

forget.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,28 @@ func NewCmdForget() *cobra.Command {
2222
Use: "forget [snapshotID ...]",
2323
Short: "Delete snapshots from a restic repository",
2424
DisableAutoGenTag: true,
25-
Run: func(cmd *cobra.Command, args []string) {
25+
RunE: func(cmd *cobra.Command, args []string) error {
2626
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
2727
if err != nil {
28-
fmt.Errorf(err.Error())
28+
return err
2929
}
3030

3131
stashClient := cs.NewForConfigOrDie(config)
3232

3333
if repositoryName == "" {
34-
fmt.Errorf("repository name not found")
35-
return
34+
return fmt.Errorf("repository name not found")
3635
}
3736
repo, err := stashClient.Repositories(meta.Namespace()).Get(repositoryName, metav1.GetOptions{})
3837
if err != nil {
39-
fmt.Errorf(err.Error())
40-
return
38+
return err
4139
}
4240

4341
r := snapshot.NewREST(config)
4442
err = r.ForgetSnapshots(repo, args)
4543
if err != nil {
46-
fmt.Errorf(err.Error())
44+
return err
4745
}
46+
return nil
4847
},
4948
}
5049
cmd.Flags().StringVar(&masterURL, "master", masterURL, "The address of the Kubernetes API server (overrides any value in kubeconfig)")

snapshot.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,30 @@ func NewCmdSnapshots() *cobra.Command {
2323
Use: "snapshots [snapshotID ...]",
2424
Short: "Get snapshots of restic repo",
2525
DisableAutoGenTag: true,
26-
Run: func(cmd *cobra.Command, args []string) {
26+
RunE: func(cmd *cobra.Command, args []string) error {
2727
config, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigPath)
2828
if err != nil {
29-
fmt.Errorf(err.Error())
29+
return err
3030
}
3131

3232
stashClient := cs.NewForConfigOrDie(config)
3333

3434
if repositoryName == "" {
35-
fmt.Errorf("repository name not found")
36-
return
35+
return fmt.Errorf("repository name not found")
3736
}
3837
repo, err := stashClient.Repositories(meta.Namespace()).Get(repositoryName, metav1.GetOptions{})
3938
if err != nil {
40-
fmt.Errorf(err.Error())
41-
return
39+
return err
4240
}
4341

4442
r := snapshot.NewREST(config)
4543
snapshots, err := r.GetSnapshots(repo, args)
4644
if err != nil {
47-
fmt.Errorf(err.Error())
45+
return err
4846
}
4947
jsonSnaps, err := json.MarshalIndent(snapshots, "", " ")
5048
fmt.Println(string(jsonSnaps))
49+
return nil
5150
},
5251
}
5352
cmd.Flags().StringVar(&masterURL, "master", masterURL, "The address of the Kubernetes API server (overrides any value in kubeconfig)")

0 commit comments

Comments
 (0)