Skip to content

Commit

Permalink
Refactor Duplicate Functions and Tests from kando package (#2234)
Browse files Browse the repository at this point in the history
* Remove test files from kando package

Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>

* - Remove Unused Functions
- Refactored helper function

Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>

---------

Signed-off-by: Rajat Gupta <rajat.gupta@veeam.com>
  • Loading branch information
r4rajat committed Sep 27, 2023
1 parent 59924f8 commit 410853d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 136 deletions.
16 changes: 14 additions & 2 deletions pkg/kando/chronicle_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ package kando
import (
"context"
"encoding/json"
"io"
"os"

"github.com/kanisterio/kanister/pkg/chronicle"
"github.com/kanisterio/kanister/pkg/param"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/kanisterio/kanister/pkg/chronicle"
"github.com/kanisterio/kanister/pkg/param"
)

func newChroniclePullCommand() *cobra.Command {
Expand Down Expand Up @@ -64,3 +67,12 @@ func runChroniclePull(cmd *cobra.Command, p locationParams, arg string) error {
ctx := context.Background()
return chronicle.Pull(ctx, target, *prof, p.suffix)
}

const usePipeParam = `-`

func targetWriter(target string) (io.Writer, error) {
if target != usePipeParam {
return os.OpenFile(target, os.O_RDWR|os.O_CREATE, 0755)
}
return os.Stdout, nil
}
24 changes: 0 additions & 24 deletions pkg/kando/kando_test.go

This file was deleted.

9 changes: 0 additions & 9 deletions pkg/kando/location_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
package kando

import (
"context"

"github.com/spf13/cobra"

"github.com/kanisterio/kanister/pkg/location"
"github.com/kanisterio/kanister/pkg/param"
)

func newLocationDeleteCommand() *cobra.Command {
Expand All @@ -42,7 +37,3 @@ func newLocationDeleteCommand() *cobra.Command {
cmd.Flags().StringP(kopiaSnapshotFlagName, "k", "", "Pass the kopia snapshot information from the location push command (optional)")
return cmd
}

func locationDelete(ctx context.Context, p *param.Profile, path string) error {
return location.Delete(ctx, *p, path)
}
18 changes: 0 additions & 18 deletions pkg/kando/location_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@
package kando

import (
"context"
"io"
"os"

"github.com/spf13/cobra"

"github.com/kanisterio/kanister/pkg/location"
"github.com/kanisterio/kanister/pkg/param"
)

const (
Expand All @@ -49,14 +42,3 @@ func newLocationPullCommand() *cobra.Command {
cmd.Flags().StringP(kopiaSnapshotFlagName, "k", "", "Pass the kopia snapshot information from the location push command (optional)")
return cmd
}

func targetWriter(target string) (io.Writer, error) {
if target != usePipeParam {
return os.OpenFile(target, os.O_RDWR|os.O_CREATE, 0755)
}
return os.Stdout, nil
}

func locationPull(ctx context.Context, p *param.Profile, path string, target io.Writer) error {
return location.Read(ctx, target, *p, path)
}
12 changes: 0 additions & 12 deletions pkg/kando/location_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
package kando

import (
"context"
"io"

"github.com/spf13/cobra"

"github.com/kanisterio/kanister/pkg/location"
"github.com/kanisterio/kanister/pkg/param"
)

const (
Expand Down Expand Up @@ -50,9 +44,3 @@ func newLocationPushCommand() *cobra.Command {

return cmd
}

const usePipeParam = `-`

func locationPush(ctx context.Context, p *param.Profile, path string, source io.Reader) error {
return location.Write(ctx, source, *p, path)
}
71 changes: 0 additions & 71 deletions pkg/kando/location_test.go

This file was deleted.

0 comments on commit 410853d

Please sign in to comment.