@@ -11,16 +11,19 @@ import (
11
11
"time"
12
12
13
13
"github.com/davecgh/go-spew/spew"
14
- "github.com/ghodss/yaml"
15
-
16
14
g "github.com/onsi/ginkgo"
17
15
o "github.com/onsi/gomega"
18
16
19
17
corev1 "k8s.io/api/core/v1"
20
18
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21
19
"k8s.io/apimachinery/pkg/fields"
20
+ "k8s.io/apimachinery/pkg/labels"
21
+ "k8s.io/apimachinery/pkg/runtime"
22
+ "k8s.io/apimachinery/pkg/runtime/serializer"
23
+ "k8s.io/apimachinery/pkg/selection"
22
24
"k8s.io/apimachinery/pkg/util/sets"
23
25
"k8s.io/apimachinery/pkg/util/wait"
26
+ kyaml "k8s.io/apimachinery/pkg/util/yaml"
24
27
"k8s.io/apimachinery/pkg/watch"
25
28
"k8s.io/client-go/kubernetes"
26
29
"k8s.io/client-go/util/retry"
@@ -33,8 +36,6 @@ import (
33
36
appstypedclientset "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion"
34
37
appsutil "github.com/openshift/origin/pkg/apps/util"
35
38
exutil "github.com/openshift/origin/test/extended/util"
36
- "k8s.io/apimachinery/pkg/labels"
37
- "k8s.io/apimachinery/pkg/selection"
38
39
)
39
40
40
41
type updateConfigFunc func (d * appsapi.DeploymentConfig )
@@ -489,30 +490,18 @@ func waitForDCModification(oc *exutil.CLI, namespace string, name string, timeou
489
490
return event .Object .(* appsapi.DeploymentConfig ), nil
490
491
}
491
492
492
- // createFixture will create the provided fixture and return the resource and the
493
- // name separately.
494
- // TODO: Probably move to a more general location like test/extended/util/cli.go
495
- func createFixture (oc * exutil.CLI , fixture string ) (string , string , error ) {
496
- resource , err := oc .Run ("create" ).Args ("-f" , fixture , "-o" , "name" ).Output ()
493
+ func createDeploymentConfig (oc * exutil.CLI , fixture string ) (* appsapi.DeploymentConfig , error ) {
494
+ dcFixture , err := readDCFixture (fixture )
497
495
if err != nil {
498
- return "" , "" , err
499
- }
500
- parts := strings .Split (resource , "/" )
501
- if len (parts ) != 2 {
502
- return "" , "" , fmt .Errorf ("expected type/name syntax, got: %s" , resource )
496
+ return nil , err
503
497
}
504
- return resource , parts [1 ], nil
505
- }
506
-
507
- func createDeploymentConfig (oc * exutil.CLI , fixture string ) (* appsapi.DeploymentConfig , error ) {
508
- _ , name , err := createFixture (oc , fixture )
498
+ dc , err := oc .AppsClient ().Apps ().DeploymentConfigs (oc .Namespace ()).Create (dcFixture )
509
499
if err != nil {
510
500
return nil , err
511
501
}
512
502
var pollErr error
513
- var dc * appsapi.DeploymentConfig
514
503
err = wait .PollImmediate (1 * time .Second , 1 * time .Minute , func () (bool , error ) {
515
- dc , err = oc .AppsClient ().Apps ().DeploymentConfigs (oc .Namespace ()).Get (name , metav1.GetOptions {})
504
+ dc , err = oc .AppsClient ().Apps ().DeploymentConfigs (oc .Namespace ()).Get (dc . Name , metav1.GetOptions {})
516
505
if err != nil {
517
506
pollErr = err
518
507
return false , nil
@@ -625,24 +614,20 @@ func readDCFixture(path string) (*appsapi.DeploymentConfig, error) {
625
614
if err != nil {
626
615
return nil , err
627
616
}
628
-
629
- dcv1 := new (appsapiv1.DeploymentConfig )
630
- err = yaml .Unmarshal (data , dcv1 )
617
+ content , err := kyaml .ToJSON (data )
631
618
if err != nil {
632
619
return nil , err
633
620
}
634
-
635
- dc := new (appsapi.DeploymentConfig )
636
- err = legacyscheme .Scheme .Convert (dcv1 , dc , nil )
637
- return dc , err
638
- }
639
-
640
- func readDCFixtureOrDie (path string ) * appsapi.DeploymentConfig {
641
- data , err := readDCFixture (path )
621
+ appsScheme := runtime .NewScheme ()
622
+ appsCodecs := serializer .NewCodecFactory (appsScheme )
623
+ appsapiv1 .AddToScheme (appsScheme )
624
+ obj , err := runtime .Decode (appsCodecs .UniversalDecoder (appsapiv1 .SchemeGroupVersion ), content )
642
625
if err != nil {
643
- panic ( err )
626
+ return nil , err
644
627
}
645
- return data
628
+ var dc appsapi.DeploymentConfig
629
+ err = legacyscheme .Scheme .Convert (obj , & dc , nil )
630
+ return & dc , err
646
631
}
647
632
648
633
type deployerPodInvariantChecker struct {
0 commit comments