@@ -13,12 +13,15 @@ import (
13
13
"k8s.io/apimachinery/pkg/api/meta/testrestmapper"
14
14
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15
15
"k8s.io/apimachinery/pkg/runtime"
16
+ "k8s.io/apimachinery/pkg/runtime/serializer"
16
17
utilerrors "k8s.io/apimachinery/pkg/util/errors"
17
18
fakekubernetes "k8s.io/client-go/kubernetes/fake"
19
+ kubernetesscheme "k8s.io/client-go/kubernetes/scheme"
18
20
clientgotesting "k8s.io/client-go/testing"
19
21
"k8s.io/kubernetes/pkg/api/legacyscheme"
20
22
kubeclientscheme "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/scheme"
21
23
24
+ "github.com/openshift/api"
22
25
appsv1 "github.com/openshift/api/apps/v1"
23
26
projectv1 "github.com/openshift/api/project/v1"
24
27
fakeappsclient "github.com/openshift/client-go/apps/clientset/versioned/fake"
@@ -484,8 +487,7 @@ func TestProjectStatus(t *testing.T) {
484
487
if len (test .File ) > 0 {
485
488
// Load data from a folder dedicated to mock data, which is never loaded into the API during tests
486
489
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" )
489
491
if err != nil {
490
492
t .Errorf ("%s: unexpected error: %v" , k , err )
491
493
}
@@ -663,17 +665,21 @@ func TestPrintMarkerSuggestions(t *testing.T) {
663
665
}
664
666
665
667
// 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 ) {
667
669
data , err := ioutil .ReadFile (path )
668
670
if err != nil {
669
671
return nil , err
670
672
}
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 )
672
678
if err != nil {
673
679
return nil , err
674
680
}
675
681
if ! meta .IsListType (obj ) {
676
- if err := setNamespace (typer , obj , namespace ); err != nil {
682
+ if err := setNamespace (scheme , obj , namespace ); err != nil {
677
683
return nil , err
678
684
}
679
685
return []runtime.Object {obj }, nil
@@ -682,12 +688,12 @@ func readObjectsFromPath(path, namespace string, decoder runtime.Decoder, typer
682
688
if err != nil {
683
689
return nil , err
684
690
}
685
- errs := runtime .DecodeList (list , decoder )
691
+ errs := runtime .DecodeList (list , codecs . UniversalDeserializer () )
686
692
if len (errs ) > 0 {
687
693
return nil , errs [0 ]
688
694
}
689
695
for _ , o := range list {
690
- if err := setNamespace (typer , o , namespace ); err != nil {
696
+ if err := setNamespace (scheme , o , namespace ); err != nil {
691
697
return nil , err
692
698
}
693
699
}
0 commit comments