Commit Graph

2 Commits

Author SHA1 Message Date
Julio Lopez
c8360ce6ca cleanup: fix linter errors
```
make lint
kopia/tools/.tools/bin/golangci-lint --deadline 180s run | tee .linterr.txt
cli/command_snapshot_delete.go:5: File is not `goimports`-ed with -local github.com/kopia/kopia (goimports)

tests/end_to_end_test/end_to_end_test.go:303: Function 'TestSnapshotDelete' is too long (187 > 100) (funlen)
func TestSnapshotDelete(t *testing.T) {
tests/end_to_end_test/end_to_end_test.go:306:2: only one cuddle assignment allowed before range statement (wsl)
	for _, tc := range []struct {
	^
tests/end_to_end_test/end_to_end_test.go:517:4: only one cuddle assignment allowed before if statement (wsl)
			if expectDeleteSucceeds {
			^
tests/end_to_end_test/end_to_end_test.go:537:2: assignments should only be cuddled with other assignments (wsl)
	line := lines[0]
	^
tests/end_to_end_test/end_to_end_test.go:542:2: only one cuddle assignment allowed before if statement (wsl)
	if typeVal != "policy" {
	^
tests/end_to_end_test/end_to_end_test.go:558:2: assignments should only be cuddled with other assignments (wsl)
	restoreDir := filepath.Join(e.dataDir, "restored")
	^
tests/end_to_end_test/end_to_end_test.go:568:2: if statements should only be cuddled with assignments (wsl)
	if got, want := len(si[0].snapshots), 1; got != want {
	^
tests/end_to_end_test/end_to_end_test.go:571:2: assignments should only be cuddled with other assignments (wsl)
	snapID := si[0].snapshots[0].snapshotID
	^
tests/end_to_end_test/end_to_end_test.go:604:2: if statements should only be cuddled with assignments (wsl)
	if len(fileInfo) != 0 {
	^
cli/command_snapshot_delete.go:25:2: only one cuddle assignment allowed before if statement (wsl)
	if err != nil {
	^
cli/command_snapshot_delete.go:36:3: if statements should only be cuddled with assignments (wsl)
		if labels["username"] != getUserName() {
		^
```
2019-12-18 18:17:15 -08:00
Nick
ae3d5610bf Dedicated snapshot delete command to delete by snap ID (#8)
Implemented snapshot delete command. Behaves similarly to manifest rm, but with extra verification steps. 
- Checks that the referenced manifest is of type "snapshot"
- Checks that the ID points to a snapshot, checks that the host name, user name, and path provided by flag or defaults match the source of the snapshot ID. Command will fail if they do not match, except if given --unsafe-ignore-source, which will bypass the associated safety requirement and delete anyway.

Added end to end tests for input combinations, restore in conjunction with delete, and trying to snapshot delete a manifest by ID of a non-snapshot manifest.
2019-12-12 18:02:48 -08:00