mirror of
https://github.com/octoleo/restic.git
synced 2024-12-23 11:28:54 +00:00
fix(cmd_tag): Use restic.TagLists
This commit is contained in:
parent
e88f3fb80c
commit
25ecf9eafb
@ -38,9 +38,9 @@ type TagOptions struct {
|
|||||||
Hosts []string
|
Hosts []string
|
||||||
Paths []string
|
Paths []string
|
||||||
Tags restic.TagLists
|
Tags restic.TagLists
|
||||||
SetTags restic.TagList
|
SetTags restic.TagLists
|
||||||
AddTags restic.TagList
|
AddTags restic.TagLists
|
||||||
RemoveTags restic.TagList
|
RemoveTags restic.TagLists
|
||||||
}
|
}
|
||||||
|
|
||||||
var tagOptions TagOptions
|
var tagOptions TagOptions
|
||||||
@ -130,7 +130,7 @@ func runTag(opts TagOptions, gopts GlobalOptions, args []string) error {
|
|||||||
ctx, cancel := context.WithCancel(gopts.ctx)
|
ctx, cancel := context.WithCancel(gopts.ctx)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
for sn := range FindFilteredSnapshots(ctx, repo, opts.Hosts, opts.Tags, opts.Paths, args) {
|
for sn := range FindFilteredSnapshots(ctx, repo, opts.Hosts, opts.Tags, opts.Paths, args) {
|
||||||
changed, err := changeTags(ctx, repo, sn, opts.SetTags, opts.AddTags, opts.RemoveTags)
|
changed, err := changeTags(ctx, repo, sn, opts.SetTags.Flatten(), opts.AddTags.Flatten(), opts.RemoveTags.Flatten())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Warnf("unable to modify the tags for snapshot ID %q, ignoring: %v\n", sn.ID(), err)
|
Warnf("unable to modify the tags for snapshot ID %q, ignoring: %v\n", sn.ID(), err)
|
||||||
continue
|
continue
|
||||||
|
@ -840,7 +840,7 @@ func TestTag(t *testing.T) {
|
|||||||
"expected original ID to be nil, got %v", newest.Original)
|
"expected original ID to be nil, got %v", newest.Original)
|
||||||
originalID := *newest.ID
|
originalID := *newest.ID
|
||||||
|
|
||||||
testRunTag(t, TagOptions{SetTags: []string{"NL"}}, env.gopts)
|
testRunTag(t, TagOptions{SetTags: restic.TagLists{[]string{"NL"}}}, env.gopts)
|
||||||
testRunCheck(t, env.gopts)
|
testRunCheck(t, env.gopts)
|
||||||
newest, _ = testRunSnapshots(t, env.gopts)
|
newest, _ = testRunSnapshots(t, env.gopts)
|
||||||
rtest.Assert(t, newest != nil, "expected a new backup, got nil")
|
rtest.Assert(t, newest != nil, "expected a new backup, got nil")
|
||||||
@ -850,7 +850,7 @@ func TestTag(t *testing.T) {
|
|||||||
rtest.Assert(t, *newest.Original == originalID,
|
rtest.Assert(t, *newest.Original == originalID,
|
||||||
"expected original ID to be set to the first snapshot id")
|
"expected original ID to be set to the first snapshot id")
|
||||||
|
|
||||||
testRunTag(t, TagOptions{AddTags: []string{"CH"}}, env.gopts)
|
testRunTag(t, TagOptions{AddTags: restic.TagLists{[]string{"CH"}}}, env.gopts)
|
||||||
testRunCheck(t, env.gopts)
|
testRunCheck(t, env.gopts)
|
||||||
newest, _ = testRunSnapshots(t, env.gopts)
|
newest, _ = testRunSnapshots(t, env.gopts)
|
||||||
rtest.Assert(t, newest != nil, "expected a new backup, got nil")
|
rtest.Assert(t, newest != nil, "expected a new backup, got nil")
|
||||||
@ -860,7 +860,7 @@ func TestTag(t *testing.T) {
|
|||||||
rtest.Assert(t, *newest.Original == originalID,
|
rtest.Assert(t, *newest.Original == originalID,
|
||||||
"expected original ID to be set to the first snapshot id")
|
"expected original ID to be set to the first snapshot id")
|
||||||
|
|
||||||
testRunTag(t, TagOptions{RemoveTags: []string{"NL"}}, env.gopts)
|
testRunTag(t, TagOptions{RemoveTags: restic.TagLists{[]string{"NL"}}}, env.gopts)
|
||||||
testRunCheck(t, env.gopts)
|
testRunCheck(t, env.gopts)
|
||||||
newest, _ = testRunSnapshots(t, env.gopts)
|
newest, _ = testRunSnapshots(t, env.gopts)
|
||||||
rtest.Assert(t, newest != nil, "expected a new backup, got nil")
|
rtest.Assert(t, newest != nil, "expected a new backup, got nil")
|
||||||
@ -870,8 +870,8 @@ func TestTag(t *testing.T) {
|
|||||||
rtest.Assert(t, *newest.Original == originalID,
|
rtest.Assert(t, *newest.Original == originalID,
|
||||||
"expected original ID to be set to the first snapshot id")
|
"expected original ID to be set to the first snapshot id")
|
||||||
|
|
||||||
testRunTag(t, TagOptions{AddTags: []string{"US", "RU"}}, env.gopts)
|
testRunTag(t, TagOptions{AddTags: restic.TagLists{[]string{"US", "RU"}}}, env.gopts)
|
||||||
testRunTag(t, TagOptions{RemoveTags: []string{"CH", "US", "RU"}}, env.gopts)
|
testRunTag(t, TagOptions{RemoveTags: restic.TagLists{[]string{"CH", "US", "RU"}}}, env.gopts)
|
||||||
testRunCheck(t, env.gopts)
|
testRunCheck(t, env.gopts)
|
||||||
newest, _ = testRunSnapshots(t, env.gopts)
|
newest, _ = testRunSnapshots(t, env.gopts)
|
||||||
rtest.Assert(t, newest != nil, "expected a new backup, got nil")
|
rtest.Assert(t, newest != nil, "expected a new backup, got nil")
|
||||||
@ -882,7 +882,7 @@ func TestTag(t *testing.T) {
|
|||||||
"expected original ID to be set to the first snapshot id")
|
"expected original ID to be set to the first snapshot id")
|
||||||
|
|
||||||
// Check special case of removing all tags.
|
// Check special case of removing all tags.
|
||||||
testRunTag(t, TagOptions{SetTags: []string{""}}, env.gopts)
|
testRunTag(t, TagOptions{SetTags: restic.TagLists{[]string{""}}}, env.gopts)
|
||||||
testRunCheck(t, env.gopts)
|
testRunCheck(t, env.gopts)
|
||||||
newest, _ = testRunSnapshots(t, env.gopts)
|
newest, _ = testRunSnapshots(t, env.gopts)
|
||||||
rtest.Assert(t, newest != nil, "expected a new backup, got nil")
|
rtest.Assert(t, newest != nil, "expected a new backup, got nil")
|
||||||
|
Loading…
Reference in New Issue
Block a user