Skip to content

Commit ea2ce08

Browse files
committed
describe
1 parent 24d12c2 commit ea2ce08

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

pkg/oc/lib/describe/chaindescriber_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010

1111
"k8s.io/apimachinery/pkg/runtime"
1212
"k8s.io/apimachinery/pkg/util/sets"
13-
"k8s.io/kubernetes/pkg/api/legacyscheme"
1413

1514
fakebuildclient "github.com/openshift/client-go/build/clientset/versioned/fake"
1615
fakebuildv1client "github.com/openshift/client-go/build/clientset/versioned/typed/build/v1/fake"
@@ -204,7 +203,7 @@ func TestChainDescriber(t *testing.T) {
204203
objs := []runtime.Object{}
205204
if len(test.path) > 0 {
206205
var err error
207-
objs, err = readObjectsFromPath(test.path, test.defaultNamespace, legacyscheme.Codecs.UniversalDecoder(), legacyscheme.Scheme)
206+
objs, err = readObjectsFromPath(test.path, test.defaultNamespace)
208207
if err != nil {
209208
t.Fatal(err)
210209
}

pkg/oc/lib/describe/projectstatus_test.go

+13-7
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ import (
1313
"k8s.io/apimachinery/pkg/api/meta/testrestmapper"
1414
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1515
"k8s.io/apimachinery/pkg/runtime"
16+
"k8s.io/apimachinery/pkg/runtime/serializer"
1617
utilerrors "k8s.io/apimachinery/pkg/util/errors"
1718
fakekubernetes "k8s.io/client-go/kubernetes/fake"
19+
kubernetesscheme "k8s.io/client-go/kubernetes/scheme"
1820
clientgotesting "k8s.io/client-go/testing"
1921
"k8s.io/kubernetes/pkg/api/legacyscheme"
2022
kubeclientscheme "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/scheme"
2123

24+
"github.com/openshift/api"
2225
appsv1 "github.com/openshift/api/apps/v1"
2326
projectv1 "github.com/openshift/api/project/v1"
2427
fakeappsclient "github.com/openshift/client-go/apps/clientset/versioned/fake"
@@ -484,8 +487,7 @@ func TestProjectStatus(t *testing.T) {
484487
if len(test.File) > 0 {
485488
// Load data from a folder dedicated to mock data, which is never loaded into the API during tests
486489
var err error
487-
objs, err = readObjectsFromPath("../../../../pkg/oc/lib/graph/genericgraph/test/"+test.File, "example",
488-
legacyscheme.Codecs.LegacyCodec(legacyscheme.Scheme.PrioritizedVersionsAllGroups()...), legacyscheme.Scheme)
490+
objs, err = readObjectsFromPath("../../../../pkg/oc/lib/graph/genericgraph/test/"+test.File, "example")
489491
if err != nil {
490492
t.Errorf("%s: unexpected error: %v", k, err)
491493
}
@@ -663,17 +665,21 @@ func TestPrintMarkerSuggestions(t *testing.T) {
663665
}
664666

665667
// ReadObjectsFromPath reads objects from the specified file for testing.
666-
func readObjectsFromPath(path, namespace string, decoder runtime.Decoder, typer runtime.ObjectTyper) ([]runtime.Object, error) {
668+
func readObjectsFromPath(path, namespace string) ([]runtime.Object, error) {
667669
data, err := ioutil.ReadFile(path)
668670
if err != nil {
669671
return nil, err
670672
}
671-
obj, err := runtime.Decode(decoder, data)
673+
scheme := runtime.NewScheme()
674+
kubernetesscheme.AddToScheme(scheme)
675+
api.Install(scheme)
676+
codecs := serializer.NewCodecFactory(scheme)
677+
obj, err := runtime.Decode(codecs.UniversalDeserializer(), data)
672678
if err != nil {
673679
return nil, err
674680
}
675681
if !meta.IsListType(obj) {
676-
if err := setNamespace(typer, obj, namespace); err != nil {
682+
if err := setNamespace(scheme, obj, namespace); err != nil {
677683
return nil, err
678684
}
679685
return []runtime.Object{obj}, nil
@@ -682,12 +688,12 @@ func readObjectsFromPath(path, namespace string, decoder runtime.Decoder, typer
682688
if err != nil {
683689
return nil, err
684690
}
685-
errs := runtime.DecodeList(list, decoder)
691+
errs := runtime.DecodeList(list, codecs.UniversalDeserializer())
686692
if len(errs) > 0 {
687693
return nil, errs[0]
688694
}
689695
for _, o := range list {
690-
if err := setNamespace(typer, o, namespace); err != nil {
696+
if err := setNamespace(scheme, o, namespace); err != nil {
691697
return nil, err
692698
}
693699
}

0 commit comments

Comments
 (0)