pkg/controller: remove usage of pkg/util/collections
Signed-off-by: Steve Kriss <krisss@vmware.com>pull/1146/head
parent
38ad7d71f5
commit
88fc6e2141
|
@ -30,6 +30,7 @@ import (
|
|||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
core "k8s.io/client-go/testing"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
|
@ -45,7 +46,6 @@ import (
|
|||
"github.com/heptio/velero/pkg/plugin"
|
||||
pluginmocks "github.com/heptio/velero/pkg/plugin/mocks"
|
||||
"github.com/heptio/velero/pkg/restore"
|
||||
"github.com/heptio/velero/pkg/util/collections"
|
||||
velerotest "github.com/heptio/velero/pkg/util/test"
|
||||
"github.com/heptio/velero/pkg/volume"
|
||||
)
|
||||
|
@ -440,11 +440,15 @@ func TestProcessRestore(t *testing.T) {
|
|||
return false, nil, err
|
||||
}
|
||||
|
||||
phase, err := collections.GetString(patchMap, "status.phase")
|
||||
phase, found, err := unstructured.NestedString(patchMap, "status", "phase")
|
||||
if err != nil {
|
||||
t.Logf("error getting status.phase: %s\n", err)
|
||||
return false, nil, err
|
||||
}
|
||||
if !found {
|
||||
t.Logf("status.phase not found")
|
||||
return false, nil, errors.New("status.phase not found")
|
||||
}
|
||||
|
||||
res := test.restore.DeepCopy()
|
||||
|
||||
|
@ -453,7 +457,8 @@ func TestProcessRestore(t *testing.T) {
|
|||
|
||||
res.Status.Phase = api.RestorePhase(phase)
|
||||
|
||||
if backupName, err := collections.GetString(patchMap, "spec.backupName"); err == nil {
|
||||
backupName, found, err := unstructured.NestedString(patchMap, "spec", "backupName")
|
||||
if err == nil && found {
|
||||
res.Spec.BackupName = backupName
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/util/clock"
|
||||
core "k8s.io/client-go/testing"
|
||||
|
@ -35,7 +36,6 @@ import (
|
|||
"github.com/heptio/velero/pkg/generated/clientset/versioned/fake"
|
||||
informers "github.com/heptio/velero/pkg/generated/informers/externalversions"
|
||||
"github.com/heptio/velero/pkg/metrics"
|
||||
"github.com/heptio/velero/pkg/util/collections"
|
||||
velerotest "github.com/heptio/velero/pkg/util/test"
|
||||
)
|
||||
|
||||
|
@ -159,13 +159,13 @@ func TestProcessSchedule(t *testing.T) {
|
|||
}
|
||||
|
||||
// these are the fields that may be updated by the controller
|
||||
phase, err := collections.GetString(patchMap, "status.phase")
|
||||
if err == nil {
|
||||
phase, found, err := unstructured.NestedString(patchMap, "status", "phase")
|
||||
if err == nil && found {
|
||||
res.Status.Phase = api.SchedulePhase(phase)
|
||||
}
|
||||
|
||||
lastBackupStr, err := collections.GetString(patchMap, "status.lastBackup")
|
||||
if err == nil {
|
||||
lastBackupStr, found, err := unstructured.NestedString(patchMap, "status", "lastBackup")
|
||||
if err == nil && found {
|
||||
parsed, err := time.Parse(time.RFC3339, lastBackupStr)
|
||||
if err != nil {
|
||||
t.Logf("error parsing status.lastBackup: %s\n", err)
|
||||
|
|
Loading…
Reference in New Issue