chore: enable use-any from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>pull/8624/head
parent
5b1738abf8
commit
cbba3bdde7
|
@ -282,7 +282,6 @@ linters-settings:
|
|||
- name: unused-parameter
|
||||
disabled: true
|
||||
- name: use-any
|
||||
disabled: true
|
||||
- name: var-declaration
|
||||
disabled: true
|
||||
- name: var-naming
|
||||
|
|
|
@ -106,7 +106,7 @@ func (p *volumeSnapshotDeleteItemAction) Execute(
|
|||
}
|
||||
|
||||
func NewVolumeSnapshotDeleteItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
crClient, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
|
|
|
@ -112,7 +112,7 @@ func (p *volumeSnapshotContentDeleteItemAction) Execute(
|
|||
func NewVolumeSnapshotContentDeleteItemAction(
|
||||
f client.Factory,
|
||||
) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
crClient, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -116,7 +116,7 @@ func (e *DefaultWaitExecHookHandler) HandleHooks(
|
|||
// not yet been observed to be running. It relies on the Informer not to be called concurrently.
|
||||
// When a container is observed running and its hooks are executed, the container is deleted
|
||||
// from the byContainer map. When the map is empty the watch is ended.
|
||||
handler := func(newObj interface{}) {
|
||||
handler := func(newObj any) {
|
||||
newPod, ok := newObj.(*v1.Pod)
|
||||
if !ok {
|
||||
return
|
||||
|
@ -217,10 +217,10 @@ func (e *DefaultWaitExecHookHandler) HandleHooks(
|
|||
|
||||
_, podWatcher := cache.NewInformer(lw, pod, 0, cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: handler,
|
||||
UpdateFunc: func(_, newObj interface{}) {
|
||||
UpdateFunc: func(_, newObj any) {
|
||||
handler(newObj)
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
DeleteFunc: func(obj any) {
|
||||
err := fmt.Errorf("pod %s deleted before all hooks were executed", kube.NamespaceAndName(pod))
|
||||
log.Error(err)
|
||||
cancel()
|
||||
|
|
|
@ -429,69 +429,69 @@ func TestGetResourceModifiersFromConfig(t *testing.T) {
|
|||
|
||||
func TestResourceModifiers_ApplyResourceModifierRules(t *testing.T) {
|
||||
pvcStandardSc := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"apiVersion": "v1",
|
||||
"kind": "PersistentVolumeClaim",
|
||||
"metadata": map[string]interface{}{
|
||||
"metadata": map[string]any{
|
||||
"name": "test-pvc",
|
||||
"namespace": "foo",
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"spec": map[string]any{
|
||||
"storageClassName": "standard",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
pvcPremiumSc := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"apiVersion": "v1",
|
||||
"kind": "PersistentVolumeClaim",
|
||||
"metadata": map[string]interface{}{
|
||||
"metadata": map[string]any{
|
||||
"name": "test-pvc",
|
||||
"namespace": "foo",
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"spec": map[string]any{
|
||||
"storageClassName": "premium",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
pvcGoldSc := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"apiVersion": "v1",
|
||||
"kind": "PersistentVolumeClaim",
|
||||
"metadata": map[string]interface{}{
|
||||
"metadata": map[string]any{
|
||||
"name": "test-pvc",
|
||||
"namespace": "foo",
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"spec": map[string]any{
|
||||
"storageClassName": "gold",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
deployNginxOneReplica := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"apiVersion": "apps/v1",
|
||||
"kind": "Deployment",
|
||||
"metadata": map[string]interface{}{
|
||||
"metadata": map[string]any{
|
||||
"name": "test-deployment",
|
||||
"namespace": "foo",
|
||||
"labels": map[string]interface{}{
|
||||
"labels": map[string]any{
|
||||
"app": "nginx",
|
||||
},
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"spec": map[string]any{
|
||||
"replicas": int64(1),
|
||||
"template": map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
"labels": map[string]interface{}{
|
||||
"template": map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"labels": map[string]any{
|
||||
"app": "nginx",
|
||||
},
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"containers": []interface{}{
|
||||
map[string]interface{}{
|
||||
"spec": map[string]any{
|
||||
"containers": []any{
|
||||
map[string]any{
|
||||
"name": "nginx",
|
||||
"image": "nginx:latest",
|
||||
},
|
||||
|
@ -502,27 +502,27 @@ func TestResourceModifiers_ApplyResourceModifierRules(t *testing.T) {
|
|||
},
|
||||
}
|
||||
deployNginxTwoReplica := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"apiVersion": "apps/v1",
|
||||
"kind": "Deployment",
|
||||
"metadata": map[string]interface{}{
|
||||
"metadata": map[string]any{
|
||||
"name": "test-deployment",
|
||||
"namespace": "foo",
|
||||
"labels": map[string]interface{}{
|
||||
"labels": map[string]any{
|
||||
"app": "nginx",
|
||||
},
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"spec": map[string]any{
|
||||
"replicas": int64(2),
|
||||
"template": map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
"labels": map[string]interface{}{
|
||||
"template": map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"labels": map[string]any{
|
||||
"app": "nginx",
|
||||
},
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"containers": []interface{}{
|
||||
map[string]interface{}{
|
||||
"spec": map[string]any{
|
||||
"containers": []any{
|
||||
map[string]any{
|
||||
"name": "nginx",
|
||||
"image": "nginx:latest",
|
||||
},
|
||||
|
@ -533,31 +533,31 @@ func TestResourceModifiers_ApplyResourceModifierRules(t *testing.T) {
|
|||
},
|
||||
}
|
||||
deployNginxMysql := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"apiVersion": "apps/v1",
|
||||
"kind": "Deployment",
|
||||
"metadata": map[string]interface{}{
|
||||
"metadata": map[string]any{
|
||||
"name": "test-deployment",
|
||||
"namespace": "foo",
|
||||
"labels": map[string]interface{}{
|
||||
"labels": map[string]any{
|
||||
"app": "nginx",
|
||||
},
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"spec": map[string]any{
|
||||
"replicas": int64(1),
|
||||
"template": map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
"labels": map[string]interface{}{
|
||||
"template": map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"labels": map[string]any{
|
||||
"app": "nginx",
|
||||
},
|
||||
},
|
||||
"spec": map[string]interface{}{
|
||||
"containers": []interface{}{
|
||||
map[string]interface{}{
|
||||
"spec": map[string]any{
|
||||
"containers": []any{
|
||||
map[string]any{
|
||||
"name": "nginx",
|
||||
"image": "nginx:latest",
|
||||
},
|
||||
map[string]interface{}{
|
||||
map[string]any{
|
||||
"name": "mysql",
|
||||
"image": "mysql:latest",
|
||||
},
|
||||
|
@ -568,19 +568,19 @@ func TestResourceModifiers_ApplyResourceModifierRules(t *testing.T) {
|
|||
},
|
||||
}
|
||||
cmTrue := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
"data": map[string]interface{}{
|
||||
"data": map[string]any{
|
||||
"test": "true",
|
||||
},
|
||||
},
|
||||
}
|
||||
cmFalse := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"apiVersion": "v1",
|
||||
"kind": "ConfigMap",
|
||||
"data": map[string]interface{}{
|
||||
"data": map[string]any{
|
||||
"test": "false",
|
||||
},
|
||||
},
|
||||
|
|
|
@ -53,7 +53,7 @@ func (p *StrategicMergePatcher) Patch(u *unstructured.Unstructured, _ logrus.Fie
|
|||
|
||||
// strategicPatchObject applies a strategic merge patch of `patchBytes` to
|
||||
// `originalObject` and stores the result in `objToUpdate`.
|
||||
// It additionally returns the map[string]interface{} representation of the
|
||||
// It additionally returns the map[string]any representation of the
|
||||
// `originalObject` and `patchBytes`.
|
||||
// NOTE: Both `originalObject` and `objToUpdate` are supposed to be versioned.
|
||||
func strategicPatchObject(
|
||||
|
@ -67,7 +67,7 @@ func strategicPatchObject(
|
|||
return err
|
||||
}
|
||||
|
||||
patchMap := make(map[string]interface{})
|
||||
patchMap := make(map[string]any)
|
||||
var strictErrs []error
|
||||
strictErrs, err = kubejson.UnmarshalStrict(patchBytes, &patchMap)
|
||||
if err != nil {
|
||||
|
@ -84,8 +84,8 @@ func strategicPatchObject(
|
|||
// <originalMap> and stores the result in <objToUpdate>.
|
||||
// NOTE: <objToUpdate> must be a versioned object.
|
||||
func applyPatchToObject(
|
||||
originalMap map[string]interface{},
|
||||
patchMap map[string]interface{},
|
||||
originalMap map[string]any,
|
||||
patchMap map[string]any,
|
||||
objToUpdate runtime.Object,
|
||||
schemaReferenceObj runtime.Object,
|
||||
strictErrs []error,
|
||||
|
|
|
@ -46,14 +46,14 @@ type Action struct {
|
|||
// Type defined specific type of action, currently only support 'skip'
|
||||
Type VolumeActionType `yaml:"type"`
|
||||
// Parameters defined map of parameters when executing a specific action
|
||||
Parameters map[string]interface{} `yaml:"parameters,omitempty"`
|
||||
Parameters map[string]any `yaml:"parameters,omitempty"`
|
||||
}
|
||||
|
||||
// volumePolicy defined policy to conditions to match Volumes and related action to handle matched Volumes
|
||||
type VolumePolicy struct {
|
||||
// Conditions defined list of conditions to match Volumes
|
||||
Conditions map[string]interface{} `yaml:"conditions"`
|
||||
Action Action `yaml:"action"`
|
||||
Conditions map[string]any `yaml:"conditions"`
|
||||
Action Action `yaml:"action"`
|
||||
}
|
||||
|
||||
// resourcePolicies currently defined slice of volume policies to handle backup
|
||||
|
@ -122,7 +122,7 @@ func (p *Policies) match(res *structuredVolume) *Action {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *Policies) GetMatchAction(res interface{}) (*Action, error) {
|
||||
func (p *Policies) GetMatchAction(res any) (*Action, error) {
|
||||
volume := &structuredVolume{}
|
||||
switch obj := res.(type) {
|
||||
case *v1.PersistentVolume:
|
||||
|
|
|
@ -138,20 +138,20 @@ func TestGetResourceMatchedAction(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "files.csi.driver",
|
||||
"volumeAttributes": map[string]string{"protocol": "nfs"},
|
||||
}),
|
||||
|
@ -159,21 +159,21 @@ func TestGetResourceMatchedAction(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Action: Action{Type: "snapshot"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "10,100Gi",
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
},
|
||||
},
|
||||
{
|
||||
Action: Action{Type: "fs-backup"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
},
|
||||
|
@ -281,9 +281,9 @@ func TestGetResourcePoliciesFromConfig(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"csi": map[string]interface{}{
|
||||
"csi": map[string]any{
|
||||
"driver": "disks.csi.driver",
|
||||
},
|
||||
},
|
||||
|
@ -292,8 +292,8 @@ func TestGetResourcePoliciesFromConfig(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
"csi": map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"csi": map[string]any{
|
||||
"driver": "files.csi.driver",
|
||||
"volumeAttributes": map[string]string{"protocol": "nfs"},
|
||||
},
|
||||
|
|
|
@ -226,9 +226,9 @@ func (c *capacity) isInRange(y resource.Quantity) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// unmarshalVolConditions parse map[string]interface{} into volumeConditions format
|
||||
// unmarshalVolConditions parse map[string]any into volumeConditions format
|
||||
// and validate key fields of the map.
|
||||
func unmarshalVolConditions(con map[string]interface{}) (*volumeConditions, error) {
|
||||
func unmarshalVolConditions(con map[string]any) (*volumeConditions, error) {
|
||||
volConditons := &volumeConditions{}
|
||||
buffer := new(bytes.Buffer)
|
||||
err := yaml.NewEncoder(buffer).Encode(con)
|
||||
|
|
|
@ -256,12 +256,12 @@ func TestCSIConditionMatch(t *testing.T) {
|
|||
func TestUnmarshalVolumeConditions(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
input map[string]interface{}
|
||||
input map[string]any
|
||||
expectedError string
|
||||
}{
|
||||
{
|
||||
name: "Valid input",
|
||||
input: map[string]interface{}{
|
||||
input: map[string]any{
|
||||
"capacity": "1Gi,10Gi",
|
||||
"storageClass": []string{
|
||||
"gp2",
|
||||
|
@ -275,28 +275,28 @@ func TestUnmarshalVolumeConditions(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "Invalid input: invalid capacity filed name",
|
||||
input: map[string]interface{}{
|
||||
input: map[string]any{
|
||||
"Capacity": "1Gi,10Gi",
|
||||
},
|
||||
expectedError: "field Capacity not found",
|
||||
},
|
||||
{
|
||||
name: "Invalid input: invalid storage class format",
|
||||
input: map[string]interface{}{
|
||||
input: map[string]any{
|
||||
"storageClass": "ebs-sc",
|
||||
},
|
||||
expectedError: "str `ebs-sc` into []string",
|
||||
},
|
||||
{
|
||||
name: "Invalid input: invalid csi format",
|
||||
input: map[string]interface{}{
|
||||
input: map[string]any{
|
||||
"csi": "csi.driver",
|
||||
},
|
||||
expectedError: "str `csi.driver` into resourcepolicies.csiVolumeSource",
|
||||
},
|
||||
{
|
||||
name: "Invalid input: unknown field",
|
||||
input: map[string]interface{}{
|
||||
input: map[string]any{
|
||||
"unknown": "foo",
|
||||
},
|
||||
expectedError: "field unknown not found in type",
|
||||
|
|
|
@ -78,7 +78,7 @@ func (c *csiCondition) validate() error {
|
|||
}
|
||||
|
||||
// decodeStruct restric validate the keys in decoded mappings to exist as fields in the struct being decoded into
|
||||
func decodeStruct(r io.Reader, s interface{}) error {
|
||||
func decodeStruct(r io.Reader, s any) error {
|
||||
dec := yaml.NewDecoder(r)
|
||||
dec.KnownFields(true)
|
||||
return dec.Decode(s)
|
||||
|
|
|
@ -94,12 +94,12 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"unknown": "",
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
},
|
||||
|
@ -115,11 +115,11 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "10Gi",
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
},
|
||||
|
@ -135,11 +135,11 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"storageClass": "ebs-sc",
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
},
|
||||
|
@ -155,7 +155,7 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"csi": "aws.efs.csi.driver",
|
||||
|
@ -172,11 +172,11 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": []string{"aws.efs.csi.driver"},
|
||||
}),
|
||||
},
|
||||
|
@ -192,11 +192,11 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
"volumeAttributes": "test",
|
||||
}),
|
||||
|
@ -213,10 +213,10 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
},
|
||||
|
@ -232,10 +232,10 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "unsupported"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
},
|
||||
|
@ -251,7 +251,7 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"nfs": "aws.efs.csi.driver",
|
||||
|
@ -268,9 +268,9 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
},
|
||||
|
@ -286,9 +286,9 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"volumeAttributes": map[string]string{
|
||||
"key1": "value1",
|
||||
},
|
||||
|
@ -306,9 +306,9 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
"volumeAttributes": map[string]string{
|
||||
"key1": "value1",
|
||||
|
@ -327,15 +327,15 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "skip"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
"nfs": interface{}(
|
||||
map[string]interface{}{
|
||||
"nfs": any(
|
||||
map[string]any{
|
||||
"server": "192.168.20.90",
|
||||
"path": "/mnt/data/",
|
||||
}),
|
||||
|
@ -352,15 +352,15 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "snapshot"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
"nfs": interface{}(
|
||||
map[string]interface{}{
|
||||
"nfs": any(
|
||||
map[string]any{
|
||||
"server": "192.168.20.90",
|
||||
"path": "/mnt/data/",
|
||||
}),
|
||||
|
@ -377,15 +377,15 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: "fs-backup"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"capacity": "0,10Gi",
|
||||
"storageClass": []string{"gp2", "ebs-sc"},
|
||||
"csi": interface{}(
|
||||
map[string]interface{}{
|
||||
"csi": any(
|
||||
map[string]any{
|
||||
"driver": "aws.efs.csi.driver",
|
||||
}),
|
||||
"nfs": interface{}(
|
||||
map[string]interface{}{
|
||||
"nfs": any(
|
||||
map[string]any{
|
||||
"server": "192.168.20.90",
|
||||
"path": "/mnt/data/",
|
||||
}),
|
||||
|
@ -402,15 +402,15 @@ func TestValidate(t *testing.T) {
|
|||
VolumePolicies: []VolumePolicy{
|
||||
{
|
||||
Action: Action{Type: Snapshot},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Action: Action{Type: FSBackup},
|
||||
Conditions: map[string]interface{}{
|
||||
"nfs": interface{}(
|
||||
map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"nfs": any(
|
||||
map[string]any{
|
||||
"server": "192.168.20.90",
|
||||
"path": "/mnt/data/",
|
||||
}),
|
||||
|
|
|
@ -46,7 +46,7 @@ func (rp *MockRestartableProcess) ResetIfNeeded() error {
|
|||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (rp *MockRestartableProcess) GetByKindAndName(key process.KindAndName) (interface{}, error) {
|
||||
func (rp *MockRestartableProcess) GetByKindAndName(key process.KindAndName) (any, error) {
|
||||
args := rp.Called(key)
|
||||
return args.Get(0), args.Error(1)
|
||||
}
|
||||
|
@ -57,21 +57,21 @@ func (rp *MockRestartableProcess) Stop() {
|
|||
|
||||
type RestartableDelegateTest struct {
|
||||
Function string
|
||||
Inputs []interface{}
|
||||
ExpectedErrorOutputs []interface{}
|
||||
ExpectedDelegateOutputs []interface{}
|
||||
Inputs []any
|
||||
ExpectedErrorOutputs []any
|
||||
ExpectedDelegateOutputs []any
|
||||
}
|
||||
|
||||
type Mockable interface {
|
||||
Test(t mock.TestingT)
|
||||
On(method string, args ...interface{}) *mock.Call
|
||||
On(method string, args ...any) *mock.Call
|
||||
AssertExpectations(t mock.TestingT) bool
|
||||
}
|
||||
|
||||
func RunRestartableDelegateTests(
|
||||
t *testing.T,
|
||||
kind common.PluginKind,
|
||||
newRestartable func(key process.KindAndName, p process.RestartableProcess) interface{},
|
||||
newRestartable func(key process.KindAndName, p process.RestartableProcess) any,
|
||||
newMock func() Mockable,
|
||||
tests ...RestartableDelegateTest,
|
||||
) {
|
||||
|
@ -92,7 +92,7 @@ func RunRestartableDelegateTests(
|
|||
method := reflect.ValueOf(r).MethodByName(tc.Function)
|
||||
require.NotEmpty(t, method)
|
||||
|
||||
// Convert the test case inputs ([]interface{}) to []reflect.Value
|
||||
// Convert the test case inputs ([]any) to []reflect.Value
|
||||
var inputValues []reflect.Value
|
||||
for i := range tc.Inputs {
|
||||
inputValues = append(inputValues, reflect.ValueOf(tc.Inputs[i]))
|
||||
|
@ -102,7 +102,7 @@ func RunRestartableDelegateTests(
|
|||
actual := method.Call(inputValues)
|
||||
|
||||
// This Function asserts that the actual outputs match the expected outputs
|
||||
checkOutputs := func(expected []interface{}, actual []reflect.Value) {
|
||||
checkOutputs := func(expected []any, actual []reflect.Value) {
|
||||
require.Equal(t, len(expected), len(actual))
|
||||
|
||||
for i := range actual {
|
||||
|
|
|
@ -143,7 +143,7 @@ func (v volumeHelperImpl) ShouldPerformFSBackup(volume corev1api.Volume, pod cor
|
|||
}
|
||||
|
||||
if v.volumePolicy != nil {
|
||||
var resource interface{}
|
||||
var resource any
|
||||
resource = &volume
|
||||
if volume.VolumeSource.PersistentVolumeClaim != nil {
|
||||
pvc, err := kubeutil.GetPVCForPodVolume(&volume, &pod, v.client)
|
||||
|
|
|
@ -57,7 +57,7 @@ func TestVolumeHelperImpl_ShouldPerformSnapshot(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -78,7 +78,7 @@ func TestVolumeHelperImpl_ShouldPerformSnapshot(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -99,7 +99,7 @@ func TestVolumeHelperImpl_ShouldPerformSnapshot(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -121,7 +121,7 @@ func TestVolumeHelperImpl_ShouldPerformSnapshot(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -152,7 +152,7 @@ func TestVolumeHelperImpl_ShouldPerformSnapshot(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -186,7 +186,7 @@ func TestVolumeHelperImpl_ShouldPerformSnapshot(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -220,7 +220,7 @@ func TestVolumeHelperImpl_ShouldPerformSnapshot(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -253,7 +253,7 @@ func TestVolumeHelperImpl_ShouldPerformSnapshot(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -465,7 +465,7 @@ func TestVolumeHelperImpl_ShouldIncludeVolumeInBackup(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -540,7 +540,7 @@ func TestVolumeHelperImpl_ShouldPerformFSBackup(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -566,7 +566,7 @@ func TestVolumeHelperImpl_ShouldPerformFSBackup(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"volumeTypes": []string{"emptyDir"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -600,7 +600,7 @@ func TestVolumeHelperImpl_ShouldPerformFSBackup(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
@ -635,7 +635,7 @@ func TestVolumeHelperImpl_ShouldPerformFSBackup(t *testing.T) {
|
|||
Version: "v1",
|
||||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp3-csi"},
|
||||
},
|
||||
Action: resourcepolicies.Action{
|
||||
|
|
|
@ -36,9 +36,9 @@ import (
|
|||
|
||||
func TestBackupPVAction(t *testing.T) {
|
||||
pvc := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
"spec": map[string]interface{}{},
|
||||
"status": map[string]interface{}{},
|
||||
Object: map[string]any{
|
||||
"spec": map[string]any{},
|
||||
"status": map[string]any{},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ func TestBackupPVAction(t *testing.T) {
|
|||
|
||||
// empty spec.volumeName should result in no error
|
||||
// and no additional items
|
||||
pvc.Object["spec"].(map[string]interface{})["volumeName"] = ""
|
||||
pvc.Object["spec"].(map[string]any)["volumeName"] = ""
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
assert.NoError(t, err)
|
||||
assert.Empty(t, additional)
|
||||
|
@ -116,28 +116,28 @@ func TestBackupPVAction(t *testing.T) {
|
|||
|
||||
// non-empty spec.volumeName when status.phase is empty
|
||||
// should result in no error and no additional items
|
||||
pvc.Object["spec"].(map[string]interface{})["volumeName"] = "myVolume"
|
||||
pvc.Object["spec"].(map[string]any)["volumeName"] = "myVolume"
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, additional)
|
||||
|
||||
// non-empty spec.volumeName when status.phase is 'Pending'
|
||||
// should result in no error and no additional items
|
||||
pvc.Object["status"].(map[string]interface{})["phase"] = corev1api.ClaimPending
|
||||
pvc.Object["status"].(map[string]any)["phase"] = corev1api.ClaimPending
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, additional)
|
||||
|
||||
// non-empty spec.volumeName when status.phase is 'Lost'
|
||||
// should result in no error and no additional items
|
||||
pvc.Object["status"].(map[string]interface{})["phase"] = corev1api.ClaimLost
|
||||
pvc.Object["status"].(map[string]any)["phase"] = corev1api.ClaimLost
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, additional)
|
||||
|
||||
// non-empty spec.volumeName when status.phase is 'Bound'
|
||||
// should result in no error and one additional item for the PV
|
||||
pvc.Object["status"].(map[string]interface{})["phase"] = corev1api.ClaimBound
|
||||
pvc.Object["status"].(map[string]any)["phase"] = corev1api.ClaimBound
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, additional, 1)
|
||||
|
@ -145,7 +145,7 @@ func TestBackupPVAction(t *testing.T) {
|
|||
|
||||
// empty spec.volumeName when status.phase is 'Bound' should
|
||||
// result in no error and no additional items
|
||||
pvc.Object["spec"].(map[string]interface{})["volumeName"] = ""
|
||||
pvc.Object["spec"].(map[string]any)["volumeName"] = ""
|
||||
_, additional, err = a.Execute(pvc, backup)
|
||||
assert.NoError(t, err)
|
||||
assert.Empty(t, additional)
|
||||
|
|
|
@ -552,7 +552,7 @@ func cancelDataUpload(
|
|||
}
|
||||
|
||||
func NewPvcBackupItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
crClient, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
|
|
|
@ -372,7 +372,7 @@ func (p *volumeSnapshotBackupItemAction) Cancel(
|
|||
func NewVolumeSnapshotBackupItemAction(
|
||||
f client.Factory,
|
||||
) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
crClient, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
|
|
|
@ -119,6 +119,6 @@ func (p *volumeSnapshotClassBackupItemAction) Cancel(
|
|||
|
||||
// NewVolumeSnapshotClassBackupItemAction returns a
|
||||
// VolumeSnapshotClassBackupItemAction instance.
|
||||
func NewVolumeSnapshotClassBackupItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func NewVolumeSnapshotClassBackupItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return &volumeSnapshotClassBackupItemAction{log: logger}, nil
|
||||
}
|
||||
|
|
|
@ -136,6 +136,6 @@ func (p *volumeSnapshotContentBackupItemAction) Cancel(
|
|||
// VolumeSnapshotContentBackupItemAction instance.
|
||||
func NewVolumeSnapshotContentBackupItemAction(
|
||||
logger logrus.FieldLogger,
|
||||
) (interface{}, error) {
|
||||
) (any, error) {
|
||||
return &volumeSnapshotContentBackupItemAction{log: logger}, nil
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ func TestRemapCRDVersionActionData(t *testing.T) {
|
|||
// For ElasticSearch and Kibana, problems manifested when additionalPrinterColumns was moved from the top-level spec down to the
|
||||
// versions slice.
|
||||
if test.expectAdditionalColumns {
|
||||
_, ok := item.UnstructuredContent()["spec"].(map[string]interface{})["additionalPrinterColumns"]
|
||||
_, ok := item.UnstructuredContent()["spec"].(map[string]any)["additionalPrinterColumns"]
|
||||
assert.True(t, ok)
|
||||
}
|
||||
|
||||
|
|
|
@ -446,7 +446,7 @@ func (kb *kubernetesBackupper) BackupWithResolvers(
|
|||
var itemBlock *BackupItemBlock
|
||||
|
||||
for i := range items {
|
||||
log.WithFields(map[string]interface{}{
|
||||
log.WithFields(map[string]any{
|
||||
"progress": "",
|
||||
"resource": items[i].groupResource.String(),
|
||||
"namespace": items[i].namespace,
|
||||
|
@ -507,7 +507,7 @@ func (kb *kubernetesBackupper) BackupWithResolvers(
|
|||
itemsBackedUp: backedUpItems,
|
||||
}
|
||||
|
||||
log.WithFields(map[string]interface{}{
|
||||
log.WithFields(map[string]any{
|
||||
"progress": "",
|
||||
"resource": items[i].groupResource.String(),
|
||||
"namespace": items[i].namespace,
|
||||
|
@ -973,7 +973,7 @@ func (kb *kubernetesBackupper) FinalizeBackup(
|
|||
unstructuredDataUploads := make([]unstructured.Unstructured, 0)
|
||||
|
||||
for i, item := range items {
|
||||
log.WithFields(map[string]interface{}{
|
||||
log.WithFields(map[string]any{
|
||||
"progress": "",
|
||||
"resource": item.groupResource.String(),
|
||||
"namespace": item.namespace,
|
||||
|
@ -1016,7 +1016,7 @@ func (kb *kubernetesBackupper) FinalizeBackup(
|
|||
backedUpItems := backupRequest.BackedUpItems.Len()
|
||||
totalItems := backedUpItems + (len(items) - (i + 1))
|
||||
|
||||
log.WithFields(map[string]interface{}{
|
||||
log.WithFields(map[string]any{
|
||||
"progress": "",
|
||||
"resource": item.groupResource.String(),
|
||||
"namespace": item.namespace,
|
||||
|
|
|
@ -1364,7 +1364,7 @@ func TestBackupItemActionsForSkippedPV(t *testing.T) {
|
|||
VolumePolicies: []resourcepolicies.VolumePolicy{
|
||||
{
|
||||
Action: resourcepolicies.Action{Type: "snapshot"},
|
||||
Conditions: map[string]interface{}{
|
||||
Conditions: map[string]any{
|
||||
"storageClass": []string{"gp2"},
|
||||
},
|
||||
},
|
||||
|
@ -1849,7 +1849,7 @@ func TestBackupActionModifications(t *testing.T) {
|
|||
},
|
||||
actions: []biav2.BackupItemAction{
|
||||
modifyingActionGetter(func(item *unstructured.Unstructured) {
|
||||
item.Object["spec"].(map[string]interface{})["nodeName"] = "foo"
|
||||
item.Object["spec"].(map[string]any)["nodeName"] = "foo"
|
||||
}),
|
||||
},
|
||||
want: map[string]unstructuredObject{
|
||||
|
@ -4282,7 +4282,7 @@ func defaultBackup() *builder.BackupBuilder {
|
|||
return builder.ForBackup(velerov1.DefaultNamespace, "backup-1").DefaultVolumesToFsBackup(false)
|
||||
}
|
||||
|
||||
func toUnstructuredOrFail(t *testing.T, obj interface{}) map[string]interface{} {
|
||||
func toUnstructuredOrFail(t *testing.T, obj any) map[string]any {
|
||||
t.Helper()
|
||||
|
||||
res, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj)
|
||||
|
@ -4318,7 +4318,7 @@ func assertTarballContents(t *testing.T, backupFile io.Reader, items ...string)
|
|||
}
|
||||
|
||||
// unstructuredObject is a type alias to improve readability.
|
||||
type unstructuredObject map[string]interface{}
|
||||
type unstructuredObject map[string]any
|
||||
|
||||
// assertTarballFileContents verifies that the gzipped tarball stored in the provided
|
||||
// backupFile contains the files specified as keys in 'want', and for each of those
|
||||
|
|
|
@ -159,7 +159,7 @@ func (ib *itemBackupper) backupItemInternal(logger logrus.FieldLogger, obj runti
|
|||
namespace := metadata.GetNamespace()
|
||||
name := metadata.GetName()
|
||||
|
||||
log := logger.WithFields(map[string]interface{}{
|
||||
log := logger.WithFields(map[string]any{
|
||||
"name": name,
|
||||
"resource": groupResource.String(),
|
||||
"namespace": namespace,
|
||||
|
@ -218,7 +218,7 @@ func (ib *itemBackupper) backupItemInternal(logger logrus.FieldLogger, obj runti
|
|||
ib.podVolumeSnapshotTracker.Track(pod, volume.Name)
|
||||
|
||||
if found, pvcName := ib.podVolumeSnapshotTracker.TakenForPodVolume(pod, volume.Name); found {
|
||||
log.WithFields(map[string]interface{}{
|
||||
log.WithFields(map[string]any{
|
||||
"podVolume": volume,
|
||||
"pvcName": pvcName,
|
||||
}).Info("Pod volume uses a persistent volume claim which has already been backed up from another pod, skipping.")
|
||||
|
|
|
@ -33,9 +33,9 @@ const (
|
|||
ConfigKeyColorized = "colorized"
|
||||
)
|
||||
|
||||
// VeleroConfig is a map of strings to interface{} for deserializing Velero client config options.
|
||||
// VeleroConfig is a map of strings to any for deserializing Velero client config options.
|
||||
// The alias is a way to attach type-asserting convenience methods.
|
||||
type VeleroConfig map[string]interface{}
|
||||
type VeleroConfig map[string]any
|
||||
|
||||
// LoadConfig loads the Velero client configuration file and returns it as a VeleroConfig. If the
|
||||
// file does not exist, an empty map is returned.
|
||||
|
|
|
@ -36,14 +36,14 @@ func TestFactory(t *testing.T) {
|
|||
|
||||
// Env variable should set the namespace if no config or argument are used
|
||||
os.Setenv("VELERO_NAMESPACE", "env-velero")
|
||||
f := NewFactory("velero", make(map[string]interface{}))
|
||||
f := NewFactory("velero", make(map[string]any))
|
||||
|
||||
assert.Equal(t, "env-velero", f.Namespace())
|
||||
|
||||
os.Unsetenv("VELERO_NAMESPACE")
|
||||
|
||||
// Argument should change the namespace
|
||||
f = NewFactory("velero", make(map[string]interface{}))
|
||||
f = NewFactory("velero", make(map[string]any))
|
||||
s := "flag-velero"
|
||||
flags := new(flag.FlagSet)
|
||||
|
||||
|
@ -55,7 +55,7 @@ func TestFactory(t *testing.T) {
|
|||
|
||||
// An argument overrides the env variable if both are set.
|
||||
os.Setenv("VELERO_NAMESPACE", "env-velero")
|
||||
f = NewFactory("velero", make(map[string]interface{}))
|
||||
f = NewFactory("velero", make(map[string]any))
|
||||
flags = new(flag.FlagSet)
|
||||
|
||||
f.BindFlags(flags)
|
||||
|
|
|
@ -257,7 +257,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
|||
backupInformer := cache.NewSharedInformer(&lw, &velerov1api.Backup{}, time.Second)
|
||||
_, _ = backupInformer.AddEventHandler(
|
||||
cache.FilteringResourceEventHandler{
|
||||
FilterFunc: func(obj interface{}) bool {
|
||||
FilterFunc: func(obj any) bool {
|
||||
backup, ok := obj.(*velerov1api.Backup)
|
||||
|
||||
if !ok {
|
||||
|
@ -266,14 +266,14 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
|||
return backup.Name == o.Name
|
||||
},
|
||||
Handler: cache.ResourceEventHandlerFuncs{
|
||||
UpdateFunc: func(_, obj interface{}) {
|
||||
UpdateFunc: func(_, obj any) {
|
||||
backup, ok := obj.(*velerov1api.Backup)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
updates <- backup
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
DeleteFunc: func(obj any) {
|
||||
backup, ok := obj.(*velerov1api.Backup)
|
||||
if !ok {
|
||||
return
|
||||
|
|
|
@ -56,7 +56,7 @@ func TestExitWithMessage(t *testing.T) {
|
|||
name string
|
||||
message string
|
||||
succeed bool
|
||||
args []interface{}
|
||||
args []any
|
||||
createErr error
|
||||
writeFail bool
|
||||
expectedExitCode int
|
||||
|
@ -77,7 +77,7 @@ func TestExitWithMessage(t *testing.T) {
|
|||
{
|
||||
name: "not succeed",
|
||||
message: "fake-message-1, arg-1 %s, arg-2 %v, arg-3 %v",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
"arg-1-1",
|
||||
10,
|
||||
false,
|
||||
|
@ -88,7 +88,7 @@ func TestExitWithMessage(t *testing.T) {
|
|||
{
|
||||
name: "not succeed",
|
||||
message: "fake-message-2, arg-1 %s, arg-2 %v, arg-3 %v",
|
||||
args: []interface{}{
|
||||
args: []any{
|
||||
"arg-1-2",
|
||||
20,
|
||||
true,
|
||||
|
|
|
@ -369,7 +369,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
|||
|
||||
_, _ = restoreInformer.AddEventHandler(
|
||||
cache.FilteringResourceEventHandler{
|
||||
FilterFunc: func(obj interface{}) bool {
|
||||
FilterFunc: func(obj any) bool {
|
||||
restore, ok := obj.(*api.Restore)
|
||||
if !ok {
|
||||
return false
|
||||
|
@ -377,14 +377,14 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
|
|||
return restore.Name == o.RestoreName
|
||||
},
|
||||
Handler: cache.ResourceEventHandlerFuncs{
|
||||
UpdateFunc: func(_, obj interface{}) {
|
||||
UpdateFunc: func(_, obj any) {
|
||||
restore, ok := obj.(*api.Restore)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
updates <- restore
|
||||
},
|
||||
DeleteFunc: func(obj interface{}) {
|
||||
DeleteFunc: func(obj any) {
|
||||
restore, ok := obj.(*api.Restore)
|
||||
if !ok {
|
||||
return
|
||||
|
|
|
@ -34,7 +34,7 @@ func CheckError(err error) {
|
|||
}
|
||||
|
||||
// Exit prints msg (with optional args), plus a newline, to stderr and exits with code 1.
|
||||
func Exit(msg string, args ...interface{}) {
|
||||
func Exit(msg string, args ...any) {
|
||||
fmt.Fprintf(os.Stderr, msg+"\n", args...)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
|
|
@ -209,16 +209,16 @@ func NewCommand(f client.Factory) *cobra.Command {
|
|||
return c
|
||||
}
|
||||
|
||||
func newPVBackupItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newPVBackupItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return bia.NewPVCAction(logger), nil
|
||||
}
|
||||
|
||||
func newPodBackupItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newPodBackupItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return bia.NewPodAction(logger), nil
|
||||
}
|
||||
|
||||
func newServiceAccountBackupItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
// TODO(ncdc): consider a k8s style WantsKubernetesClientSet initialization approach
|
||||
clientset, err := f.KubeClient()
|
||||
if err != nil {
|
||||
|
@ -248,7 +248,7 @@ func newServiceAccountBackupItemAction(f client.Factory) plugincommon.HandlerIni
|
|||
}
|
||||
|
||||
func newRemapCRDVersionAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
config, err := f.ClientConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -272,20 +272,20 @@ func newRemapCRDVersionAction(f client.Factory) plugincommon.HandlerInitializer
|
|||
}
|
||||
}
|
||||
|
||||
func newJobRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newJobRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewJobAction(logger), nil
|
||||
}
|
||||
|
||||
func newPodRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newPodRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewPodAction(logger), nil
|
||||
}
|
||||
|
||||
func newInitRestoreHookPodAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newInitRestoreHookPodAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewInitRestoreHookPodAction(logger), nil
|
||||
}
|
||||
|
||||
func newPodVolumeRestoreItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubeClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -300,28 +300,28 @@ func newPodVolumeRestoreItemAction(f client.Factory) plugincommon.HandlerInitial
|
|||
}
|
||||
}
|
||||
|
||||
func newServiceRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newServiceRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewServiceAction(logger), nil
|
||||
}
|
||||
|
||||
func newServiceAccountRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newServiceAccountRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewServiceAccountAction(logger), nil
|
||||
}
|
||||
|
||||
func newAddPVCFromPodRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newAddPVCFromPodRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewAddPVCFromPodAction(logger), nil
|
||||
}
|
||||
|
||||
func newAddPVFromPVCRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newAddPVFromPVCRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewAddPVFromPVCAction(logger), nil
|
||||
}
|
||||
|
||||
func newCRDV1PreserveUnknownFieldsItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newCRDV1PreserveUnknownFieldsItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewCRDV1PreserveUnknownFieldsAction(logger), nil
|
||||
}
|
||||
|
||||
func newChangeStorageClassRestoreItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubeClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -336,7 +336,7 @@ func newChangeStorageClassRestoreItemAction(f client.Factory) plugincommon.Handl
|
|||
}
|
||||
|
||||
func newChangeImageNameRestoreItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubeClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -348,16 +348,16 @@ func newChangeImageNameRestoreItemAction(f client.Factory) plugincommon.HandlerI
|
|||
), nil
|
||||
}
|
||||
}
|
||||
func newRoleBindingItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newRoleBindingItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewRoleBindingAction(logger), nil
|
||||
}
|
||||
|
||||
func newClusterRoleBindingItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newClusterRoleBindingItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewClusterRoleBindingAction(logger), nil
|
||||
}
|
||||
|
||||
func newChangePVCNodeSelectorItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubeClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -371,16 +371,16 @@ func newChangePVCNodeSelectorItemAction(f client.Factory) plugincommon.HandlerIn
|
|||
}
|
||||
}
|
||||
|
||||
func newAPIServiceRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newAPIServiceRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewAPIServiceAction(logger), nil
|
||||
}
|
||||
|
||||
func newAdmissionWebhookConfigurationAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newAdmissionWebhookConfigurationAction(logger logrus.FieldLogger) (any, error) {
|
||||
return ria.NewAdmissionWebhookConfigurationAction(logger), nil
|
||||
}
|
||||
|
||||
func newSecretRestoreItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -390,7 +390,7 @@ func newSecretRestoreItemAction(f client.Factory) plugincommon.HandlerInitialize
|
|||
}
|
||||
|
||||
func newDataUploadRetrieveAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -401,7 +401,7 @@ func newDataUploadRetrieveAction(f client.Factory) plugincommon.HandlerInitializ
|
|||
}
|
||||
|
||||
func newDateUploadDeleteItemAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
client, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -422,11 +422,11 @@ func newVolumeSnapshotBackupItemAction(f client.Factory) plugincommon.HandlerIni
|
|||
return csibia.NewVolumeSnapshotBackupItemAction(f)
|
||||
}
|
||||
|
||||
func newVolumeSnapshotContentBackupItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newVolumeSnapshotContentBackupItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return csibia.NewVolumeSnapshotContentBackupItemAction(logger)
|
||||
}
|
||||
|
||||
func newVolumeSnapshotClassBackupItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newVolumeSnapshotClassBackupItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return csibia.NewVolumeSnapshotClassBackupItemAction(logger)
|
||||
}
|
||||
|
||||
|
@ -450,11 +450,11 @@ func newVolumeSnapshotRestoreItemAction(f client.Factory) plugincommon.HandlerIn
|
|||
return csiria.NewVolumeSnapshotRestoreItemAction(f)
|
||||
}
|
||||
|
||||
func newVolumeSnapshotContentRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newVolumeSnapshotContentRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return csiria.NewVolumeSnapshotContentRestoreItemAction(logger)
|
||||
}
|
||||
|
||||
func newVolumeSnapshotClassRestoreItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newVolumeSnapshotClassRestoreItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return csiria.NewVolumeSnapshotClassRestoreItemAction(logger)
|
||||
}
|
||||
|
||||
|
@ -464,12 +464,12 @@ func newPVCItemBlockAction(f client.Factory) plugincommon.HandlerInitializer {
|
|||
return iba.NewPVCAction(f)
|
||||
}
|
||||
|
||||
func newPodItemBlockAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newPodItemBlockAction(logger logrus.FieldLogger) (any, error) {
|
||||
return iba.NewPodAction(logger), nil
|
||||
}
|
||||
|
||||
func newServiceAccountItemBlockAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
// TODO(ncdc): consider a k8s style WantsKubernetesClientSet initialization approach
|
||||
clientset, err := f.KubeClient()
|
||||
if err != nil {
|
||||
|
|
|
@ -74,11 +74,11 @@ func DescribeBackupInSF(
|
|||
|
||||
// DescribeBackupSpecInSF describes a backup spec in structured format.
|
||||
func DescribeBackupSpecInSF(d *StructuredDescriber, spec velerov1api.BackupSpec) {
|
||||
backupSpecInfo := make(map[string]interface{})
|
||||
backupSpecInfo := make(map[string]any)
|
||||
var s string
|
||||
|
||||
// describe namespaces
|
||||
namespaceInfo := make(map[string]interface{})
|
||||
namespaceInfo := make(map[string]any)
|
||||
if len(spec.IncludedNamespaces) == 0 {
|
||||
s = "*"
|
||||
} else {
|
||||
|
@ -140,10 +140,10 @@ func DescribeBackupSpecInSF(d *StructuredDescriber, spec velerov1api.BackupSpec)
|
|||
backupSpecInfo["CSISnapshotTimeout"] = spec.CSISnapshotTimeout.Duration.String()
|
||||
|
||||
// describe hooks
|
||||
hooksInfo := make(map[string]interface{})
|
||||
hooksResources := make(map[string]interface{})
|
||||
hooksInfo := make(map[string]any)
|
||||
hooksResources := make(map[string]any)
|
||||
for _, backupResourceHookSpec := range spec.Hooks.Resources {
|
||||
ResourceDetails := make(map[string]interface{})
|
||||
ResourceDetails := make(map[string]any)
|
||||
var s string
|
||||
namespaceInfo := make(map[string]string)
|
||||
if len(backupResourceHookSpec.IncludedNamespaces) == 0 {
|
||||
|
@ -181,10 +181,10 @@ func DescribeBackupSpecInSF(d *StructuredDescriber, spec velerov1api.BackupSpec)
|
|||
}
|
||||
ResourceDetails["labelSelector"] = s
|
||||
|
||||
preHooks := make([]map[string]interface{}, 0)
|
||||
preHooks := make([]map[string]any, 0)
|
||||
for _, hook := range backupResourceHookSpec.PreHooks {
|
||||
if hook.Exec != nil {
|
||||
preExecHook := make(map[string]interface{})
|
||||
preExecHook := make(map[string]any)
|
||||
preExecHook["container"] = hook.Exec.Container
|
||||
preExecHook["command"] = strings.Join(hook.Exec.Command, " ")
|
||||
preExecHook["onError:"] = hook.Exec.OnError
|
||||
|
@ -194,10 +194,10 @@ func DescribeBackupSpecInSF(d *StructuredDescriber, spec velerov1api.BackupSpec)
|
|||
}
|
||||
ResourceDetails["preExecHook"] = preHooks
|
||||
|
||||
postHooks := make([]map[string]interface{}, 0)
|
||||
postHooks := make([]map[string]any, 0)
|
||||
for _, hook := range backupResourceHookSpec.PostHooks {
|
||||
if hook.Exec != nil {
|
||||
postExecHook := make(map[string]interface{})
|
||||
postExecHook := make(map[string]any)
|
||||
postExecHook["container"] = hook.Exec.Container
|
||||
postExecHook["command"] = strings.Join(hook.Exec.Command, " ")
|
||||
postExecHook["onError:"] = hook.Exec.OnError
|
||||
|
@ -225,7 +225,7 @@ func DescribeBackupSpecInSF(d *StructuredDescriber, spec velerov1api.BackupSpec)
|
|||
func DescribeBackupStatusInSF(ctx context.Context, kbClient kbclient.Client, d *StructuredDescriber, backup *velerov1api.Backup, details bool,
|
||||
insecureSkipTLSVerify bool, caCertPath string, podVolumeBackups []velerov1api.PodVolumeBackup) {
|
||||
status := backup.Status
|
||||
backupStatusInfo := make(map[string]interface{})
|
||||
backupStatusInfo := make(map[string]any)
|
||||
|
||||
// Status.Version has been deprecated, use Status.FormatVersion
|
||||
backupStatusInfo["backupFormatVersion"] = status.FormatVersion
|
||||
|
@ -271,7 +271,7 @@ func DescribeBackupStatusInSF(ctx context.Context, kbClient kbclient.Client, d *
|
|||
}
|
||||
}
|
||||
|
||||
func describeBackupResourceListInSF(ctx context.Context, kbClient kbclient.Client, backupStatusInfo map[string]interface{}, backup *velerov1api.Backup, insecureSkipTLSVerify bool, caCertPath string) {
|
||||
func describeBackupResourceListInSF(ctx context.Context, kbClient kbclient.Client, backupStatusInfo map[string]any, backup *velerov1api.Backup, insecureSkipTLSVerify bool, caCertPath string) {
|
||||
// In consideration of decoding structured output conveniently, the two separate fields were created here(in func describeBackupResourceList, there is only one field describing either error message or resource list)
|
||||
// the field of 'errorGettingResourceList' gives specific error message when it fails to get resources list
|
||||
// the field of 'resourceList' lists the rearranged resources
|
||||
|
@ -299,8 +299,8 @@ func describeBackupResourceListInSF(ctx context.Context, kbClient kbclient.Clien
|
|||
}
|
||||
|
||||
func describeBackupVolumesInSF(ctx context.Context, kbClient kbclient.Client, backup *velerov1api.Backup, details bool,
|
||||
insecureSkipTLSVerify bool, caCertPath string, podVolumeBackupCRs []velerov1api.PodVolumeBackup, backupStatusInfo map[string]interface{}) {
|
||||
backupVolumes := make(map[string]interface{})
|
||||
insecureSkipTLSVerify bool, caCertPath string, podVolumeBackupCRs []velerov1api.PodVolumeBackup, backupStatusInfo map[string]any) {
|
||||
backupVolumes := make(map[string]any)
|
||||
|
||||
nativeSnapshots := []*volume.BackupVolumeInfo{}
|
||||
csiSnapshots := []*volume.BackupVolumeInfo{}
|
||||
|
@ -351,20 +351,20 @@ func describeBackupVolumesInSF(ctx context.Context, kbClient kbclient.Client, ba
|
|||
backupStatusInfo["backupVolumes"] = backupVolumes
|
||||
}
|
||||
|
||||
func describeNativeSnapshotsInSF(details bool, infos []*volume.BackupVolumeInfo, backupVolumes map[string]interface{}) {
|
||||
func describeNativeSnapshotsInSF(details bool, infos []*volume.BackupVolumeInfo, backupVolumes map[string]any) {
|
||||
if len(infos) == 0 {
|
||||
backupVolumes["nativeSnapshots"] = "<none included>"
|
||||
return
|
||||
}
|
||||
|
||||
snapshotDetails := make(map[string]interface{})
|
||||
snapshotDetails := make(map[string]any)
|
||||
for _, info := range infos {
|
||||
describNativeSnapshotInSF(details, info, snapshotDetails)
|
||||
}
|
||||
backupVolumes["nativeSnapshots"] = snapshotDetails
|
||||
}
|
||||
|
||||
func describNativeSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetails map[string]interface{}) {
|
||||
func describNativeSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetails map[string]any) {
|
||||
if details {
|
||||
snapshotInfo := make(map[string]string)
|
||||
snapshotInfo["snapshotID"] = info.NativeSnapshotInfo.SnapshotHandle
|
||||
|
@ -379,7 +379,7 @@ func describNativeSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snap
|
|||
}
|
||||
}
|
||||
|
||||
func describeCSISnapshotsInSF(details bool, infos []*volume.BackupVolumeInfo, backupVolumes map[string]interface{}, legacyInfoSource bool) {
|
||||
func describeCSISnapshotsInSF(details bool, infos []*volume.BackupVolumeInfo, backupVolumes map[string]any, legacyInfoSource bool) {
|
||||
if len(infos) == 0 {
|
||||
if legacyInfoSource {
|
||||
backupVolumes["csiSnapshots"] = "<none included or not detectable>"
|
||||
|
@ -389,15 +389,15 @@ func describeCSISnapshotsInSF(details bool, infos []*volume.BackupVolumeInfo, ba
|
|||
return
|
||||
}
|
||||
|
||||
snapshotDetails := make(map[string]interface{})
|
||||
snapshotDetails := make(map[string]any)
|
||||
for _, info := range infos {
|
||||
describeCSISnapshotInSF(details, info, snapshotDetails)
|
||||
}
|
||||
backupVolumes["csiSnapshots"] = snapshotDetails
|
||||
}
|
||||
|
||||
func describeCSISnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetails map[string]interface{}) {
|
||||
snapshotDetail := make(map[string]interface{})
|
||||
func describeCSISnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetails map[string]any) {
|
||||
snapshotDetail := make(map[string]any)
|
||||
|
||||
describeLocalSnapshotInSF(details, info, snapshotDetail)
|
||||
describeDataMovementInSF(details, info, snapshotDetail)
|
||||
|
@ -406,13 +406,13 @@ func describeCSISnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapsh
|
|||
}
|
||||
|
||||
// describeLocalSnapshotInSF describes CSI volume snapshot contents in structured format.
|
||||
func describeLocalSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetail map[string]interface{}) {
|
||||
func describeLocalSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetail map[string]any) {
|
||||
if !info.PreserveLocalSnapshot {
|
||||
return
|
||||
}
|
||||
|
||||
if details {
|
||||
localSnapshot := make(map[string]interface{})
|
||||
localSnapshot := make(map[string]any)
|
||||
|
||||
if !info.SnapshotDataMoved {
|
||||
localSnapshot["operationID"] = info.CSISnapshotInfo.OperationID
|
||||
|
@ -430,13 +430,13 @@ func describeLocalSnapshotInSF(details bool, info *volume.BackupVolumeInfo, snap
|
|||
}
|
||||
}
|
||||
|
||||
func describeDataMovementInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetail map[string]interface{}) {
|
||||
func describeDataMovementInSF(details bool, info *volume.BackupVolumeInfo, snapshotDetail map[string]any) {
|
||||
if !info.SnapshotDataMoved {
|
||||
return
|
||||
}
|
||||
|
||||
if details {
|
||||
dataMovement := make(map[string]interface{})
|
||||
dataMovement := make(map[string]any)
|
||||
dataMovement["operationID"] = info.SnapshotDataMovementInfo.OperationID
|
||||
|
||||
dataMover := "velero"
|
||||
|
@ -456,14 +456,14 @@ func describeDataMovementInSF(details bool, info *volume.BackupVolumeInfo, snaps
|
|||
|
||||
// DescribeDeleteBackupRequestsInSF describes delete backup requests in structured format.
|
||||
func DescribeDeleteBackupRequestsInSF(d *StructuredDescriber, requests []velerov1api.DeleteBackupRequest) {
|
||||
deletionAttempts := make(map[string]interface{})
|
||||
deletionAttempts := make(map[string]any)
|
||||
if count := failedDeletionCount(requests); count > 0 {
|
||||
deletionAttempts["failed"] = count
|
||||
}
|
||||
|
||||
deletionRequests := make([]map[string]interface{}, 0)
|
||||
deletionRequests := make([]map[string]any, 0)
|
||||
for _, req := range requests {
|
||||
deletionReq := make(map[string]interface{})
|
||||
deletionReq := make(map[string]any)
|
||||
deletionReq["creationTimestamp"] = req.CreationTimestamp.String()
|
||||
deletionReq["phase"] = req.Status.Phase
|
||||
|
||||
|
@ -477,8 +477,8 @@ func DescribeDeleteBackupRequestsInSF(d *StructuredDescriber, requests []velerov
|
|||
}
|
||||
|
||||
// describePodVolumeBackupsInSF describes pod volume backups in structured format.
|
||||
func describePodVolumeBackupsInSF(backups []velerov1api.PodVolumeBackup, details bool, backupVolumes map[string]interface{}) {
|
||||
podVolumeBackupsInfo := make(map[string]interface{})
|
||||
func describePodVolumeBackupsInSF(backups []velerov1api.PodVolumeBackup, details bool, backupVolumes map[string]any) {
|
||||
podVolumeBackupsInfo := make(map[string]any)
|
||||
// Get the type of pod volume uploader. Since the uploader only comes from a single source, we can
|
||||
// take the uploader type from the first element of the array.
|
||||
var uploaderType string
|
||||
|
@ -491,7 +491,7 @@ func describePodVolumeBackupsInSF(backups []velerov1api.PodVolumeBackup, details
|
|||
// type display the type of pod volume backups
|
||||
podVolumeBackupsInfo["uploderType"] = uploaderType
|
||||
|
||||
podVolumeBackupsDetails := make(map[string]interface{})
|
||||
podVolumeBackupsDetails := make(map[string]any)
|
||||
// separate backups by phase (combining <none> and New into a single group)
|
||||
backupsByPhase := groupByPhase(backups)
|
||||
|
||||
|
@ -537,7 +537,7 @@ func DescribeBackupResultsInSF(ctx context.Context, kbClient kbclient.Client, d
|
|||
var buf bytes.Buffer
|
||||
var resultMap map[string]results.Result
|
||||
|
||||
errors, warnings := make(map[string]interface{}), make(map[string]interface{})
|
||||
errors, warnings := make(map[string]any), make(map[string]any)
|
||||
defer func() {
|
||||
d.Describe("errors", errors)
|
||||
d.Describe("warnings", warnings)
|
||||
|
@ -572,13 +572,13 @@ func DescribeBackupResultsInSF(ctx context.Context, kbClient kbclient.Client, d
|
|||
|
||||
// DescribeResourcePoliciesInSF describes resource policies in structured format.
|
||||
func DescribeResourcePoliciesInSF(d *StructuredDescriber, resPolicies *v1.TypedLocalObjectReference) {
|
||||
policiesInfo := make(map[string]interface{})
|
||||
policiesInfo := make(map[string]any)
|
||||
policiesInfo["type"] = resPolicies.Kind
|
||||
policiesInfo["name"] = resPolicies.Name
|
||||
d.Describe("resourcePolicies", policiesInfo)
|
||||
}
|
||||
|
||||
func describeResultInSF(m map[string]interface{}, result results.Result) {
|
||||
func describeResultInSF(m map[string]any, result results.Result) {
|
||||
m["velero"], m["cluster"], m["namespace"] = []string{}, []string{}, []string{}
|
||||
|
||||
if len(result.Velero) > 0 {
|
||||
|
|
|
@ -33,7 +33,7 @@ import (
|
|||
|
||||
func TestDescribeBackupInSF(t *testing.T) {
|
||||
sd := &StructuredDescriber{
|
||||
output: make(map[string]interface{}),
|
||||
output: make(map[string]any),
|
||||
format: "",
|
||||
}
|
||||
backupBuilder1 := builder.ForBackup("test-ns", "test-backup")
|
||||
|
@ -75,9 +75,9 @@ func TestDescribeBackupInSF(t *testing.T) {
|
|||
},
|
||||
})
|
||||
|
||||
expect1 := map[string]interface{}{
|
||||
"spec": map[string]interface{}{
|
||||
"namespaces": map[string]interface{}{
|
||||
expect1 := map[string]any{
|
||||
"spec": map[string]any{
|
||||
"namespaces": map[string]any{
|
||||
"included": "inc-ns-1, inc-ns-2",
|
||||
"excluded": "exc-ns-1, exc-ns-2",
|
||||
},
|
||||
|
@ -93,15 +93,15 @@ func TestDescribeBackupInSF(t *testing.T) {
|
|||
"TTL": "72h0m0s",
|
||||
"CSISnapshotTimeout": "10m0s",
|
||||
"veleroSnapshotMoveData": "auto",
|
||||
"hooks": map[string]interface{}{
|
||||
"resources": map[string]interface{}{
|
||||
"hook-1": map[string]interface{}{
|
||||
"hooks": map[string]any{
|
||||
"resources": map[string]any{
|
||||
"hook-1": map[string]any{
|
||||
"labelSelector": emptyDisplay,
|
||||
"namespaces": map[string]string{
|
||||
"included": "hook-inc-ns-1, hook-inc-ns-2",
|
||||
"excluded": "hook-exc-ns-1, hook-exc-ns-2",
|
||||
},
|
||||
"preExecHook": []map[string]interface{}{
|
||||
"preExecHook": []map[string]any{
|
||||
{
|
||||
"container": "hook-container-1",
|
||||
"command": "pre",
|
||||
|
@ -109,7 +109,7 @@ func TestDescribeBackupInSF(t *testing.T) {
|
|||
"timeout": "0s",
|
||||
},
|
||||
},
|
||||
"postExecHook": []map[string]interface{}{
|
||||
"postExecHook": []map[string]any{
|
||||
{
|
||||
"container": "hook-container-1",
|
||||
"command": "post",
|
||||
|
@ -160,9 +160,9 @@ func TestDescribeBackupInSF(t *testing.T) {
|
|||
},
|
||||
})
|
||||
|
||||
expect2 := map[string]interface{}{
|
||||
"spec": map[string]interface{}{
|
||||
"namespaces": map[string]interface{}{
|
||||
expect2 := map[string]any{
|
||||
"spec": map[string]any{
|
||||
"namespaces": map[string]any{
|
||||
"included": "*",
|
||||
"excluded": emptyDisplay,
|
||||
},
|
||||
|
@ -178,15 +178,15 @@ func TestDescribeBackupInSF(t *testing.T) {
|
|||
"TTL": "0s",
|
||||
"CSISnapshotTimeout": "0s",
|
||||
"veleroSnapshotMoveData": "auto",
|
||||
"hooks": map[string]interface{}{
|
||||
"resources": map[string]interface{}{
|
||||
"hook-1": map[string]interface{}{
|
||||
"hooks": map[string]any{
|
||||
"resources": map[string]any{
|
||||
"hook-1": map[string]any{
|
||||
"labelSelector": emptyDisplay,
|
||||
"namespaces": map[string]string{
|
||||
"included": "*",
|
||||
"excluded": emptyDisplay,
|
||||
},
|
||||
"preExecHook": []map[string]interface{}{
|
||||
"preExecHook": []map[string]any{
|
||||
{
|
||||
"container": "hook-container-1",
|
||||
"command": "pre",
|
||||
|
@ -194,7 +194,7 @@ func TestDescribeBackupInSF(t *testing.T) {
|
|||
"timeout": "0s",
|
||||
},
|
||||
},
|
||||
"postExecHook": []map[string]interface{}{
|
||||
"postExecHook": []map[string]any{
|
||||
{
|
||||
"container": "hook-container-1",
|
||||
"command": "post",
|
||||
|
@ -244,21 +244,21 @@ func TestDescribePodVolumeBackupsInSF(t *testing.T) {
|
|||
name string
|
||||
inputPVBList []velerov1api.PodVolumeBackup
|
||||
inputDetails bool
|
||||
expect map[string]interface{}
|
||||
expect map[string]any
|
||||
}{
|
||||
{
|
||||
name: "empty list",
|
||||
inputPVBList: []velerov1api.PodVolumeBackup{},
|
||||
inputDetails: false,
|
||||
expect: map[string]interface{}{"podVolumeBackups": "<none included>"},
|
||||
expect: map[string]any{"podVolumeBackups": "<none included>"},
|
||||
},
|
||||
{
|
||||
name: "2 completed pvbs",
|
||||
inputPVBList: []velerov1api.PodVolumeBackup{*pvb1, *pvb2},
|
||||
inputDetails: true,
|
||||
expect: map[string]interface{}{
|
||||
"podVolumeBackups": map[string]interface{}{
|
||||
"podVolumeBackupsDetails": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"podVolumeBackups": map[string]any{
|
||||
"podVolumeBackupsDetails": map[string]any{
|
||||
"Completed": []map[string]string{
|
||||
{"pod-ns-1/pod-1": "vol-1"},
|
||||
{"pod-ns-1/pod-2": "vol-2"},
|
||||
|
@ -271,7 +271,7 @@ func TestDescribePodVolumeBackupsInSF(t *testing.T) {
|
|||
}
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(tt *testing.T) {
|
||||
output := make(map[string]interface{})
|
||||
output := make(map[string]any)
|
||||
describePodVolumeBackupsInSF(tc.inputPVBList, tc.inputDetails, output)
|
||||
assert.True(tt, reflect.DeepEqual(output, tc.expect))
|
||||
})
|
||||
|
@ -283,7 +283,7 @@ func TestDescribeNativeSnapshotsInSF(t *testing.T) {
|
|||
name string
|
||||
volumeInfo []*volume.BackupVolumeInfo
|
||||
inputDetails bool
|
||||
expect map[string]interface{}
|
||||
expect map[string]any
|
||||
}{
|
||||
{
|
||||
name: "no details",
|
||||
|
@ -299,8 +299,8 @@ func TestDescribeNativeSnapshotsInSF(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
expect: map[string]interface{}{
|
||||
"nativeSnapshots": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"nativeSnapshots": map[string]any{
|
||||
"pv-1": "specify --details for more information",
|
||||
},
|
||||
},
|
||||
|
@ -321,8 +321,8 @@ func TestDescribeNativeSnapshotsInSF(t *testing.T) {
|
|||
},
|
||||
},
|
||||
inputDetails: true,
|
||||
expect: map[string]interface{}{
|
||||
"nativeSnapshots": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"nativeSnapshots": map[string]any{
|
||||
"pv-1": map[string]string{
|
||||
"snapshotID": "snapshot-1",
|
||||
"type": "ebs",
|
||||
|
@ -337,7 +337,7 @@ func TestDescribeNativeSnapshotsInSF(t *testing.T) {
|
|||
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(tt *testing.T) {
|
||||
output := make(map[string]interface{})
|
||||
output := make(map[string]any)
|
||||
describeNativeSnapshotsInSF(tc.inputDetails, tc.volumeInfo, output)
|
||||
assert.True(tt, reflect.DeepEqual(output, tc.expect))
|
||||
})
|
||||
|
@ -349,13 +349,13 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
|||
name string
|
||||
volumeInfo []*volume.BackupVolumeInfo
|
||||
inputDetails bool
|
||||
expect map[string]interface{}
|
||||
expect map[string]any
|
||||
legacyInfoSource bool
|
||||
}{
|
||||
{
|
||||
name: "empty info, not legacy",
|
||||
volumeInfo: []*volume.BackupVolumeInfo{},
|
||||
expect: map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": "<none included>",
|
||||
},
|
||||
},
|
||||
|
@ -363,7 +363,7 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
|||
name: "empty info, legacy",
|
||||
volumeInfo: []*volume.BackupVolumeInfo{},
|
||||
legacyInfoSource: true,
|
||||
expect: map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": "<none included or not detectable>",
|
||||
},
|
||||
},
|
||||
|
@ -384,9 +384,9 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
expect: map[string]interface{}{
|
||||
"csiSnapshots": map[string]interface{}{
|
||||
"pvc-ns-1/pvc-1": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": map[string]any{
|
||||
"pvc-ns-1/pvc-1": map[string]any{
|
||||
"snapshot": "included, specify --details for more information",
|
||||
},
|
||||
},
|
||||
|
@ -411,10 +411,10 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
|||
},
|
||||
},
|
||||
inputDetails: true,
|
||||
expect: map[string]interface{}{
|
||||
"csiSnapshots": map[string]interface{}{
|
||||
"pvc-ns-2/pvc-2": map[string]interface{}{
|
||||
"snapshot": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": map[string]any{
|
||||
"pvc-ns-2/pvc-2": map[string]any{
|
||||
"snapshot": map[string]any{
|
||||
"operationID": "fake-operation-2",
|
||||
"snapshotContentName": "vsc-2",
|
||||
"storageSnapshotID": "snapshot-2",
|
||||
|
@ -442,9 +442,9 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
expect: map[string]interface{}{
|
||||
"csiSnapshots": map[string]interface{}{
|
||||
"pvc-ns-3/pvc-3": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": map[string]any{
|
||||
"pvc-ns-3/pvc-3": map[string]any{
|
||||
"dataMovement": "included, specify --details for more information",
|
||||
},
|
||||
},
|
||||
|
@ -468,10 +468,10 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
|||
},
|
||||
},
|
||||
inputDetails: true,
|
||||
expect: map[string]interface{}{
|
||||
"csiSnapshots": map[string]interface{}{
|
||||
"pvc-ns-4/pvc-4": map[string]interface{}{
|
||||
"dataMovement": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": map[string]any{
|
||||
"pvc-ns-4/pvc-4": map[string]any{
|
||||
"dataMovement": map[string]any{
|
||||
"operationID": "fake-operation-4",
|
||||
"dataMover": "velero",
|
||||
"uploaderType": "fake-uploader",
|
||||
|
@ -498,10 +498,10 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
|||
},
|
||||
},
|
||||
inputDetails: true,
|
||||
expect: map[string]interface{}{
|
||||
"csiSnapshots": map[string]interface{}{
|
||||
"pvc-ns-4/pvc-4": map[string]interface{}{
|
||||
"dataMovement": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"csiSnapshots": map[string]any{
|
||||
"pvc-ns-4/pvc-4": map[string]any{
|
||||
"dataMovement": map[string]any{
|
||||
"operationID": "fake-operation-4",
|
||||
"dataMover": "velero",
|
||||
"uploaderType": "fake-uploader",
|
||||
|
@ -515,7 +515,7 @@ func TestDescribeCSISnapshotsInSF(t *testing.T) {
|
|||
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(tt *testing.T) {
|
||||
output := make(map[string]interface{})
|
||||
output := make(map[string]any)
|
||||
describeCSISnapshotsInSF(tc.inputDetails, tc.volumeInfo, output, tc.legacyInfoSource)
|
||||
assert.True(tt, reflect.DeepEqual(output, tc.expect))
|
||||
})
|
||||
|
@ -527,14 +527,14 @@ func TestDescribeResourcePoliciesInSF(t *testing.T) {
|
|||
Kind: "configmap",
|
||||
Name: "resource-policy-1",
|
||||
}
|
||||
expect := map[string]interface{}{
|
||||
"resourcePolicies": map[string]interface{}{
|
||||
expect := map[string]any{
|
||||
"resourcePolicies": map[string]any{
|
||||
"type": "configmap",
|
||||
"name": "resource-policy-1",
|
||||
},
|
||||
}
|
||||
sd := &StructuredDescriber{
|
||||
output: make(map[string]interface{}),
|
||||
output: make(map[string]any),
|
||||
format: "",
|
||||
}
|
||||
DescribeResourcePoliciesInSF(sd, input)
|
||||
|
@ -549,8 +549,8 @@ func TestDescribeBackupResultInSF(t *testing.T) {
|
|||
"ns-1": {"ns-1-msg-1", "ns-1-msg-2"},
|
||||
},
|
||||
}
|
||||
got := map[string]interface{}{}
|
||||
expect := map[string]interface{}{
|
||||
got := map[string]any{}
|
||||
expect := map[string]any{
|
||||
"velero": []string{"msg-1", "msg-2"},
|
||||
"cluster": []string{"cluster-1", "cluster-2"},
|
||||
"namespace": map[string][]string{
|
||||
|
@ -579,24 +579,24 @@ func TestDescribeDeleteBackupRequestsInSF(t *testing.T) {
|
|||
testcases := []struct {
|
||||
name string
|
||||
input []velerov1api.DeleteBackupRequest
|
||||
expect map[string]interface{}
|
||||
expect map[string]any
|
||||
}{
|
||||
{
|
||||
name: "empty list",
|
||||
input: []velerov1api.DeleteBackupRequest{},
|
||||
expect: map[string]interface{}{
|
||||
"deletionAttempts": map[string]interface{}{
|
||||
"deleteBackupRequests": []map[string]interface{}{},
|
||||
expect: map[string]any{
|
||||
"deletionAttempts": map[string]any{
|
||||
"deleteBackupRequests": []map[string]any{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "list with one failed and one in-progress request",
|
||||
input: []velerov1api.DeleteBackupRequest{*dbr1, *dbr2},
|
||||
expect: map[string]interface{}{
|
||||
"deletionAttempts": map[string]interface{}{
|
||||
expect: map[string]any{
|
||||
"deletionAttempts": map[string]any{
|
||||
"failed": int(1),
|
||||
"deleteBackupRequests": []map[string]interface{}{
|
||||
"deleteBackupRequests": []map[string]any{
|
||||
{
|
||||
"creationTimestamp": t1.String(),
|
||||
"phase": velerov1api.DeleteBackupRequestPhaseProcessed,
|
||||
|
@ -616,7 +616,7 @@ func TestDescribeDeleteBackupRequestsInSF(t *testing.T) {
|
|||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(tt *testing.T) {
|
||||
sd := &StructuredDescriber{
|
||||
output: make(map[string]interface{}),
|
||||
output: make(map[string]any),
|
||||
format: "",
|
||||
}
|
||||
DescribeDeleteBackupRequestsInSF(sd, tc.input)
|
||||
|
|
|
@ -47,12 +47,12 @@ func Describe(fn func(d *Describer)) string {
|
|||
return d.buf.String()
|
||||
}
|
||||
|
||||
func (d *Describer) Printf(msg string, args ...interface{}) {
|
||||
func (d *Describer) Printf(msg string, args ...any) {
|
||||
fmt.Fprint(d.out, d.Prefix)
|
||||
fmt.Fprintf(d.out, msg, args...)
|
||||
}
|
||||
|
||||
func (d *Describer) Println(args ...interface{}) {
|
||||
func (d *Describer) Println(args ...any) {
|
||||
fmt.Fprint(d.out, d.Prefix)
|
||||
fmt.Fprintln(d.out, args...)
|
||||
}
|
||||
|
@ -122,14 +122,14 @@ func BoolPointerString(b *bool, falseString, trueString, nilString string) strin
|
|||
}
|
||||
|
||||
type StructuredDescriber struct {
|
||||
output map[string]interface{}
|
||||
output map[string]any
|
||||
format string
|
||||
}
|
||||
|
||||
// NewStructuredDescriber creates a StructuredDescriber.
|
||||
func NewStructuredDescriber(format string) *StructuredDescriber {
|
||||
return &StructuredDescriber{
|
||||
output: make(map[string]interface{}),
|
||||
output: make(map[string]any),
|
||||
format: format,
|
||||
}
|
||||
}
|
||||
|
@ -144,13 +144,13 @@ func DescribeInSF(fn func(d *StructuredDescriber), format string) string {
|
|||
}
|
||||
|
||||
// Describe adds all types of argument to d.output.
|
||||
func (d *StructuredDescriber) Describe(name string, arg interface{}) {
|
||||
func (d *StructuredDescriber) Describe(name string, arg any) {
|
||||
d.output[name] = arg
|
||||
}
|
||||
|
||||
// DescribeMetadata describes standard object metadata.
|
||||
func (d *StructuredDescriber) DescribeMetadata(metadata metav1.ObjectMeta) {
|
||||
metadataInfo := make(map[string]interface{})
|
||||
metadataInfo := make(map[string]any)
|
||||
metadataInfo["name"] = metadata.Name
|
||||
metadataInfo["namespace"] = metadata.Namespace
|
||||
metadataInfo["labels"] = metadata.Labels
|
||||
|
|
|
@ -106,17 +106,17 @@ func TestDescriber_DescribeSlice(t *testing.T) {
|
|||
func TestStructuredDescriber_JSONEncode(t *testing.T) {
|
||||
testcases := []struct {
|
||||
name string
|
||||
inputMap map[string]interface{}
|
||||
inputMap map[string]any
|
||||
expect string
|
||||
}{
|
||||
{
|
||||
name: "invalid json",
|
||||
inputMap: map[string]interface{}{},
|
||||
inputMap: map[string]any{},
|
||||
expect: "{}\n",
|
||||
},
|
||||
{
|
||||
name: "valid json",
|
||||
inputMap: map[string]interface{}{"k1": "v1"},
|
||||
inputMap: map[string]any{"k1": "v1"},
|
||||
expect: `{
|
||||
"k1": "v1"
|
||||
}
|
||||
|
@ -148,8 +148,8 @@ func TestStructuredDescriber_DescribeMetadata(t *testing.T) {
|
|||
"annotation-2": "v2",
|
||||
},
|
||||
}
|
||||
expect := map[string]interface{}{
|
||||
"metadata": map[string]interface{}{
|
||||
expect := map[string]any{
|
||||
"metadata": map[string]any{
|
||||
"name": "test",
|
||||
"namespace": "test-ns",
|
||||
"labels": map[string]string{
|
||||
|
|
|
@ -548,7 +548,7 @@ func getBackupRepositoryConfig(ctx context.Context, ctrlClient client.Client, co
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
var unmarshalled map[string]interface{}
|
||||
var unmarshalled map[string]any
|
||||
if err := json.Unmarshal([]byte(jsonData), &unmarshalled); err != nil {
|
||||
return nil, errors.Wrapf(err, "error unmarshalling config data from %s for repo %s, repo type %s", configName, repoName, repoType)
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ import (
|
|||
|
||||
const testMaintenanceFrequency = 10 * time.Minute
|
||||
|
||||
func mockBackupRepoReconciler(t *testing.T, mockOn string, arg interface{}, ret ...interface{}) *BackupRepoReconciler {
|
||||
func mockBackupRepoReconciler(t *testing.T, mockOn string, arg any, ret ...any) *BackupRepoReconciler {
|
||||
t.Helper()
|
||||
mgr := &repomokes.Manager{}
|
||||
if mockOn != "" {
|
||||
|
|
|
@ -796,7 +796,7 @@ func (r *DataUploadReconciler) closeDataPath(ctx context.Context, duName string)
|
|||
r.dataPathMgr.RemoveAsyncBR(duName)
|
||||
}
|
||||
|
||||
func (r *DataUploadReconciler) setupExposeParam(du *velerov2alpha1api.DataUpload) (interface{}, error) {
|
||||
func (r *DataUploadReconciler) setupExposeParam(du *velerov2alpha1api.DataUpload) (any, error) {
|
||||
log := r.logger.WithField("dataupload", du.Name)
|
||||
|
||||
if du.Spec.SnapshotType == velerov2alpha1api.SnapshotTypeCSI {
|
||||
|
@ -854,7 +854,7 @@ func (r *DataUploadReconciler) setupExposeParam(du *velerov2alpha1api.DataUpload
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func (r *DataUploadReconciler) setupWaitExposePara(du *velerov2alpha1api.DataUpload) interface{} {
|
||||
func (r *DataUploadReconciler) setupWaitExposePara(du *velerov2alpha1api.DataUpload) any {
|
||||
if du.Spec.SnapshotType == velerov2alpha1api.SnapshotTypeCSI {
|
||||
return &exposer.CSISnapshotExposeWaitParam{
|
||||
NodeClient: r.client,
|
||||
|
|
|
@ -272,7 +272,7 @@ type fakeSnapshotExposer struct {
|
|||
peekErr error
|
||||
}
|
||||
|
||||
func (f *fakeSnapshotExposer) Expose(ctx context.Context, ownerObject corev1.ObjectReference, param interface{}) error {
|
||||
func (f *fakeSnapshotExposer) Expose(ctx context.Context, ownerObject corev1.ObjectReference, param any) error {
|
||||
du := velerov2alpha1api.DataUpload{}
|
||||
err := f.kubeClient.Get(ctx, kbclient.ObjectKey{
|
||||
Name: dataUploadName,
|
||||
|
@ -289,7 +289,7 @@ func (f *fakeSnapshotExposer) Expose(ctx context.Context, ownerObject corev1.Obj
|
|||
return nil
|
||||
}
|
||||
|
||||
func (f *fakeSnapshotExposer) GetExposed(ctx context.Context, du corev1.ObjectReference, tm time.Duration, para interface{}) (*exposer.ExposeResult, error) {
|
||||
func (f *fakeSnapshotExposer) GetExposed(ctx context.Context, du corev1.ObjectReference, tm time.Duration, para any) (*exposer.ExposeResult, error) {
|
||||
pod := &corev1.Pod{}
|
||||
err := f.kubeClient.Get(ctx, kbclient.ObjectKey{
|
||||
Name: dataUploadName,
|
||||
|
@ -326,11 +326,11 @@ type fakeDataUploadFSBR struct {
|
|||
startErr error
|
||||
}
|
||||
|
||||
func (f *fakeDataUploadFSBR) Init(ctx context.Context, param interface{}) error {
|
||||
func (f *fakeDataUploadFSBR) Init(ctx context.Context, param any) error {
|
||||
return f.initErr
|
||||
}
|
||||
|
||||
func (f *fakeDataUploadFSBR) StartBackup(source datapath.AccessPoint, uploaderConfigs map[string]string, param interface{}) error {
|
||||
func (f *fakeDataUploadFSBR) StartBackup(source datapath.AccessPoint, uploaderConfigs map[string]string, param any) error {
|
||||
return f.startErr
|
||||
}
|
||||
|
||||
|
@ -1087,11 +1087,11 @@ func (dt *duResumeTestHelper) resumeCancellableDataPath(_ *DataUploadReconciler,
|
|||
return dt.resumeErr
|
||||
}
|
||||
|
||||
func (dt *duResumeTestHelper) Expose(context.Context, corev1.ObjectReference, interface{}) error {
|
||||
func (dt *duResumeTestHelper) Expose(context.Context, corev1.ObjectReference, any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dt *duResumeTestHelper) GetExposed(context.Context, corev1.ObjectReference, time.Duration, interface{}) (*exposer.ExposeResult, error) {
|
||||
func (dt *duResumeTestHelper) GetExposed(context.Context, corev1.ObjectReference, time.Duration, any) (*exposer.ExposeResult, error) {
|
||||
return dt.exposeResult, dt.getExposeErr
|
||||
}
|
||||
|
||||
|
|
|
@ -348,7 +348,7 @@ func (r *PodVolumeBackupReconciler) getParentSnapshot(ctx context.Context, log l
|
|||
return ""
|
||||
}
|
||||
|
||||
log.WithFields(map[string]interface{}{
|
||||
log.WithFields(map[string]any{
|
||||
"parentPodVolumeBackup": mostRecentPVB.Name,
|
||||
"parentSnapshotID": mostRecentPVB.Status.SnapshotID,
|
||||
}).Info("Found most recent completed PodVolumeBackup for PVC")
|
||||
|
|
|
@ -97,11 +97,11 @@ type fakeFSBR struct {
|
|||
clock clock.WithTickerAndDelayedExecution
|
||||
}
|
||||
|
||||
func (b *fakeFSBR) Init(ctx context.Context, param interface{}) error {
|
||||
func (b *fakeFSBR) Init(ctx context.Context, param any) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *fakeFSBR) StartBackup(source datapath.AccessPoint, uploaderConfigs map[string]string, param interface{}) error {
|
||||
func (b *fakeFSBR) StartBackup(source datapath.AccessPoint, uploaderConfigs map[string]string, param any) error {
|
||||
pvb := b.pvb
|
||||
|
||||
original := b.pvb.DeepCopy()
|
||||
|
|
|
@ -99,7 +99,7 @@ func (r *BackupMicroService) Init() error {
|
|||
|
||||
handler, err := r.duInformer.AddEventHandler(
|
||||
cachetool.ResourceEventHandlerFuncs{
|
||||
UpdateFunc: func(oldObj interface{}, newObj interface{}) {
|
||||
UpdateFunc: func(oldObj any, newObj any) {
|
||||
oldDu := oldObj.(*velerov2alpha1api.DataUpload)
|
||||
newDu := newObj.(*velerov2alpha1api.DataUpload)
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ func (r *RestoreMicroService) Init() error {
|
|||
|
||||
handler, err := r.ddInformer.AddEventHandler(
|
||||
cachetool.ResourceEventHandlerFuncs{
|
||||
UpdateFunc: func(oldObj interface{}, newObj interface{}) {
|
||||
UpdateFunc: func(oldObj any, newObj any) {
|
||||
oldDd := oldObj.(*velerov2alpha1api.DataDownload)
|
||||
newDd := newObj.(*velerov2alpha1api.DataDownload)
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ func newFileSystemBR(jobName string, requestorType string, client client.Client,
|
|||
return fs
|
||||
}
|
||||
|
||||
func (fs *fileSystemBR) Init(ctx context.Context, param interface{}) error {
|
||||
func (fs *fileSystemBR) Init(ctx context.Context, param any) error {
|
||||
initParam := param.(*FSBRInitParam)
|
||||
|
||||
var err error
|
||||
|
@ -164,7 +164,7 @@ func (fs *fileSystemBR) close(ctx context.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
func (fs *fileSystemBR) StartBackup(source AccessPoint, uploaderConfig map[string]string, param interface{}) error {
|
||||
func (fs *fileSystemBR) StartBackup(source AccessPoint, uploaderConfig map[string]string, param any) error {
|
||||
if !fs.initialized {
|
||||
return errors.New("file system data path is not initialized")
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ func newMicroServiceBRWatcher(client client.Client, kubeClient kubernetes.Interf
|
|||
return ms
|
||||
}
|
||||
|
||||
func (ms *microServiceBRWatcher) Init(ctx context.Context, param interface{}) error {
|
||||
func (ms *microServiceBRWatcher) Init(ctx context.Context, param any) error {
|
||||
eventInformer, err := ms.mgr.GetCache().GetInformer(ctx, &v1.Event{})
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting event informer")
|
||||
|
@ -117,7 +117,7 @@ func (ms *microServiceBRWatcher) Init(ctx context.Context, param interface{}) er
|
|||
|
||||
eventHandler, err := eventInformer.AddEventHandler(
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
AddFunc: func(obj interface{}) {
|
||||
AddFunc: func(obj any) {
|
||||
evt := obj.(*v1.Event)
|
||||
if evt.InvolvedObject.Namespace != ms.namespace || evt.InvolvedObject.Name != ms.associatedObject {
|
||||
return
|
||||
|
@ -125,7 +125,7 @@ func (ms *microServiceBRWatcher) Init(ctx context.Context, param interface{}) er
|
|||
|
||||
ms.eventCh <- evt
|
||||
},
|
||||
UpdateFunc: func(_, obj interface{}) {
|
||||
UpdateFunc: func(_, obj any) {
|
||||
evt := obj.(*v1.Event)
|
||||
if evt.InvolvedObject.Namespace != ms.namespace || evt.InvolvedObject.Name != ms.associatedObject {
|
||||
return
|
||||
|
@ -141,7 +141,7 @@ func (ms *microServiceBRWatcher) Init(ctx context.Context, param interface{}) er
|
|||
|
||||
podHandler, err := podInformer.AddEventHandler(
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
UpdateFunc: func(_, obj interface{}) {
|
||||
UpdateFunc: func(_, obj any) {
|
||||
pod := obj.(*v1.Pod)
|
||||
if pod.Namespace != ms.namespace || pod.Name != ms.thisPod {
|
||||
return
|
||||
|
@ -213,7 +213,7 @@ func (ms *microServiceBRWatcher) close() {
|
|||
}
|
||||
}
|
||||
|
||||
func (ms *microServiceBRWatcher) StartBackup(source AccessPoint, uploaderConfig map[string]string, param interface{}) error {
|
||||
func (ms *microServiceBRWatcher) StartBackup(source AccessPoint, uploaderConfig map[string]string, param any) error {
|
||||
ms.log.Infof("Start watching backup ms for source %v", source.ByPath)
|
||||
|
||||
ms.startWatch()
|
||||
|
|
|
@ -59,10 +59,10 @@ type AccessPoint struct {
|
|||
// AsyncBR is the interface for asynchronous data path methods
|
||||
type AsyncBR interface {
|
||||
// Init initializes an asynchronous data path instance
|
||||
Init(ctx context.Context, param interface{}) error
|
||||
Init(ctx context.Context, param any) error
|
||||
|
||||
// StartBackup starts an asynchronous data path instance for backup
|
||||
StartBackup(source AccessPoint, dataMoverConfig map[string]string, param interface{}) error
|
||||
StartBackup(source AccessPoint, dataMoverConfig map[string]string, param any) error
|
||||
|
||||
// StartRestore starts an asynchronous data path instance for restore
|
||||
StartRestore(snapshotID string, target AccessPoint, dataMoverConfig map[string]string) error
|
||||
|
|
|
@ -100,7 +100,7 @@ type csiSnapshotExposer struct {
|
|||
log logrus.FieldLogger
|
||||
}
|
||||
|
||||
func (e *csiSnapshotExposer) Expose(ctx context.Context, ownerObject corev1.ObjectReference, param interface{}) error {
|
||||
func (e *csiSnapshotExposer) Expose(ctx context.Context, ownerObject corev1.ObjectReference, param any) error {
|
||||
csiExposeParam := param.(*CSISnapshotExposeParam)
|
||||
|
||||
curLog := e.log.WithFields(logrus.Fields{
|
||||
|
@ -232,7 +232,7 @@ func (e *csiSnapshotExposer) Expose(ctx context.Context, ownerObject corev1.Obje
|
|||
return nil
|
||||
}
|
||||
|
||||
func (e *csiSnapshotExposer) GetExposed(ctx context.Context, ownerObject corev1.ObjectReference, timeout time.Duration, param interface{}) (*ExposeResult, error) {
|
||||
func (e *csiSnapshotExposer) GetExposed(ctx context.Context, ownerObject corev1.ObjectReference, timeout time.Duration, param any) (*ExposeResult, error) {
|
||||
exposeWaitParam := param.(*CSISnapshotExposeWaitParam)
|
||||
|
||||
backupPodName := ownerObject.Name
|
||||
|
|
|
@ -26,11 +26,11 @@ import (
|
|||
// SnapshotExposer is the interfaces for a snapshot exposer
|
||||
type SnapshotExposer interface {
|
||||
// Expose starts the process to expose a snapshot, the expose process may take long time
|
||||
Expose(context.Context, corev1.ObjectReference, interface{}) error
|
||||
Expose(context.Context, corev1.ObjectReference, any) error
|
||||
// GetExposed polls the status of the expose.
|
||||
// If the expose is accessible by the current caller, it waits the expose ready and returns the expose result.
|
||||
// Otherwise, it returns nil as the expose result without an error.
|
||||
GetExposed(context.Context, corev1.ObjectReference, time.Duration, interface{}) (*ExposeResult, error)
|
||||
GetExposed(context.Context, corev1.ObjectReference, time.Duration, any) (*ExposeResult, error)
|
||||
|
||||
// PeekExposed tests the status of the expose.
|
||||
// If the expose is incomplete but not recoverable, it returns an error.
|
||||
|
|
|
@ -284,7 +284,7 @@ func createResource(r *unstructured.Unstructured, factory client.DynamicFactory,
|
|||
id := fmt.Sprintf("%s/%s", r.GetKind(), r.GetName())
|
||||
|
||||
// Helper to reduce boilerplate message about the same object
|
||||
log := func(f string, a ...interface{}) {
|
||||
log := func(f string, a ...any) {
|
||||
format := strings.Join([]string{id, ": ", f, "\n"}, "")
|
||||
fmt.Fprintf(w, format, a...)
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ func CreateClient(r *unstructured.Unstructured, factory client.DynamicFactory, w
|
|||
id := fmt.Sprintf("%s/%s", r.GetKind(), r.GetName())
|
||||
|
||||
// Helper to reduce boilerplate message about the same object
|
||||
log := func(f string, a ...interface{}) {
|
||||
log := func(f string, a ...any) {
|
||||
format := strings.Join([]string{id, ": ", f, "\n"}, "")
|
||||
fmt.Fprintf(w, format, a...)
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ type PVCAction struct {
|
|||
}
|
||||
|
||||
func NewPVCAction(f client.Factory) plugincommon.HandlerInitializer {
|
||||
return func(logger logrus.FieldLogger) (interface{}, error) {
|
||||
return func(logger logrus.FieldLogger) (any, error) {
|
||||
crClient, err := f.KubebuilderClient()
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
|
|
|
@ -187,7 +187,7 @@ func (b *objectBackupStoreGetter) Get(location *velerov1api.BackupStorageLocatio
|
|||
return nil, err
|
||||
}
|
||||
|
||||
log := logger.WithFields(logrus.Fields(map[string]interface{}{
|
||||
log := logger.WithFields(logrus.Fields(map[string]any{
|
||||
"bucket": bucket,
|
||||
"prefix": prefix,
|
||||
}))
|
||||
|
@ -410,7 +410,7 @@ func tryGet(objectStore velero.ObjectStore, bucket, key string) (io.ReadCloser,
|
|||
|
||||
// decode extracts a .json.gz file reader into the object pointed to
|
||||
// by 'into'.
|
||||
func decode(jsongzReader io.Reader, into interface{}) error {
|
||||
func decode(jsongzReader io.Reader, into any) error {
|
||||
gzr, err := gzip.NewReader(jsongzReader)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
|
|
|
@ -36,7 +36,7 @@ import (
|
|||
func TestRestartableGetBackupItemAction(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
plugin interface{}
|
||||
plugin any
|
||||
getError error
|
||||
expectedError string
|
||||
}{
|
||||
|
@ -105,13 +105,13 @@ func TestRestartableBackupItemActionDelegatedFunctions(t *testing.T) {
|
|||
b := new(v1.Backup)
|
||||
|
||||
pv := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "blue",
|
||||
},
|
||||
}
|
||||
|
||||
pvToReturn := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "green",
|
||||
},
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ func TestRestartableBackupItemActionDelegatedFunctions(t *testing.T) {
|
|||
restartabletest.RunRestartableDelegateTests(
|
||||
t,
|
||||
common.PluginKindBackupItemAction,
|
||||
func(key process.KindAndName, p process.RestartableProcess) interface{} {
|
||||
func(key process.KindAndName, p process.RestartableProcess) any {
|
||||
return &RestartableBackupItemAction{
|
||||
Key: key,
|
||||
SharedPluginProcess: p,
|
||||
|
@ -136,15 +136,15 @@ func TestRestartableBackupItemActionDelegatedFunctions(t *testing.T) {
|
|||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "AppliesTo",
|
||||
Inputs: []interface{}{},
|
||||
ExpectedErrorOutputs: []interface{}{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
Inputs: []any{},
|
||||
ExpectedErrorOutputs: []any{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "Execute",
|
||||
Inputs: []interface{}{pv, b},
|
||||
ExpectedErrorOutputs: []interface{}{nil, ([]velero.ResourceIdentifier)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{pvToReturn, additionalItems, errors.Errorf("delegate error")},
|
||||
Inputs: []any{pv, b},
|
||||
ExpectedErrorOutputs: []any{nil, ([]velero.ResourceIdentifier)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{pvToReturn, additionalItems, errors.Errorf("delegate error")},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import (
|
|||
func TestRestartableGetBackupItemAction(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
plugin interface{}
|
||||
plugin any
|
||||
getError error
|
||||
expectedError string
|
||||
}{
|
||||
|
@ -105,7 +105,7 @@ func TestRestartableBackupItemActionDelegatedFunctions(t *testing.T) {
|
|||
b := new(v1.Backup)
|
||||
|
||||
pv := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "blue",
|
||||
},
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ func TestRestartableBackupItemActionDelegatedFunctions(t *testing.T) {
|
|||
oid := "operation1"
|
||||
|
||||
pvToReturn := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "green",
|
||||
},
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ func TestRestartableBackupItemActionDelegatedFunctions(t *testing.T) {
|
|||
restartabletest.RunRestartableDelegateTests(
|
||||
t,
|
||||
common.PluginKindBackupItemAction,
|
||||
func(key process.KindAndName, p process.RestartableProcess) interface{} {
|
||||
func(key process.KindAndName, p process.RestartableProcess) any {
|
||||
return &RestartableBackupItemAction{
|
||||
Key: key,
|
||||
SharedPluginProcess: p,
|
||||
|
@ -138,27 +138,27 @@ func TestRestartableBackupItemActionDelegatedFunctions(t *testing.T) {
|
|||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "AppliesTo",
|
||||
Inputs: []interface{}{},
|
||||
ExpectedErrorOutputs: []interface{}{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
Inputs: []any{},
|
||||
ExpectedErrorOutputs: []any{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "Execute",
|
||||
Inputs: []interface{}{pv, b},
|
||||
ExpectedErrorOutputs: []interface{}{nil, ([]velero.ResourceIdentifier)(nil), "", ([]velero.ResourceIdentifier)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{pvToReturn, additionalItems, "", ([]velero.ResourceIdentifier)(nil), errors.Errorf("delegate error")},
|
||||
Inputs: []any{pv, b},
|
||||
ExpectedErrorOutputs: []any{nil, ([]velero.ResourceIdentifier)(nil), "", ([]velero.ResourceIdentifier)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{pvToReturn, additionalItems, "", ([]velero.ResourceIdentifier)(nil), errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "Progress",
|
||||
Inputs: []interface{}{oid, b},
|
||||
ExpectedErrorOutputs: []interface{}{velero.OperationProgress{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{velero.OperationProgress{}, errors.Errorf("delegate error")},
|
||||
Inputs: []any{oid, b},
|
||||
ExpectedErrorOutputs: []any{velero.OperationProgress{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{velero.OperationProgress{}, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "Cancel",
|
||||
Inputs: []interface{}{oid, b},
|
||||
ExpectedErrorOutputs: []interface{}{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{errors.Errorf("delegate error")},
|
||||
Inputs: []any{oid, b},
|
||||
ExpectedErrorOutputs: []any{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{errors.Errorf("delegate error")},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ import (
|
|||
func TestRestartableGetItemBlockAction(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
plugin interface{}
|
||||
plugin any
|
||||
getError error
|
||||
expectedError string
|
||||
}{
|
||||
|
@ -105,7 +105,7 @@ func TestRestartableItemBlockActionDelegatedFunctions(t *testing.T) {
|
|||
b := new(v1.Backup)
|
||||
|
||||
pv := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "blue",
|
||||
},
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ func TestRestartableItemBlockActionDelegatedFunctions(t *testing.T) {
|
|||
restartabletest.RunRestartableDelegateTests(
|
||||
t,
|
||||
common.PluginKindItemBlockAction,
|
||||
func(key process.KindAndName, p process.RestartableProcess) interface{} {
|
||||
func(key process.KindAndName, p process.RestartableProcess) any {
|
||||
return &RestartableItemBlockAction{
|
||||
Key: key,
|
||||
SharedPluginProcess: p,
|
||||
|
@ -130,15 +130,15 @@ func TestRestartableItemBlockActionDelegatedFunctions(t *testing.T) {
|
|||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "AppliesTo",
|
||||
Inputs: []interface{}{},
|
||||
ExpectedErrorOutputs: []interface{}{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
Inputs: []any{},
|
||||
ExpectedErrorOutputs: []any{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "GetRelatedItems",
|
||||
Inputs: []interface{}{pv, b},
|
||||
ExpectedErrorOutputs: []interface{}{([]velero.ResourceIdentifier)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{relatedItems, errors.Errorf("delegate error")},
|
||||
Inputs: []any{pv, b},
|
||||
ExpectedErrorOutputs: []any{([]velero.ResourceIdentifier)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{relatedItems, errors.Errorf("delegate error")},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -159,10 +159,10 @@ func TestGetObjectStore(t *testing.T) {
|
|||
getPluginTest(t,
|
||||
common.PluginKindObjectStore,
|
||||
"velero.io/aws",
|
||||
func(m Manager, name string) (interface{}, error) {
|
||||
func(m Manager, name string) (any, error) {
|
||||
return m.GetObjectStore(name)
|
||||
},
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) interface{} {
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) any {
|
||||
return &restartableObjectStore{
|
||||
key: process.KindAndName{Kind: common.PluginKindObjectStore, Name: name},
|
||||
sharedPluginProcess: sharedPluginProcess,
|
||||
|
@ -176,10 +176,10 @@ func TestGetVolumeSnapshotter(t *testing.T) {
|
|||
getPluginTest(t,
|
||||
common.PluginKindVolumeSnapshotter,
|
||||
"velero.io/aws",
|
||||
func(m Manager, name string) (interface{}, error) {
|
||||
func(m Manager, name string) (any, error) {
|
||||
return m.GetVolumeSnapshotter(name)
|
||||
},
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) interface{} {
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) any {
|
||||
return &vsv1cli.RestartableVolumeSnapshotter{
|
||||
Key: process.KindAndName{Kind: common.PluginKindVolumeSnapshotter, Name: name},
|
||||
SharedPluginProcess: sharedPluginProcess,
|
||||
|
@ -193,10 +193,10 @@ func TestGetBackupItemAction(t *testing.T) {
|
|||
getPluginTest(t,
|
||||
common.PluginKindBackupItemAction,
|
||||
"velero.io/pod",
|
||||
func(m Manager, name string) (interface{}, error) {
|
||||
func(m Manager, name string) (any, error) {
|
||||
return m.GetBackupItemAction(name)
|
||||
},
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) interface{} {
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) any {
|
||||
return &biav1cli.RestartableBackupItemAction{
|
||||
Key: process.KindAndName{Kind: common.PluginKindBackupItemAction, Name: name},
|
||||
SharedPluginProcess: sharedPluginProcess,
|
||||
|
@ -210,10 +210,10 @@ func TestGetBackupItemActionV2(t *testing.T) {
|
|||
getPluginTest(t,
|
||||
common.PluginKindBackupItemActionV2,
|
||||
"velero.io/pod",
|
||||
func(m Manager, name string) (interface{}, error) {
|
||||
func(m Manager, name string) (any, error) {
|
||||
return m.GetBackupItemActionV2(name)
|
||||
},
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) interface{} {
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) any {
|
||||
return &biav2cli.RestartableBackupItemAction{
|
||||
Key: process.KindAndName{Kind: common.PluginKindBackupItemActionV2, Name: name},
|
||||
SharedPluginProcess: sharedPluginProcess,
|
||||
|
@ -227,10 +227,10 @@ func TestGetRestoreItemAction(t *testing.T) {
|
|||
getPluginTest(t,
|
||||
common.PluginKindRestoreItemAction,
|
||||
"velero.io/pod",
|
||||
func(m Manager, name string) (interface{}, error) {
|
||||
func(m Manager, name string) (any, error) {
|
||||
return m.GetRestoreItemAction(name)
|
||||
},
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) interface{} {
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) any {
|
||||
return &riav1cli.RestartableRestoreItemAction{
|
||||
Key: process.KindAndName{Kind: common.PluginKindRestoreItemAction, Name: name},
|
||||
SharedPluginProcess: sharedPluginProcess,
|
||||
|
@ -244,10 +244,10 @@ func TestGetRestoreItemActionV2(t *testing.T) {
|
|||
getPluginTest(t,
|
||||
common.PluginKindRestoreItemActionV2,
|
||||
"velero.io/pod",
|
||||
func(m Manager, name string) (interface{}, error) {
|
||||
func(m Manager, name string) (any, error) {
|
||||
return m.GetRestoreItemActionV2(name)
|
||||
},
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) interface{} {
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) any {
|
||||
return &riav2cli.RestartableRestoreItemAction{
|
||||
Key: process.KindAndName{Kind: common.PluginKindRestoreItemActionV2, Name: name},
|
||||
SharedPluginProcess: sharedPluginProcess,
|
||||
|
@ -261,10 +261,10 @@ func TestGetItemBlockAction(t *testing.T) {
|
|||
getPluginTest(t,
|
||||
common.PluginKindItemBlockAction,
|
||||
"velero.io/pod",
|
||||
func(m Manager, name string) (interface{}, error) {
|
||||
func(m Manager, name string) (any, error) {
|
||||
return m.GetItemBlockAction(name)
|
||||
},
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) interface{} {
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) any {
|
||||
return &ibav1cli.RestartableItemBlockAction{
|
||||
Key: process.KindAndName{Kind: common.PluginKindItemBlockAction, Name: name},
|
||||
SharedPluginProcess: sharedPluginProcess,
|
||||
|
@ -278,8 +278,8 @@ func getPluginTest(
|
|||
t *testing.T,
|
||||
kind common.PluginKind,
|
||||
name string,
|
||||
getPluginFunc func(m Manager, name string) (interface{}, error),
|
||||
expectedResultFunc func(name string, sharedPluginProcess process.RestartableProcess) interface{},
|
||||
getPluginFunc func(m Manager, name string) (any, error),
|
||||
expectedResultFunc func(name string, sharedPluginProcess process.RestartableProcess) any,
|
||||
reinitializable bool,
|
||||
) {
|
||||
t.Helper()
|
||||
|
@ -373,7 +373,7 @@ func TestGetBackupItemActions(t *testing.T) {
|
|||
}
|
||||
registry.On("List", pluginKind).Return(pluginIDs)
|
||||
|
||||
var expectedActions []interface{}
|
||||
var expectedActions []any
|
||||
for i := range pluginIDs {
|
||||
pluginID := pluginIDs[i]
|
||||
pluginName := pluginID.Name
|
||||
|
@ -408,7 +408,7 @@ func TestGetBackupItemActions(t *testing.T) {
|
|||
assert.EqualError(t, err, "NewRestartableProcess")
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var actual []interface{}
|
||||
var actual []any
|
||||
for i := range backupItemActions {
|
||||
actual = append(actual, backupItemActions[i])
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ func TestGetBackupItemActionsV2(t *testing.T) {
|
|||
}
|
||||
registry.On("List", pluginKind).Return(pluginIDs)
|
||||
|
||||
var expectedActions []interface{}
|
||||
var expectedActions []any
|
||||
for i := range pluginIDs {
|
||||
pluginID := pluginIDs[i]
|
||||
pluginName := pluginID.Name
|
||||
|
@ -500,7 +500,7 @@ func TestGetBackupItemActionsV2(t *testing.T) {
|
|||
assert.EqualError(t, err, "NewRestartableProcess")
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var actual []interface{}
|
||||
var actual []any
|
||||
for i := range backupItemActions {
|
||||
actual = append(actual, backupItemActions[i])
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ func TestGetRestoreItemActions(t *testing.T) {
|
|||
}
|
||||
registry.On("List", pluginKind).Return(pluginIDs)
|
||||
|
||||
var expectedActions []interface{}
|
||||
var expectedActions []any
|
||||
for i := range pluginIDs {
|
||||
pluginID := pluginIDs[i]
|
||||
pluginName := pluginID.Name
|
||||
|
@ -592,7 +592,7 @@ func TestGetRestoreItemActions(t *testing.T) {
|
|||
assert.EqualError(t, err, "NewRestartableProcess")
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var actual []interface{}
|
||||
var actual []any
|
||||
for i := range restoreItemActions {
|
||||
actual = append(actual, restoreItemActions[i])
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ func TestGetRestoreItemActionsV2(t *testing.T) {
|
|||
}
|
||||
registry.On("List", pluginKind).Return(pluginIDs)
|
||||
|
||||
var expectedActions []interface{}
|
||||
var expectedActions []any
|
||||
for i := range pluginIDs {
|
||||
pluginID := pluginIDs[i]
|
||||
pluginName := pluginID.Name
|
||||
|
@ -684,7 +684,7 @@ func TestGetRestoreItemActionsV2(t *testing.T) {
|
|||
assert.EqualError(t, err, "NewRestartableProcess")
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var actual []interface{}
|
||||
var actual []any
|
||||
for i := range restoreItemActions {
|
||||
actual = append(actual, restoreItemActions[i])
|
||||
}
|
||||
|
@ -698,10 +698,10 @@ func TestGetDeleteItemAction(t *testing.T) {
|
|||
getPluginTest(t,
|
||||
common.PluginKindDeleteItemAction,
|
||||
"velero.io/deleter",
|
||||
func(m Manager, name string) (interface{}, error) {
|
||||
func(m Manager, name string) (any, error) {
|
||||
return m.GetDeleteItemAction(name)
|
||||
},
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) interface{} {
|
||||
func(name string, sharedPluginProcess process.RestartableProcess) any {
|
||||
return &restartableDeleteItemAction{
|
||||
key: process.KindAndName{Kind: common.PluginKindDeleteItemAction, Name: name},
|
||||
sharedPluginProcess: sharedPluginProcess,
|
||||
|
@ -758,7 +758,7 @@ func TestGetDeleteItemActions(t *testing.T) {
|
|||
}
|
||||
registry.On("List", pluginKind).Return(pluginIDs)
|
||||
|
||||
var expectedActions []interface{}
|
||||
var expectedActions []any
|
||||
for i := range pluginIDs {
|
||||
pluginID := pluginIDs[i]
|
||||
pluginName := pluginID.Name
|
||||
|
@ -793,7 +793,7 @@ func TestGetDeleteItemActions(t *testing.T) {
|
|||
assert.EqualError(t, err, "NewRestartableProcess")
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var actual []interface{}
|
||||
var actual []any
|
||||
for i := range deleteItemActions {
|
||||
actual = append(actual, deleteItemActions[i])
|
||||
}
|
||||
|
@ -850,7 +850,7 @@ func TestGetItemBlockActions(t *testing.T) {
|
|||
}
|
||||
registry.On("List", pluginKind).Return(pluginIDs)
|
||||
|
||||
var expectedActions []interface{}
|
||||
var expectedActions []any
|
||||
for i := range pluginIDs {
|
||||
pluginID := pluginIDs[i]
|
||||
pluginName := pluginID.Name
|
||||
|
@ -885,7 +885,7 @@ func TestGetItemBlockActions(t *testing.T) {
|
|||
assert.EqualError(t, err, "NewRestartableProcess")
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var actual []interface{}
|
||||
var actual []any
|
||||
for i := range itemBlockActions {
|
||||
actual = append(actual, itemBlockActions[i])
|
||||
}
|
||||
|
|
|
@ -37,8 +37,8 @@ type logrusAdapter struct {
|
|||
|
||||
// args are alternating key, value pairs, where the keys
|
||||
// are expected to be strings, and values can be any type.
|
||||
func argsToFields(args ...interface{}) logrus.Fields {
|
||||
fields := make(map[string]interface{})
|
||||
func argsToFields(args ...any) logrus.Fields {
|
||||
fields := make(map[string]any)
|
||||
|
||||
for i := 0; i < len(args); i += 2 {
|
||||
switch args[i] {
|
||||
|
@ -52,7 +52,7 @@ func argsToFields(args ...interface{}) logrus.Fields {
|
|||
// to log at based on the hclog-compatible `@level` field which
|
||||
// we're adding via HcLogLevelHook).
|
||||
default:
|
||||
var val interface{}
|
||||
var val any
|
||||
if i+1 < len(args) {
|
||||
val = args[i+1]
|
||||
}
|
||||
|
@ -66,27 +66,27 @@ func argsToFields(args ...interface{}) logrus.Fields {
|
|||
|
||||
// Trace emits a message and key/value pairs at the DEBUG level
|
||||
// (logrus doesn't have a TRACE level)
|
||||
func (l *logrusAdapter) Trace(msg string, args ...interface{}) {
|
||||
func (l *logrusAdapter) Trace(msg string, args ...any) {
|
||||
l.Debug(msg, args...)
|
||||
}
|
||||
|
||||
// Debug emits a message and key/value pairs at the DEBUG level
|
||||
func (l *logrusAdapter) Debug(msg string, args ...interface{}) {
|
||||
func (l *logrusAdapter) Debug(msg string, args ...any) {
|
||||
l.impl.WithFields(argsToFields(args...)).Debug(msg)
|
||||
}
|
||||
|
||||
// Info emits a message and key/value pairs at the INFO level
|
||||
func (l *logrusAdapter) Info(msg string, args ...interface{}) {
|
||||
func (l *logrusAdapter) Info(msg string, args ...any) {
|
||||
l.impl.WithFields(argsToFields(args...)).Info(msg)
|
||||
}
|
||||
|
||||
// Warn emits a message and key/value pairs at the WARN level
|
||||
func (l *logrusAdapter) Warn(msg string, args ...interface{}) {
|
||||
func (l *logrusAdapter) Warn(msg string, args ...any) {
|
||||
l.impl.WithFields(argsToFields(args...)).Warn(msg)
|
||||
}
|
||||
|
||||
// Error emits a message and key/value pairs at the ERROR level
|
||||
func (l *logrusAdapter) Error(msg string, args ...interface{}) {
|
||||
func (l *logrusAdapter) Error(msg string, args ...any) {
|
||||
l.impl.WithFields(argsToFields(args...)).Error(msg)
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ func (l *logrusAdapter) IsError() bool {
|
|||
}
|
||||
|
||||
// With creates a sublogger that will always have the given key/value pairs
|
||||
func (l *logrusAdapter) With(args ...interface{}) hclog.Logger {
|
||||
func (l *logrusAdapter) With(args ...any) hclog.Logger {
|
||||
return &logrusAdapter{
|
||||
impl: l.impl.WithFields(argsToFields(args...)),
|
||||
level: l.level,
|
||||
|
@ -164,7 +164,7 @@ func (l *logrusAdapter) SetLevel(_ hclog.Level) {
|
|||
}
|
||||
|
||||
// ImpliedArgs returns With key/value pairs
|
||||
func (l *logrusAdapter) ImpliedArgs() []interface{} {
|
||||
func (l *logrusAdapter) ImpliedArgs() []any {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ func (l *logrusAdapter) ImpliedArgs() []interface{} {
|
|||
// keys must be strings
|
||||
// vals can be any type, but display is implementation specific
|
||||
// Emit a message and key/value pairs at a provided log level
|
||||
func (l *logrusAdapter) Log(level hclog.Level, msg string, args ...interface{}) {
|
||||
func (l *logrusAdapter) Log(level hclog.Level, msg string, args ...any) {
|
||||
switch level {
|
||||
case hclog.Trace:
|
||||
l.Trace(msg, args...)
|
||||
|
|
|
@ -26,34 +26,34 @@ import (
|
|||
func TestArgsToFields(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
args []interface{}
|
||||
args []any
|
||||
expectedFields logrus.Fields
|
||||
}{
|
||||
{
|
||||
name: "empty args results in empty map of fields",
|
||||
args: []interface{}{},
|
||||
expectedFields: logrus.Fields(map[string]interface{}{}),
|
||||
args: []any{},
|
||||
expectedFields: logrus.Fields(map[string]any{}),
|
||||
},
|
||||
{
|
||||
name: "matching string keys/values are correctly set as fields",
|
||||
args: []interface{}{"key-1", "value-1", "key-2", "value-2"},
|
||||
expectedFields: logrus.Fields(map[string]interface{}{
|
||||
args: []any{"key-1", "value-1", "key-2", "value-2"},
|
||||
expectedFields: logrus.Fields(map[string]any{
|
||||
"key-1": "value-1",
|
||||
"key-2": "value-2",
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "time/timestamp/level entries are removed",
|
||||
args: []interface{}{"time", time.Now(), "key-1", "value-1", "timestamp", time.Now(), "key-2", "value-2", "level", "WARN"},
|
||||
expectedFields: logrus.Fields(map[string]interface{}{
|
||||
args: []any{"time", time.Now(), "key-1", "value-1", "timestamp", time.Now(), "key-2", "value-2", "level", "WARN"},
|
||||
expectedFields: logrus.Fields(map[string]any{
|
||||
"key-1": "value-1",
|
||||
"key-2": "value-2",
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "odd number of args adds the last arg as a field with a nil value",
|
||||
args: []interface{}{"key-1", "value-1", "key-2", "value-2", "key-3"},
|
||||
expectedFields: logrus.Fields(map[string]interface{}{
|
||||
args: []any{"key-1", "value-1", "key-2", "value-2", "key-3"},
|
||||
expectedFields: logrus.Fields(map[string]any{
|
||||
"key-1": "value-1",
|
||||
"key-2": "value-2",
|
||||
"key-3": nil,
|
||||
|
|
|
@ -40,7 +40,7 @@ func (pf *processFactory) newProcess(command string, logger logrus.FieldLogger,
|
|||
}
|
||||
|
||||
type Process interface {
|
||||
dispense(key KindAndName) (interface{}, error)
|
||||
dispense(key KindAndName) (any, error)
|
||||
exited() bool
|
||||
kill()
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ func removeFeaturesFlag(args []string) []string {
|
|||
return commandArgs
|
||||
}
|
||||
|
||||
func (r *process) dispense(key KindAndName) (interface{}, error) {
|
||||
func (r *process) dispense(key KindAndName) (any, error) {
|
||||
// This calls GRPCClient(clientConn) on the plugin instance registered for key.name.
|
||||
dispensed, err := r.protocolClient.Dispense(key.Kind.String())
|
||||
if err != nil {
|
||||
|
|
|
@ -36,7 +36,7 @@ func (cp *mockClientProtocol) Close() error {
|
|||
return args.Error(0)
|
||||
}
|
||||
|
||||
func (cp *mockClientProtocol) Dispense(name string) (interface{}, error) {
|
||||
func (cp *mockClientProtocol) Dispense(name string) (any, error) {
|
||||
args := cp.Called(name)
|
||||
return args.Get(0), args.Error(1)
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ type mockClientDispenser struct {
|
|||
mock.Mock
|
||||
}
|
||||
|
||||
func (cd *mockClientDispenser) ClientFor(name string) interface{} {
|
||||
func (cd *mockClientDispenser) ClientFor(name string) any {
|
||||
args := cd.Called(name)
|
||||
return args.Get(0)
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ func TestDispense(t *testing.T) {
|
|||
clientDispenser := new(mockClientDispenser)
|
||||
defer clientDispenser.AssertExpectations(t)
|
||||
|
||||
var client interface{}
|
||||
var client any
|
||||
|
||||
key := KindAndName{}
|
||||
if tc.clientDispenser {
|
||||
|
|
|
@ -42,7 +42,7 @@ type RestartableProcess interface {
|
|||
AddReinitializer(key KindAndName, r Reinitializer)
|
||||
Reset() error
|
||||
ResetIfNeeded() error
|
||||
GetByKindAndName(key KindAndName) (interface{}, error)
|
||||
GetByKindAndName(key KindAndName) (any, error)
|
||||
Stop()
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ type restartableProcess struct {
|
|||
// lock guards all of the fields below
|
||||
lock sync.RWMutex
|
||||
process Process
|
||||
plugins map[KindAndName]interface{}
|
||||
plugins map[KindAndName]any
|
||||
reinitializers map[KindAndName]Reinitializer
|
||||
resetFailures int
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ type restartableProcess struct {
|
|||
// reinitializer is capable of reinitializing a restartable plugin instance using the newly dispensed plugin.
|
||||
type Reinitializer interface {
|
||||
// reinitialize reinitializes a restartable plugin instance using the newly dispensed plugin.
|
||||
Reinitialize(dispensed interface{}) error
|
||||
Reinitialize(dispensed any) error
|
||||
}
|
||||
|
||||
// newRestartableProcess creates a new restartableProcess for the given command and options.
|
||||
|
@ -74,7 +74,7 @@ func newRestartableProcess(command string, logger logrus.FieldLogger, logLevel l
|
|||
command: command,
|
||||
logger: logger,
|
||||
logLevel: logLevel,
|
||||
plugins: make(map[KindAndName]interface{}),
|
||||
plugins: make(map[KindAndName]any),
|
||||
reinitializers: make(map[KindAndName]Reinitializer),
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ func (p *restartableProcess) resetLH() error {
|
|||
|
||||
// Redispense any previously dispensed plugins, reinitializing if necessary.
|
||||
// Start by creating a new map to hold the newly dispensed plugins.
|
||||
newPlugins := make(map[KindAndName]interface{})
|
||||
newPlugins := make(map[KindAndName]any)
|
||||
for key := range p.plugins {
|
||||
// Re-dispense
|
||||
dispensed, err := p.process.dispense(key)
|
||||
|
@ -160,7 +160,7 @@ func (p *restartableProcess) ResetIfNeeded() error {
|
|||
}
|
||||
|
||||
// GetByKindAndName acquires the lock and calls getByKindAndNameLH.
|
||||
func (p *restartableProcess) GetByKindAndName(key KindAndName) (interface{}, error) {
|
||||
func (p *restartableProcess) GetByKindAndName(key KindAndName) (any, error) {
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
|
||||
|
@ -169,7 +169,7 @@ func (p *restartableProcess) GetByKindAndName(key KindAndName) (interface{}, err
|
|||
|
||||
// getByKindAndNameLH returns the dispensed plugin for key. If the plugin hasn't been dispensed before, it dispenses a
|
||||
// new one.
|
||||
func (p *restartableProcess) getByKindAndNameLH(key KindAndName) (interface{}, error) {
|
||||
func (p *restartableProcess) getByKindAndNameLH(key KindAndName) (any, error) {
|
||||
dispensed, found := p.plugins[key]
|
||||
if found {
|
||||
return dispensed, nil
|
||||
|
|
|
@ -35,7 +35,7 @@ import (
|
|||
func TestRestartableGetDeleteItemAction(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
plugin interface{}
|
||||
plugin any
|
||||
getError error
|
||||
expectedError string
|
||||
}{
|
||||
|
@ -103,7 +103,7 @@ func TestRestartableDeleteItemActionGetDelegate(t *testing.T) {
|
|||
|
||||
func TestRestartableDeleteItemActionDelegatedFunctions(t *testing.T) {
|
||||
pv := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "blue",
|
||||
},
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ func TestRestartableDeleteItemActionDelegatedFunctions(t *testing.T) {
|
|||
restartabletest.RunRestartableDelegateTests(
|
||||
t,
|
||||
common.PluginKindDeleteItemAction,
|
||||
func(key process.KindAndName, p process.RestartableProcess) interface{} {
|
||||
func(key process.KindAndName, p process.RestartableProcess) any {
|
||||
return &restartableDeleteItemAction{
|
||||
key: key,
|
||||
sharedPluginProcess: p,
|
||||
|
@ -130,15 +130,15 @@ func TestRestartableDeleteItemActionDelegatedFunctions(t *testing.T) {
|
|||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "AppliesTo",
|
||||
Inputs: []interface{}{},
|
||||
ExpectedErrorOutputs: []interface{}{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
Inputs: []any{},
|
||||
ExpectedErrorOutputs: []any{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "Execute",
|
||||
Inputs: []interface{}{input},
|
||||
ExpectedErrorOutputs: []interface{}{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{errors.Errorf("delegate error")},
|
||||
Inputs: []any{input},
|
||||
ExpectedErrorOutputs: []any{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{errors.Errorf("delegate error")},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ func NewRestartableObjectStore(name string, sharedPluginProcess process.Restarta
|
|||
}
|
||||
|
||||
// reinitialize reinitializes a re-dispensed plugin using the initial data passed to Init().
|
||||
func (r *restartableObjectStore) Reinitialize(dispensed interface{}) error {
|
||||
func (r *restartableObjectStore) Reinitialize(dispensed any) error {
|
||||
objectStore, ok := dispensed.(velero.ObjectStore)
|
||||
if !ok {
|
||||
return errors.Errorf("plugin %T is not a ObjectStore", dispensed)
|
||||
|
|
|
@ -35,7 +35,7 @@ import (
|
|||
func TestRestartableGetObjectStore(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
plugin interface{}
|
||||
plugin any
|
||||
getError error
|
||||
expectedError string
|
||||
}{
|
||||
|
@ -189,7 +189,7 @@ func TestRestartableObjectStoreDelegatedFunctions(t *testing.T) {
|
|||
restartabletest.RunRestartableDelegateTests(
|
||||
t,
|
||||
common.PluginKindObjectStore,
|
||||
func(key process.KindAndName, p process.RestartableProcess) interface{} {
|
||||
func(key process.KindAndName, p process.RestartableProcess) any {
|
||||
return &restartableObjectStore{
|
||||
key: key,
|
||||
sharedPluginProcess: p,
|
||||
|
@ -200,39 +200,39 @@ func TestRestartableObjectStoreDelegatedFunctions(t *testing.T) {
|
|||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "PutObject",
|
||||
Inputs: []interface{}{"bucket", "key", strings.NewReader("body")},
|
||||
ExpectedErrorOutputs: []interface{}{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{errors.Errorf("delegate error")},
|
||||
Inputs: []any{"bucket", "key", strings.NewReader("body")},
|
||||
ExpectedErrorOutputs: []any{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "GetObject",
|
||||
Inputs: []interface{}{"bucket", "key"},
|
||||
ExpectedErrorOutputs: []interface{}{nil, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{io.NopCloser(strings.NewReader("object")), errors.Errorf("delegate error")},
|
||||
Inputs: []any{"bucket", "key"},
|
||||
ExpectedErrorOutputs: []any{nil, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{io.NopCloser(strings.NewReader("object")), errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "ListCommonPrefixes",
|
||||
Inputs: []interface{}{"bucket", "prefix", "delimiter"},
|
||||
ExpectedErrorOutputs: []interface{}{([]string)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{[]string{"a", "b"}, errors.Errorf("delegate error")},
|
||||
Inputs: []any{"bucket", "prefix", "delimiter"},
|
||||
ExpectedErrorOutputs: []any{([]string)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{[]string{"a", "b"}, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "ListObjects",
|
||||
Inputs: []interface{}{"bucket", "prefix"},
|
||||
ExpectedErrorOutputs: []interface{}{([]string)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{[]string{"a", "b"}, errors.Errorf("delegate error")},
|
||||
Inputs: []any{"bucket", "prefix"},
|
||||
ExpectedErrorOutputs: []any{([]string)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{[]string{"a", "b"}, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "DeleteObject",
|
||||
Inputs: []interface{}{"bucket", "key"},
|
||||
ExpectedErrorOutputs: []interface{}{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{errors.Errorf("delegate error")},
|
||||
Inputs: []any{"bucket", "key"},
|
||||
ExpectedErrorOutputs: []any{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "CreateSignedURL",
|
||||
Inputs: []interface{}{"bucket", "key", 30 * time.Minute},
|
||||
ExpectedErrorOutputs: []interface{}{"", errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{"signedURL", errors.Errorf("delegate error")},
|
||||
Inputs: []any{"bucket", "key", 30 * time.Minute},
|
||||
ExpectedErrorOutputs: []any{"", errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{"signedURL", errors.Errorf("delegate error")},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import (
|
|||
func TestRestartableGetRestoreItemAction(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
plugin interface{}
|
||||
plugin any
|
||||
getError error
|
||||
expectedError string
|
||||
}{
|
||||
|
@ -102,7 +102,7 @@ func TestRestartableRestoreItemActionGetDelegate(t *testing.T) {
|
|||
|
||||
func TestRestartableRestoreItemActionDelegatedFunctions(t *testing.T) {
|
||||
pv := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "blue",
|
||||
},
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func TestRestartableRestoreItemActionDelegatedFunctions(t *testing.T) {
|
|||
|
||||
output := &velero.RestoreItemActionExecuteOutput{
|
||||
UpdatedItem: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "green",
|
||||
},
|
||||
},
|
||||
|
@ -124,7 +124,7 @@ func TestRestartableRestoreItemActionDelegatedFunctions(t *testing.T) {
|
|||
restartabletest.RunRestartableDelegateTests(
|
||||
t,
|
||||
common.PluginKindRestoreItemAction,
|
||||
func(key process.KindAndName, p process.RestartableProcess) interface{} {
|
||||
func(key process.KindAndName, p process.RestartableProcess) any {
|
||||
return &RestartableRestoreItemAction{
|
||||
Key: key,
|
||||
SharedPluginProcess: p,
|
||||
|
@ -135,15 +135,15 @@ func TestRestartableRestoreItemActionDelegatedFunctions(t *testing.T) {
|
|||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "AppliesTo",
|
||||
Inputs: []interface{}{},
|
||||
ExpectedErrorOutputs: []interface{}{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
Inputs: []any{},
|
||||
ExpectedErrorOutputs: []any{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "Execute",
|
||||
Inputs: []interface{}{input},
|
||||
ExpectedErrorOutputs: []interface{}{nil, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{output, errors.Errorf("delegate error")},
|
||||
Inputs: []any{input},
|
||||
ExpectedErrorOutputs: []any{nil, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{output, errors.Errorf("delegate error")},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ import (
|
|||
func TestRestartableGetRestoreItemAction(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
plugin interface{}
|
||||
plugin any
|
||||
getError error
|
||||
expectedError string
|
||||
}{
|
||||
|
@ -102,7 +102,7 @@ func TestRestartableRestoreItemActionGetDelegate(t *testing.T) {
|
|||
|
||||
func TestRestartableRestoreItemActionDelegatedFunctions(t *testing.T) {
|
||||
pv := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "blue",
|
||||
},
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func TestRestartableRestoreItemActionDelegatedFunctions(t *testing.T) {
|
|||
|
||||
output := &velero.RestoreItemActionExecuteOutput{
|
||||
UpdatedItem: &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "green",
|
||||
},
|
||||
},
|
||||
|
@ -127,7 +127,7 @@ func TestRestartableRestoreItemActionDelegatedFunctions(t *testing.T) {
|
|||
restartabletest.RunRestartableDelegateTests(
|
||||
t,
|
||||
common.PluginKindRestoreItemActionV2,
|
||||
func(key process.KindAndName, p process.RestartableProcess) interface{} {
|
||||
func(key process.KindAndName, p process.RestartableProcess) any {
|
||||
return &RestartableRestoreItemAction{
|
||||
Key: key,
|
||||
SharedPluginProcess: p,
|
||||
|
@ -138,33 +138,33 @@ func TestRestartableRestoreItemActionDelegatedFunctions(t *testing.T) {
|
|||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "AppliesTo",
|
||||
Inputs: []interface{}{},
|
||||
ExpectedErrorOutputs: []interface{}{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
Inputs: []any{},
|
||||
ExpectedErrorOutputs: []any{velero.ResourceSelector{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{velero.ResourceSelector{IncludedNamespaces: []string{"a"}}, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "Execute",
|
||||
Inputs: []interface{}{input},
|
||||
ExpectedErrorOutputs: []interface{}{nil, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{output, errors.Errorf("delegate error")},
|
||||
Inputs: []any{input},
|
||||
ExpectedErrorOutputs: []any{nil, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{output, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "Progress",
|
||||
Inputs: []interface{}{oid, r},
|
||||
ExpectedErrorOutputs: []interface{}{velero.OperationProgress{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{velero.OperationProgress{}, errors.Errorf("delegate error")},
|
||||
Inputs: []any{oid, r},
|
||||
ExpectedErrorOutputs: []any{velero.OperationProgress{}, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{velero.OperationProgress{}, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "Cancel",
|
||||
Inputs: []interface{}{oid, r},
|
||||
ExpectedErrorOutputs: []interface{}{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{errors.Errorf("delegate error")},
|
||||
Inputs: []any{oid, r},
|
||||
ExpectedErrorOutputs: []any{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "AreAdditionalItemsReady",
|
||||
Inputs: []interface{}{additionalItems, r},
|
||||
ExpectedErrorOutputs: []interface{}{false, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{true, errors.Errorf("delegate error")},
|
||||
Inputs: []any{additionalItems, r},
|
||||
ExpectedErrorOutputs: []any{false, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{true, errors.Errorf("delegate error")},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ func NewRestartableVolumeSnapshotter(name string, sharedPluginProcess process.Re
|
|||
}
|
||||
|
||||
// reinitialize reinitializes a re-dispensed plugin using the initial data passed to Init().
|
||||
func (r *RestartableVolumeSnapshotter) Reinitialize(dispensed interface{}) error {
|
||||
func (r *RestartableVolumeSnapshotter) Reinitialize(dispensed any) error {
|
||||
volumeSnapshotter, ok := dispensed.(vsv1.VolumeSnapshotter)
|
||||
if !ok {
|
||||
return errors.Errorf("plugin %T is not a VolumeSnapshotter", dispensed)
|
||||
|
|
|
@ -34,7 +34,7 @@ import (
|
|||
func TestRestartableGetVolumeSnapshotter(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
plugin interface{}
|
||||
plugin any
|
||||
getError error
|
||||
expectedError string
|
||||
}{
|
||||
|
@ -186,13 +186,13 @@ func TestRestartableVolumeSnapshotterInit(t *testing.T) {
|
|||
|
||||
func TestRestartableVolumeSnapshotterDelegatedFunctions(t *testing.T) {
|
||||
pv := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "blue",
|
||||
},
|
||||
}
|
||||
|
||||
pvToReturn := &unstructured.Unstructured{
|
||||
Object: map[string]interface{}{
|
||||
Object: map[string]any{
|
||||
"color": "green",
|
||||
},
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ func TestRestartableVolumeSnapshotterDelegatedFunctions(t *testing.T) {
|
|||
restartabletest.RunRestartableDelegateTests(
|
||||
t,
|
||||
common.PluginKindVolumeSnapshotter,
|
||||
func(key process.KindAndName, p process.RestartableProcess) interface{} {
|
||||
func(key process.KindAndName, p process.RestartableProcess) any {
|
||||
return &RestartableVolumeSnapshotter{
|
||||
Key: key,
|
||||
SharedPluginProcess: p,
|
||||
|
@ -211,39 +211,39 @@ func TestRestartableVolumeSnapshotterDelegatedFunctions(t *testing.T) {
|
|||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "CreateVolumeFromSnapshot",
|
||||
Inputs: []interface{}{"snapshotID", "volumeID", "volumeAZ", to.Ptr(int64(10000))},
|
||||
ExpectedErrorOutputs: []interface{}{"", errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{"volumeID", errors.Errorf("delegate error")},
|
||||
Inputs: []any{"snapshotID", "volumeID", "volumeAZ", to.Ptr(int64(10000))},
|
||||
ExpectedErrorOutputs: []any{"", errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{"volumeID", errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "GetVolumeID",
|
||||
Inputs: []interface{}{pv},
|
||||
ExpectedErrorOutputs: []interface{}{"", errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{"volumeID", errors.Errorf("delegate error")},
|
||||
Inputs: []any{pv},
|
||||
ExpectedErrorOutputs: []any{"", errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{"volumeID", errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "SetVolumeID",
|
||||
Inputs: []interface{}{pv, "volumeID"},
|
||||
ExpectedErrorOutputs: []interface{}{nil, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{pvToReturn, errors.Errorf("delegate error")},
|
||||
Inputs: []any{pv, "volumeID"},
|
||||
ExpectedErrorOutputs: []any{nil, errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{pvToReturn, errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "GetVolumeInfo",
|
||||
Inputs: []interface{}{"volumeID", "volumeAZ"},
|
||||
ExpectedErrorOutputs: []interface{}{"", (*int64)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{"volumeType", to.Ptr(int64(10000)), errors.Errorf("delegate error")},
|
||||
Inputs: []any{"volumeID", "volumeAZ"},
|
||||
ExpectedErrorOutputs: []any{"", (*int64)(nil), errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{"volumeType", to.Ptr(int64(10000)), errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "CreateSnapshot",
|
||||
Inputs: []interface{}{"volumeID", "volumeAZ", map[string]string{"a": "b"}},
|
||||
ExpectedErrorOutputs: []interface{}{"", errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{"snapshotID", errors.Errorf("delegate error")},
|
||||
Inputs: []any{"volumeID", "volumeAZ", map[string]string{"a": "b"}},
|
||||
ExpectedErrorOutputs: []any{"", errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{"snapshotID", errors.Errorf("delegate error")},
|
||||
},
|
||||
restartabletest.RestartableDelegateTest{
|
||||
Function: "DeleteSnapshot",
|
||||
Inputs: []interface{}{"snapshotID"},
|
||||
ExpectedErrorOutputs: []interface{}{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []interface{}{errors.Errorf("delegate error")},
|
||||
Inputs: []any{"snapshotID"},
|
||||
ExpectedErrorOutputs: []any{errors.Errorf("reset error")},
|
||||
ExpectedDelegateOutputs: []any{errors.Errorf("delegate error")},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ type BackupItemActionPlugin struct {
|
|||
}
|
||||
|
||||
// GRPCClient returns a clientDispenser for BackupItemAction gRPC clients.
|
||||
func (p *BackupItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
func (p *BackupItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
|
||||
return common.NewClientDispenser(p.ClientLogger, clientConn, newBackupItemActionGRPCClient), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ type BackupItemActionGRPCClient struct {
|
|||
grpcClient protobiav1.BackupItemActionClient
|
||||
}
|
||||
|
||||
func newBackupItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
|
||||
func newBackupItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
|
||||
return &BackupItemActionGRPCClient{
|
||||
ClientBase: base,
|
||||
grpcClient: protobiav1.NewBackupItemActionClient(clientConn),
|
||||
|
|
|
@ -156,7 +156,7 @@ func TestBackupItemActionGRPCServerExecute(t *testing.T) {
|
|||
|
||||
s := &BackupItemActionGRPCServer{mux: &common.ServerMux{
|
||||
ServerLog: velerotest.NewLogger(),
|
||||
Handlers: map[string]interface{}{
|
||||
Handlers: map[string]any{
|
||||
"xyz": itemAction,
|
||||
},
|
||||
}}
|
||||
|
|
|
@ -34,7 +34,7 @@ type BackupItemActionPlugin struct {
|
|||
}
|
||||
|
||||
// GRPCClient returns a clientDispenser for BackupItemAction gRPC clients.
|
||||
func (p *BackupItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
func (p *BackupItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
|
||||
return common.NewClientDispenser(p.ClientLogger, clientConn, newBackupItemActionGRPCClient), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ type BackupItemActionGRPCClient struct {
|
|||
grpcClient protobiav2.BackupItemActionClient
|
||||
}
|
||||
|
||||
func newBackupItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
|
||||
func newBackupItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
|
||||
return &BackupItemActionGRPCClient{
|
||||
ClientBase: base,
|
||||
grpcClient: protobiav2.NewBackupItemActionClient(clientConn),
|
||||
|
|
|
@ -159,7 +159,7 @@ func TestBackupItemActionGRPCServerExecute(t *testing.T) {
|
|||
|
||||
s := &BackupItemActionGRPCServer{mux: &common.ServerMux{
|
||||
ServerLog: velerotest.NewLogger(),
|
||||
Handlers: map[string]interface{}{
|
||||
Handlers: map[string]any{
|
||||
"xyz": itemAction,
|
||||
},
|
||||
}}
|
||||
|
|
|
@ -28,7 +28,7 @@ type ClientBase struct {
|
|||
}
|
||||
|
||||
type ClientDispenser interface {
|
||||
ClientFor(name string) interface{}
|
||||
ClientFor(name string) any
|
||||
}
|
||||
|
||||
// clientDispenser supports the initialization and retrieval of multiple implementations for a single plugin kind, such as
|
||||
|
@ -41,10 +41,10 @@ type clientDispenser struct {
|
|||
// initFunc returns a client that implements a plugin interface, such as ObjectStore.
|
||||
initFunc clientInitFunc
|
||||
// clients keeps track of all the initialized implementations.
|
||||
clients map[string]interface{}
|
||||
clients map[string]any
|
||||
}
|
||||
|
||||
type clientInitFunc func(base *ClientBase, clientConn *grpc.ClientConn) interface{}
|
||||
type clientInitFunc func(base *ClientBase, clientConn *grpc.ClientConn) any
|
||||
|
||||
// newClientDispenser creates a new clientDispenser.
|
||||
func NewClientDispenser(logger logrus.FieldLogger, clientConn *grpc.ClientConn, initFunc clientInitFunc) *clientDispenser {
|
||||
|
@ -52,13 +52,13 @@ func NewClientDispenser(logger logrus.FieldLogger, clientConn *grpc.ClientConn,
|
|||
clientConn: clientConn,
|
||||
logger: logger,
|
||||
initFunc: initFunc,
|
||||
clients: make(map[string]interface{}),
|
||||
clients: make(map[string]any),
|
||||
}
|
||||
}
|
||||
|
||||
// ClientFor returns a gRPC client stub for the implementation of a plugin named name. If the client stub does not
|
||||
// currently exist, clientFor creates it.
|
||||
func (cd *clientDispenser) ClientFor(name string) interface{} {
|
||||
func (cd *clientDispenser) ClientFor(name string) any {
|
||||
if client, found := cd.clients[name]; found {
|
||||
return client
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestNewClientDispenser(t *testing.T) {
|
|||
clientConn := new(grpc.ClientConn)
|
||||
|
||||
c := 3
|
||||
initFunc := func(base *ClientBase, clientConn *grpc.ClientConn) interface{} {
|
||||
initFunc := func(base *ClientBase, clientConn *grpc.ClientConn) any {
|
||||
return c
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ func TestClientFor(t *testing.T) {
|
|||
|
||||
c := new(fakeClient)
|
||||
count := 0
|
||||
initFunc := func(base *ClientBase, clientConn *grpc.ClientConn) interface{} {
|
||||
initFunc := func(base *ClientBase, clientConn *grpc.ClientConn) any {
|
||||
c.base = base
|
||||
c.clientConn = clientConn
|
||||
count++
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
)
|
||||
|
||||
// HandlePanic is a panic handler for the server half of velero plugins.
|
||||
func HandlePanic(p interface{}) error {
|
||||
func HandlePanic(p any) error {
|
||||
if p == nil {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -27,13 +27,13 @@ import (
|
|||
|
||||
// HandlerInitializer is a function that initializes and returns a new instance of one of Velero's plugin interfaces
|
||||
// (ObjectStore, VolumeSnapshotter, BackupItemAction, RestoreItemAction).
|
||||
type HandlerInitializer func(logger logrus.FieldLogger) (interface{}, error)
|
||||
type HandlerInitializer func(logger logrus.FieldLogger) (any, error)
|
||||
|
||||
// ServerMux manages multiple implementations of a single plugin kind, such as pod and pvc BackupItemActions.
|
||||
type ServerMux struct {
|
||||
kind PluginKind
|
||||
initializers map[string]HandlerInitializer
|
||||
Handlers map[string]interface{}
|
||||
Handlers map[string]any
|
||||
ServerLog logrus.FieldLogger
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ type ServerMux struct {
|
|||
func NewServerMux(logger logrus.FieldLogger) *ServerMux {
|
||||
return &ServerMux{
|
||||
initializers: make(map[string]HandlerInitializer),
|
||||
Handlers: make(map[string]interface{}),
|
||||
Handlers: make(map[string]any),
|
||||
ServerLog: logger,
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ func (m *ServerMux) Names() []string {
|
|||
|
||||
// GetHandler returns the instance for a plugin with the given name. If an instance has already been initialized,
|
||||
// that is returned. Otherwise, the instance is initialized by calling its initialization function.
|
||||
func (m *ServerMux) GetHandler(name string) (interface{}, error) {
|
||||
func (m *ServerMux) GetHandler(name string) (any, error) {
|
||||
if instance, found := m.Handlers[name]; found {
|
||||
return instance, nil
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ type DeleteItemActionPlugin struct {
|
|||
}
|
||||
|
||||
// GRPCClient returns a DeleteItemAction gRPC client.
|
||||
func (p *DeleteItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
func (p *DeleteItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
|
||||
return common.NewClientDispenser(p.ClientLogger, clientConn, newDeleteItemActionGRPCClient), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ type DeleteItemActionGRPCClient struct {
|
|||
grpcClient proto.DeleteItemActionClient
|
||||
}
|
||||
|
||||
func newDeleteItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
|
||||
func newDeleteItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
|
||||
return &DeleteItemActionGRPCClient{
|
||||
ClientBase: base,
|
||||
grpcClient: proto.NewDeleteItemActionClient(clientConn),
|
||||
|
|
|
@ -30,7 +30,7 @@ func ExampleNewServer_volumeSnapshotter() {
|
|||
Serve() // serve the plugin
|
||||
}
|
||||
|
||||
func newVolumeSnapshotter(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newVolumeSnapshotter(logger logrus.FieldLogger) (any, error) {
|
||||
return &VolumeSnapshotter{FieldLogger: logger}, nil
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ func (b *VolumeSnapshotter) DeleteSnapshot(snapshotID string) error {
|
|||
|
||||
// Implement all methods for the DeleteItemAction interface
|
||||
|
||||
func newDeleteItemAction(logger logrus.FieldLogger) (interface{}, error) {
|
||||
func newDeleteItemAction(logger logrus.FieldLogger) (any, error) {
|
||||
return DeleteItemAction{FieldLogger: logger}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ type ItemBlockActionPlugin struct {
|
|||
}
|
||||
|
||||
// GRPCClient returns a clientDispenser for ItemBlockAction gRPC clients.
|
||||
func (p *ItemBlockActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
func (p *ItemBlockActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
|
||||
return common.NewClientDispenser(p.ClientLogger, clientConn, newItemBlockActionGRPCClient), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ type ItemBlockActionGRPCClient struct {
|
|||
grpcClient protoibav1.ItemBlockActionClient
|
||||
}
|
||||
|
||||
func newItemBlockActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
|
||||
func newItemBlockActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
|
||||
return &ItemBlockActionGRPCClient{
|
||||
ClientBase: base,
|
||||
grpcClient: protoibav1.NewItemBlockActionClient(clientConn),
|
||||
|
|
|
@ -132,7 +132,7 @@ func TestItemBlockActionGRPCServerGetRelatedItems(t *testing.T) {
|
|||
|
||||
s := &ItemBlockActionGRPCServer{mux: &common.ServerMux{
|
||||
ServerLog: velerotest.NewLogger(),
|
||||
Handlers: map[string]interface{}{
|
||||
Handlers: map[string]any{
|
||||
"xyz": itemAction,
|
||||
},
|
||||
}}
|
||||
|
|
|
@ -34,7 +34,7 @@ type ObjectStorePlugin struct {
|
|||
}
|
||||
|
||||
// GRPCClient returns an ObjectStore gRPC client.
|
||||
func (p *ObjectStorePlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
func (p *ObjectStorePlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
|
||||
return common.NewClientDispenser(p.ClientLogger, clientConn, newObjectStoreGRPCClient), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ type ObjectStoreGRPCClient struct {
|
|||
grpcClient proto.ObjectStoreClient
|
||||
}
|
||||
|
||||
func newObjectStoreGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
|
||||
func newObjectStoreGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
|
||||
return &ObjectStoreGRPCClient{
|
||||
ClientBase: base,
|
||||
grpcClient: proto.NewObjectStoreClient(clientConn),
|
||||
|
|
|
@ -69,7 +69,7 @@ func NewPluginListerPlugin(impl PluginLister) *PluginListerPlugin {
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// GRPCClient returns a PluginLister gRPC client.
|
||||
func (p *PluginListerPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
func (p *PluginListerPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
|
||||
return &PluginListerGRPCClient{grpcClient: proto.NewPluginListerClient(clientConn)}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
)
|
||||
|
||||
func TestPluginImplementationsAreGRPCPlugins(t *testing.T) {
|
||||
pluginImpls := []interface{}{
|
||||
pluginImpls := []any{
|
||||
new(VolumeSnapshotterPlugin),
|
||||
new(BackupItemActionPlugin),
|
||||
new(ObjectStorePlugin),
|
||||
|
|
|
@ -34,7 +34,7 @@ type RestoreItemActionPlugin struct {
|
|||
}
|
||||
|
||||
// GRPCClient returns a RestoreItemAction gRPC client.
|
||||
func (p *RestoreItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
func (p *RestoreItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
|
||||
return common.NewClientDispenser(p.ClientLogger, clientConn, newRestoreItemActionGRPCClient), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ type RestoreItemActionGRPCClient struct {
|
|||
grpcClient proto.RestoreItemActionClient
|
||||
}
|
||||
|
||||
func newRestoreItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
|
||||
func newRestoreItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
|
||||
return &RestoreItemActionGRPCClient{
|
||||
ClientBase: base,
|
||||
grpcClient: proto.NewRestoreItemActionClient(clientConn),
|
||||
|
|
|
@ -34,7 +34,7 @@ type RestoreItemActionPlugin struct {
|
|||
}
|
||||
|
||||
// GRPCClient returns a RestoreItemAction gRPC client.
|
||||
func (p *RestoreItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
func (p *RestoreItemActionPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
|
||||
return common.NewClientDispenser(p.ClientLogger, clientConn, newRestoreItemActionGRPCClient), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ type RestoreItemActionGRPCClient struct {
|
|||
grpcClient protoriav2.RestoreItemActionClient
|
||||
}
|
||||
|
||||
func newRestoreItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
|
||||
func newRestoreItemActionGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
|
||||
return &RestoreItemActionGRPCClient{
|
||||
ClientBase: base,
|
||||
grpcClient: protoriav2.NewRestoreItemActionClient(clientConn),
|
||||
|
|
|
@ -34,7 +34,7 @@ type VolumeSnapshotterPlugin struct {
|
|||
}
|
||||
|
||||
// GRPCClient returns a VolumeSnapshotter gRPC client.
|
||||
func (p *VolumeSnapshotterPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error) {
|
||||
func (p *VolumeSnapshotterPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (any, error) {
|
||||
return common.NewClientDispenser(p.ClientLogger, clientConn, newVolumeSnapshotterGRPCClient), nil
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ type VolumeSnapshotterGRPCClient struct {
|
|||
grpcClient proto.VolumeSnapshotterClient
|
||||
}
|
||||
|
||||
func newVolumeSnapshotterGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) interface{} {
|
||||
func newVolumeSnapshotterGRPCClient(base *common.ClientBase, clientConn *grpc.ClientConn) any {
|
||||
return &VolumeSnapshotterGRPCClient{
|
||||
ClientBase: base,
|
||||
grpcClient: proto.NewVolumeSnapshotterClient(clientConn),
|
||||
|
|
|
@ -39,7 +39,7 @@ const defaultTimeout = 30 * time.Second
|
|||
type PodCommandExecutor interface {
|
||||
// ExecutePodCommand executes a command in a container in a pod. If the command takes longer than
|
||||
// the specified timeout, an error is returned.
|
||||
ExecutePodCommand(log logrus.FieldLogger, item map[string]interface{}, namespace, name, hookName string, hook *api.ExecHook) error
|
||||
ExecutePodCommand(log logrus.FieldLogger, item map[string]any, namespace, name, hookName string, hook *api.ExecHook) error
|
||||
}
|
||||
|
||||
type poster interface {
|
||||
|
@ -67,7 +67,7 @@ func NewPodCommandExecutor(restClientConfig *rest.Config, restClient poster) Pod
|
|||
// command takes longer than the specified timeout, an error is returned (NOTE: it is not currently
|
||||
// possible to ensure the command is terminated when the timeout occurs, so it may continue to run
|
||||
// in the background).
|
||||
func (e *defaultPodCommandExecutor) ExecutePodCommand(log logrus.FieldLogger, item map[string]interface{}, namespace, name, hookName string, hook *api.ExecHook) error {
|
||||
func (e *defaultPodCommandExecutor) ExecutePodCommand(log logrus.FieldLogger, item map[string]any, namespace, name, hookName string, hook *api.ExecHook) error {
|
||||
if item == nil {
|
||||
return errors.New("item is required")
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestNewPodCommandExecutor(t *testing.T) {
|
|||
func TestExecutePodCommandMissingInputs(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
item map[string]interface{}
|
||||
item map[string]any
|
||||
podNamespace string
|
||||
podName string
|
||||
hookName string
|
||||
|
@ -63,22 +63,22 @@ func TestExecutePodCommandMissingInputs(t *testing.T) {
|
|||
},
|
||||
{
|
||||
name: "missing pod namespace",
|
||||
item: map[string]interface{}{},
|
||||
item: map[string]any{},
|
||||
},
|
||||
{
|
||||
name: "missing pod name",
|
||||
item: map[string]interface{}{},
|
||||
item: map[string]any{},
|
||||
podNamespace: "ns",
|
||||
},
|
||||
{
|
||||
name: "missing hookName",
|
||||
item: map[string]interface{}{},
|
||||
item: map[string]any{},
|
||||
podNamespace: "ns",
|
||||
podName: "pod",
|
||||
},
|
||||
{
|
||||
name: "missing hook",
|
||||
item: map[string]interface{}{},
|
||||
item: map[string]any{},
|
||||
podNamespace: "ns",
|
||||
podName: "pod",
|
||||
hookName: "hook",
|
||||
|
|
|
@ -108,7 +108,7 @@ func (pbs *PVCBackupSummary) addSkipped(volumeName string, reason string) {
|
|||
|
||||
const indexNamePod = "POD"
|
||||
|
||||
func podIndexFunc(obj interface{}) ([]string, error) {
|
||||
func podIndexFunc(obj any) ([]string, error) {
|
||||
pvb, ok := obj.(*velerov1api.PodVolumeBackup)
|
||||
if !ok {
|
||||
return nil, errors.Errorf("expected PodVolumeBackup, but got %T", obj)
|
||||
|
@ -144,7 +144,7 @@ func newBackupper(
|
|||
|
||||
b.handlerRegistration, _ = pvbInformer.AddEventHandler(
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
UpdateFunc: func(_, obj interface{}) {
|
||||
UpdateFunc: func(_, obj any) {
|
||||
pvb, ok := obj.(*velerov1api.PodVolumeBackup)
|
||||
if !ok {
|
||||
log.Errorf("expected PodVolumeBackup, but got %T", obj)
|
||||
|
|
|
@ -92,7 +92,7 @@ func newRestorer(
|
|||
|
||||
_, _ = pvrInformer.AddEventHandler(
|
||||
cache.ResourceEventHandlerFuncs{
|
||||
UpdateFunc: func(_, obj interface{}) {
|
||||
UpdateFunc: func(_, obj any) {
|
||||
pvr := obj.(*velerov1api.PodVolumeRestore)
|
||||
if pvr.GetLabels()[velerov1api.RestoreUIDLabel] != string(restore.UID) {
|
||||
return
|
||||
|
|
|
@ -376,7 +376,7 @@ func (urp *unifiedRepoProvider) DefaultMaintenanceFrequency(ctx context.Context,
|
|||
return urp.repoService.DefaultMaintenanceFrequency()
|
||||
}
|
||||
|
||||
func (urp *unifiedRepoProvider) GetPassword(param interface{}) (string, error) {
|
||||
func (urp *unifiedRepoProvider) GetPassword(param any) (string, error) {
|
||||
_, ok := param.(RepoParam)
|
||||
if !ok {
|
||||
return "", errors.Errorf("invalid parameter, expect %T, actual %T", RepoParam{}, param)
|
||||
|
@ -390,7 +390,7 @@ func (urp *unifiedRepoProvider) GetPassword(param interface{}) (string, error) {
|
|||
return repoPassword, nil
|
||||
}
|
||||
|
||||
func (urp *unifiedRepoProvider) GetStoreType(param interface{}) (string, error) {
|
||||
func (urp *unifiedRepoProvider) GetStoreType(param any) (string, error) {
|
||||
repoParam, ok := param.(RepoParam)
|
||||
if !ok {
|
||||
return "", errors.Errorf("invalid parameter, expect %T, actual %T", RepoParam{}, param)
|
||||
|
@ -399,7 +399,7 @@ func (urp *unifiedRepoProvider) GetStoreType(param interface{}) (string, error)
|
|||
return getStorageType(repoParam.BackupLocation), nil
|
||||
}
|
||||
|
||||
func (urp *unifiedRepoProvider) GetStoreOptions(param interface{}) (map[string]string, error) {
|
||||
func (urp *unifiedRepoProvider) GetStoreOptions(param any) (map[string]string, error) {
|
||||
repoParam, ok := param.(RepoParam)
|
||||
if !ok {
|
||||
return map[string]string{}, errors.Errorf("invalid parameter, expect %T, actual %T", RepoParam{}, param)
|
||||
|
|
|
@ -538,7 +538,7 @@ func TestGetStoreOptions(t *testing.T) {
|
|||
testCases := []struct {
|
||||
name string
|
||||
funcTable localFuncTable
|
||||
repoParam interface{}
|
||||
repoParam any
|
||||
expected map[string]string
|
||||
expectedErr string
|
||||
}{
|
||||
|
@ -798,9 +798,9 @@ func TestForget(t *testing.T) {
|
|||
getter *credmock.SecretStore
|
||||
repoService *reposervicenmocks.BackupRepoService
|
||||
backupRepo *reposervicenmocks.BackupRepo
|
||||
retFuncOpen []interface{}
|
||||
retFuncDelete interface{}
|
||||
retFuncFlush interface{}
|
||||
retFuncOpen []any
|
||||
retFuncDelete any
|
||||
retFuncFlush any
|
||||
credStoreReturn string
|
||||
credStoreError error
|
||||
expectedErr string
|
||||
|
@ -822,7 +822,7 @@ func TestForget(t *testing.T) {
|
|||
},
|
||||
},
|
||||
repoService: new(reposervicenmocks.BackupRepoService),
|
||||
retFuncOpen: []interface{}{
|
||||
retFuncOpen: []any{
|
||||
func(context.Context, udmrepo.RepoOptions) udmrepo.BackupRepo {
|
||||
return backupRepo
|
||||
},
|
||||
|
@ -847,7 +847,7 @@ func TestForget(t *testing.T) {
|
|||
},
|
||||
repoService: new(reposervicenmocks.BackupRepoService),
|
||||
backupRepo: new(reposervicenmocks.BackupRepo),
|
||||
retFuncOpen: []interface{}{
|
||||
retFuncOpen: []any{
|
||||
func(context.Context, udmrepo.RepoOptions) udmrepo.BackupRepo {
|
||||
return backupRepo
|
||||
},
|
||||
|
@ -875,7 +875,7 @@ func TestForget(t *testing.T) {
|
|||
},
|
||||
repoService: new(reposervicenmocks.BackupRepoService),
|
||||
backupRepo: new(reposervicenmocks.BackupRepo),
|
||||
retFuncOpen: []interface{}{
|
||||
retFuncOpen: []any{
|
||||
func(context.Context, udmrepo.RepoOptions) udmrepo.BackupRepo {
|
||||
return backupRepo
|
||||
},
|
||||
|
@ -947,9 +947,9 @@ func TestBatchForget(t *testing.T) {
|
|||
getter *credmock.SecretStore
|
||||
repoService *reposervicenmocks.BackupRepoService
|
||||
backupRepo *reposervicenmocks.BackupRepo
|
||||
retFuncOpen []interface{}
|
||||
retFuncDelete interface{}
|
||||
retFuncFlush interface{}
|
||||
retFuncOpen []any
|
||||
retFuncDelete any
|
||||
retFuncFlush any
|
||||
credStoreReturn string
|
||||
credStoreError error
|
||||
snapshots []string
|
||||
|
@ -972,7 +972,7 @@ func TestBatchForget(t *testing.T) {
|
|||
},
|
||||
},
|
||||
repoService: new(reposervicenmocks.BackupRepoService),
|
||||
retFuncOpen: []interface{}{
|
||||
retFuncOpen: []any{
|
||||
func(context.Context, udmrepo.RepoOptions) udmrepo.BackupRepo {
|
||||
return backupRepo
|
||||
},
|
||||
|
@ -997,7 +997,7 @@ func TestBatchForget(t *testing.T) {
|
|||
},
|
||||
repoService: new(reposervicenmocks.BackupRepoService),
|
||||
backupRepo: new(reposervicenmocks.BackupRepo),
|
||||
retFuncOpen: []interface{}{
|
||||
retFuncOpen: []any{
|
||||
func(context.Context, udmrepo.RepoOptions) udmrepo.BackupRepo {
|
||||
return backupRepo
|
||||
},
|
||||
|
@ -1026,7 +1026,7 @@ func TestBatchForget(t *testing.T) {
|
|||
},
|
||||
repoService: new(reposervicenmocks.BackupRepoService),
|
||||
backupRepo: new(reposervicenmocks.BackupRepo),
|
||||
retFuncOpen: []interface{}{
|
||||
retFuncOpen: []any{
|
||||
func(context.Context, udmrepo.RepoOptions) udmrepo.BackupRepo {
|
||||
return backupRepo
|
||||
},
|
||||
|
@ -1106,7 +1106,7 @@ func TestInitRepo(t *testing.T) {
|
|||
funcTable localFuncTable
|
||||
getter *credmock.SecretStore
|
||||
repoService *reposervicenmocks.BackupRepoService
|
||||
retFuncInit interface{}
|
||||
retFuncInit any
|
||||
credStoreReturn string
|
||||
credStoreError error
|
||||
readOnlyBSL bool
|
||||
|
@ -1206,7 +1206,7 @@ func TestConnectToRepo(t *testing.T) {
|
|||
funcTable localFuncTable
|
||||
getter *credmock.SecretStore
|
||||
repoService *reposervicenmocks.BackupRepoService
|
||||
retFuncInit interface{}
|
||||
retFuncInit any
|
||||
credStoreReturn string
|
||||
credStoreError error
|
||||
expectedErr string
|
||||
|
@ -1297,8 +1297,8 @@ func TestBoostRepoConnect(t *testing.T) {
|
|||
getter *credmock.SecretStore
|
||||
repoService *reposervicenmocks.BackupRepoService
|
||||
backupRepo *reposervicenmocks.BackupRepo
|
||||
retFuncInit interface{}
|
||||
retFuncOpen []interface{}
|
||||
retFuncInit any
|
||||
retFuncOpen []any
|
||||
credStoreReturn string
|
||||
credStoreError error
|
||||
expectedErr string
|
||||
|
@ -1320,7 +1320,7 @@ func TestBoostRepoConnect(t *testing.T) {
|
|||
},
|
||||
},
|
||||
repoService: new(reposervicenmocks.BackupRepoService),
|
||||
retFuncOpen: []interface{}{
|
||||
retFuncOpen: []any{
|
||||
func(context.Context, udmrepo.RepoOptions) udmrepo.BackupRepo {
|
||||
return backupRepo
|
||||
},
|
||||
|
@ -1347,7 +1347,7 @@ func TestBoostRepoConnect(t *testing.T) {
|
|||
},
|
||||
},
|
||||
repoService: new(reposervicenmocks.BackupRepoService),
|
||||
retFuncOpen: []interface{}{
|
||||
retFuncOpen: []any{
|
||||
func(context.Context, udmrepo.RepoOptions) udmrepo.BackupRepo {
|
||||
return backupRepo
|
||||
},
|
||||
|
@ -1374,7 +1374,7 @@ func TestBoostRepoConnect(t *testing.T) {
|
|||
},
|
||||
repoService: new(reposervicenmocks.BackupRepoService),
|
||||
backupRepo: new(reposervicenmocks.BackupRepo),
|
||||
retFuncOpen: []interface{}{
|
||||
retFuncOpen: []any{
|
||||
func(context.Context, udmrepo.RepoOptions) udmrepo.BackupRepo {
|
||||
return backupRepo
|
||||
},
|
||||
|
@ -1438,7 +1438,7 @@ func TestPruneRepo(t *testing.T) {
|
|||
funcTable localFuncTable
|
||||
getter *credmock.SecretStore
|
||||
repoService *reposervicenmocks.BackupRepoService
|
||||
retFuncMaintain interface{}
|
||||
retFuncMaintain any
|
||||
credStoreReturn string
|
||||
credStoreError error
|
||||
expectedErr string
|
||||
|
|
|
@ -33,7 +33,7 @@ type ManifestEntryMetadata struct {
|
|||
}
|
||||
|
||||
type RepoManifest struct {
|
||||
Payload interface{} // The user data of manifest
|
||||
Payload any // The user data of manifest
|
||||
Metadata *ManifestEntryMetadata // The metadata data of manifest
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue