mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-03 11:45:20 +00:00
chore: enable use-any from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user