mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-18 22:14:29 +00:00
Allow forced backup deletion
Add --force and --confirm to `ark backup delete` to support forced backup deletion. This forcibly removes the Ark GC finalizer (if it's present) from a backup and will orphan any resources associated with the backup, such as backup tarballs in object storage, persistent volume snapshots, and restores for the backup. If a backup has a deletion timestamp, display `Deleting` in `ark backup describe` and `ark backup get`. Signed-off-by: Andy Goldstein <andy.goldstein@gmail.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
Copyright 2018 the Heptio Ark contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package stringslice
|
||||
|
||||
// Has returns true if the `items` slice contains the
|
||||
// value `val`, or false otherwise.
|
||||
func Has(items []string, val string) bool {
|
||||
for _, itm := range items {
|
||||
if itm == val {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// Except returns a new string slice that contains all of the entries
|
||||
// from `items` except `val`.
|
||||
func Except(items []string, val string) []string {
|
||||
// Default the capacity the len(items) instead of len(items)-1 in case items does not contain val.
|
||||
newItems := make([]string, 0, len(items))
|
||||
|
||||
for _, itm := range items {
|
||||
if itm != val {
|
||||
newItems = append(newItems, itm)
|
||||
}
|
||||
}
|
||||
|
||||
return newItems
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
Copyright 2018 the Heptio Ark contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package stringslice
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestHas(t *testing.T) {
|
||||
items := []string{}
|
||||
assert.False(t, Has(items, "a"))
|
||||
|
||||
items = []string{"a", "b", "c"}
|
||||
assert.True(t, Has(items, "a"))
|
||||
assert.True(t, Has(items, "b"))
|
||||
assert.True(t, Has(items, "c"))
|
||||
assert.False(t, Has(items, "d"))
|
||||
}
|
||||
|
||||
func TestExcept(t *testing.T) {
|
||||
items := []string{}
|
||||
except := Except(items, "asdf")
|
||||
assert.Len(t, except, 0)
|
||||
|
||||
items = []string{"a", "b", "c"}
|
||||
assert.Equal(t, []string{"b", "c"}, Except(items, "a"))
|
||||
assert.Equal(t, []string{"a", "c"}, Except(items, "b"))
|
||||
assert.Equal(t, []string{"a", "b"}, Except(items, "c"))
|
||||
assert.Equal(t, []string{"a", "b", "c"}, Except(items, "d"))
|
||||
}
|
||||
Reference in New Issue
Block a user