Skip to content

Commit ea950f2

Browse files
authored
make fmt (#156)
/cherry-pick Signed-off-by: 1gtm <1gtm@appscode.com>
1 parent fdf799c commit ea950f2

22 files changed

+40
-75
lines changed

hack/gendocs/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func main() {
8383
if err != nil {
8484
klog.Fatalln(err)
8585
}
86-
err = os.MkdirAll(dir, 0755)
86+
err = os.MkdirAll(dir, 0o755)
8787
if err != nil {
8888
klog.Fatalln(err)
8989
}
@@ -121,7 +121,7 @@ func main() {
121121
}
122122

123123
index := filepath.Join(dir, "_index.md")
124-
f, err := os.OpenFile(index, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
124+
f, err := os.OpenFile(index, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o644)
125125
if err != nil {
126126
klog.Fatalln(err)
127127
}

pkg/cli.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ func (localDirs *cliLocalDirectories) prepareDownloadDir() (err error) {
6464
return err
6565
}
6666
}
67-
return os.MkdirAll(localDirs.downloadDir, 0755)
67+
return os.MkdirAll(localDirs.downloadDir, 0o755)
6868
}

pkg/clone.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ func NewCmdClone(clientGetter genericclioptions.RESTClientGetter) *cobra.Command
3131
Short: `Clone Kubernetes resources`,
3232
DisableAutoGenTag: true,
3333
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
34-
3534
cfg, err := clientGetter.ToRESTConfig()
3635
if err != nil {
3736
return errors.Wrap(err, "failed to read kubeconfig")

pkg/clone_pvc.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,13 @@ import (
3434
ofst "kmodules.xyz/offshoot-api/api/v1"
3535
)
3636

37-
var (
38-
cloneExample = templates.Examples(`
37+
var cloneExample = templates.Examples(`
3938
# Clone PVC
4039
stash clone pvc source-pvc -n demo --to-namespace=demo1 --secret=<secret> --bucket=<bucket> --prefix=<prefix> --provider=<provider>`)
41-
)
4240

4341
func NewCmdClonePVC() *cobra.Command {
44-
var repoOpt = repositoryOption{}
45-
var cmd = &cobra.Command{
42+
repoOpt := repositoryOption{}
43+
cmd := &cobra.Command{
4644
Use: "pvc",
4745
Short: `Clone PVC`,
4846
Long: `Use Backup and Restore process for cloning PVC`,
@@ -198,6 +196,7 @@ func restorePVC(pvcName string, repository kmapi.ObjectReference) error {
198196
// delete RestoreSession
199197
return stashClient.StashV1beta1().RestoreSessions(dstNamespace).Delete(context.TODO(), restoreSession.Name, metav1.DeleteOptions{})
200198
}
199+
201200
func ensurePVC(pvc *core.PersistentVolumeClaim) error {
202201
klog.Infof("Creating pvc in %s namespace", pvc.Namespace)
203202
pvcTemplates := []ofst.PersistentVolumeClaim{
@@ -215,7 +214,6 @@ func ensurePVC(pvc *core.PersistentVolumeClaim) error {
215214
}
216215
claim := pvcTemplates[0].DeepCopy().ToCorePVC()
217216
_, err := kubeClient.CoreV1().PersistentVolumeClaims(dstNamespace).Create(context.TODO(), claim, metav1.CreateOptions{})
218-
219217
if err != nil {
220218
return err
221219
}

pkg/copy.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func NewCmdCopy(clientGetter genericclioptions.RESTClientGetter) *cobra.Command
4040
Short: `Copy stash resources from one namespace to another namespace`,
4141
DisableAutoGenTag: true,
4242
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
43-
4443
cfg, err := clientGetter.ToRESTConfig()
4544
if err != nil {
4645
return errors.Wrap(err, "failed to read kubeconfig")

pkg/copy_backupconfiguration.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ import (
2828
)
2929

3030
func NewCmdCopyBackupConfiguration() *cobra.Command {
31-
var cmd = &cobra.Command{
31+
cmd := &cobra.Command{
3232
Use: "backupconfig",
3333
Short: `Copy BackupConfiguration from one namespace to another namespace`,
3434
Long: `Copy BackupConfiguration with respective Repository and Secret if they are not present in the target namespace`,
3535
DisableAutoGenTag: true,
3636
RunE: func(cmd *cobra.Command, args []string) error {
37-
3837
if len(args) == 0 || args[0] == "" {
3938
return fmt.Errorf("BackupConfiguration name is not provided")
4039
}

pkg/copy_repository.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ import (
2626
)
2727

2828
func NewCmdCopyRepository() *cobra.Command {
29-
30-
var cmd = &cobra.Command{
29+
cmd := &cobra.Command{
3130
Use: "repository",
3231
Short: `Copy Repository and Secret`,
3332
Long: `Copy Repository and Secret from one namespace to another namespace`,
3433
DisableAutoGenTag: true,
3534
RunE: func(cmd *cobra.Command, args []string) error {
36-
3735
if len(args) == 0 || args[0] == "" {
3836
return fmt.Errorf("Repository name is not provided")
3937
}

pkg/copy_secret.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,12 @@ import (
2828
)
2929

3030
func NewCmdCopySecret() *cobra.Command {
31-
var cmd = &cobra.Command{
31+
cmd := &cobra.Command{
3232
Use: "secret",
3333
Short: `Copy Secret`,
3434
Long: `Copy Secret from one namespace to another namespace`,
3535
DisableAutoGenTag: true,
3636
RunE: func(cmd *cobra.Command, args []string) error {
37-
3837
if len(args) == 0 || args[0] == "" {
3938
return fmt.Errorf("secret name is not provided")
4039
}

pkg/copy_volumesnapshot.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@ import (
3131
var json = jsoniter.ConfigFastest
3232

3333
func NewCmdCopyVolumeSnapshot() *cobra.Command {
34-
var cmd = &cobra.Command{
34+
cmd := &cobra.Command{
3535
Use: "volumesnapshot",
3636
Short: `Copy VolumeSnapshot`,
3737
Long: `Copy VolumeSnapshot from one namespace to another namespace`,
3838
DisableAutoGenTag: true,
3939
RunE: func(cmd *cobra.Command, args []string) error {
40-
4140
if len(args) == 0 || args[0] == "" {
4241
return fmt.Errorf("volumeSnapshot name not found")
4342
}

pkg/create.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ import (
2525
"k8s.io/client-go/kubernetes"
2626
)
2727

28-
var (
29-
namespace string
30-
)
28+
var namespace string
3129

3230
func NewCmdCreate(clientGetter genericclioptions.RESTClientGetter) *cobra.Command {
3331
cmd := &cobra.Command{
3432
Use: "create",
3533
Short: `create stash resources`,
3634
DisableAutoGenTag: true,
3735
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
38-
3936
cfg, err := clientGetter.ToRESTConfig()
4037
if err != nil {
4138
return errors.Wrap(err, "failed to read kubeconfig")

0 commit comments

Comments
 (0)