Skip to content

Commit

Permalink
Add Tags in SnapshotCreate Kopia Wrapper (#1664)
Browse files Browse the repository at this point in the history
  • Loading branch information
r4rajat committed Oct 11, 2022
1 parent a83a548 commit e1bfd96
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pkg/kopia/command/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func commonArgs(password, configFilePath, logDirectory string, requireInfoLevel
return c
}

func addTags(tags []string, args logsafe.Cmd) logsafe.Cmd {
// kopia required tags in name:value format, but all checks are performed on kopia side
for _, tag := range tags {
args = args.AppendLoggable(tagsFlag, tag)
}
return args
}

// ExecKopiaArgs returns the basic Argv for executing kopia with the given config file path.
func ExecKopiaArgs(configFilePath string) []string {
return commonArgs("", configFilePath, "", false).StringSliceCMD()
Expand Down
1 change: 1 addition & 0 deletions pkg/kopia/command/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
progressUpdateIntervalFlag = "--progress-update-interval"
rawFlag = "--raw"
showIdenticalFlag = "--show-identical"
tagsFlag = "--tags"
unsafeIgnoreSourceFlag = "--unsafe-ignore-source"
ownerFlag = "--owner"
sparseFlag = "--sparse"
Expand Down
3 changes: 2 additions & 1 deletion pkg/kopia/command/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
type SnapshotCreateCommandArgs struct {
*CommandArgs
PathToBackup string
Tags []string
}

// SnapshotCreate returns the kopia command for creation of a snapshot
Expand All @@ -42,7 +43,7 @@ func SnapshotCreate(cmdArgs SnapshotCreateCommandArgs) []string {
args = args.AppendLoggable(snapshotSubCommand, createSubCommand, cmdArgs.PathToBackup, jsonFlag)
args = args.AppendLoggableKV(parallelFlag, parallelismStr)
args = args.AppendLoggableKV(progressUpdateIntervalFlag, longUpdateInterval)

args = addTags(cmdArgs.Tags, args)
return stringSliceCommand(args)
}

Expand Down

0 comments on commit e1bfd96

Please sign in to comment.