diff --git a/examples/examples_test.go b/examples/examples_test.go index cf777d5ed656..588ae13495ab 100644 --- a/examples/examples_test.go +++ b/examples/examples_test.go @@ -18,7 +18,7 @@ import ( "k8s.io/kubernetes/pkg/capabilities" "github.com/openshift/origin/pkg/api/validation" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" networkapi "github.com/openshift/origin/pkg/network/apis/network" @@ -113,7 +113,7 @@ func TestExampleObjectSchemas(t *testing.T) { }, "../test/extended/testdata/ldap": { "ldapserver-buildconfig": &buildapi.BuildConfig{}, - "ldapserver-deploymentconfig": &deployapi.DeploymentConfig{}, + "ldapserver-deploymentconfig": &appsapi.DeploymentConfig{}, "ldapserver-imagestream": &imageapi.ImageStream{}, "ldapserver-imagestream-testenv": &imageapi.ImageStream{}, "ldapserver-service": &kapi.Service{}, @@ -122,7 +122,7 @@ func TestExampleObjectSchemas(t *testing.T) { // TODO fix this test to handle json and yaml "project-request-template-with-quota": nil, // skip a yaml file "test-replication-controller": nil, // skip &api.ReplicationController - "test-deployment-config": &deployapi.DeploymentConfig{}, + "test-deployment-config": &appsapi.DeploymentConfig{}, "test-image": &imageapi.Image{}, "test-image-stream": &imageapi.ImageStream{}, "test-image-stream-mapping": nil, // skip &imageapi.ImageStreamMapping{}, diff --git a/pkg/api/graph/graphview/dc_pipeline.go b/pkg/api/graph/graphview/dc_pipeline.go index 6c238eb2b95f..1a76e4f503d9 100644 --- a/pkg/api/graph/graphview/dc_pipeline.go +++ b/pkg/api/graph/graphview/dc_pipeline.go @@ -5,12 +5,12 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployedges "github.com/openshift/origin/pkg/apps/graph" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsedges "github.com/openshift/origin/pkg/apps/graph" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" ) type DeploymentConfigPipeline struct { - Deployment *deploygraph.DeploymentConfigNode + Deployment *appsgraph.DeploymentConfigNode ActiveDeployment *kubegraph.ReplicationControllerNode InactiveDeployments []*kubegraph.ReplicationControllerNode @@ -23,12 +23,12 @@ func AllDeploymentConfigPipelines(g osgraph.Graph, excludeNodeIDs IntSet) ([]Dep covered := IntSet{} dcPipelines := []DeploymentConfigPipeline{} - for _, uncastNode := range g.NodesByKind(deploygraph.DeploymentConfigNodeKind) { + for _, uncastNode := range g.NodesByKind(appsgraph.DeploymentConfigNodeKind) { if excludeNodeIDs.Has(uncastNode.ID()) { continue } - pipeline, covers := NewDeploymentConfigPipeline(g, uncastNode.(*deploygraph.DeploymentConfigNode)) + pipeline, covers := NewDeploymentConfigPipeline(g, uncastNode.(*appsgraph.DeploymentConfigNode)) covered.Insert(covers.List()...) dcPipelines = append(dcPipelines, pipeline) } @@ -38,7 +38,7 @@ func AllDeploymentConfigPipelines(g osgraph.Graph, excludeNodeIDs IntSet) ([]Dep } // NewDeploymentConfigPipeline returns the DeploymentConfigPipeline and a set of all the NodeIDs covered by the DeploymentConfigPipeline -func NewDeploymentConfigPipeline(g osgraph.Graph, dcNode *deploygraph.DeploymentConfigNode) (DeploymentConfigPipeline, IntSet) { +func NewDeploymentConfigPipeline(g osgraph.Graph, dcNode *appsgraph.DeploymentConfigNode) (DeploymentConfigPipeline, IntSet) { covered := IntSet{} covered.Insert(dcNode.ID()) @@ -46,7 +46,7 @@ func NewDeploymentConfigPipeline(g osgraph.Graph, dcNode *deploygraph.Deployment dcPipeline.Deployment = dcNode // for everything that can trigger a deployment, create an image pipeline and add it to the list - for _, istNode := range g.PredecessorNodesByEdgeKind(dcNode, deployedges.TriggersDeploymentEdgeKind) { + for _, istNode := range g.PredecessorNodesByEdgeKind(dcNode, appsedges.TriggersDeploymentEdgeKind) { imagePipeline, covers := NewImagePipelineFromImageTagLocation(g, istNode, istNode.(ImageTagLocation)) covered.Insert(covers.List()...) @@ -54,14 +54,14 @@ func NewDeploymentConfigPipeline(g osgraph.Graph, dcNode *deploygraph.Deployment } // for image that we use, create an image pipeline and add it to the list - for _, tagNode := range g.PredecessorNodesByEdgeKind(dcNode, deployedges.UsedInDeploymentEdgeKind) { + for _, tagNode := range g.PredecessorNodesByEdgeKind(dcNode, appsedges.UsedInDeploymentEdgeKind) { imagePipeline, covers := NewImagePipelineFromImageTagLocation(g, tagNode, tagNode.(ImageTagLocation)) covered.Insert(covers.List()...) dcPipeline.Images = append(dcPipeline.Images, imagePipeline) } - dcPipeline.ActiveDeployment, dcPipeline.InactiveDeployments = deployedges.RelevantDeployments(g, dcNode) + dcPipeline.ActiveDeployment, dcPipeline.InactiveDeployments = appsedges.RelevantDeployments(g, dcNode) for _, rc := range dcPipeline.InactiveDeployments { _, covers := NewReplicationController(g, rc) covered.Insert(covers.List()...) diff --git a/pkg/api/graph/graphview/service_group.go b/pkg/api/graph/graphview/service_group.go index 101a30db6797..95ad5e4029f3 100644 --- a/pkg/api/graph/graphview/service_group.go +++ b/pkg/api/graph/graphview/service_group.go @@ -10,7 +10,7 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" kubeedges "github.com/openshift/origin/pkg/api/kubegraph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" routeedges "github.com/openshift/origin/pkg/route/graph" routegraph "github.com/openshift/origin/pkg/route/graph/nodes" ) @@ -25,7 +25,7 @@ type ServiceGroup struct { // TODO: this has to stop FulfillingStatefulSets []*kubegraph.StatefulSetNode - FulfillingDCs []*deploygraph.DeploymentConfigNode + FulfillingDCs []*appsgraph.DeploymentConfigNode FulfillingRCs []*kubegraph.ReplicationControllerNode FulfillingPods []*kubegraph.PodNode @@ -63,7 +63,7 @@ func NewServiceGroup(g osgraph.Graph, serviceNode *kubegraph.ServiceNode) (Servi container := osgraph.GetTopLevelContainerNode(g, uncastServiceFulfiller) switch castContainer := container.(type) { - case *deploygraph.DeploymentConfigNode: + case *appsgraph.DeploymentConfigNode: service.FulfillingDCs = append(service.FulfillingDCs, castContainer) case *kubegraph.ReplicationControllerNode: service.FulfillingRCs = append(service.FulfillingRCs, castContainer) diff --git a/pkg/api/graph/graphview/veneering_test.go b/pkg/api/graph/graphview/veneering_test.go index 722aae5c904f..7f9ee08430b3 100644 --- a/pkg/api/graph/graphview/veneering_test.go +++ b/pkg/api/graph/graphview/veneering_test.go @@ -14,9 +14,9 @@ import ( osgraphtest "github.com/openshift/origin/pkg/api/graph/test" kubeedges "github.com/openshift/origin/pkg/api/kubegraph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployedges "github.com/openshift/origin/pkg/apps/graph" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsedges "github.com/openshift/origin/pkg/apps/graph" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildedges "github.com/openshift/origin/pkg/build/graph" buildgraph "github.com/openshift/origin/pkg/build/graph/nodes" @@ -31,7 +31,7 @@ func TestServiceGroup(t *testing.T) { kubeedges.AddAllExposedPodTemplateSpecEdges(g) buildedges.AddAllInputOutputEdges(g) - deployedges.AddAllTriggerEdges(g) + appsedges.AddAllTriggerEdges(g) coveredNodes := IntSet{} @@ -104,7 +104,7 @@ func TestBareDCGroup(t *testing.T) { kubeedges.AddAllExposedPodTemplateSpecEdges(g) buildedges.AddAllInputOutputEdges(g) - deployedges.AddAllTriggerEdges(g) + appsedges.AddAllTriggerEdges(g) coveredNodes := IntSet{} @@ -160,7 +160,7 @@ func TestBareBCGroup(t *testing.T) { kubeedges.AddAllExposedPodTemplateSpecEdges(g) buildedges.AddAllInputOutputEdges(g) - deployedges.AddAllTriggerEdges(g) + appsedges.AddAllTriggerEdges(g) coveredNodes := IntSet{} @@ -286,12 +286,12 @@ func TestGraph(t *testing.T) { }, }, }) - deploygraph.EnsureDeploymentConfigNode(g, &deployapi.DeploymentConfig{ + appsgraph.EnsureDeploymentConfigNode(g, &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Namespace: "other", Name: "deploy1"}, - Spec: deployapi.DeploymentConfigSpec{ - Triggers: []deployapi.DeploymentTriggerPolicy{ + Spec: appsapi.DeploymentConfigSpec{ + Triggers: []appsapi.DeploymentTriggerPolicy{ { - ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ + ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ From: kapi.ObjectReference{Kind: "ImageStreamTag", Namespace: "default", Name: "other:tag1"}, ContainerNames: []string{"1", "2"}, }, @@ -323,9 +323,9 @@ func TestGraph(t *testing.T) { }, }, }) - deploygraph.EnsureDeploymentConfigNode(g, &deployapi.DeploymentConfig{ + appsgraph.EnsureDeploymentConfigNode(g, &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Namespace: "default", Name: "deploy2"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Template: &kapi.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{ @@ -348,8 +348,8 @@ func TestGraph(t *testing.T) { kubeedges.AddAllExposedPodTemplateSpecEdges(g) buildedges.AddAllInputOutputEdges(g) buildedges.AddAllBuildEdges(g) - deployedges.AddAllTriggerEdges(g) - deployedges.AddAllDeploymentEdges(g) + appsedges.AddAllTriggerEdges(g) + appsedges.AddAllDeploymentEdges(g) t.Log(g) diff --git a/pkg/api/graph/test/runtimeobject_nodebuilder.go b/pkg/api/graph/test/runtimeobject_nodebuilder.go index ec7540491b61..fc9ace3f596a 100644 --- a/pkg/api/graph/test/runtimeobject_nodebuilder.go +++ b/pkg/api/graph/test/runtimeobject_nodebuilder.go @@ -14,8 +14,8 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" _ "github.com/openshift/origin/pkg/api/install" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildgraph "github.com/openshift/origin/pkg/build/graph/nodes" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -34,7 +34,7 @@ func init() { if err := RegisterEnsureNode(&imageapi.ImageStream{}, imagegraph.EnsureImageStreamNode); err != nil { panic(err) } - if err := RegisterEnsureNode(&deployapi.DeploymentConfig{}, deploygraph.EnsureDeploymentConfigNode); err != nil { + if err := RegisterEnsureNode(&appsapi.DeploymentConfig{}, appsgraph.EnsureDeploymentConfigNode); err != nil { panic(err) } if err := RegisterEnsureNode(&buildapi.BuildConfig{}, buildgraph.EnsureBuildConfigNode); err != nil { diff --git a/pkg/api/install/install.go b/pkg/api/install/install.go index 6333e775f8d9..a6a016137427 100644 --- a/pkg/api/install/install.go +++ b/pkg/api/install/install.go @@ -38,7 +38,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" watchapi "k8s.io/apimachinery/pkg/watch" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -48,7 +48,7 @@ import ( templateapi "github.com/openshift/origin/pkg/template/apis/template" userapi "github.com/openshift/origin/pkg/user/apis/user" - deployv1 "github.com/openshift/api/apps/v1" + appsv1 "github.com/openshift/api/apps/v1" authorizationv1 "github.com/openshift/api/authorization/v1" buildv1 "github.com/openshift/api/build/v1" imagev1 "github.com/openshift/api/image/v1" @@ -58,7 +58,7 @@ import ( templatev1 "github.com/openshift/api/template/v1" userv1 "github.com/openshift/api/user/v1" - deployconversionv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsconversionv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" authorizationconversionv1 "github.com/openshift/origin/pkg/authorization/apis/authorization/v1" buildconversionv1 "github.com/openshift/origin/pkg/build/apis/build/v1" imageconversionv1 "github.com/openshift/origin/pkg/image/apis/image/v1" @@ -312,15 +312,15 @@ func init() { return true, templateconversionv1.Convert_template_BrokerTemplateInstanceList_To_v1_BrokerTemplateInstanceList(a, b, s) } - case *deployv1.DeploymentConfig: + case *appsv1.DeploymentConfig: switch b := objB.(type) { - case *deployapi.DeploymentConfig: - return true, deployconversionv1.Convert_v1_DeploymentConfig_To_apps_DeploymentConfig(a, b, s) + case *appsapi.DeploymentConfig: + return true, appsconversionv1.Convert_v1_DeploymentConfig_To_apps_DeploymentConfig(a, b, s) } - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: switch b := objB.(type) { - case *deployv1.DeploymentConfig: - return true, deployconversionv1.Convert_apps_DeploymentConfig_To_v1_DeploymentConfig(a, b, s) + case *appsv1.DeploymentConfig: + return true, appsconversionv1.Convert_apps_DeploymentConfig_To_v1_DeploymentConfig(a, b, s) } case *imagev1.ImageStream: diff --git a/pkg/api/kubegraph/analysis/hpa.go b/pkg/api/kubegraph/analysis/hpa.go index dfd080f9dbf9..eee05e469d8a 100644 --- a/pkg/api/kubegraph/analysis/hpa.go +++ b/pkg/api/kubegraph/analysis/hpa.go @@ -15,8 +15,8 @@ import ( "github.com/openshift/origin/pkg/api/kubegraph" kubeedges "github.com/openshift/origin/pkg/api/kubegraph" kubenodes "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deploygraph "github.com/openshift/origin/pkg/apps/graph" - deploynodes "github.com/openshift/origin/pkg/apps/graph/nodes" + appsgraph "github.com/openshift/origin/pkg/apps/graph" + appsnodes "github.com/openshift/origin/pkg/apps/graph/nodes" ) const ( @@ -123,11 +123,11 @@ func FindOverlappingHPAs(graph osgraph.Graph, namer osgraph.Namer) []osgraph.Mar nodeFilter := osgraph.NodesOfKind( kubenodes.HorizontalPodAutoscalerNodeKind, kubenodes.ReplicationControllerNodeKind, - deploynodes.DeploymentConfigNodeKind, + appsnodes.DeploymentConfigNodeKind, ) edgeFilter := osgraph.EdgesOfKind( kubegraph.ScalingEdgeKind, - deploygraph.DeploymentEdgeKind, + appsgraph.DeploymentEdgeKind, kubeedges.ManagedByControllerEdgeKind, ) diff --git a/pkg/api/kubegraph/analysis/hpa_test.go b/pkg/api/kubegraph/analysis/hpa_test.go index 8725ba805b1a..4e13bcd2e37f 100644 --- a/pkg/api/kubegraph/analysis/hpa_test.go +++ b/pkg/api/kubegraph/analysis/hpa_test.go @@ -7,7 +7,7 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" osgraphtest "github.com/openshift/origin/pkg/api/graph/test" "github.com/openshift/origin/pkg/api/kubegraph" - deploygraph "github.com/openshift/origin/pkg/apps/graph" + appsgraph "github.com/openshift/origin/pkg/apps/graph" ) func TestHPAMissingCPUTargetError(t *testing.T) { @@ -62,7 +62,7 @@ func TestOverlappingHPAsWarning(t *testing.T) { } kubegraph.AddHPAScaleRefEdges(g) - deploygraph.AddAllDeploymentEdges(g) + appsgraph.AddAllDeploymentEdges(g) markers := FindOverlappingHPAs(g, osgraph.DefaultNamer) if len(markers) != 8 { @@ -87,7 +87,7 @@ func TestOverlappingLegacyHPAsWarning(t *testing.T) { } kubegraph.AddHPAScaleRefEdges(g) - deploygraph.AddAllDeploymentEdges(g) + appsgraph.AddAllDeploymentEdges(g) markers := FindOverlappingHPAs(g, osgraph.DefaultNamer) if len(markers) != 8 { diff --git a/pkg/api/kubegraph/edge_test.go b/pkg/api/kubegraph/edge_test.go index 43c64c5d45ac..32bc44a641b2 100644 --- a/pkg/api/kubegraph/edge_test.go +++ b/pkg/api/kubegraph/edge_test.go @@ -16,9 +16,9 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" _ "github.com/openshift/origin/pkg/apps/apis/apps/install" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" ) type objectifier interface { @@ -186,13 +186,13 @@ func TestHPADCEdges(t *testing.T) { }, } - dc := &deployapi.DeploymentConfig{} + dc := &appsapi.DeploymentConfig{} dc.Name = "test-dc" dc.Namespace = "test-ns" g := osgraph.New() hpaNode := kubegraph.EnsureHorizontalPodAutoscalerNode(g, hpa) - dcNode := deploygraph.EnsureDeploymentConfigNode(g, dc) + dcNode := appsgraph.EnsureDeploymentConfigNode(g, dc) AddHPAScaleRefEdges(g) diff --git a/pkg/api/kubegraph/edges.go b/pkg/api/kubegraph/edges.go index 27dfc916ee0f..b945eec6c1fc 100644 --- a/pkg/api/kubegraph/edges.go +++ b/pkg/api/kubegraph/edges.go @@ -14,8 +14,8 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" ) const ( @@ -239,8 +239,8 @@ func AddHPAScaleRefEdges(g osgraph.Graph) { switch { case r == kapi.Resource("replicationcontrollers"): syntheticNode = kubegraph.FindOrCreateSyntheticReplicationControllerNode(g, &kapi.ReplicationController{ObjectMeta: syntheticMeta}) - case deployapi.IsResourceOrLegacy("deploymentconfigs", r): - syntheticNode = deploygraph.FindOrCreateSyntheticDeploymentConfigNode(g, &deployapi.DeploymentConfig{ObjectMeta: syntheticMeta}) + case appsapi.IsResourceOrLegacy("deploymentconfigs", r): + syntheticNode = appsgraph.FindOrCreateSyntheticDeploymentConfigNode(g, &appsapi.DeploymentConfig{ObjectMeta: syntheticMeta}) default: continue } diff --git a/pkg/api/meta/pods.go b/pkg/api/meta/pods.go index 364075ac8d38..636360afa3bd 100644 --- a/pkg/api/meta/pods.go +++ b/pkg/api/meta/pods.go @@ -17,9 +17,9 @@ import ( "k8s.io/kubernetes/pkg/apis/batch" "k8s.io/kubernetes/pkg/apis/extensions" - deployapiv1 "github.com/openshift/api/apps/v1" + appsapiv1 "github.com/openshift/api/apps/v1" securityapiv1 "github.com/openshift/api/security/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" securityapi "github.com/openshift/origin/pkg/security/apis/security" ) @@ -61,8 +61,8 @@ var resourcesToCheck = map[schema.GroupResource]schema.GroupKind{ extensions.Resource("replicasets"): extensions.Kind("ReplicaSet"), apps.Resource("statefulsets"): apps.Kind("StatefulSet"), - deployapi.Resource("deploymentconfigs"): deployapi.Kind("DeploymentConfig"), - deployapi.LegacyResource("deploymentconfigs"): deployapi.LegacyKind("DeploymentConfig"), + appsapi.Resource("deploymentconfigs"): appsapi.Kind("DeploymentConfig"), + appsapi.LegacyResource("deploymentconfigs"): appsapi.LegacyKind("DeploymentConfig"), securityapi.Resource("podsecuritypolicysubjectreviews"): securityapi.Kind("PodSecurityPolicySubjectReview"), securityapi.LegacyResource("podsecuritypolicysubjectreviews"): securityapi.LegacyKind("PodSecurityPolicySubjectReview"), securityapi.Resource("podsecuritypolicyselfsubjectreviews"): securityapi.Kind("PodSecurityPolicySelfSubjectReview"), @@ -112,7 +112,7 @@ func GetPodSpec(obj runtime.Object) (*kapi.PodSpec, *field.Path, error) { return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil case *securityapi.PodSecurityPolicyReview: return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: if r.Spec.Template != nil { return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil } @@ -155,7 +155,7 @@ func GetPodSpecV1(obj runtime.Object) (*kapiv1.PodSpec, *field.Path, error) { return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil case *securityapiv1.PodSecurityPolicyReview: return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil - case *deployapiv1.DeploymentConfig: + case *appsapiv1.DeploymentConfig: if r.Spec.Template != nil { return &r.Spec.Template.Spec, field.NewPath("spec", "template", "spec"), nil } @@ -195,7 +195,7 @@ func GetTemplateMetaObject(obj runtime.Object) (metav1.Object, bool) { return &r.Spec.Template.ObjectMeta, true case *securityapiv1.PodSecurityPolicyReview: return &r.Spec.Template.ObjectMeta, true - case *deployapiv1.DeploymentConfig: + case *appsapiv1.DeploymentConfig: if r.Spec.Template != nil { return &r.Spec.Template.ObjectMeta, true } @@ -225,7 +225,7 @@ func GetTemplateMetaObject(obj runtime.Object) (metav1.Object, bool) { return &r.Spec.Template.ObjectMeta, true case *securityapi.PodSecurityPolicyReview: return &r.Spec.Template.ObjectMeta, true - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: if r.Spec.Template != nil { return &r.Spec.Template.ObjectMeta, true } diff --git a/pkg/api/serialization_test.go b/pkg/api/serialization_test.go index ff3a9810379b..e4d6201eedab 100644 --- a/pkg/api/serialization_test.go +++ b/pkg/api/serialization_test.go @@ -27,14 +27,14 @@ import ( extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" buildv1 "github.com/openshift/api/build/v1" - deploy "github.com/openshift/origin/pkg/apps/apis/apps" + apps "github.com/openshift/origin/pkg/apps/apis/apps" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" build "github.com/openshift/origin/pkg/build/apis/build" image "github.com/openshift/origin/pkg/image/apis/image" oauthapi "github.com/openshift/origin/pkg/oauth/apis/oauth" - route "github.com/openshift/origin/pkg/route/apis/route" + routeapi "github.com/openshift/origin/pkg/route/apis/route" securityapi "github.com/openshift/origin/pkg/security/apis/security" - template "github.com/openshift/origin/pkg/template/apis/template" + templateapi "github.com/openshift/origin/pkg/template/apis/template" uservalidation "github.com/openshift/origin/pkg/user/apis/user/validation" // install all APIs @@ -175,7 +175,7 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { j.Subjects[i].FieldPath = "" } }, - func(j *template.Template, c fuzz.Continue) { + func(j *templateapi.Template, c fuzz.Continue) { c.FuzzNoCustom(j) j.Objects = nil @@ -339,21 +339,21 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { j.To.Name = strings.Replace(j.To.Name, ":", "-", -1) } }, - func(j *route.RouteTargetReference, c fuzz.Continue) { + func(j *routeapi.RouteTargetReference, c fuzz.Continue) { c.FuzzNoCustom(j) j.Kind = "Service" j.Weight = new(int32) *j.Weight = 100 }, - func(j *route.TLSConfig, c fuzz.Continue) { + func(j *routeapi.TLSConfig, c fuzz.Continue) { c.FuzzNoCustom(j) if len(j.Termination) == 0 && len(j.DestinationCACertificate) == 0 { - j.Termination = route.TLSTerminationEdge + j.Termination = routeapi.TLSTerminationEdge } }, - func(j *deploy.DeploymentConfig, c fuzz.Continue) { + func(j *apps.DeploymentConfig, c fuzz.Continue) { c.FuzzNoCustom(j) - j.Spec.Triggers = []deploy.DeploymentTriggerPolicy{{Type: deploy.DeploymentTriggerOnConfigChange}} + j.Spec.Triggers = []apps.DeploymentTriggerPolicy{{Type: apps.DeploymentTriggerOnConfigChange}} if j.Spec.Template != nil && len(j.Spec.Template.Spec.Containers) == 1 { containerName := j.Spec.Template.Spec.Containers[0].Name if p := j.Spec.Strategy.RecreateParams; p != nil { @@ -367,48 +367,48 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { } } }, - func(j *deploy.DeploymentStrategy, c fuzz.Continue) { + func(j *apps.DeploymentStrategy, c fuzz.Continue) { randInt64 := func() *int64 { p := int64(c.RandUint64()) return &p } c.FuzzNoCustom(j) j.RecreateParams, j.RollingParams, j.CustomParams = nil, nil, nil - strategyTypes := []deploy.DeploymentStrategyType{deploy.DeploymentStrategyTypeRecreate, deploy.DeploymentStrategyTypeRolling, deploy.DeploymentStrategyTypeCustom} + strategyTypes := []apps.DeploymentStrategyType{apps.DeploymentStrategyTypeRecreate, apps.DeploymentStrategyTypeRolling, apps.DeploymentStrategyTypeCustom} j.Type = strategyTypes[c.Rand.Intn(len(strategyTypes))] j.ActiveDeadlineSeconds = randInt64() switch j.Type { - case deploy.DeploymentStrategyTypeRecreate: - params := &deploy.RecreateDeploymentStrategyParams{} + case apps.DeploymentStrategyTypeRecreate: + params := &apps.RecreateDeploymentStrategyParams{} c.Fuzz(params) if params.TimeoutSeconds == nil { s := int64(120) params.TimeoutSeconds = &s } j.RecreateParams = params - case deploy.DeploymentStrategyTypeRolling: - params := &deploy.RollingDeploymentStrategyParams{} + case apps.DeploymentStrategyTypeRolling: + params := &apps.RollingDeploymentStrategyParams{} params.TimeoutSeconds = randInt64() params.IntervalSeconds = randInt64() params.UpdatePeriodSeconds = randInt64() - policyTypes := []deploy.LifecycleHookFailurePolicy{ - deploy.LifecycleHookFailurePolicyRetry, - deploy.LifecycleHookFailurePolicyAbort, - deploy.LifecycleHookFailurePolicyIgnore, + policyTypes := []apps.LifecycleHookFailurePolicy{ + apps.LifecycleHookFailurePolicyRetry, + apps.LifecycleHookFailurePolicyAbort, + apps.LifecycleHookFailurePolicyIgnore, } if c.RandBool() { - params.Pre = &deploy.LifecycleHook{ + params.Pre = &apps.LifecycleHook{ FailurePolicy: policyTypes[c.Rand.Intn(len(policyTypes))], - ExecNewPod: &deploy.ExecNewPodHook{ + ExecNewPod: &apps.ExecNewPodHook{ ContainerName: c.RandString(), }, } } if c.RandBool() { - params.Post = &deploy.LifecycleHook{ + params.Post = &apps.LifecycleHook{ FailurePolicy: policyTypes[c.Rand.Intn(len(policyTypes))], - ExecNewPod: &deploy.ExecNewPodHook{ + ExecNewPod: &apps.ExecNewPodHook{ ContainerName: c.RandString(), }, } @@ -423,7 +423,7 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { j.RollingParams = params } }, - func(j *deploy.DeploymentCauseImageTrigger, c fuzz.Continue) { + func(j *apps.DeploymentCauseImageTrigger, c fuzz.Continue) { c.FuzzNoCustom(j) specs := []string{"", "a/b", "a/b/c", "a:5000/b/c", "a/b", "a/b"} tags := []string{"stuff", "other"} @@ -432,7 +432,7 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { j.From.Name = image.JoinImageStreamTag(j.From.Name, tags[c.Intn(len(tags))]) } }, - func(j *deploy.DeploymentTriggerImageChangeParams, c fuzz.Continue) { + func(j *apps.DeploymentTriggerImageChangeParams, c fuzz.Continue) { c.FuzzNoCustom(j) specs := []string{"a/b", "a/b/c", "a:5000/b/c", "a/b:latest", "a/b@test"} j.From.Kind = "DockerImage" @@ -470,16 +470,16 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { j.Scopes = append(j.Scopes, "user:full") } }, - func(j *route.RouteSpec, c fuzz.Continue) { + func(j *routeapi.RouteSpec, c fuzz.Continue) { c.FuzzNoCustom(j) if len(j.WildcardPolicy) == 0 { - j.WildcardPolicy = route.WildcardPolicyNone + j.WildcardPolicy = routeapi.WildcardPolicyNone } }, - func(j *route.RouteIngress, c fuzz.Continue) { + func(j *routeapi.RouteIngress, c fuzz.Continue) { c.FuzzNoCustom(j) if len(j.WildcardPolicy) == 0 { - j.WildcardPolicy = route.WildcardPolicyNone + j.WildcardPolicy = routeapi.WildcardPolicyNone } }, @@ -536,7 +536,7 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { return f } -func defaultHookContainerName(hook *deploy.LifecycleHook, containerName string) { +func defaultHookContainerName(hook *apps.LifecycleHook, containerName string) { if hook == nil { return } diff --git a/pkg/api/validation/coverage_test.go b/pkg/api/validation/coverage_test.go index 7c355c380b40..4e7eae50a351 100644 --- a/pkg/api/validation/coverage_test.go +++ b/pkg/api/validation/coverage_test.go @@ -8,7 +8,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "github.com/openshift/origin/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -20,7 +20,7 @@ import ( // reason. var KnownValidationExceptions = []reflect.Type{ reflect.TypeOf(&buildapi.BuildLog{}), // masks calls to a build subresource - reflect.TypeOf(&deployapi.DeploymentLog{}), // masks calls to a deploymentConfig subresource + reflect.TypeOf(&appsapi.DeploymentLog{}), // masks calls to a deploymentConfig subresource reflect.TypeOf(&imageapi.ImageStreamImage{}), // this object is only returned, never accepted reflect.TypeOf(&imageapi.ImageStreamTag{}), // this object is only returned, never accepted reflect.TypeOf(&authorizationapi.IsPersonalSubjectAccessReview{}), // only an api type for runtime.EmbeddedObject, never accepted diff --git a/pkg/api/validation/register.go b/pkg/api/validation/register.go index 268952c6ea39..4607a7db895c 100644 --- a/pkg/api/validation/register.go +++ b/pkg/api/validation/register.go @@ -1,7 +1,7 @@ package validation import ( - deployvalidation "github.com/openshift/origin/pkg/apps/apis/apps/validation" + appsvalidation "github.com/openshift/origin/pkg/apps/apis/apps/validation" authorizationvalidation "github.com/openshift/origin/pkg/authorization/apis/authorization/validation" buildvalidation "github.com/openshift/origin/pkg/build/apis/build/validation" imagevalidation "github.com/openshift/origin/pkg/image/apis/image/validation" @@ -15,7 +15,7 @@ import ( uservalidation "github.com/openshift/origin/pkg/user/apis/user/validation" extvalidation "k8s.io/kubernetes/pkg/apis/extensions/validation" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -62,10 +62,10 @@ func registerAll() { Validator.MustRegister(&buildapi.BuildRequest{}, buildvalidation.ValidateBuildRequest, nil) Validator.MustRegister(&buildapi.BuildLogOptions{}, buildvalidation.ValidateBuildLogOptions, nil) - Validator.MustRegister(&deployapi.DeploymentConfig{}, deployvalidation.ValidateDeploymentConfig, deployvalidation.ValidateDeploymentConfigUpdate) - Validator.MustRegister(&deployapi.DeploymentConfigRollback{}, deployvalidation.ValidateDeploymentConfigRollback, nil) - Validator.MustRegister(&deployapi.DeploymentLogOptions{}, deployvalidation.ValidateDeploymentLogOptions, nil) - Validator.MustRegister(&deployapi.DeploymentRequest{}, deployvalidation.ValidateDeploymentRequest, nil) + Validator.MustRegister(&appsapi.DeploymentConfig{}, appsvalidation.ValidateDeploymentConfig, appsvalidation.ValidateDeploymentConfigUpdate) + Validator.MustRegister(&appsapi.DeploymentConfigRollback{}, appsvalidation.ValidateDeploymentConfigRollback, nil) + Validator.MustRegister(&appsapi.DeploymentLogOptions{}, appsvalidation.ValidateDeploymentLogOptions, nil) + Validator.MustRegister(&appsapi.DeploymentRequest{}, appsvalidation.ValidateDeploymentRequest, nil) Validator.MustRegister(&extensions.Scale{}, extvalidation.ValidateScale, nil) Validator.MustRegister(&imageapi.Image{}, imagevalidation.ValidateImage, imagevalidation.ValidateImageUpdate) diff --git a/pkg/apps/apis/apps/install/install.go b/pkg/apps/apis/apps/install/install.go index 142c7e5efd0f..e1d186f00a1f 100644 --- a/pkg/apps/apis/apps/install/install.go +++ b/pkg/apps/apis/apps/install/install.go @@ -7,13 +7,13 @@ import ( kapi "k8s.io/kubernetes/pkg/api" legacy "github.com/openshift/origin/pkg/api/legacy" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" "k8s.io/apimachinery/pkg/util/sets" ) func init() { - legacy.InstallLegacy(deployapi.GroupName, deployapi.AddToSchemeInCoreGroup, deployapiv1.AddToSchemeInCoreGroup, sets.NewString(), kapi.Registry, kapi.Scheme) + legacy.InstallLegacy(appsapi.GroupName, appsapi.AddToSchemeInCoreGroup, appsapiv1.AddToSchemeInCoreGroup, sets.NewString(), kapi.Registry, kapi.Scheme) Install(kapi.GroupFactoryRegistry, kapi.Registry, kapi.Scheme) } @@ -21,12 +21,12 @@ func init() { func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) { if err := announced.NewGroupMetaFactory( &announced.GroupMetaFactoryArgs{ - GroupName: deployapi.GroupName, - VersionPreferenceOrder: []string{deployapiv1.SchemeGroupVersion.Version}, - AddInternalObjectsToScheme: deployapi.AddToScheme, + GroupName: appsapi.GroupName, + VersionPreferenceOrder: []string{appsapiv1.SchemeGroupVersion.Version}, + AddInternalObjectsToScheme: appsapi.AddToScheme, }, announced.VersionToSchemeFunc{ - deployapiv1.SchemeGroupVersion.Version: deployapiv1.AddToScheme, + appsapiv1.SchemeGroupVersion.Version: appsapiv1.AddToScheme, }, ).Announce(groupFactoryRegistry).RegisterAndEnable(registry, scheme); err != nil { panic(err) diff --git a/pkg/apps/apis/apps/test/ok.go b/pkg/apps/apis/apps/test/ok.go index 5d715c983150..536c7c82b252 100644 --- a/pkg/apps/apis/apps/test/ok.go +++ b/pkg/apps/apis/apps/test/ok.go @@ -9,8 +9,8 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/apis/autoscaling" - deployv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" imageapi "github.com/openshift/origin/pkg/image/apis/image" ) @@ -20,8 +20,8 @@ const ( DockerImageReference = "registry:5000/openshift/test-image-stream@sha256:0000000000000000000000000000000000000000000000000000000000000001" ) -func OkDeploymentConfig(version int64) *deployapi.DeploymentConfig { - return &deployapi.DeploymentConfig{ +func OkDeploymentConfig(version int64) *appsapi.DeploymentConfig { + return &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: "config", Namespace: kapi.NamespaceDefault, @@ -31,62 +31,62 @@ func OkDeploymentConfig(version int64) *deployapi.DeploymentConfig { } } -func OkDeploymentConfigSpec() deployapi.DeploymentConfigSpec { - return deployapi.DeploymentConfigSpec{ +func OkDeploymentConfigSpec() appsapi.DeploymentConfigSpec { + return appsapi.DeploymentConfigSpec{ Replicas: 1, Selector: OkSelector(), Strategy: OkStrategy(), Template: OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ + Triggers: []appsapi.DeploymentTriggerPolicy{ OkImageChangeTrigger(), OkConfigChangeTrigger(), }, } } -func OkDeploymentConfigStatus(version int64) deployapi.DeploymentConfigStatus { - return deployapi.DeploymentConfigStatus{ +func OkDeploymentConfigStatus(version int64) appsapi.DeploymentConfigStatus { + return appsapi.DeploymentConfigStatus{ LatestVersion: version, } } -func OkImageChangeDetails() *deployapi.DeploymentDetails { - return &deployapi.DeploymentDetails{ - Causes: []deployapi.DeploymentCause{{ - Type: deployapi.DeploymentTriggerOnImageChange, - ImageTrigger: &deployapi.DeploymentCauseImageTrigger{ +func OkImageChangeDetails() *appsapi.DeploymentDetails { + return &appsapi.DeploymentDetails{ + Causes: []appsapi.DeploymentCause{{ + Type: appsapi.DeploymentTriggerOnImageChange, + ImageTrigger: &appsapi.DeploymentCauseImageTrigger{ From: kapi.ObjectReference{ Name: imageapi.JoinImageStreamTag(ImageStreamName, imageapi.DefaultImageTag), Kind: "ImageStreamTag", }}}}} } -func OkConfigChangeDetails() *deployapi.DeploymentDetails { - return &deployapi.DeploymentDetails{ - Causes: []deployapi.DeploymentCause{{ - Type: deployapi.DeploymentTriggerOnConfigChange, +func OkConfigChangeDetails() *appsapi.DeploymentDetails { + return &appsapi.DeploymentDetails{ + Causes: []appsapi.DeploymentCause{{ + Type: appsapi.DeploymentTriggerOnConfigChange, }}} } -func OkStrategy() deployapi.DeploymentStrategy { - return deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, +func OkStrategy() appsapi.DeploymentStrategy { + return appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, Resources: kapi.ResourceRequirements{ Limits: kapi.ResourceList{ kapi.ResourceName(kapi.ResourceCPU): resource.MustParse("10"), kapi.ResourceName(kapi.ResourceMemory): resource.MustParse("10G"), }, }, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ TimeoutSeconds: mkintp(20), }, - ActiveDeadlineSeconds: mkintp(int(deployapi.MaxDeploymentDurationSeconds)), + ActiveDeadlineSeconds: mkintp(int(appsapi.MaxDeploymentDurationSeconds)), } } -func OkCustomStrategy() deployapi.DeploymentStrategy { - return deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeCustom, +func OkCustomStrategy() appsapi.DeploymentStrategy { + return appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeCustom, CustomParams: OkCustomParams(), Resources: kapi.ResourceRequirements{ Limits: kapi.ResourceList{ @@ -97,8 +97,8 @@ func OkCustomStrategy() deployapi.DeploymentStrategy { } } -func OkCustomParams() *deployapi.CustomDeploymentStrategyParams { - return &deployapi.CustomDeploymentStrategyParams{ +func OkCustomParams() *appsapi.CustomDeploymentStrategyParams { + return &appsapi.CustomDeploymentStrategyParams{ Image: "openshift/origin-deployer", Environment: []kapi.EnvVar{ { @@ -115,10 +115,10 @@ func mkintp(i int) *int64 { return &v } -func OkRollingStrategy() deployapi.DeploymentStrategy { - return deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRolling, - RollingParams: &deployapi.RollingDeploymentStrategyParams{ +func OkRollingStrategy() appsapi.DeploymentStrategy { + return appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRolling, + RollingParams: &appsapi.RollingDeploymentStrategyParams{ UpdatePeriodSeconds: mkintp(1), IntervalSeconds: mkintp(1), TimeoutSeconds: mkintp(20), @@ -192,16 +192,16 @@ func OkPodTemplateMissingImage(missing ...string) *kapi.PodTemplateSpec { return template } -func OkConfigChangeTrigger() deployapi.DeploymentTriggerPolicy { - return deployapi.DeploymentTriggerPolicy{ - Type: deployapi.DeploymentTriggerOnConfigChange, +func OkConfigChangeTrigger() appsapi.DeploymentTriggerPolicy { + return appsapi.DeploymentTriggerPolicy{ + Type: appsapi.DeploymentTriggerOnConfigChange, } } -func OkImageChangeTrigger() deployapi.DeploymentTriggerPolicy { - return deployapi.DeploymentTriggerPolicy{ - Type: deployapi.DeploymentTriggerOnImageChange, - ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ +func OkImageChangeTrigger() appsapi.DeploymentTriggerPolicy { + return appsapi.DeploymentTriggerPolicy{ + Type: appsapi.DeploymentTriggerOnImageChange, + ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: true, ContainerNames: []string{ "container1", @@ -214,30 +214,30 @@ func OkImageChangeTrigger() deployapi.DeploymentTriggerPolicy { } } -func OkTriggeredImageChange() deployapi.DeploymentTriggerPolicy { +func OkTriggeredImageChange() appsapi.DeploymentTriggerPolicy { ict := OkImageChangeTrigger() ict.ImageChangeParams.LastTriggeredImage = DockerImageReference return ict } -func OkNonAutomaticICT() deployapi.DeploymentTriggerPolicy { +func OkNonAutomaticICT() appsapi.DeploymentTriggerPolicy { ict := OkImageChangeTrigger() ict.ImageChangeParams.Automatic = false return ict } -func OkTriggeredNonAutomatic() deployapi.DeploymentTriggerPolicy { +func OkTriggeredNonAutomatic() appsapi.DeploymentTriggerPolicy { ict := OkNonAutomaticICT() ict.ImageChangeParams.LastTriggeredImage = DockerImageReference return ict } -func TestDeploymentConfig(config *deployapi.DeploymentConfig) *deployapi.DeploymentConfig { +func TestDeploymentConfig(config *appsapi.DeploymentConfig) *appsapi.DeploymentConfig { config.Spec.Test = true return config } -func OkHPAForDeploymentConfig(config *deployapi.DeploymentConfig, min, max int) *autoscaling.HorizontalPodAutoscaler { +func OkHPAForDeploymentConfig(config *appsapi.DeploymentConfig, min, max int) *autoscaling.HorizontalPodAutoscaler { newMin := int32(min) return &autoscaling.HorizontalPodAutoscaler{ ObjectMeta: metav1.ObjectMeta{Name: config.Name, Namespace: config.Namespace}, @@ -252,9 +252,9 @@ func OkHPAForDeploymentConfig(config *deployapi.DeploymentConfig, min, max int) } } -func OkStreamForConfig(config *deployapi.DeploymentConfig) *imageapi.ImageStream { +func OkStreamForConfig(config *appsapi.DeploymentConfig) *imageapi.ImageStream { for _, t := range config.Spec.Triggers { - if t.Type != deployapi.DeploymentTriggerOnImageChange { + if t.Type != appsapi.DeploymentTriggerOnImageChange { continue } @@ -275,13 +275,13 @@ func OkStreamForConfig(config *deployapi.DeploymentConfig) *imageapi.ImageStream return nil } -func RemoveTriggerTypes(config *deployapi.DeploymentConfig, triggerTypes ...deployapi.DeploymentTriggerType) { +func RemoveTriggerTypes(config *appsapi.DeploymentConfig, triggerTypes ...appsapi.DeploymentTriggerType) { types := sets.NewString() for _, triggerType := range triggerTypes { types.Insert(string(triggerType)) } - remaining := []deployapi.DeploymentTriggerPolicy{} + remaining := []appsapi.DeploymentTriggerPolicy{} for _, trigger := range config.Spec.Triggers { if types.Has(string(trigger.Type)) { continue @@ -292,16 +292,16 @@ func RemoveTriggerTypes(config *deployapi.DeploymentConfig, triggerTypes ...depl config.Spec.Triggers = remaining } -func RoundTripConfig(t *testing.T, config *deployapi.DeploymentConfig) *deployapi.DeploymentConfig { - versioned, err := kapi.Scheme.ConvertToVersion(config, deployv1.SchemeGroupVersion) +func RoundTripConfig(t *testing.T, config *appsapi.DeploymentConfig) *appsapi.DeploymentConfig { + versioned, err := kapi.Scheme.ConvertToVersion(config, appsv1.SchemeGroupVersion) if err != nil { t.Errorf("unexpected conversion error: %v", err) return nil } - defaulted, err := kapi.Scheme.ConvertToVersion(versioned, deployapi.SchemeGroupVersion) + defaulted, err := kapi.Scheme.ConvertToVersion(versioned, appsapi.SchemeGroupVersion) if err != nil { t.Errorf("unexpected conversion error: %v", err) return nil } - return defaulted.(*deployapi.DeploymentConfig) + return defaulted.(*appsapi.DeploymentConfig) } diff --git a/pkg/apps/apis/apps/v1/defaults.go b/pkg/apps/apis/apps/v1/defaults.go index de087ad6909d..96bea8ff1a9a 100644 --- a/pkg/apps/apis/apps/v1/defaults.go +++ b/pkg/apps/apis/apps/v1/defaults.go @@ -4,7 +4,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) // Keep this in sync with pkg/api/serialization_test.go#defaultHookContainerName @@ -56,9 +56,9 @@ func SetDefaults_DeploymentStrategy(obj *v1.DeploymentStrategy) { if obj.Type == v1.DeploymentStrategyTypeRolling && obj.RollingParams == nil { obj.RollingParams = &v1.RollingDeploymentStrategyParams{ - IntervalSeconds: mkintp(deployapi.DefaultRollingIntervalSeconds), - UpdatePeriodSeconds: mkintp(deployapi.DefaultRollingUpdatePeriodSeconds), - TimeoutSeconds: mkintp(deployapi.DefaultRollingTimeoutSeconds), + IntervalSeconds: mkintp(appsapi.DefaultRollingIntervalSeconds), + UpdatePeriodSeconds: mkintp(appsapi.DefaultRollingUpdatePeriodSeconds), + TimeoutSeconds: mkintp(appsapi.DefaultRollingTimeoutSeconds), } } if obj.Type == v1.DeploymentStrategyTypeRecreate && obj.RecreateParams == nil { @@ -66,27 +66,27 @@ func SetDefaults_DeploymentStrategy(obj *v1.DeploymentStrategy) { } if obj.ActiveDeadlineSeconds == nil { - obj.ActiveDeadlineSeconds = mkintp(deployapi.MaxDeploymentDurationSeconds) + obj.ActiveDeadlineSeconds = mkintp(appsapi.MaxDeploymentDurationSeconds) } } func SetDefaults_RecreateDeploymentStrategyParams(obj *v1.RecreateDeploymentStrategyParams) { if obj.TimeoutSeconds == nil { - obj.TimeoutSeconds = mkintp(deployapi.DefaultRecreateTimeoutSeconds) + obj.TimeoutSeconds = mkintp(appsapi.DefaultRecreateTimeoutSeconds) } } func SetDefaults_RollingDeploymentStrategyParams(obj *v1.RollingDeploymentStrategyParams) { if obj.IntervalSeconds == nil { - obj.IntervalSeconds = mkintp(deployapi.DefaultRollingIntervalSeconds) + obj.IntervalSeconds = mkintp(appsapi.DefaultRollingIntervalSeconds) } if obj.UpdatePeriodSeconds == nil { - obj.UpdatePeriodSeconds = mkintp(deployapi.DefaultRollingUpdatePeriodSeconds) + obj.UpdatePeriodSeconds = mkintp(appsapi.DefaultRollingUpdatePeriodSeconds) } if obj.TimeoutSeconds == nil { - obj.TimeoutSeconds = mkintp(deployapi.DefaultRollingTimeoutSeconds) + obj.TimeoutSeconds = mkintp(appsapi.DefaultRollingTimeoutSeconds) } if obj.MaxUnavailable == nil && obj.MaxSurge == nil { diff --git a/pkg/apps/apis/apps/v1/defaults_test.go b/pkg/apps/apis/apps/v1/defaults_test.go index cca52beff753..067d37b244a5 100644 --- a/pkg/apps/apis/apps/v1/defaults_test.go +++ b/pkg/apps/apis/apps/v1/defaults_test.go @@ -12,7 +12,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) func TestDefaults(t *testing.T) { @@ -29,13 +29,13 @@ func TestDefaults(t *testing.T) { Strategy: v1.DeploymentStrategy{ Type: v1.DeploymentStrategyTypeRolling, RollingParams: &v1.RollingDeploymentStrategyParams{ - UpdatePeriodSeconds: newInt64(deployapi.DefaultRollingUpdatePeriodSeconds), - IntervalSeconds: newInt64(deployapi.DefaultRollingIntervalSeconds), - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + UpdatePeriodSeconds: newInt64(appsapi.DefaultRollingUpdatePeriodSeconds), + IntervalSeconds: newInt64(appsapi.DefaultRollingIntervalSeconds), + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), MaxSurge: &defaultIntOrString, MaxUnavailable: &defaultIntOrString, }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, Triggers: []v1.DeploymentTriggerPolicy{ { @@ -51,7 +51,7 @@ func TestDefaults(t *testing.T) { Strategy: v1.DeploymentStrategy{ Type: v1.DeploymentStrategyTypeRecreate, RecreateParams: &v1.RecreateDeploymentStrategyParams{ - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), Pre: &v1.LifecycleHook{ TagImages: []v1.TagImageHook{{}, {}}, }, @@ -97,7 +97,7 @@ func TestDefaults(t *testing.T) { Strategy: v1.DeploymentStrategy{ Type: v1.DeploymentStrategyTypeRecreate, RecreateParams: &v1.RecreateDeploymentStrategyParams{ - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), Pre: &v1.LifecycleHook{ TagImages: []v1.TagImageHook{{ContainerName: "test"}, {ContainerName: "test"}}, }, @@ -121,7 +121,7 @@ func TestDefaults(t *testing.T) { MaxSurge: &differentIntOrString, MaxUnavailable: &differentIntOrString, }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, Triggers: []v1.DeploymentTriggerPolicy{ { @@ -222,7 +222,7 @@ func TestDefaults(t *testing.T) { MaxSurge: newIntOrString(intstr.FromInt(0)), MaxUnavailable: newIntOrString(intstr.FromString("25%")), }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, Triggers: []v1.DeploymentTriggerPolicy{ { @@ -260,7 +260,7 @@ func TestDefaults(t *testing.T) { MaxUnavailable: newIntOrString(intstr.FromString("25%")), MaxSurge: newIntOrString(intstr.FromInt(0)), }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, Triggers: []v1.DeploymentTriggerPolicy{ {}, @@ -285,13 +285,13 @@ func TestDefaults(t *testing.T) { Strategy: v1.DeploymentStrategy{ Type: v1.DeploymentStrategyTypeRolling, RollingParams: &v1.RollingDeploymentStrategyParams{ - IntervalSeconds: newInt64(deployapi.DefaultRollingIntervalSeconds), - UpdatePeriodSeconds: newInt64(deployapi.DefaultRollingUpdatePeriodSeconds), - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + IntervalSeconds: newInt64(appsapi.DefaultRollingIntervalSeconds), + UpdatePeriodSeconds: newInt64(appsapi.DefaultRollingUpdatePeriodSeconds), + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), MaxSurge: newIntOrString(intstr.FromString("25%")), MaxUnavailable: newIntOrString(intstr.FromString("25%")), }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, Triggers: []v1.DeploymentTriggerPolicy{ {}, @@ -317,9 +317,9 @@ func TestDefaults(t *testing.T) { Strategy: v1.DeploymentStrategy{ Type: v1.DeploymentStrategyTypeRecreate, RecreateParams: &v1.RecreateDeploymentStrategyParams{ - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, Triggers: []v1.DeploymentTriggerPolicy{ {}, @@ -344,9 +344,9 @@ func TestDefaults(t *testing.T) { Strategy: v1.DeploymentStrategy{ Type: v1.DeploymentStrategyTypeRecreate, RecreateParams: &v1.RecreateDeploymentStrategyParams{ - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, Triggers: []v1.DeploymentTriggerPolicy{ {}, @@ -408,7 +408,7 @@ func TestDefaults(t *testing.T) { Strategy: v1.DeploymentStrategy{ Type: v1.DeploymentStrategyTypeRecreate, RecreateParams: &v1.RecreateDeploymentStrategyParams{ - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), Pre: &v1.LifecycleHook{ TagImages: []v1.TagImageHook{{ContainerName: "first"}}, ExecNewPod: &v1.ExecNewPodHook{ContainerName: "first"}, @@ -422,7 +422,7 @@ func TestDefaults(t *testing.T) { ExecNewPod: &v1.ExecNewPodHook{ContainerName: "first"}, }, }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, Triggers: []v1.DeploymentTriggerPolicy{ {}, @@ -480,9 +480,9 @@ func TestDefaults(t *testing.T) { Strategy: v1.DeploymentStrategy{ Type: v1.DeploymentStrategyTypeRolling, RollingParams: &v1.RollingDeploymentStrategyParams{ - UpdatePeriodSeconds: newInt64(deployapi.DefaultRollingUpdatePeriodSeconds), - IntervalSeconds: newInt64(deployapi.DefaultRollingIntervalSeconds), - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + UpdatePeriodSeconds: newInt64(appsapi.DefaultRollingUpdatePeriodSeconds), + IntervalSeconds: newInt64(appsapi.DefaultRollingIntervalSeconds), + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), MaxSurge: &defaultIntOrString, MaxUnavailable: &defaultIntOrString, Pre: &v1.LifecycleHook{ @@ -494,7 +494,7 @@ func TestDefaults(t *testing.T) { ExecNewPod: &v1.ExecNewPodHook{ContainerName: "first"}, }, }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, Triggers: []v1.DeploymentTriggerPolicy{ {}, @@ -518,13 +518,13 @@ func TestDefaults(t *testing.T) { Strategy: v1.DeploymentStrategy{ Type: v1.DeploymentStrategyTypeRolling, RollingParams: &v1.RollingDeploymentStrategyParams{ - UpdatePeriodSeconds: newInt64(deployapi.DefaultRollingUpdatePeriodSeconds), - IntervalSeconds: newInt64(deployapi.DefaultRollingIntervalSeconds), - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + UpdatePeriodSeconds: newInt64(appsapi.DefaultRollingUpdatePeriodSeconds), + IntervalSeconds: newInt64(appsapi.DefaultRollingIntervalSeconds), + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), MaxSurge: &defaultIntOrString, MaxUnavailable: &defaultIntOrString, }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, Triggers: []v1.DeploymentTriggerPolicy{ { diff --git a/pkg/apps/apis/apps/validation/validation.go b/pkg/apps/apis/apps/validation/validation.go index 26b829440645..1c3681d1b677 100644 --- a/pkg/apps/apis/apps/validation/validation.go +++ b/pkg/apps/apis/apps/validation/validation.go @@ -15,19 +15,19 @@ import ( "k8s.io/kubernetes/pkg/api/validation" kapivalidation "k8s.io/kubernetes/pkg/api/validation" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" imageapi "github.com/openshift/origin/pkg/image/apis/image" imageval "github.com/openshift/origin/pkg/image/apis/image/validation" ) -func ValidateDeploymentConfig(config *deployapi.DeploymentConfig) field.ErrorList { +func ValidateDeploymentConfig(config *appsapi.DeploymentConfig) field.ErrorList { allErrs := validation.ValidateObjectMeta(&config.ObjectMeta, true, validation.NameIsDNSSubdomain, field.NewPath("metadata")) allErrs = append(allErrs, ValidateDeploymentConfigSpec(config.Spec)...) allErrs = append(allErrs, ValidateDeploymentConfigStatus(config.Status)...) return allErrs } -func ValidateDeploymentConfigSpec(spec deployapi.DeploymentConfigSpec) field.ErrorList { +func ValidateDeploymentConfigSpec(spec appsapi.DeploymentConfigSpec) field.ErrorList { allErrs := field.ErrorList{} specPath := field.NewPath("spec") for i := range spec.Triggers { @@ -44,7 +44,7 @@ func ValidateDeploymentConfigSpec(spec deployapi.DeploymentConfigSpec) field.Err allErrs = append(allErrs, kapivalidation.ValidateNonnegativeField(int64(*spec.RevisionHistoryLimit), specPath.Child("revisionHistoryLimit"))...) } allErrs = append(allErrs, kapivalidation.ValidateNonnegativeField(int64(spec.MinReadySeconds), specPath.Child("minReadySeconds"))...) - timeoutSeconds := deployapi.DefaultRollingTimeoutSeconds + timeoutSeconds := appsapi.DefaultRollingTimeoutSeconds if spec.Strategy.RollingParams != nil && spec.Strategy.RollingParams.TimeoutSeconds != nil { timeoutSeconds = *(spec.Strategy.RollingParams.TimeoutSeconds) } else if spec.Strategy.RecreateParams != nil && spec.Strategy.RecreateParams.TimeoutSeconds != nil { @@ -87,7 +87,7 @@ func setContainerImageNames(template *kapi.PodTemplateSpec, originalNames []stri } } -func handleEmptyImageReferences(template *kapi.PodTemplateSpec, triggers []deployapi.DeploymentTriggerPolicy) { +func handleEmptyImageReferences(template *kapi.PodTemplateSpec, triggers []appsapi.DeploymentTriggerPolicy) { // if we have both an ICT defined and an empty Template->PodSpec->Container->Image field, we are going // to modify this method's local copy (a pointer was NOT used for the parameter) by setting the field to a non-empty value to // work around the k8s validation as our ICT will supply the image field value @@ -106,7 +106,7 @@ func handleEmptyImageReferences(template *kapi.PodTemplateSpec, triggers []deplo for _, trigger := range triggers { // note, the validateTrigger call above will add an error if ImageChangeParams is nil, but // we can still fall down this path so account for it being nil - if trigger.Type != deployapi.DeploymentTriggerOnImageChange || trigger.ImageChangeParams == nil { + if trigger.Type != appsapi.DeploymentTriggerOnImageChange || trigger.ImageChangeParams == nil { continue } @@ -130,7 +130,7 @@ func handleEmptyImageReferences(template *kapi.PodTemplateSpec, triggers []deplo } -func ValidateDeploymentConfigStatus(status deployapi.DeploymentConfigStatus) field.ErrorList { +func ValidateDeploymentConfigStatus(status appsapi.DeploymentConfigStatus) field.ErrorList { allErrs := field.ErrorList{} statusPath := field.NewPath("status") allErrs = append(allErrs, kapivalidation.ValidateNonnegativeField(int64(status.LatestVersion), statusPath.Child("latestVersion"))...) @@ -142,14 +142,14 @@ func ValidateDeploymentConfigStatus(status deployapi.DeploymentConfigStatus) fie return allErrs } -func ValidateDeploymentConfigUpdate(newConfig *deployapi.DeploymentConfig, oldConfig *deployapi.DeploymentConfig) field.ErrorList { +func ValidateDeploymentConfigUpdate(newConfig *appsapi.DeploymentConfig, oldConfig *appsapi.DeploymentConfig) field.ErrorList { allErrs := validation.ValidateObjectMetaUpdate(&newConfig.ObjectMeta, &oldConfig.ObjectMeta, field.NewPath("metadata")) allErrs = append(allErrs, ValidateDeploymentConfig(newConfig)...) allErrs = append(allErrs, ValidateDeploymentConfigStatusUpdate(newConfig, oldConfig)...) return allErrs } -func ValidateDeploymentConfigStatusUpdate(newConfig *deployapi.DeploymentConfig, oldConfig *deployapi.DeploymentConfig) field.ErrorList { +func ValidateDeploymentConfigStatusUpdate(newConfig *appsapi.DeploymentConfig, oldConfig *appsapi.DeploymentConfig) field.ErrorList { allErrs := validation.ValidateObjectMetaUpdate(&newConfig.ObjectMeta, &oldConfig.ObjectMeta, field.NewPath("metadata")) allErrs = append(allErrs, ValidateDeploymentConfigStatus(newConfig.Status)...) statusPath := field.NewPath("status") @@ -164,7 +164,7 @@ func ValidateDeploymentConfigStatusUpdate(newConfig *deployapi.DeploymentConfig, return allErrs } -func ValidateDeploymentConfigRollback(rollback *deployapi.DeploymentConfigRollback) field.ErrorList { +func ValidateDeploymentConfigRollback(rollback *appsapi.DeploymentConfigRollback) field.ErrorList { result := field.ErrorList{} if len(rollback.Name) == 0 { @@ -181,7 +181,7 @@ func ValidateDeploymentConfigRollback(rollback *deployapi.DeploymentConfigRollba return result } -func ValidateDeploymentConfigRollbackDeprecated(rollback *deployapi.DeploymentConfigRollback) field.ErrorList { +func ValidateDeploymentConfigRollbackDeprecated(rollback *appsapi.DeploymentConfigRollback) field.ErrorList { result := field.ErrorList{} fromPath := field.NewPath("spec", "from") @@ -200,7 +200,7 @@ func ValidateDeploymentConfigRollbackDeprecated(rollback *deployapi.DeploymentCo return result } -func validateDeploymentStrategy(strategy *deployapi.DeploymentStrategy, pod *kapi.PodSpec, fldPath *field.Path) field.ErrorList { +func validateDeploymentStrategy(strategy *appsapi.DeploymentStrategy, pod *kapi.PodSpec, fldPath *field.Path) field.ErrorList { errs := field.ErrorList{} if len(strategy.Type) == 0 { @@ -212,17 +212,17 @@ func validateDeploymentStrategy(strategy *deployapi.DeploymentStrategy, pod *kap } switch strategy.Type { - case deployapi.DeploymentStrategyTypeRecreate: + case appsapi.DeploymentStrategyTypeRecreate: if strategy.RecreateParams != nil { errs = append(errs, validateRecreateParams(strategy.RecreateParams, pod, fldPath.Child("recreateParams"))...) } - case deployapi.DeploymentStrategyTypeRolling: + case appsapi.DeploymentStrategyTypeRolling: if strategy.RollingParams == nil { errs = append(errs, field.Required(fldPath.Child("rollingParams"), "")) } else { errs = append(errs, validateRollingParams(strategy.RollingParams, pod, fldPath.Child("rollingParams"))...) } - case deployapi.DeploymentStrategyTypeCustom: + case appsapi.DeploymentStrategyTypeCustom: if strategy.CustomParams == nil { errs = append(errs, field.Required(fldPath.Child("customParams"), "")) } @@ -263,7 +263,7 @@ func validateDeploymentStrategy(strategy *deployapi.DeploymentStrategy, pod *kap return errs } -func validateCustomParams(params *deployapi.CustomDeploymentStrategyParams, fldPath *field.Path) field.ErrorList { +func validateCustomParams(params *appsapi.CustomDeploymentStrategyParams, fldPath *field.Path) field.ErrorList { errs := field.ErrorList{} errs = append(errs, validateEnv(params.Environment, fldPath.Child("environment"))...) @@ -271,7 +271,7 @@ func validateCustomParams(params *deployapi.CustomDeploymentStrategyParams, fldP return errs } -func validateRecreateParams(params *deployapi.RecreateDeploymentStrategyParams, pod *kapi.PodSpec, fldPath *field.Path) field.ErrorList { +func validateRecreateParams(params *appsapi.RecreateDeploymentStrategyParams, pod *kapi.PodSpec, fldPath *field.Path) field.ErrorList { errs := field.ErrorList{} if params.TimeoutSeconds != nil && *params.TimeoutSeconds < 1 { @@ -291,7 +291,7 @@ func validateRecreateParams(params *deployapi.RecreateDeploymentStrategyParams, return errs } -func validateLifecycleHook(hook *deployapi.LifecycleHook, pod *kapi.PodSpec, fldPath *field.Path) field.ErrorList { +func validateLifecycleHook(hook *appsapi.LifecycleHook, pod *kapi.PodSpec, fldPath *field.Path) field.ErrorList { errs := field.ErrorList{} if len(hook.FailurePolicy) == 0 { @@ -308,7 +308,7 @@ func validateLifecycleHook(hook *deployapi.LifecycleHook, pod *kapi.PodSpec, fld if len(image.ContainerName) == 0 { errs = append(errs, field.Required(fldPath.Child("tagImages").Index(i).Child("containerName"), "a containerName is required")) } else { - if _, err := deployapi.TemplateImageForContainer(pod, deployapi.IgnoreTriggers, image.ContainerName); err != nil { + if _, err := appsapi.TemplateImageForContainer(pod, appsapi.IgnoreTriggers, image.ContainerName); err != nil { errs = append(errs, field.Invalid(fldPath.Child("tagImages").Index(i).Child("containerName"), image.ContainerName, err.Error())) } } @@ -326,7 +326,7 @@ func validateLifecycleHook(hook *deployapi.LifecycleHook, pod *kapi.PodSpec, fld return errs } -func validateExecNewPod(hook *deployapi.ExecNewPodHook, fldPath *field.Path) field.ErrorList { +func validateExecNewPod(hook *appsapi.ExecNewPodHook, fldPath *field.Path) field.ErrorList { errs := field.ErrorList{} if len(hook.Command) == 0 { @@ -375,7 +375,7 @@ func validateHookVolumes(volumes []string, fldPath *field.Path) field.ErrorList return errs } -func validateRollingParams(params *deployapi.RollingDeploymentStrategyParams, pod *kapi.PodSpec, fldPath *field.Path) field.ErrorList { +func validateRollingParams(params *appsapi.RollingDeploymentStrategyParams, pod *kapi.PodSpec, fldPath *field.Path) field.ErrorList { errs := field.ErrorList{} if params.IntervalSeconds != nil && *params.IntervalSeconds < 1 { @@ -412,14 +412,14 @@ func validateRollingParams(params *deployapi.RollingDeploymentStrategyParams, po return errs } -func validateTrigger(trigger *deployapi.DeploymentTriggerPolicy, fldPath *field.Path) field.ErrorList { +func validateTrigger(trigger *appsapi.DeploymentTriggerPolicy, fldPath *field.Path) field.ErrorList { errs := field.ErrorList{} if len(trigger.Type) == 0 { errs = append(errs, field.Required(fldPath.Child("type"), "")) } - if trigger.Type == deployapi.DeploymentTriggerOnImageChange { + if trigger.Type == appsapi.DeploymentTriggerOnImageChange { if trigger.ImageChangeParams == nil { errs = append(errs, field.Required(fldPath.Child("imageChangeParams"), "")) } else { @@ -430,7 +430,7 @@ func validateTrigger(trigger *deployapi.DeploymentTriggerPolicy, fldPath *field. return errs } -func validateImageChangeParams(params *deployapi.DeploymentTriggerImageChangeParams, fldPath *field.Path) field.ErrorList { +func validateImageChangeParams(params *appsapi.DeploymentTriggerImageChangeParams, fldPath *field.Path) field.ErrorList { errs := field.ErrorList{} fromPath := fldPath.Child("from") @@ -523,7 +523,7 @@ func IsValidPercent(percent string) bool { const isNegativeErrorMsg string = `must be non-negative` -func ValidateDeploymentRequest(req *deployapi.DeploymentRequest) field.ErrorList { +func ValidateDeploymentRequest(req *appsapi.DeploymentRequest) field.ErrorList { allErrs := field.ErrorList{} if len(req.Name) == 0 { @@ -535,7 +535,7 @@ func ValidateDeploymentRequest(req *deployapi.DeploymentRequest) field.ErrorList return allErrs } -func ValidateRequestForDeploymentConfig(req *deployapi.DeploymentRequest, config *deployapi.DeploymentConfig) field.ErrorList { +func ValidateRequestForDeploymentConfig(req *appsapi.DeploymentRequest, config *appsapi.DeploymentConfig) field.ErrorList { allErrs := ValidateDeploymentRequest(req) if config.Spec.Paused { @@ -548,11 +548,11 @@ func ValidateRequestForDeploymentConfig(req *deployapi.DeploymentRequest, config return allErrs } -func ValidateDeploymentLogOptions(opts *deployapi.DeploymentLogOptions) field.ErrorList { +func ValidateDeploymentLogOptions(opts *appsapi.DeploymentLogOptions) field.ErrorList { allErrs := field.ErrorList{} // TODO: Replace by validating PodLogOptions via DeploymentLogOptions once it's bundled in - popts := deployapi.DeploymentToPodLogOptions(opts) + popts := appsapi.DeploymentToPodLogOptions(opts) if errs := validation.ValidatePodLogOptions(popts); len(errs) > 0 { allErrs = append(allErrs, errs...) } diff --git a/pkg/apps/apis/apps/validation/validation_test.go b/pkg/apps/apis/apps/validation/validation_test.go index 3ad3ca143d8b..334e95a016bd 100644 --- a/pkg/apps/apis/apps/validation/validation_test.go +++ b/pkg/apps/apis/apps/validation/validation_test.go @@ -8,28 +8,28 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/apps/apis/apps/test" ) // Convenience methods -func manualTrigger() []deployapi.DeploymentTriggerPolicy { - return []deployapi.DeploymentTriggerPolicy{ +func manualTrigger() []appsapi.DeploymentTriggerPolicy { + return []appsapi.DeploymentTriggerPolicy{ { - Type: deployapi.DeploymentTriggerManual, + Type: appsapi.DeploymentTriggerManual, }, } } -func rollingConfig(interval, updatePeriod, timeout int) deployapi.DeploymentConfig { - return deployapi.DeploymentConfig{ +func rollingConfig(interval, updatePeriod, timeout int) appsapi.DeploymentConfig { + return appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Triggers: manualTrigger(), - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRolling, - RollingParams: &deployapi.RollingDeploymentStrategyParams{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRolling, + RollingParams: &appsapi.RollingDeploymentStrategyParams{ IntervalSeconds: mkint64p(interval), UpdatePeriodSeconds: mkint64p(updatePeriod), TimeoutSeconds: mkint64p(timeout), @@ -43,14 +43,14 @@ func rollingConfig(interval, updatePeriod, timeout int) deployapi.DeploymentConf } } -func rollingConfigMax(maxSurge, maxUnavailable intstr.IntOrString) deployapi.DeploymentConfig { - return deployapi.DeploymentConfig{ +func rollingConfigMax(maxSurge, maxUnavailable intstr.IntOrString) appsapi.DeploymentConfig { + return appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Triggers: manualTrigger(), - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRolling, - RollingParams: &deployapi.RollingDeploymentStrategyParams{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRolling, + RollingParams: &appsapi.RollingDeploymentStrategyParams{ IntervalSeconds: mkint64p(1), UpdatePeriodSeconds: mkint64p(1), TimeoutSeconds: mkint64p(1), @@ -66,9 +66,9 @@ func rollingConfigMax(maxSurge, maxUnavailable intstr.IntOrString) deployapi.Dep } func TestValidateDeploymentConfigOK(t *testing.T) { - errs := ValidateDeploymentConfig(&deployapi.DeploymentConfig{ + errs := ValidateDeploymentConfig(&appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, Triggers: manualTrigger(), Selector: test.OkSelector(), @@ -83,11 +83,11 @@ func TestValidateDeploymentConfigOK(t *testing.T) { } func TestValidateDeploymentConfigICTMissingImage(t *testing.T) { - dc := &deployapi.DeploymentConfig{ + dc := &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Triggers: []deployapi.DeploymentTriggerPolicy{test.OkImageChangeTrigger()}, + Triggers: []appsapi.DeploymentTriggerPolicy{test.OkImageChangeTrigger()}, Selector: test.OkSelector(), Strategy: test.OkStrategy(), Template: test.OkPodTemplateMissingImage("container1"), @@ -108,16 +108,16 @@ func TestValidateDeploymentConfigICTMissingImage(t *testing.T) { func TestValidateDeploymentConfigMissingFields(t *testing.T) { errorCases := map[string]struct { - DeploymentConfig deployapi.DeploymentConfig + DeploymentConfig appsapi.DeploymentConfig ErrorType field.ErrorType Field string }{ "empty container field": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Triggers: []deployapi.DeploymentTriggerPolicy{test.OkConfigChangeTrigger()}, + Triggers: []appsapi.DeploymentTriggerPolicy{test.OkConfigChangeTrigger()}, Selector: test.OkSelector(), Strategy: test.OkStrategy(), Template: test.OkPodTemplateMissingImage("container1"), @@ -127,7 +127,7 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.template.spec.containers[0].image", }, "missing name": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "", Namespace: "bar"}, Spec: test.OkDeploymentConfigSpec(), }, @@ -135,7 +135,7 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "metadata.name", }, "missing namespace": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: ""}, Spec: test.OkDeploymentConfigSpec(), }, @@ -143,7 +143,7 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "metadata.namespace", }, "invalid name": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "-foo", Namespace: "bar"}, Spec: test.OkDeploymentConfigSpec(), }, @@ -151,7 +151,7 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "metadata.name", }, "invalid namespace": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "-bar"}, Spec: test.OkDeploymentConfigSpec(), }, @@ -160,13 +160,13 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { }, "missing trigger.type": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Triggers: []deployapi.DeploymentTriggerPolicy{ + Triggers: []appsapi.DeploymentTriggerPolicy{ { - ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ + ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ ContainerNames: []string{"foo"}, }, }, @@ -180,14 +180,14 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.triggers[0].type", }, "missing Trigger imageChangeParams.from": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Triggers: []deployapi.DeploymentTriggerPolicy{ + Triggers: []appsapi.DeploymentTriggerPolicy{ { - Type: deployapi.DeploymentTriggerOnImageChange, - ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ + Type: appsapi.DeploymentTriggerOnImageChange, + ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ ContainerNames: []string{"foo"}, }, }, @@ -201,14 +201,14 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.triggers[0].imageChangeParams.from", }, "invalid Trigger imageChangeParams.from.kind": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Triggers: []deployapi.DeploymentTriggerPolicy{ + Triggers: []appsapi.DeploymentTriggerPolicy{ { - Type: deployapi.DeploymentTriggerOnImageChange, - ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ + Type: appsapi.DeploymentTriggerOnImageChange, + ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ From: kapi.ObjectReference{ Kind: "Invalid", Name: "name:tag", @@ -226,14 +226,14 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.triggers[0].imageChangeParams.from.kind", }, "missing Trigger imageChangeParams.containerNames": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Triggers: []deployapi.DeploymentTriggerPolicy{ + Triggers: []appsapi.DeploymentTriggerPolicy{ { - Type: deployapi.DeploymentTriggerOnImageChange, - ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ + Type: appsapi.DeploymentTriggerOnImageChange, + ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ From: kapi.ObjectReference{ Kind: "ImageStreamTag", Name: "foo:v1", @@ -250,13 +250,13 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.triggers[0].imageChangeParams.containerNames", }, "missing strategy.type": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, Triggers: manualTrigger(), Selector: test.OkSelector(), - Strategy: deployapi.DeploymentStrategy{ + Strategy: appsapi.DeploymentStrategy{ CustomParams: test.OkCustomParams(), ActiveDeadlineSeconds: mkint64p(3600), }, @@ -267,14 +267,14 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.type", }, "missing strategy.customParams": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, Triggers: manualTrigger(), Selector: test.OkSelector(), - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeCustom, + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeCustom, ActiveDeadlineSeconds: mkint64p(3600), }, Template: test.OkPodTemplate(), @@ -284,15 +284,15 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.customParams", }, "invalid spec.strategy.customParams.environment": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, Triggers: manualTrigger(), Selector: test.OkSelector(), - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeCustom, - CustomParams: &deployapi.CustomDeploymentStrategyParams{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeCustom, + CustomParams: &appsapi.CustomDeploymentStrategyParams{ Environment: []kapi.EnvVar{ {Name: "A=B"}, }, @@ -306,15 +306,15 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.customParams.environment[0].name", }, "missing spec.strategy.recreateParams.pre.failurePolicy": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ - Pre: &deployapi.LifecycleHook{ - ExecNewPod: &deployapi.ExecNewPodHook{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ + Pre: &appsapi.LifecycleHook{ + ExecNewPod: &appsapi.ExecNewPodHook{ Command: []string{"cmd"}, ContainerName: "container", }, @@ -330,15 +330,15 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.recreateParams.pre.failurePolicy", }, "missing spec.strategy.recreateParams.pre.execNewPod": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ - Pre: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyRetry, + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ + Pre: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyRetry, }, }, ActiveDeadlineSeconds: mkint64p(3600), @@ -351,16 +351,16 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.recreateParams.pre", }, "missing spec.strategy.recreateParams.pre.execNewPod.command": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ - Pre: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyRetry, - ExecNewPod: &deployapi.ExecNewPodHook{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ + Pre: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyRetry, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container", }, }, @@ -375,16 +375,16 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.recreateParams.pre.execNewPod.command", }, "missing spec.strategy.recreateParams.pre.execNewPod.containerName": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ - Pre: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyRetry, - ExecNewPod: &deployapi.ExecNewPodHook{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ + Pre: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyRetry, + ExecNewPod: &appsapi.ExecNewPodHook{ Command: []string{"cmd"}, }, }, @@ -399,16 +399,16 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.recreateParams.pre.execNewPod.containerName", }, "invalid spec.strategy.recreateParams.pre.execNewPod.volumes": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ - Pre: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyRetry, - ExecNewPod: &deployapi.ExecNewPodHook{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ + Pre: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyRetry, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container", Command: []string{"cmd"}, Volumes: []string{"good", ""}, @@ -425,15 +425,15 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.recreateParams.pre.execNewPod.volumes[1]", }, "missing spec.strategy.recreateParams.mid.execNewPod": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ - Mid: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyRetry, + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ + Mid: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyRetry, }, }, ActiveDeadlineSeconds: mkint64p(3600), @@ -446,15 +446,15 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.recreateParams.mid", }, "missing spec.strategy.recreateParams.post.execNewPod": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ - Post: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyRetry, + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ + Post: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyRetry, }, }, ActiveDeadlineSeconds: mkint64p(3600), @@ -467,16 +467,16 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.recreateParams.post", }, "missing spec.strategy.after.tagImages": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ - Post: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyRetry, - TagImages: []deployapi.TagImageHook{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ + Post: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyRetry, + TagImages: []appsapi.TagImageHook{ { ContainerName: "missing", To: kapi.ObjectReference{Kind: "ImageStreamTag", Name: "stream:tag"}, @@ -494,16 +494,16 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.recreateParams.post.tagImages[0].containerName", }, "missing spec.strategy.after.tagImages.to.kind": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ - Post: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyRetry, - TagImages: []deployapi.TagImageHook{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ + Post: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyRetry, + TagImages: []appsapi.TagImageHook{ { ContainerName: "container1", To: kapi.ObjectReference{Name: "stream:tag"}, @@ -521,16 +521,16 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.recreateParams.post.tagImages[0].to.kind", }, "missing spec.strategy.after.tagImages.to.name": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ - Post: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyRetry, - TagImages: []deployapi.TagImageHook{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ + Post: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyRetry, + TagImages: []appsapi.TagImageHook{ { ContainerName: "container1", To: kapi.ObjectReference{Kind: "ImageStreamTag"}, @@ -548,17 +548,17 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.recreateParams.post.tagImages[0].to.name", }, "can't have both tag and execNewPod": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ - Post: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyRetry, - ExecNewPod: &deployapi.ExecNewPodHook{}, - TagImages: []deployapi.TagImageHook{{}}, + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ + Post: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyRetry, + ExecNewPod: &appsapi.ExecNewPodHook{}, + TagImages: []appsapi.TagImageHook{{}}, }, }, ActiveDeadlineSeconds: mkint64p(3600), @@ -586,19 +586,19 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { "spec.strategy.rollingParams.timeoutSeconds", }, "missing spec.strategy.rollingParams.pre.failurePolicy": { - deployapi.DeploymentConfig{ + appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRolling, - RollingParams: &deployapi.RollingDeploymentStrategyParams{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRolling, + RollingParams: &appsapi.RollingDeploymentStrategyParams{ IntervalSeconds: mkint64p(1), UpdatePeriodSeconds: mkint64p(1), TimeoutSeconds: mkint64p(20), MaxSurge: intstr.FromInt(1), - Pre: &deployapi.LifecycleHook{ - ExecNewPod: &deployapi.ExecNewPodHook{ + Pre: &appsapi.LifecycleHook{ + ExecNewPod: &appsapi.ExecNewPodHook{ Command: []string{"cmd"}, ContainerName: "container", }, @@ -681,29 +681,29 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) { } func TestValidateDeploymentConfigUpdate(t *testing.T) { - oldConfig := &deployapi.DeploymentConfig{ + oldConfig := &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar", ResourceVersion: "1"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, Triggers: manualTrigger(), Selector: test.OkSelector(), Strategy: test.OkStrategy(), Template: test.OkPodTemplate(), }, - Status: deployapi.DeploymentConfigStatus{ + Status: appsapi.DeploymentConfigStatus{ LatestVersion: 5, }, } - newConfig := &deployapi.DeploymentConfig{ + newConfig := &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar", ResourceVersion: "1"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, Triggers: manualTrigger(), Selector: test.OkSelector(), Strategy: test.OkStrategy(), Template: test.OkPodTemplate(), }, - Status: deployapi.DeploymentConfigStatus{ + Status: appsapi.DeploymentConfigStatus{ LatestVersion: 3, }, } @@ -744,9 +744,9 @@ func TestValidateDeploymentConfigUpdate(t *testing.T) { } func TestValidateDeploymentConfigRollbackOK(t *testing.T) { - rollback := &deployapi.DeploymentConfigRollback{ + rollback := &appsapi.DeploymentConfigRollback{ Name: "config", - Spec: deployapi.DeploymentConfigRollbackSpec{ + Spec: appsapi.DeploymentConfigRollbackSpec{ Revision: 2, }, } @@ -758,8 +758,8 @@ func TestValidateDeploymentConfigRollbackOK(t *testing.T) { } func TestValidateDeploymentConfigRollbackDeprecatedOK(t *testing.T) { - rollback := &deployapi.DeploymentConfigRollback{ - Spec: deployapi.DeploymentConfigRollbackSpec{ + rollback := &appsapi.DeploymentConfigRollback{ + Spec: appsapi.DeploymentConfigRollbackSpec{ From: kapi.ObjectReference{ Name: "deployment", }, @@ -778,13 +778,13 @@ func TestValidateDeploymentConfigRollbackDeprecatedOK(t *testing.T) { func TestValidateDeploymentConfigRollbackInvalidFields(t *testing.T) { errorCases := map[string]struct { - D deployapi.DeploymentConfigRollback + D appsapi.DeploymentConfigRollback T field.ErrorType F string }{ "missing name": { - deployapi.DeploymentConfigRollback{ - Spec: deployapi.DeploymentConfigRollbackSpec{ + appsapi.DeploymentConfigRollback{ + Spec: appsapi.DeploymentConfigRollbackSpec{ Revision: 2, }, }, @@ -792,9 +792,9 @@ func TestValidateDeploymentConfigRollbackInvalidFields(t *testing.T) { "name", }, "invalid name": { - deployapi.DeploymentConfigRollback{ + appsapi.DeploymentConfigRollback{ Name: "*_*myconfig", - Spec: deployapi.DeploymentConfigRollbackSpec{ + Spec: appsapi.DeploymentConfigRollbackSpec{ Revision: 2, }, }, @@ -802,9 +802,9 @@ func TestValidateDeploymentConfigRollbackInvalidFields(t *testing.T) { "name", }, "invalid revision": { - deployapi.DeploymentConfigRollback{ + appsapi.DeploymentConfigRollback{ Name: "config", - Spec: deployapi.DeploymentConfigRollbackSpec{ + Spec: appsapi.DeploymentConfigRollbackSpec{ Revision: -1, }, }, @@ -831,13 +831,13 @@ func TestValidateDeploymentConfigRollbackInvalidFields(t *testing.T) { func TestValidateDeploymentConfigRollbackDeprecatedInvalidFields(t *testing.T) { errorCases := map[string]struct { - D deployapi.DeploymentConfigRollback + D appsapi.DeploymentConfigRollback T field.ErrorType F string }{ "missing spec.from.name": { - deployapi.DeploymentConfigRollback{ - Spec: deployapi.DeploymentConfigRollbackSpec{ + appsapi.DeploymentConfigRollback{ + Spec: appsapi.DeploymentConfigRollbackSpec{ From: kapi.ObjectReference{}, }, }, @@ -845,8 +845,8 @@ func TestValidateDeploymentConfigRollbackDeprecatedInvalidFields(t *testing.T) { "spec.from.name", }, "wrong spec.from.kind": { - deployapi.DeploymentConfigRollback{ - Spec: deployapi.DeploymentConfigRollbackSpec{ + appsapi.DeploymentConfigRollback{ + Spec: appsapi.DeploymentConfigRollbackSpec{ From: kapi.ObjectReference{ Kind: "unknown", Name: "deployment", @@ -875,14 +875,14 @@ func TestValidateDeploymentConfigRollbackDeprecatedInvalidFields(t *testing.T) { } func TestValidateDeploymentConfigDefaultImageStreamKind(t *testing.T) { - config := &deployapi.DeploymentConfig{ + config := &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "bar"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, - Triggers: []deployapi.DeploymentTriggerPolicy{ + Triggers: []appsapi.DeploymentTriggerPolicy{ { - Type: deployapi.DeploymentTriggerOnImageChange, - ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ + Type: appsapi.DeploymentTriggerOnImageChange, + ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ From: kapi.ObjectReference{ Kind: "ImageStreamTag", Name: "name:v1", @@ -913,20 +913,20 @@ func mkintp(i int) *int { func TestValidateSelectorMatchesPodTemplateLabels(t *testing.T) { tests := map[string]struct { - spec deployapi.DeploymentConfigSpec + spec appsapi.DeploymentConfigSpec expectedErr bool errorType field.ErrorType field string }{ "valid template labels": { - spec: deployapi.DeploymentConfigSpec{ + spec: appsapi.DeploymentConfigSpec{ Selector: test.OkSelector(), Strategy: test.OkStrategy(), Template: test.OkPodTemplate(), }, }, "invalid template labels": { - spec: deployapi.DeploymentConfigSpec{ + spec: appsapi.DeploymentConfigSpec{ Selector: test.OkSelector(), Strategy: test.OkStrategy(), Template: test.OkPodTemplate(), diff --git a/pkg/apps/cmd/delete.go b/pkg/apps/cmd/delete.go index b620c8b65024..24f084a7461a 100644 --- a/pkg/apps/cmd/delete.go +++ b/pkg/apps/cmd/delete.go @@ -12,7 +12,7 @@ import ( kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/kubectl" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset" "github.com/openshift/origin/pkg/apps/util" ) @@ -31,7 +31,7 @@ type DeploymentConfigReaper struct { // pause marks the deployment configuration as paused to avoid triggering new // deployments. -func (reaper *DeploymentConfigReaper) pause(namespace, name string) (*deployapi.DeploymentConfig, error) { +func (reaper *DeploymentConfigReaper) pause(namespace, name string) (*appsapi.DeploymentConfig, error) { patchBytes := []byte(`{"spec":{"paused":true,"replicas":0,"revisionHistoryLimit":0}}`) return reaper.appsClient.Apps().DeploymentConfigs(namespace).Patch(name, types.StrategicMergePatchType, patchBytes) } diff --git a/pkg/apps/cmd/delete_test.go b/pkg/apps/cmd/delete_test.go index 4ff0a7aecd2c..ad960be999d7 100644 --- a/pkg/apps/cmd/delete_test.go +++ b/pkg/apps/cmd/delete_test.go @@ -15,15 +15,15 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" _ "github.com/openshift/origin/pkg/apps/apis/apps/install" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" appsfake "github.com/openshift/origin/pkg/apps/generated/internalclientset/fake" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" ) func mkdeployment(version int64) kapi.ReplicationController { - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(appsapi.SchemeGroupVersion)) return *deployment } @@ -44,13 +44,13 @@ func TestStop(t *testing.T) { pauseBytes := []byte(`{"spec":{"paused":true,"replicas":0,"revisionHistoryLimit":0}}`) - fakeDC := map[string]*deployapi.DeploymentConfig{ - "simple-stop": deploytest.OkDeploymentConfig(1), - "legacy-simple-stop": deploytest.OkDeploymentConfig(1), - "multi-stop": deploytest.OkDeploymentConfig(5), - "legacy-multi-stop": deploytest.OkDeploymentConfig(5), - "no-deployments": deploytest.OkDeploymentConfig(5), - "legacy-no-deployments": deploytest.OkDeploymentConfig(5), + fakeDC := map[string]*appsapi.DeploymentConfig{ + "simple-stop": appstest.OkDeploymentConfig(1), + "legacy-simple-stop": appstest.OkDeploymentConfig(1), + "multi-stop": appstest.OkDeploymentConfig(5), + "legacy-multi-stop": appstest.OkDeploymentConfig(5), + "no-deployments": appstest.OkDeploymentConfig(5), + "legacy-no-deployments": appstest.OkDeploymentConfig(5), } emptyClientset := func() *appsfake.Clientset { diff --git a/pkg/apps/cmd/generate.go b/pkg/apps/cmd/generate.go index 5649cbcecc80..a5295fcf7986 100644 --- a/pkg/apps/cmd/generate.go +++ b/pkg/apps/cmd/generate.go @@ -8,7 +8,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/kubernetes/pkg/kubectl" - deployapi "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/api/apps/v1" ) var basic = kubectl.BasicReplicationController{} @@ -26,9 +26,9 @@ func (BasicDeploymentConfigController) Generate(genericParams map[string]interfa } switch t := obj.(type) { case *kapi.ReplicationController: - obj = &deployapi.DeploymentConfig{ + obj = &appsapi.DeploymentConfig{ ObjectMeta: t.ObjectMeta, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Selector: t.Spec.Selector, Replicas: *t.Spec.Replicas, // the generator never leaves this nil Template: t.Spec.Template, diff --git a/pkg/apps/cmd/history.go b/pkg/apps/cmd/history.go index fa33f9c9baf8..8482b0458d90 100644 --- a/pkg/apps/cmd/history.go +++ b/pkg/apps/cmd/history.go @@ -13,8 +13,8 @@ import ( "k8s.io/kubernetes/pkg/kubectl" kinternalprinters "k8s.io/kubernetes/pkg/printers/internalversion" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" ) func NewDeploymentConfigHistoryViewer(kc kclientset.Interface) kubectl.HistoryViewer { @@ -31,7 +31,7 @@ var _ kubectl.HistoryViewer = &DeploymentConfigHistoryViewer{} // ViewHistory returns a description of all the history it can find for a deployment config. func (h *DeploymentConfigHistoryViewer) ViewHistory(namespace, name string, revision int64) (string, error) { - opts := metav1.ListOptions{LabelSelector: deployutil.ConfigSelector(name).String()} + opts := metav1.ListOptions{LabelSelector: appsutil.ConfigSelector(name).String()} deploymentList, err := h.rn.ReplicationControllers(namespace).List(opts) if err != nil { return "", err @@ -54,7 +54,7 @@ func (h *DeploymentConfigHistoryViewer) ViewHistory(namespace, name string, revi for i := range history { rc := history[i] - if deployutil.DeploymentVersionFor(rc) == revision { + if appsutil.DeploymentVersionFor(rc) == revision { desired = rc.Spec.Template break } @@ -69,16 +69,16 @@ func (h *DeploymentConfigHistoryViewer) ViewHistory(namespace, name string, revi return buf.String(), nil } - sort.Sort(deployutil.ByLatestVersionAsc(history)) + sort.Sort(appsutil.ByLatestVersionAsc(history)) return tabbedString(func(out *tabwriter.Writer) error { fmt.Fprintf(out, "REVISION\tSTATUS\tCAUSE\n") for i := range history { rc := history[i] - rev := deployutil.DeploymentVersionFor(rc) - status := deployutil.DeploymentStatusFor(rc) - cause := rc.Annotations[deployapi.DeploymentStatusReasonAnnotation] + rev := appsutil.DeploymentVersionFor(rc) + status := appsutil.DeploymentStatusFor(rc) + cause := rc.Annotations[appsapi.DeploymentStatusReasonAnnotation] if len(cause) == 0 { cause = "" } diff --git a/pkg/apps/cmd/rollback.go b/pkg/apps/cmd/rollback.go index 5d2fc41a6cc5..97ad0259930e 100644 --- a/pkg/apps/cmd/rollback.go +++ b/pkg/apps/cmd/rollback.go @@ -8,7 +8,7 @@ import ( "k8s.io/kubernetes/pkg/kubectl" kinternalprinters "k8s.io/kubernetes/pkg/printers/internalversion" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset" appsinternal "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" ) @@ -28,7 +28,7 @@ var _ kubectl.Rollbacker = &DeploymentConfigRollbacker{} // Rollback the provided deployment config to a specific revision. If revision is zero, we will // rollback to the previous deployment. func (r *DeploymentConfigRollbacker) Rollback(obj runtime.Object, updatedAnnotations map[string]string, toRevision int64, dryRun bool) (string, error) { - config, ok := obj.(*deployapi.DeploymentConfig) + config, ok := obj.(*appsapi.DeploymentConfig) if !ok { return "", fmt.Errorf("passed object is not a deployment config: %#v", obj) } @@ -36,10 +36,10 @@ func (r *DeploymentConfigRollbacker) Rollback(obj runtime.Object, updatedAnnotat return "", fmt.Errorf("cannot rollback a paused config; resume it first with 'rollout resume dc/%s' and try again", config.Name) } - rollback := &deployapi.DeploymentConfigRollback{ + rollback := &appsapi.DeploymentConfigRollback{ Name: config.Name, UpdatedAnnotations: updatedAnnotations, - Spec: deployapi.DeploymentConfigRollbackSpec{ + Spec: appsapi.DeploymentConfigRollbackSpec{ Revision: toRevision, IncludeTemplate: true, }, diff --git a/pkg/apps/cmd/scale_test.go b/pkg/apps/cmd/scale_test.go index 198cd8aabcda..9a7e261b9777 100644 --- a/pkg/apps/cmd/scale_test.go +++ b/pkg/apps/cmd/scale_test.go @@ -11,11 +11,11 @@ import ( "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/kubectl" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" _ "github.com/openshift/origin/pkg/apps/apis/apps/install" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" appsfake "github.com/openshift/origin/pkg/apps/generated/internalclientset/fake" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" ) func TestScale(t *testing.T) { @@ -45,9 +45,9 @@ func TestScale(t *testing.T) { kc := &fake.Clientset{} scaler := NewDeploymentConfigScaler(oc, kc) - config := deploytest.OkDeploymentConfig(1) + config := appstest.OkDeploymentConfig(1) config.Spec.Replicas = 1 - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(appsapi.SchemeGroupVersion)) var wait *kubectl.RetryParams if test.wait { diff --git a/pkg/apps/cmd/status.go b/pkg/apps/cmd/status.go index a19698847d13..98097850a01b 100644 --- a/pkg/apps/cmd/status.go +++ b/pkg/apps/cmd/status.go @@ -7,8 +7,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/kubernetes/pkg/kubectl" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset" appsinternal "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" @@ -36,7 +36,7 @@ func (s *DeploymentConfigStatusViewer) Status(namespace, name string, desiredRev if latestRevision == 0 { switch { - case deployutil.HasImageChangeTrigger(config): + case appsutil.HasImageChangeTrigger(config): return fmt.Sprintf("Deployment config %q waiting on image update\n", name), false, nil case len(config.Spec.Triggers) == 0: @@ -48,20 +48,20 @@ func (s *DeploymentConfigStatusViewer) Status(namespace, name string, desiredRev return "", false, fmt.Errorf("desired revision (%d) is different from the running revision (%d)", desiredRevision, latestRevision) } - cond := deployutil.GetDeploymentCondition(config.Status, deployapi.DeploymentProgressing) + cond := appsutil.GetDeploymentCondition(config.Status, appsapi.DeploymentProgressing) if config.Generation <= config.Status.ObservedGeneration { switch { - case cond != nil && cond.Reason == deployapi.NewRcAvailableReason: + case cond != nil && cond.Reason == appsapi.NewRcAvailableReason: return fmt.Sprintf("%s\n", cond.Message), true, nil - case cond != nil && cond.Reason == deployapi.TimedOutReason: + case cond != nil && cond.Reason == appsapi.TimedOutReason: return "", true, errors.New(cond.Message) - case cond != nil && cond.Reason == deployapi.CancelledRolloutReason: + case cond != nil && cond.Reason == appsapi.CancelledRolloutReason: return "", true, errors.New(cond.Message) - case cond != nil && cond.Reason == deployapi.PausedConfigReason: + case cond != nil && cond.Reason == appsapi.PausedConfigReason: return "", true, fmt.Errorf("Deployment config %q is paused. Resume to continue watching the status of the rollout.\n", config.Name) case config.Status.UpdatedReplicas < config.Spec.Replicas: diff --git a/pkg/apps/controller/deployer/deployer_controller.go b/pkg/apps/controller/deployer/deployer_controller.go index e944b2f76703..f479455b4a8b 100755 --- a/pkg/apps/controller/deployer/deployer_controller.go +++ b/pkg/apps/controller/deployer/deployer_controller.go @@ -21,8 +21,8 @@ import ( "k8s.io/client-go/util/workqueue" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" "github.com/openshift/origin/pkg/util" ) @@ -103,25 +103,25 @@ func (c *DeploymentController) handle(deployment *v1.ReplicationController, will updatedAnnotations[key] = value } - currentStatus := deployutil.DeploymentStatusFor(deployment) + currentStatus := appsutil.DeploymentStatusFor(deployment) nextStatus := currentStatus - deployerPodName := deployutil.DeployerPodNameForDeployment(deployment.Name) + deployerPodName := appsutil.DeployerPodNameForDeployment(deployment.Name) deployer, deployerErr := c.podLister.Pods(deployment.Namespace).Get(deployerPodName) if deployerErr == nil { nextStatus = c.nextStatus(deployer, deployment, updatedAnnotations) } switch currentStatus { - case deployapi.DeploymentStatusNew: + case appsapi.DeploymentStatusNew: // If the deployment has been cancelled, don't create a deployer pod. // Instead try to delete any deployer pods found and transition the // deployment to Pending so that the deployment config controller // continues to see the deployment as in-flight. Eventually the deletion // of the deployer pod should cause a requeue of this deployment and // then it can be transitioned to Failed by this controller. - if deployutil.IsDeploymentCancelled(deployment) { - nextStatus = deployapi.DeploymentStatusPending + if appsutil.IsDeploymentCancelled(deployment) { + nextStatus = appsapi.DeploymentStatusPending if err := c.cleanupDeployerPods(deployment); err != nil { return err } @@ -131,28 +131,28 @@ func (c *DeploymentController) handle(deployment *v1.ReplicationController, will // deployer pod (quota, etc..) we should respect the timeoutSeconds in the // config strategy and transition the rollout to failed instead of waiting for // the deployment pod forever. - config, err := deployutil.DecodeDeploymentConfig(deployment, c.codec) + config, err := appsutil.DecodeDeploymentConfig(deployment, c.codec) if err != nil { return err } - if deployutil.RolloutExceededTimeoutSeconds(config, deployment) { - nextStatus = deployapi.DeploymentStatusFailed - updatedAnnotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentFailedUnableToCreateDeployerPod - c.emitDeploymentEvent(deployment, v1.EventTypeWarning, "RolloutTimeout", fmt.Sprintf("Rollout for %q failed to create deployer pod (timeoutSeconds: %ds)", deployutil.LabelForDeploymentV1(deployment), deployutil.GetTimeoutSecondsForStrategy(config))) + if appsutil.RolloutExceededTimeoutSeconds(config, deployment) { + nextStatus = appsapi.DeploymentStatusFailed + updatedAnnotations[appsapi.DeploymentStatusReasonAnnotation] = appsapi.DeploymentFailedUnableToCreateDeployerPod + c.emitDeploymentEvent(deployment, v1.EventTypeWarning, "RolloutTimeout", fmt.Sprintf("Rollout for %q failed to create deployer pod (timeoutSeconds: %ds)", appsutil.LabelForDeploymentV1(deployment), appsutil.GetTimeoutSecondsForStrategy(config))) glog.V(4).Infof("Failing deployment %s/%s as we reached timeout while waiting for the deployer pod to be created", deployment.Namespace, deployment.Name) break } switch { case kerrors.IsNotFound(deployerErr): - if _, ok := deployment.Annotations[deployapi.DeploymentIgnorePodAnnotation]; ok { + if _, ok := deployment.Annotations[appsapi.DeploymentIgnorePodAnnotation]; ok { return nil } // Generate a deployer pod spec. deployerPod, err := c.makeDeployerPod(deployment) if err != nil { - return fatalError(fmt.Sprintf("couldn't make deployer pod for %q: %v", deployutil.LabelForDeploymentV1(deployment), err)) + return fatalError(fmt.Sprintf("couldn't make deployer pod for %q: %v", appsutil.LabelForDeploymentV1(deployment), err)) } // Create the deployer pod. deploymentPod, err := c.pn.Pods(deployment.Namespace).Create(deployerPod) @@ -161,15 +161,15 @@ func (c *DeploymentController) handle(deployment *v1.ReplicationController, will // if we cannot create a deployment pod (i.e lack of quota), match normal replica set experience and // emit an event. c.emitDeploymentEvent(deployment, v1.EventTypeWarning, "FailedCreate", fmt.Sprintf("Error creating deployer pod: %v", err)) - return actionableError(fmt.Sprintf("couldn't create deployer pod for %q: %v", deployutil.LabelForDeploymentV1(deployment), err)) + return actionableError(fmt.Sprintf("couldn't create deployer pod for %q: %v", appsutil.LabelForDeploymentV1(deployment), err)) } - updatedAnnotations[deployapi.DeploymentPodAnnotation] = deploymentPod.Name - updatedAnnotations[deployapi.DeployerPodCreatedAtAnnotation] = deploymentPod.CreationTimestamp.String() + updatedAnnotations[appsapi.DeploymentPodAnnotation] = deploymentPod.Name + updatedAnnotations[appsapi.DeployerPodCreatedAtAnnotation] = deploymentPod.CreationTimestamp.String() if deploymentPod.Status.StartTime != nil { - updatedAnnotations[deployapi.DeployerPodStartedAtAnnotation] = deploymentPod.Status.StartTime.String() + updatedAnnotations[appsapi.DeployerPodStartedAtAnnotation] = deploymentPod.Status.StartTime.String() } - nextStatus = deployapi.DeploymentStatusPending - glog.V(4).Infof("Created deployer pod %q for %q", deploymentPod.Name, deployutil.LabelForDeploymentV1(deployment)) + nextStatus = appsapi.DeploymentStatusPending + glog.V(4).Infof("Created deployer pod %q for %q", deploymentPod.Name, appsutil.LabelForDeploymentV1(deployment)) // Most likely dead code since we never get an error different from 404 back from the cache. case deployerErr != nil: @@ -177,7 +177,7 @@ func (c *DeploymentController) handle(deployment *v1.ReplicationController, will // succeeded but the deployment state update failed and now we're re- // entering. Ensure that the pod is the one we created by verifying the // annotation on it, and throw a retryable error. - return fmt.Errorf("couldn't fetch existing deployer pod for %s: %v", deployutil.LabelForDeploymentV1(deployment), deployerErr) + return fmt.Errorf("couldn't fetch existing deployer pod for %s: %v", appsutil.LabelForDeploymentV1(deployment), deployerErr) default: /* deployerErr == nil */ // Do a stronger check to validate that the existing deployer pod is @@ -188,43 +188,43 @@ func (c *DeploymentController) handle(deployment *v1.ReplicationController, will // to ensure that changes to 'unrelated' pods don't result in updates to // the deployment. So, the image check will have to be done in other areas // of the code as well. - if deployutil.DeploymentNameFor(deployer) != deployment.Name { - nextStatus = deployapi.DeploymentStatusFailed - updatedAnnotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentFailedUnrelatedDeploymentExists + if appsutil.DeploymentNameFor(deployer) != deployment.Name { + nextStatus = appsapi.DeploymentStatusFailed + updatedAnnotations[appsapi.DeploymentStatusReasonAnnotation] = appsapi.DeploymentFailedUnrelatedDeploymentExists c.emitDeploymentEvent(deployment, v1.EventTypeWarning, "FailedCreate", fmt.Sprintf("Error creating deployer pod since another pod with the same name (%q) exists", deployer.Name)) } else { // Update to pending or to the appropriate status relative to the existing validated deployer pod. - updatedAnnotations[deployapi.DeploymentPodAnnotation] = deployer.Name - updatedAnnotations[deployapi.DeployerPodCreatedAtAnnotation] = deployer.CreationTimestamp.String() + updatedAnnotations[appsapi.DeploymentPodAnnotation] = deployer.Name + updatedAnnotations[appsapi.DeployerPodCreatedAtAnnotation] = deployer.CreationTimestamp.String() if deployer.Status.StartTime != nil { - updatedAnnotations[deployapi.DeployerPodStartedAtAnnotation] = deployer.Status.StartTime.String() + updatedAnnotations[appsapi.DeployerPodStartedAtAnnotation] = deployer.Status.StartTime.String() } - nextStatus = nextStatusComp(nextStatus, deployapi.DeploymentStatusPending) + nextStatus = nextStatusComp(nextStatus, appsapi.DeploymentStatusPending) } } - case deployapi.DeploymentStatusPending, deployapi.DeploymentStatusRunning: + case appsapi.DeploymentStatusPending, appsapi.DeploymentStatusRunning: switch { case kerrors.IsNotFound(deployerErr): - nextStatus = deployapi.DeploymentStatusFailed + nextStatus = appsapi.DeploymentStatusFailed // If the deployment is cancelled here then we deleted the deployer in a previous // resync of the deployment. - if !deployutil.IsDeploymentCancelled(deployment) { + if !appsutil.IsDeploymentCancelled(deployment) { // Retry more before setting the deployment to Failed if it's Pending - the pod might not have // appeared in the cache yet. - if !willBeDropped && currentStatus == deployapi.DeploymentStatusPending { + if !willBeDropped && currentStatus == appsapi.DeploymentStatusPending { return deployerErr } - updatedAnnotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentFailedDeployerPodNoLongerExists + updatedAnnotations[appsapi.DeploymentStatusReasonAnnotation] = appsapi.DeploymentFailedDeployerPodNoLongerExists c.emitDeploymentEvent(deployment, v1.EventTypeWarning, "Failed", fmt.Sprintf("Deployer pod %q has gone missing", deployerPodName)) - deployerErr = fmt.Errorf("Failing rollout for %q because its deployer pod %q disappeared", deployutil.LabelForDeploymentV1(deployment), deployerPodName) + deployerErr = fmt.Errorf("Failing rollout for %q because its deployer pod %q disappeared", appsutil.LabelForDeploymentV1(deployment), deployerPodName) utilruntime.HandleError(deployerErr) } // Most likely dead code since we never get an error different from 404 back from the cache. case deployerErr != nil: // We'll try again later on resync. Continue to process cancellations. - deployerErr = fmt.Errorf("Error getting deployer pod %q for %q: %v", deployerPodName, deployutil.LabelForDeploymentV1(deployment), deployerErr) + deployerErr = fmt.Errorf("Error getting deployer pod %q for %q: %v", deployerPodName, appsutil.LabelForDeploymentV1(deployment), deployerErr) utilruntime.HandleError(deployerErr) default: /* err == nil */ @@ -232,7 +232,7 @@ func (c *DeploymentController) handle(deployment *v1.ReplicationController, will // found. Eventually the deletion of the deployer pod should cause // a requeue of this deployment and then it can be transitioned to // Failed. - if deployutil.IsDeploymentCancelled(deployment) { + if appsutil.IsDeploymentCancelled(deployment) { if err := c.cleanupDeployerPods(deployment); err != nil { return err } @@ -245,10 +245,10 @@ func (c *DeploymentController) handle(deployment *v1.ReplicationController, will } } - case deployapi.DeploymentStatusFailed: + case appsapi.DeploymentStatusFailed: // Try to cleanup once more a cancelled deployment in case hook pods // were created just after we issued the first cleanup request. - if deployutil.IsDeploymentCancelled(deployment) { + if appsutil.IsDeploymentCancelled(deployment) { if err := c.cleanupDeployerPods(deployment); err != nil { return err } @@ -260,7 +260,7 @@ func (c *DeploymentController) handle(deployment *v1.ReplicationController, will } } - case deployapi.DeploymentStatusComplete: + case appsapi.DeploymentStatusComplete: if err := c.cleanupDeployerPods(deployment); err != nil { return err } @@ -269,66 +269,66 @@ func (c *DeploymentController) handle(deployment *v1.ReplicationController, will deploymentCopy := deployment.DeepCopy() // Update only if we need to transition to a new phase. - if deployutil.CanTransitionPhase(currentStatus, nextStatus) { - updatedAnnotations[deployapi.DeploymentStatusAnnotation] = string(nextStatus) + if appsutil.CanTransitionPhase(currentStatus, nextStatus) { + updatedAnnotations[appsapi.DeploymentStatusAnnotation] = string(nextStatus) deploymentCopy.Annotations = updatedAnnotations // If we are going to transition to failed or complete and scale is non-zero, we'll check one more // time to see if we are a test deployment to guarantee that we maintain the test invariant. - if *deploymentCopy.Spec.Replicas != 0 && deployutil.IsTerminatedDeployment(deploymentCopy) { - if config, err := deployutil.DecodeDeploymentConfig(deploymentCopy, c.codec); err == nil && config.Spec.Test { + if *deploymentCopy.Spec.Replicas != 0 && appsutil.IsTerminatedDeployment(deploymentCopy) { + if config, err := appsutil.DecodeDeploymentConfig(deploymentCopy, c.codec); err == nil && config.Spec.Test { zero := int32(0) deploymentCopy.Spec.Replicas = &zero } } if _, err := c.rn.ReplicationControllers(deploymentCopy.Namespace).Update(deploymentCopy); err != nil { - return fmt.Errorf("couldn't update rollout status for %q to %s: %v", deployutil.LabelForDeploymentV1(deploymentCopy), nextStatus, err) + return fmt.Errorf("couldn't update rollout status for %q to %s: %v", appsutil.LabelForDeploymentV1(deploymentCopy), nextStatus, err) } - glog.V(4).Infof("Updated rollout status for %q from %s to %s (scale: %d)", deployutil.LabelForDeploymentV1(deploymentCopy), currentStatus, nextStatus, deploymentCopy.Spec.Replicas) + glog.V(4).Infof("Updated rollout status for %q from %s to %s (scale: %d)", appsutil.LabelForDeploymentV1(deploymentCopy), currentStatus, nextStatus, deploymentCopy.Spec.Replicas) - if deployutil.IsDeploymentCancelled(deploymentCopy) && deployutil.IsFailedDeployment(deploymentCopy) { - c.emitDeploymentEvent(deploymentCopy, v1.EventTypeNormal, "RolloutCancelled", fmt.Sprintf("Rollout for %q cancelled", deployutil.LabelForDeploymentV1(deploymentCopy))) + if appsutil.IsDeploymentCancelled(deploymentCopy) && appsutil.IsFailedDeployment(deploymentCopy) { + c.emitDeploymentEvent(deploymentCopy, v1.EventTypeNormal, "RolloutCancelled", fmt.Sprintf("Rollout for %q cancelled", appsutil.LabelForDeploymentV1(deploymentCopy))) } } return nil } -func (c *DeploymentController) nextStatus(pod *v1.Pod, deployment *v1.ReplicationController, updatedAnnotations map[string]string) deployapi.DeploymentStatus { +func (c *DeploymentController) nextStatus(pod *v1.Pod, deployment *v1.ReplicationController, updatedAnnotations map[string]string) appsapi.DeploymentStatus { switch pod.Status.Phase { case v1.PodPending: - return deployapi.DeploymentStatusPending + return appsapi.DeploymentStatusPending case v1.PodRunning: - return deployapi.DeploymentStatusRunning + return appsapi.DeploymentStatusRunning case v1.PodSucceeded: // If the deployment was cancelled just prior to the deployer pod succeeding // then we need to remove the cancel annotations from the complete deployment // and emit an event letting users know their cancellation failed. - if deployutil.IsDeploymentCancelled(deployment) { - delete(updatedAnnotations, deployapi.DeploymentCancelledAnnotation) - delete(updatedAnnotations, deployapi.DeploymentStatusReasonAnnotation) + if appsutil.IsDeploymentCancelled(deployment) { + delete(updatedAnnotations, appsapi.DeploymentCancelledAnnotation) + delete(updatedAnnotations, appsapi.DeploymentStatusReasonAnnotation) c.emitDeploymentEvent(deployment, v1.EventTypeWarning, "FailedCancellation", "Succeeded before cancel recorded") } // Sync the internal replica annotation with the target so that we can // distinguish deployer updates from other scaling events. completedTimestamp := getPodTerminatedTimestamp(pod) if completedTimestamp != nil { - updatedAnnotations[deployapi.DeployerPodCompletedAtAnnotation] = completedTimestamp.String() + updatedAnnotations[appsapi.DeployerPodCompletedAtAnnotation] = completedTimestamp.String() } - updatedAnnotations[deployapi.DeploymentReplicasAnnotation] = updatedAnnotations[deployapi.DesiredReplicasAnnotation] - delete(updatedAnnotations, deployapi.DesiredReplicasAnnotation) - return deployapi.DeploymentStatusComplete + updatedAnnotations[appsapi.DeploymentReplicasAnnotation] = updatedAnnotations[appsapi.DesiredReplicasAnnotation] + delete(updatedAnnotations, appsapi.DesiredReplicasAnnotation) + return appsapi.DeploymentStatusComplete case v1.PodFailed: completedTimestamp := getPodTerminatedTimestamp(pod) if completedTimestamp != nil { - updatedAnnotations[deployapi.DeployerPodCompletedAtAnnotation] = completedTimestamp.String() + updatedAnnotations[appsapi.DeployerPodCompletedAtAnnotation] = completedTimestamp.String() } - return deployapi.DeploymentStatusFailed + return appsapi.DeploymentStatusFailed } - return deployapi.DeploymentStatusNew + return appsapi.DeploymentStatusNew } // getPodTerminatedTimestamp gets the first terminated container in a pod and @@ -342,8 +342,8 @@ func getPodTerminatedTimestamp(pod *v1.Pod) *metav1.Time { return nil } -func nextStatusComp(fromDeployer, fromPath deployapi.DeploymentStatus) deployapi.DeploymentStatus { - if deployutil.CanTransitionPhase(fromPath, fromDeployer) { +func nextStatusComp(fromDeployer, fromPath appsapi.DeploymentStatus) appsapi.DeploymentStatus { + if appsutil.CanTransitionPhase(fromPath, fromDeployer) { return fromDeployer } return fromPath @@ -352,7 +352,7 @@ func nextStatusComp(fromDeployer, fromPath deployapi.DeploymentStatus) deployapi // makeDeployerPod creates a pod which implements deployment behavior. The pod is correlated to // the deployment with an annotation. func (c *DeploymentController) makeDeployerPod(deployment *v1.ReplicationController) (*v1.Pod, error) { - deploymentConfig, err := deployutil.DecodeDeploymentConfig(deployment, c.codec) + deploymentConfig, err := appsutil.DecodeDeploymentConfig(deployment, c.codec) if err != nil { return nil, err } @@ -368,7 +368,7 @@ func (c *DeploymentController) makeDeployerPod(deployment *v1.ReplicationControl envVars = append(envVars, v1.EnvVar{Name: "OPENSHIFT_DEPLOYMENT_NAMESPACE", Value: deployment.Namespace}) // Assigning to a variable since its address is required - maxDeploymentDurationSeconds := deployapi.MaxDeploymentDurationSeconds + maxDeploymentDurationSeconds := appsapi.MaxDeploymentDurationSeconds if deploymentConfig.Spec.Strategy.ActiveDeadlineSeconds != nil { maxDeploymentDurationSeconds = *(deploymentConfig.Spec.Strategy.ActiveDeadlineSeconds) } @@ -377,12 +377,12 @@ func (c *DeploymentController) makeDeployerPod(deployment *v1.ReplicationControl pod := &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ - Name: deployutil.DeployerPodNameForDeployment(deployment.Name), + Name: appsutil.DeployerPodNameForDeployment(deployment.Name), Annotations: map[string]string{ - deployapi.DeploymentAnnotation: deployment.Name, + appsapi.DeploymentAnnotation: deployment.Name, }, Labels: map[string]string{ - deployapi.DeployerPodForDeploymentLabel: deployment.Name, + appsapi.DeployerPodForDeploymentLabel: deployment.Name, }, // Set the owner reference to current deployment, so in case the deployment fails // and the deployer pod is preserved when a revisionHistory limit is reached and the @@ -402,7 +402,7 @@ func (c *DeploymentController) makeDeployerPod(deployment *v1.ReplicationControl Args: container.Args, Image: container.Image, Env: envVars, - Resources: deployutil.CopyApiResourcesToV1Resources(&deploymentConfig.Spec.Strategy.Resources), + Resources: appsutil.CopyApiResourcesToV1Resources(&deploymentConfig.Spec.Strategy.Resources), }, }, ActiveDeadlineSeconds: &maxDeploymentDurationSeconds, @@ -436,7 +436,7 @@ func (c *DeploymentController) makeDeployerPod(deployment *v1.ReplicationControl // of the factory's Environment and the strategy's environment as the // container environment. // -func (c *DeploymentController) makeDeployerContainer(strategy *deployapi.DeploymentStrategy) *v1.Container { +func (c *DeploymentController) makeDeployerContainer(strategy *appsapi.DeploymentStrategy) *v1.Container { image := c.deployerImage var environment []v1.EnvVar var command []string @@ -450,7 +450,7 @@ func (c *DeploymentController) makeDeployerContainer(strategy *deployapi.Deploym if len(p.Command) > 0 { command = p.Command } - for _, env := range deployutil.CopyApiEnvVarToV1EnvVar(strategy.CustomParams.Environment) { + for _, env := range appsutil.CopyApiEnvVarToV1EnvVar(strategy.CustomParams.Environment) { set.Insert(env.Name) environment = append(environment, env) } @@ -472,13 +472,13 @@ func (c *DeploymentController) makeDeployerContainer(strategy *deployapi.Deploym } func (c *DeploymentController) getDeployerPods(deployment *v1.ReplicationController) ([]*v1.Pod, error) { - return c.podLister.Pods(deployment.Namespace).List(deployutil.DeployerPodSelector(deployment.Name)) + return c.podLister.Pods(deployment.Namespace).List(appsutil.DeployerPodSelector(deployment.Name)) } func (c *DeploymentController) setDeployerPodsOwnerRef(deployment *v1.ReplicationController) error { deployerPodsList, err := c.getDeployerPods(deployment) if err != nil { - return fmt.Errorf("couldn't fetch deployer pods for %q: %v", deployutil.LabelForDeploymentV1(deployment), err) + return fmt.Errorf("couldn't fetch deployer pods for %q: %v", appsutil.LabelForDeploymentV1(deployment), err) } encoder := kapi.Codecs.LegacyCodec(kapi.Registry.EnabledVersions()...) @@ -522,7 +522,7 @@ func (c *DeploymentController) setDeployerPodsOwnerRef(deployment *v1.Replicatio func (c *DeploymentController) cleanupDeployerPods(deployment *v1.ReplicationController) error { deployerList, err := c.getDeployerPods(deployment) if err != nil { - return fmt.Errorf("couldn't fetch deployer pods for %q: %v", deployutil.LabelForDeploymentV1(deployment), err) + return fmt.Errorf("couldn't fetch deployer pods for %q: %v", appsutil.LabelForDeploymentV1(deployment), err) } cleanedAll := true @@ -530,19 +530,19 @@ func (c *DeploymentController) cleanupDeployerPods(deployment *v1.ReplicationCon if err := c.pn.Pods(deployerPod.Namespace).Delete(deployerPod.Name, &metav1.DeleteOptions{}); err != nil && !kerrors.IsNotFound(err) { // if the pod deletion failed, then log the error and continue // we will try to delete any remaining deployer pods and return an error later - utilruntime.HandleError(fmt.Errorf("couldn't delete completed deployer pod %q for %q: %v", deployerPod.Name, deployutil.LabelForDeploymentV1(deployment), err)) + utilruntime.HandleError(fmt.Errorf("couldn't delete completed deployer pod %q for %q: %v", deployerPod.Name, appsutil.LabelForDeploymentV1(deployment), err)) cleanedAll = false } } if !cleanedAll { - return actionableError(fmt.Sprintf("couldn't clean up all deployer pods for %q", deployutil.LabelForDeploymentV1(deployment))) + return actionableError(fmt.Sprintf("couldn't clean up all deployer pods for %q", appsutil.LabelForDeploymentV1(deployment))) } return nil } func (c *DeploymentController) emitDeploymentEvent(deployment *v1.ReplicationController, eventType, title, message string) { - if config, _ := deployutil.DecodeDeploymentConfig(deployment, c.codec); config != nil { + if config, _ := appsutil.DecodeDeploymentConfig(deployment, c.codec); config != nil { c.recorder.Eventf(config, eventType, title, message) } else { c.recorder.Eventf(deployment, eventType, title, message) diff --git a/pkg/apps/controller/deployer/deployer_controller_test.go b/pkg/apps/controller/deployer/deployer_controller_test.go index 9c926678e974..cff1f56ab317 100644 --- a/pkg/apps/controller/deployer/deployer_controller_test.go +++ b/pkg/apps/controller/deployer/deployer_controller_test.go @@ -26,16 +26,16 @@ import ( kapihelper "k8s.io/kubernetes/pkg/api/helper" kapitesting "k8s.io/kubernetes/pkg/api/testing" - deployapiv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapiv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" _ "github.com/openshift/origin/pkg/apps/apis/apps/install" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" - deployutil "github.com/openshift/origin/pkg/apps/util" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsutil "github.com/openshift/origin/pkg/apps/util" ) var ( env = []kapi.EnvVar{{Name: "ENV1", Value: "VAL1"}} - codec = kapi.Codecs.LegacyCodec(deployapiv1.SchemeGroupVersion) + codec = kapi.Codecs.LegacyCodec(appsapiv1.SchemeGroupVersion) ) func alwaysReady() bool { return true } @@ -74,7 +74,7 @@ func okDeploymentController(client kclientset.Interface, deployment *v1.Replicat } func deployerPod(deployment *v1.ReplicationController, alternateName string, related bool) *v1.Pod { - deployerPodName := deployutil.DeployerPodNameForDeployment(deployment.Name) + deployerPodName := appsutil.DeployerPodNameForDeployment(deployment.Name) if len(alternateName) > 0 { deployerPodName = alternateName } @@ -86,16 +86,16 @@ func deployerPod(deployment *v1.ReplicationController, alternateName string, rel Name: deployerPodName, Namespace: deployment.Namespace, Labels: map[string]string{ - deployapi.DeployerPodForDeploymentLabel: deployment.Name, + appsapi.DeployerPodForDeploymentLabel: deployment.Name, }, Annotations: map[string]string{ - deployapi.DeploymentAnnotation: deployment.Name, + appsapi.DeploymentAnnotation: deployment.Name, }, }, } if !related { - delete(pod.Annotations, deployapi.DeploymentAnnotation) + delete(pod.Annotations, appsapi.DeploymentAnnotation) } return pod @@ -105,7 +105,7 @@ func okContainer() *v1.Container { return &v1.Container{ Image: "openshift/origin-deployer", Command: []string{"/bin/echo", "hello", "world"}, - Env: deployutil.CopyApiEnvVarToV1EnvVar(env), + Env: appsutil.CopyApiEnvVarToV1EnvVar(env), Resources: v1.ResourceRequirements{ Limits: v1.ResourceList{ v1.ResourceName(v1.ResourceCPU): resource.MustParse("10"), @@ -140,10 +140,10 @@ func TestHandle_createPodOk(t *testing.T) { }) // Verify new -> pending - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = deploytest.OkCustomStrategy() - deployment, _ := deployutil.MakeDeploymentV1(config, codec) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = appstest.OkCustomStrategy() + deployment, _ := appsutil.MakeDeploymentV1(config, codec) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) deployment.Spec.Template.Spec.NodeSelector = map[string]string{"labelKey1": "labelValue1", "labelKey2": "labelValue2"} deployment.CreationTimestamp = metav1.Now() @@ -157,7 +157,7 @@ func TestHandle_createPodOk(t *testing.T) { t.Fatalf("expected an updated deployment") } - if e, a := deployapi.DeploymentStatusPending, deployutil.DeploymentStatusFor(updatedDeployment); e != a { + if e, a := appsapi.DeploymentStatusPending, appsutil.DeploymentStatusFor(updatedDeployment); e != a { t.Fatalf("expected updated deployment status %s, got %s", e, a) } @@ -165,19 +165,19 @@ func TestHandle_createPodOk(t *testing.T) { t.Fatalf("expected a pod to be created") } - if e := deployutil.DeployerPodNameFor(updatedDeployment); len(e) == 0 { + if e := appsutil.DeployerPodNameFor(updatedDeployment); len(e) == 0 { t.Fatalf("missing deployment pod annotation") } - if e, a := createdPod.Name, deployutil.DeployerPodNameFor(updatedDeployment); e != a { + if e, a := createdPod.Name, appsutil.DeployerPodNameFor(updatedDeployment); e != a { t.Fatalf("expected deployment pod annotation %s, got %s", e, a) } - if e := deployutil.DeploymentNameFor(createdPod); len(e) == 0 { + if e := appsutil.DeploymentNameFor(createdPod); len(e) == 0 { t.Fatalf("missing deployment annotation") } - if e, a := updatedDeployment.Name, deployutil.DeploymentNameFor(createdPod); e != a { + if e, a := updatedDeployment.Name, appsutil.DeploymentNameFor(createdPod); e != a { t.Fatalf("expected pod deployment annotation %s, got %s", e, a) } @@ -189,8 +189,8 @@ func TestHandle_createPodOk(t *testing.T) { t.Fatalf("expected ActiveDeadlineSeconds to be set on the deployer pod") } - if *createdPod.Spec.ActiveDeadlineSeconds != deployapi.MaxDeploymentDurationSeconds { - t.Fatalf("expected ActiveDeadlineSeconds on the deployer pod to be set to %d; found: %d", deployapi.MaxDeploymentDurationSeconds, *createdPod.Spec.ActiveDeadlineSeconds) + if *createdPod.Spec.ActiveDeadlineSeconds != appsapi.MaxDeploymentDurationSeconds { + t.Fatalf("expected ActiveDeadlineSeconds on the deployer pod to be set to %d; found: %d", appsapi.MaxDeploymentDurationSeconds, *createdPod.Spec.ActiveDeadlineSeconds) } actualContainer := createdPod.Spec.Containers[0] @@ -232,9 +232,9 @@ func TestHandle_createPodFail(t *testing.T) { return true, rc, nil }) - config := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeploymentV1(config, codec) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) deployment.CreationTimestamp = metav1.Now() controller := okDeploymentController(client, nil, nil, true, v1.PodUnknown) @@ -257,42 +257,42 @@ func TestHandle_deployerPodAlreadyExists(t *testing.T) { name string podPhase v1.PodPhase - expected deployapi.DeploymentStatus + expected appsapi.DeploymentStatus }{ { name: "pending", podPhase: v1.PodPending, - expected: deployapi.DeploymentStatusPending, + expected: appsapi.DeploymentStatusPending, }, { name: "running", podPhase: v1.PodRunning, - expected: deployapi.DeploymentStatusRunning, + expected: appsapi.DeploymentStatusRunning, }, { name: "complete", podPhase: v1.PodFailed, - expected: deployapi.DeploymentStatusFailed, + expected: appsapi.DeploymentStatusFailed, }, { name: "failed", podPhase: v1.PodSucceeded, - expected: deployapi.DeploymentStatusComplete, + expected: appsapi.DeploymentStatusComplete, }, } for _, test := range tests { var updatedDeployment *v1.ReplicationController - config := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeploymentV1(config, codec) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) deployment.CreationTimestamp = metav1.Now() - deployerPodName := deployutil.DeployerPodNameForDeployment(deployment.Name) + deployerPodName := appsutil.DeployerPodNameForDeployment(deployment.Name) client := &fake.Clientset{} client.AddReactor("create", "pods", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { @@ -312,12 +312,12 @@ func TestHandle_deployerPodAlreadyExists(t *testing.T) { continue } - if updatedDeployment.Annotations[deployapi.DeploymentPodAnnotation] != deployerPodName { + if updatedDeployment.Annotations[appsapi.DeploymentPodAnnotation] != deployerPodName { t.Errorf("%s: deployment not updated with pod name annotation", test.name) continue } - if e, a := string(test.expected), updatedDeployment.Annotations[deployapi.DeploymentStatusAnnotation]; e != a { + if e, a := string(test.expected), updatedDeployment.Annotations[appsapi.DeploymentStatusAnnotation]; e != a { t.Errorf("%s: deployment status not updated. Expected %q, got %q", test.name, e, a) } } @@ -329,10 +329,10 @@ func TestHandle_deployerPodAlreadyExists(t *testing.T) { func TestHandle_unrelatedPodAlreadyExists(t *testing.T) { var updatedDeployment *v1.ReplicationController - config := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeploymentV1(config, codec) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) deployment.CreationTimestamp = metav1.Now() - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) client := &fake.Clientset{} client.AddReactor("create", "pods", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { @@ -351,15 +351,15 @@ func TestHandle_unrelatedPodAlreadyExists(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - if _, exists := updatedDeployment.Annotations[deployapi.DeploymentPodAnnotation]; exists { + if _, exists := updatedDeployment.Annotations[appsapi.DeploymentPodAnnotation]; exists { t.Fatalf("deployment updated with pod name annotation") } - if e, a := deployapi.DeploymentFailedUnrelatedDeploymentExists, updatedDeployment.Annotations[deployapi.DeploymentStatusReasonAnnotation]; e != a { + if e, a := appsapi.DeploymentFailedUnrelatedDeploymentExists, updatedDeployment.Annotations[appsapi.DeploymentStatusReasonAnnotation]; e != a { t.Fatalf("expected reason annotation %s, got %s", e, a) } - if e, a := deployapi.DeploymentStatusFailed, deployutil.DeploymentStatusFor(updatedDeployment); e != a { + if e, a := appsapi.DeploymentStatusFailed, appsutil.DeploymentStatusFor(updatedDeployment); e != a { t.Fatalf("expected deployment status %s, got %s", e, a) } } @@ -370,9 +370,9 @@ func TestHandle_unrelatedPodAlreadyExists(t *testing.T) { func TestHandle_unrelatedPodAlreadyExistsTestScaled(t *testing.T) { var updatedDeployment *v1.ReplicationController - config := deploytest.TestDeploymentConfig(deploytest.OkDeploymentConfig(1)) - deployment, _ := deployutil.MakeDeploymentV1(config, codec) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) + config := appstest.TestDeploymentConfig(appstest.OkDeploymentConfig(1)) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) deployment.CreationTimestamp = metav1.Now() one := int32(1) deployment.Spec.Replicas = &one @@ -394,15 +394,15 @@ func TestHandle_unrelatedPodAlreadyExistsTestScaled(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - if _, exists := updatedDeployment.Annotations[deployapi.DeploymentPodAnnotation]; exists { + if _, exists := updatedDeployment.Annotations[appsapi.DeploymentPodAnnotation]; exists { t.Fatalf("deployment updated with pod name annotation") } - if e, a := deployapi.DeploymentFailedUnrelatedDeploymentExists, updatedDeployment.Annotations[deployapi.DeploymentStatusReasonAnnotation]; e != a { + if e, a := appsapi.DeploymentFailedUnrelatedDeploymentExists, updatedDeployment.Annotations[appsapi.DeploymentStatusReasonAnnotation]; e != a { t.Fatalf("expected reason annotation %s, got %s", e, a) } - if e, a := deployapi.DeploymentStatusFailed, deployutil.DeploymentStatusFor(updatedDeployment); e != a { + if e, a := appsapi.DeploymentStatusFailed, appsutil.DeploymentStatusFor(updatedDeployment); e != a { t.Fatalf("expected deployment status %s, got %s", e, a) } if e, a := int32(0), *updatedDeployment.Spec.Replicas; e != a { @@ -418,33 +418,33 @@ func TestHandle_noop(t *testing.T) { name string podPhase v1.PodPhase - deploymentPhase deployapi.DeploymentStatus + deploymentPhase appsapi.DeploymentStatus }{ { name: "pending", podPhase: v1.PodPending, - deploymentPhase: deployapi.DeploymentStatusPending, + deploymentPhase: appsapi.DeploymentStatusPending, }, { name: "running", podPhase: v1.PodRunning, - deploymentPhase: deployapi.DeploymentStatusRunning, + deploymentPhase: appsapi.DeploymentStatusRunning, }, { name: "complete", podPhase: v1.PodFailed, - deploymentPhase: deployapi.DeploymentStatusFailed, + deploymentPhase: appsapi.DeploymentStatusFailed, }, } for _, test := range tests { client := fake.NewSimpleClientset() - deployment, _ := deployutil.MakeDeploymentV1(deploytest.OkDeploymentConfig(1), codec) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(test.deploymentPhase) + deployment, _ := appsutil.MakeDeploymentV1(appstest.OkDeploymentConfig(1), codec) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(test.deploymentPhase) deployment.CreationTimestamp = metav1.Now() controller := okDeploymentController(client, deployment, nil, true, test.podPhase) @@ -487,12 +487,12 @@ func TestHandle_failedTest(t *testing.T) { }) // Verify successful cleanup - config := deploytest.TestDeploymentConfig(deploytest.OkDeploymentConfig(1)) - deployment, _ := deployutil.MakeDeploymentV1(config, codec) + config := appstest.TestDeploymentConfig(appstest.OkDeploymentConfig(1)) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) deployment.CreationTimestamp = metav1.Now() one := int32(1) deployment.Spec.Replicas = &one - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusRunning) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusRunning) controller := okDeploymentController(client, deployment, nil, true, v1.PodFailed) @@ -530,9 +530,9 @@ func TestHandle_cleanupPodOk(t *testing.T) { }) // Verify successful cleanup - config := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeploymentV1(config, codec) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusComplete) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusComplete) deployment.CreationTimestamp = metav1.Now() controller := okDeploymentController(client, deployment, hookPods, true, v1.PodSucceeded) @@ -575,12 +575,12 @@ func TestHandle_cleanupPodOkTest(t *testing.T) { }) // Verify successful cleanup - config := deploytest.TestDeploymentConfig(deploytest.OkDeploymentConfig(1)) - deployment, _ := deployutil.MakeDeploymentV1(config, codec) + config := appstest.TestDeploymentConfig(appstest.OkDeploymentConfig(1)) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) deployment.CreationTimestamp = metav1.Now() one := int32(1) deployment.Spec.Replicas = &one - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusRunning) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusRunning) controller := okDeploymentController(client, deployment, hookPods, true, v1.PodSucceeded) hookPods = append(hookPods, deployment.Name) @@ -620,14 +620,14 @@ func TestHandle_cleanupPodNoop(t *testing.T) { }) // Verify no-op - config := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeploymentV1(config, codec) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) deployment.CreationTimestamp = metav1.Now() - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusComplete) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusComplete) controller := okDeploymentController(client, deployment, nil, true, v1.PodSucceeded) pod := deployerPod(deployment, "", true) - pod.Labels[deployapi.DeployerPodForDeploymentLabel] = "unrelated" + pod.Labels[appsapi.DeployerPodForDeploymentLabel] = "unrelated" controller.podIndexer.Update(pod) if err := controller.handle(deployment, false); err != nil { @@ -652,10 +652,10 @@ func TestHandle_cleanupPodFail(t *testing.T) { }) // Verify error - config := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeploymentV1(config, codec) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) deployment.CreationTimestamp = metav1.Now() - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusComplete) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusComplete) controller := okDeploymentController(client, deployment, nil, true, v1.PodSucceeded) @@ -684,10 +684,10 @@ func TestHandle_cancelNew(t *testing.T) { return true, rc, nil }) - deployment, _ := deployutil.MakeDeploymentV1(deploytest.OkDeploymentConfig(1), codec) + deployment, _ := appsutil.MakeDeploymentV1(appstest.OkDeploymentConfig(1), codec) deployment.CreationTimestamp = metav1.Now() - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) - deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) + deployment.Annotations[appsapi.DeploymentCancelledAnnotation] = appsapi.DeploymentCancelledAnnotationValue controller := okDeploymentController(client, deployment, nil, true, v1.PodRunning) @@ -695,7 +695,7 @@ func TestHandle_cancelNew(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - if e, a := deployapi.DeploymentStatusPending, deployutil.DeploymentStatusFor(updatedDeployment); e != a { + if e, a := appsapi.DeploymentStatusPending, appsutil.DeploymentStatusFor(updatedDeployment); e != a { t.Fatalf("expected deployment status %s, got %s", e, a) } } @@ -706,10 +706,10 @@ func TestHandle_cleanupNewWithDeployers(t *testing.T) { var updatedDeployment *v1.ReplicationController deletedDeployer := false - deployment, _ := deployutil.MakeDeploymentV1(deploytest.OkDeploymentConfig(1), codec) + deployment, _ := appsutil.MakeDeploymentV1(appstest.OkDeploymentConfig(1), codec) deployment.CreationTimestamp = metav1.Now() - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) - deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) + deployment.Annotations[appsapi.DeploymentCancelledAnnotation] = appsapi.DeploymentCancelledAnnotationValue client := &fake.Clientset{} client.AddReactor("delete", "pods", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { @@ -732,7 +732,7 @@ func TestHandle_cleanupNewWithDeployers(t *testing.T) { t.Fatalf("unexpected error: %v", err) } - if e, a := deployapi.DeploymentStatusPending, deployutil.DeploymentStatusFor(updatedDeployment); e != a { + if e, a := appsapi.DeploymentStatusPending, appsutil.DeploymentStatusFor(updatedDeployment); e != a { t.Fatalf("expected deployment status %s, got %s", e, a) } if !deletedDeployer { @@ -748,7 +748,7 @@ func TestHandle_cleanupPostNew(t *testing.T) { tests := []struct { name string - deploymentPhase deployapi.DeploymentStatus + deploymentPhase appsapi.DeploymentStatus podPhase v1.PodPhase expected int @@ -756,7 +756,7 @@ func TestHandle_cleanupPostNew(t *testing.T) { { name: "pending", - deploymentPhase: deployapi.DeploymentStatusPending, + deploymentPhase: appsapi.DeploymentStatusPending, podPhase: v1.PodPending, expected: len(hookPods) + 1, @@ -764,7 +764,7 @@ func TestHandle_cleanupPostNew(t *testing.T) { { name: "running", - deploymentPhase: deployapi.DeploymentStatusRunning, + deploymentPhase: appsapi.DeploymentStatusRunning, podPhase: v1.PodRunning, expected: len(hookPods) + 1, @@ -772,7 +772,7 @@ func TestHandle_cleanupPostNew(t *testing.T) { { name: "failed", - deploymentPhase: deployapi.DeploymentStatusFailed, + deploymentPhase: appsapi.DeploymentStatusFailed, podPhase: v1.PodFailed, expected: len(hookPods) + 1, @@ -780,7 +780,7 @@ func TestHandle_cleanupPostNew(t *testing.T) { { name: "complete", - deploymentPhase: deployapi.DeploymentStatusComplete, + deploymentPhase: appsapi.DeploymentStatusComplete, podPhase: v1.PodSucceeded, expected: len(hookPods) + 1, @@ -801,10 +801,10 @@ func TestHandle_cleanupPostNew(t *testing.T) { return true, nil, nil }) - deployment, _ := deployutil.MakeDeploymentV1(deploytest.OkDeploymentConfig(1), codec) + deployment, _ := appsutil.MakeDeploymentV1(appstest.OkDeploymentConfig(1), codec) deployment.CreationTimestamp = metav1.Now() - deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(test.deploymentPhase) + deployment.Annotations[appsapi.DeploymentCancelledAnnotation] = appsapi.DeploymentCancelledAnnotationValue + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(test.deploymentPhase) controller := okDeploymentController(client, deployment, hookPods, true, test.podPhase) @@ -826,25 +826,25 @@ func TestHandle_cleanupPostNew(t *testing.T) { func TestHandle_deployerPodDisappeared(t *testing.T) { tests := []struct { name string - phase deployapi.DeploymentStatus + phase appsapi.DeploymentStatus willBeDropped bool shouldRetry bool }{ { name: "pending - retry", - phase: deployapi.DeploymentStatusPending, + phase: appsapi.DeploymentStatusPending, willBeDropped: false, shouldRetry: true, }, { name: "pending - fail", - phase: deployapi.DeploymentStatusPending, + phase: appsapi.DeploymentStatusPending, willBeDropped: true, shouldRetry: false, }, { name: "running", - phase: deployapi.DeploymentStatusRunning, + phase: appsapi.DeploymentStatusRunning, }, } @@ -860,12 +860,12 @@ func TestHandle_deployerPodDisappeared(t *testing.T) { return true, nil, nil }) - deployment, err := deployutil.MakeDeploymentV1(deploytest.OkDeploymentConfig(1), codec) + deployment, err := appsutil.MakeDeploymentV1(appstest.OkDeploymentConfig(1), codec) if err != nil { t.Errorf("%s: unexpected error: %v", test.name, err) continue } - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(test.phase) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(test.phase) deployment.CreationTimestamp = metav1.Now() updatedDeployment = deployment @@ -891,14 +891,14 @@ func TestHandle_deployerPodDisappeared(t *testing.T) { continue } - gotStatus := deployutil.DeploymentStatusFor(updatedDeployment) - if !test.shouldRetry && deployapi.DeploymentStatusFailed != gotStatus { - t.Errorf("%s: expected deployment status %q, got %q", test.name, deployapi.DeploymentStatusFailed, gotStatus) + gotStatus := appsutil.DeploymentStatusFor(updatedDeployment) + if !test.shouldRetry && appsapi.DeploymentStatusFailed != gotStatus { + t.Errorf("%s: expected deployment status %q, got %q", test.name, appsapi.DeploymentStatusFailed, gotStatus) continue } - if test.shouldRetry && deployapi.DeploymentStatusPending != gotStatus { - t.Errorf("%s: expected deployment status %q, got %q", test.name, deployapi.DeploymentStatusPending, gotStatus) + if test.shouldRetry && appsapi.DeploymentStatusPending != gotStatus { + t.Errorf("%s: expected deployment status %q, got %q", test.name, appsapi.DeploymentStatusPending, gotStatus) continue } } @@ -910,81 +910,81 @@ func TestHandle_transitionFromDeployer(t *testing.T) { name string podPhase v1.PodPhase - deploymentPhase deployapi.DeploymentStatus + deploymentPhase appsapi.DeploymentStatus - expected deployapi.DeploymentStatus + expected appsapi.DeploymentStatus }{ { name: "New -> Pending", podPhase: v1.PodPending, - deploymentPhase: deployapi.DeploymentStatusNew, + deploymentPhase: appsapi.DeploymentStatusNew, - expected: deployapi.DeploymentStatusPending, + expected: appsapi.DeploymentStatusPending, }, { name: "New -> Running", podPhase: v1.PodRunning, - deploymentPhase: deployapi.DeploymentStatusNew, + deploymentPhase: appsapi.DeploymentStatusNew, - expected: deployapi.DeploymentStatusRunning, + expected: appsapi.DeploymentStatusRunning, }, { name: "New -> Complete", podPhase: v1.PodSucceeded, - deploymentPhase: deployapi.DeploymentStatusNew, + deploymentPhase: appsapi.DeploymentStatusNew, - expected: deployapi.DeploymentStatusComplete, + expected: appsapi.DeploymentStatusComplete, }, { name: "New -> Failed", podPhase: v1.PodFailed, - deploymentPhase: deployapi.DeploymentStatusNew, + deploymentPhase: appsapi.DeploymentStatusNew, - expected: deployapi.DeploymentStatusFailed, + expected: appsapi.DeploymentStatusFailed, }, { name: "Pending -> Running", podPhase: v1.PodRunning, - deploymentPhase: deployapi.DeploymentStatusPending, + deploymentPhase: appsapi.DeploymentStatusPending, - expected: deployapi.DeploymentStatusRunning, + expected: appsapi.DeploymentStatusRunning, }, { name: "Pending -> Complete", podPhase: v1.PodSucceeded, - deploymentPhase: deployapi.DeploymentStatusPending, + deploymentPhase: appsapi.DeploymentStatusPending, - expected: deployapi.DeploymentStatusComplete, + expected: appsapi.DeploymentStatusComplete, }, { name: "Pending -> Failed", podPhase: v1.PodFailed, - deploymentPhase: deployapi.DeploymentStatusPending, + deploymentPhase: appsapi.DeploymentStatusPending, - expected: deployapi.DeploymentStatusFailed, + expected: appsapi.DeploymentStatusFailed, }, { name: "Running -> Complete", podPhase: v1.PodSucceeded, - deploymentPhase: deployapi.DeploymentStatusRunning, + deploymentPhase: appsapi.DeploymentStatusRunning, - expected: deployapi.DeploymentStatusComplete, + expected: appsapi.DeploymentStatusComplete, }, { name: "Running -> Failed", podPhase: v1.PodFailed, - deploymentPhase: deployapi.DeploymentStatusRunning, + deploymentPhase: appsapi.DeploymentStatusRunning, - expected: deployapi.DeploymentStatusFailed, + expected: appsapi.DeploymentStatusFailed, }, } @@ -1000,8 +1000,8 @@ func TestHandle_transitionFromDeployer(t *testing.T) { return true, nil, nil }) - deployment, _ := deployutil.MakeDeploymentV1(deploytest.OkDeploymentConfig(1), codec) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(test.deploymentPhase) + deployment, _ := appsutil.MakeDeploymentV1(appstest.OkDeploymentConfig(1), codec) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(test.deploymentPhase) deployment.CreationTimestamp = metav1.Now() controller := okDeploymentController(client, deployment, nil, true, test.podPhase) @@ -1016,7 +1016,7 @@ func TestHandle_transitionFromDeployer(t *testing.T) { continue } - if e, a := test.expected, deployutil.DeploymentStatusFor(updatedDeployment); e != a { + if e, a := test.expected, appsutil.DeploymentStatusFor(updatedDeployment); e != a { t.Errorf("%s: expected deployment status %q, got %q", test.name, e, a) } } @@ -1039,24 +1039,24 @@ func expectMapContains(t *testing.T, exists, expected map[string]string, what st func TestDeployerCustomLabelsAndAnnotations(t *testing.T) { testCases := []struct { name string - strategy deployapi.DeploymentStrategy + strategy appsapi.DeploymentStrategy labels map[string]string annotations map[string]string verifyLabels bool }{ - {name: "labels and annotations", strategy: deploytest.OkStrategy(), labels: map[string]string{"label1": "value1"}, annotations: map[string]string{"annotation1": "value1"}, verifyLabels: true}, - {name: "custom strategy, no annotations", strategy: deploytest.OkCustomStrategy(), labels: map[string]string{"label2": "value2", "label3": "value3"}, verifyLabels: true}, - {name: "custom strategy, no labels", strategy: deploytest.OkCustomStrategy(), annotations: map[string]string{"annotation3": "value3"}, verifyLabels: true}, - {name: "no overrride", strategy: deploytest.OkStrategy(), labels: map[string]string{deployapi.DeployerPodForDeploymentLabel: "ignored"}, verifyLabels: false}, + {name: "labels and annotations", strategy: appstest.OkStrategy(), labels: map[string]string{"label1": "value1"}, annotations: map[string]string{"annotation1": "value1"}, verifyLabels: true}, + {name: "custom strategy, no annotations", strategy: appstest.OkCustomStrategy(), labels: map[string]string{"label2": "value2", "label3": "value3"}, verifyLabels: true}, + {name: "custom strategy, no labels", strategy: appstest.OkCustomStrategy(), annotations: map[string]string{"annotation3": "value3"}, verifyLabels: true}, + {name: "no overrride", strategy: appstest.OkStrategy(), labels: map[string]string{appsapi.DeployerPodForDeploymentLabel: "ignored"}, verifyLabels: false}, } for _, test := range testCases { t.Logf("evaluating test case %s", test.name) - config := deploytest.OkDeploymentConfig(1) + config := appstest.OkDeploymentConfig(1) config.Spec.Strategy = test.strategy config.Spec.Strategy.Labels = test.labels config.Spec.Strategy.Annotations = test.annotations - deployment, _ := deployutil.MakeDeploymentV1(config, codec) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) client := &fake.Clientset{} client.AddReactor("create", "pods", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { @@ -1070,11 +1070,11 @@ func TestDeployerCustomLabelsAndAnnotations(t *testing.T) { t.Fatal(err) } - nameLabel, ok := podTemplate.Labels[deployapi.DeployerPodForDeploymentLabel] + nameLabel, ok := podTemplate.Labels[appsapi.DeployerPodForDeploymentLabel] if ok && nameLabel != deployment.Name { - t.Errorf("label %s expected %s, got %s", deployapi.DeployerPodForDeploymentLabel, deployment.Name, nameLabel) + t.Errorf("label %s expected %s, got %s", appsapi.DeployerPodForDeploymentLabel, deployment.Name, nameLabel) } else if !ok { - t.Errorf("label %s not present", deployapi.DeployerPodForDeploymentLabel) + t.Errorf("label %s not present", appsapi.DeployerPodForDeploymentLabel) } if test.verifyLabels { expectMapContains(t, podTemplate.Labels, test.labels, "labels") @@ -1086,12 +1086,12 @@ func TestDeployerCustomLabelsAndAnnotations(t *testing.T) { func TestMakeDeployerPod(t *testing.T) { client := &fake.Clientset{} controller := okDeploymentController(client, nil, nil, true, v1.PodUnknown) - config := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeploymentV1(config, codec) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) container := controller.makeDeployerContainer(&config.Spec.Strategy) - container.Resources = deployutil.CopyApiResourcesToV1Resources(&config.Spec.Strategy.Resources) + container.Resources = appsutil.CopyApiResourcesToV1Resources(&config.Spec.Strategy.Resources) defaultGracePeriod := int64(10) - maxDeploymentDurationSeconds := deployapi.MaxDeploymentDurationSeconds + maxDeploymentDurationSeconds := appsapi.MaxDeploymentDurationSeconds for i := 1; i <= 25; i++ { seed := rand.Int63() diff --git a/pkg/apps/controller/deployer/factory.go b/pkg/apps/controller/deployer/factory.go index 33450b595129..8e0a77077a47 100644 --- a/pkg/apps/controller/deployer/factory.go +++ b/pkg/apps/controller/deployer/factory.go @@ -19,7 +19,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kcontroller "k8s.io/kubernetes/pkg/controller" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" ) // NewDeployerController creates a new DeploymentController. @@ -50,7 +50,7 @@ func NewDeployerController( serviceAccount: sa, deployerImage: image, - environment: deployutil.CopyApiEnvVarToV1EnvVar(env), + environment: appsutil.CopyApiEnvVarToV1EnvVar(env), recorder: recorder, codec: codec, } @@ -94,7 +94,7 @@ func (c *DeploymentController) Run(workers int, stopCh <-chan struct{}) { func (c *DeploymentController) addReplicationController(obj interface{}) { rc := obj.(*v1.ReplicationController) // Filter out all unrelated replication controllers. - if !deployutil.IsOwnedByConfig(rc) { + if !appsutil.IsOwnedByConfig(rc) { return } @@ -110,7 +110,7 @@ func (c *DeploymentController) updateReplicationController(old, cur interface{}) } // Filter out all unrelated replication controllers. - if !deployutil.IsOwnedByConfig(curRC) { + if !appsutil.IsOwnedByConfig(curRC) { return } @@ -160,7 +160,7 @@ func (c *DeploymentController) enqueueReplicationController(rc *v1.ReplicationCo } func (c *DeploymentController) rcForDeployerPod(pod *v1.Pod) (*v1.ReplicationController, error) { - rcName := deployutil.DeploymentNameFor(pod) + rcName := appsutil.DeploymentNameFor(pod) if len(rcName) == 0 { // Not a deployer pod, so don't bother with it. return nil, nil diff --git a/pkg/apps/controller/deploymentconfig/deploymentconfig_controller.go b/pkg/apps/controller/deploymentconfig/deploymentconfig_controller.go index fc4b93f4aefc..66429c37d238 100644 --- a/pkg/apps/controller/deploymentconfig/deploymentconfig_controller.go +++ b/pkg/apps/controller/deploymentconfig/deploymentconfig_controller.go @@ -22,10 +22,10 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kcontroller "k8s.io/kubernetes/pkg/controller" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" appslister "github.com/openshift/origin/pkg/apps/generated/listers/apps/internalversion" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" ) const ( @@ -83,10 +83,10 @@ type DeploymentConfigController struct { // Handle implements the loop that processes deployment configs. Since this controller started // using caches, the provided config MUST be deep-copied beforehand (see work() in factory.go). -func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) error { +func (c *DeploymentConfigController) Handle(config *appsapi.DeploymentConfig) error { glog.V(5).Infof("Reconciling %s/%s", config.Namespace, config.Name) // There's nothing to reconcile until the version is nonzero. - if deployutil.IsInitialDeployment(config) && !deployutil.HasTrigger(config) { + if appsutil.IsInitialDeployment(config) && !appsutil.HasTrigger(config) { return c.updateStatus(config, []*v1.ReplicationController{}) } @@ -108,7 +108,7 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) } return fresh, nil }) - cm := NewRCControllerRefManager(c.rcControl, config, deployutil.ConfigSelector(config.Name), deployutil.DeploymentConfigControllerRefKind, canAdoptFunc) + cm := NewRCControllerRefManager(c.rcControl, config, appsutil.ConfigSelector(config.Name), appsutil.DeploymentConfigControllerRefKind, canAdoptFunc) existingDeployments, err := cm.ClaimReplicationControllers(rcList) if err != nil { return fmt.Errorf("error while deploymentConfigController claiming replication controllers: %v", err) @@ -121,7 +121,7 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) return c.updateStatus(config, existingDeployments) } - latestIsDeployed, latestDeployment := deployutil.LatestDeploymentInfo(config, existingDeployments) + latestIsDeployed, latestDeployment := appsutil.LatestDeploymentInfo(config, existingDeployments) if !latestIsDeployed { if err := c.cancelRunningRollouts(config, existingDeployments, cm); err != nil { @@ -136,7 +136,7 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) return c.updateStatus(configCopy, existingDeployments) } // Have to wait for the image trigger to get the image before proceeding. - if shouldSkip && deployutil.IsInitialDeployment(config) { + if shouldSkip && appsutil.IsInitialDeployment(config) { return c.updateStatus(configCopy, existingDeployments) } // If the latest deployment already exists, reconcile existing deployments @@ -144,7 +144,7 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) if latestIsDeployed { // If the latest deployment is still running, try again later. We don't // want to compete with the deployer. - if !deployutil.IsTerminatedDeployment(latestDeployment) { + if !appsutil.IsTerminatedDeployment(latestDeployment) { return c.updateStatus(config, existingDeployments) } @@ -155,7 +155,7 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) if latestIsDeployed { // If the latest deployment is still running, try again later. We don't // want to compete with the deployer. - if !deployutil.IsTerminatedDeployment(latestDeployment) { + if !appsutil.IsTerminatedDeployment(latestDeployment) { return c.updateStatus(config, existingDeployments) } @@ -173,9 +173,9 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) } // No deployments are running and the latest deployment doesn't exist, so // create the new deployment. - deployment, err := deployutil.MakeDeploymentV1(config, c.codec) + deployment, err := appsutil.MakeDeploymentV1(config, c.codec) if err != nil { - return fatalError(fmt.Sprintf("couldn't make deployment from (potentially invalid) deployment config %s: %v", deployutil.LabelForDeploymentConfig(config), err)) + return fatalError(fmt.Sprintf("couldn't make deployment from (potentially invalid) deployment config %s: %v", appsutil.LabelForDeploymentConfig(config), err)) } created, err := c.rn.ReplicationControllers(config.Namespace).Create(deployment) if err != nil { @@ -202,9 +202,9 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) } c.recorder.Eventf(config, v1.EventTypeWarning, "DeploymentCreationFailed", "Couldn't deploy version %d: %s", config.Status.LatestVersion, err) // We don't care about this error since we need to report the create failure. - cond := deployutil.NewDeploymentCondition(deployapi.DeploymentProgressing, kapi.ConditionFalse, deployapi.FailedRcCreateReason, err.Error()) + cond := appsutil.NewDeploymentCondition(appsapi.DeploymentProgressing, kapi.ConditionFalse, appsapi.FailedRcCreateReason, err.Error()) _ = c.updateStatus(config, existingDeployments, *cond) - return fmt.Errorf("couldn't create deployment for deployment config %s: %v", deployutil.LabelForDeploymentConfig(config), err) + return fmt.Errorf("couldn't create deployment for deployment config %s: %v", appsutil.LabelForDeploymentConfig(config), err) } msg := fmt.Sprintf("Created new replication controller %q for version %d", created.Name, config.Status.LatestVersion) c.recorder.Eventf(config, v1.EventTypeNormal, "DeploymentCreated", msg) @@ -216,7 +216,7 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) c.recorder.Eventf(config, v1.EventTypeWarning, "DeploymentCleanupFailed", "Couldn't clean up deployments: %v", err) } - cond := deployutil.NewDeploymentCondition(deployapi.DeploymentProgressing, kapi.ConditionTrue, deployapi.NewReplicationControllerReason, msg) + cond := appsutil.NewDeploymentCondition(appsapi.DeploymentProgressing, kapi.ConditionTrue, appsapi.NewReplicationControllerReason, msg) return c.updateStatus(config, existingDeployments, *cond) } @@ -226,8 +226,8 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) // successful deployment, not necessarily the latest in terms of the config // version. The active deployment replica count should follow the config, and // all other deployments should be scaled to zero. -func (c *DeploymentConfigController) reconcileDeployments(existingDeployments []*v1.ReplicationController, config *deployapi.DeploymentConfig, cm *RCControllerRefManager) error { - activeDeployment := deployutil.ActiveDeploymentV1(existingDeployments) +func (c *DeploymentConfigController) reconcileDeployments(existingDeployments []*v1.ReplicationController, config *appsapi.DeploymentConfig, cm *RCControllerRefManager) error { + activeDeployment := appsutil.ActiveDeploymentV1(existingDeployments) // Reconcile deployments. The active deployment follows the config, and all // other deployments should be scaled to zero. @@ -248,7 +248,7 @@ func (c *DeploymentConfigController) reconcileDeployments(existingDeployments [] newReplicaCount = config.Spec.Replicas } if config.Spec.Test { - glog.V(4).Infof("Deployment config %q is test and deployment %q will be scaled down", deployutil.LabelForDeploymentConfig(config), deployutil.LabelForDeploymentV1(deployment)) + glog.V(4).Infof("Deployment config %q is test and deployment %q will be scaled down", appsutil.LabelForDeploymentConfig(config), appsutil.LabelForDeploymentV1(deployment)) newReplicaCount = 0 } @@ -301,7 +301,7 @@ func (c *DeploymentConfigController) reconcileDeployments(existingDeployments [] // Update the status of the provided deployment config. Additional conditions will override any other condition in the // deployment config status. -func (c *DeploymentConfigController) updateStatus(config *deployapi.DeploymentConfig, deployments []*v1.ReplicationController, additional ...deployapi.DeploymentCondition) error { +func (c *DeploymentConfigController) updateStatus(config *appsapi.DeploymentConfig, deployments []*v1.ReplicationController, additional ...appsapi.DeploymentCondition) error { newStatus := calculateStatus(config, deployments, additional...) // NOTE: We should update the status of the deployment config only if we need to, otherwise @@ -316,7 +316,7 @@ func (c *DeploymentConfigController) updateStatus(config *deployapi.DeploymentCo if _, err := c.dn.DeploymentConfigs(copied.Namespace).UpdateStatus(copied); err != nil { return err } - glog.V(4).Infof(fmt.Sprintf("Updated status for DeploymentConfig: %s, ", deployutil.LabelForDeploymentConfig(config)) + + glog.V(4).Infof(fmt.Sprintf("Updated status for DeploymentConfig: %s, ", appsutil.LabelForDeploymentConfig(config)) + fmt.Sprintf("replicas %d->%d (need %d), ", config.Status.Replicas, newStatus.Replicas, config.Spec.Replicas) + fmt.Sprintf("readyReplicas %d->%d, ", config.Status.ReadyReplicas, newStatus.ReadyReplicas) + fmt.Sprintf("availableReplicas %d->%d, ", config.Status.AvailableReplicas, newStatus.AvailableReplicas) + @@ -327,17 +327,17 @@ func (c *DeploymentConfigController) updateStatus(config *deployapi.DeploymentCo // cancelRunningRollouts cancels existing rollouts when the latest deployment does not // exists yet to allow new rollout superceded by the new config version. -func (c *DeploymentConfigController) cancelRunningRollouts(config *deployapi.DeploymentConfig, existingDeployments []*v1.ReplicationController, cm *RCControllerRefManager) error { +func (c *DeploymentConfigController) cancelRunningRollouts(config *appsapi.DeploymentConfig, existingDeployments []*v1.ReplicationController, cm *RCControllerRefManager) error { awaitingCancellations := false for i := range existingDeployments { deployment := existingDeployments[i] // Skip deployments with an outcome. - if deployutil.IsTerminatedDeployment(deployment) { + if appsutil.IsTerminatedDeployment(deployment) { continue } // Cancel running deployments. awaitingCancellations = true - if deployutil.IsDeploymentCancelled(deployment) { + if appsutil.IsDeploymentCancelled(deployment) { continue } @@ -361,8 +361,8 @@ func (c *DeploymentConfigController) cancelRunningRollouts(config *deployapi.Dep } copied := rc.DeepCopy() - copied.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue - copied.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledNewerDeploymentExists + copied.Annotations[appsapi.DeploymentCancelledAnnotation] = appsapi.DeploymentCancelledAnnotationValue + copied.Annotations[appsapi.DeploymentStatusReasonAnnotation] = appsapi.DeploymentCancelledNewerDeploymentExists updatedDeployment, err = c.rn.ReplicationControllers(copied.Namespace).Update(copied) return err }) @@ -381,90 +381,90 @@ func (c *DeploymentConfigController) cancelRunningRollouts(config *deployapi.Dep // deployment to avoid competing with existing deployment processes. if awaitingCancellations { c.recorder.Eventf(config, v1.EventTypeNormal, "DeploymentAwaitingCancellation", "Deployment of version %d awaiting cancellation of older running deployments", config.Status.LatestVersion) - return fmt.Errorf("found previous inflight deployment for %s - requeuing", deployutil.LabelForDeploymentConfig(config)) + return fmt.Errorf("found previous inflight deployment for %s - requeuing", appsutil.LabelForDeploymentConfig(config)) } return nil } -func calculateStatus(config *deployapi.DeploymentConfig, rcs []*v1.ReplicationController, additional ...deployapi.DeploymentCondition) deployapi.DeploymentConfigStatus { +func calculateStatus(config *appsapi.DeploymentConfig, rcs []*v1.ReplicationController, additional ...appsapi.DeploymentCondition) appsapi.DeploymentConfigStatus { // UpdatedReplicas represents the replicas that use the current deployment config template which means // we should inform about the replicas of the latest deployment and not the active. latestReplicas := int32(0) - latestExists, latestRC := deployutil.LatestDeploymentInfo(config, rcs) + latestExists, latestRC := appsutil.LatestDeploymentInfo(config, rcs) if !latestExists { latestRC = nil } else { - latestReplicas = deployutil.GetStatusReplicaCountForDeployments([]*v1.ReplicationController{latestRC}) + latestReplicas = appsutil.GetStatusReplicaCountForDeployments([]*v1.ReplicationController{latestRC}) } - available := deployutil.GetAvailableReplicaCountForReplicationControllers(rcs) - total := deployutil.GetReplicaCountForDeployments(rcs) + available := appsutil.GetAvailableReplicaCountForReplicationControllers(rcs) + total := appsutil.GetReplicaCountForDeployments(rcs) unavailableReplicas := total - available if unavailableReplicas < 0 { unavailableReplicas = 0 } - status := deployapi.DeploymentConfigStatus{ + status := appsapi.DeploymentConfigStatus{ LatestVersion: config.Status.LatestVersion, Details: config.Status.Details, ObservedGeneration: config.Generation, - Replicas: deployutil.GetStatusReplicaCountForDeployments(rcs), + Replicas: appsutil.GetStatusReplicaCountForDeployments(rcs), UpdatedReplicas: latestReplicas, AvailableReplicas: available, - ReadyReplicas: deployutil.GetReadyReplicaCountForReplicationControllers(rcs), + ReadyReplicas: appsutil.GetReadyReplicaCountForReplicationControllers(rcs), UnavailableReplicas: unavailableReplicas, Conditions: config.Status.Conditions, } updateConditions(config, &status, latestRC) for _, cond := range additional { - deployutil.SetDeploymentCondition(&status, cond) + appsutil.SetDeploymentCondition(&status, cond) } return status } -func updateConditions(config *deployapi.DeploymentConfig, newStatus *deployapi.DeploymentConfigStatus, latestRC *v1.ReplicationController) { +func updateConditions(config *appsapi.DeploymentConfig, newStatus *appsapi.DeploymentConfigStatus, latestRC *v1.ReplicationController) { // Availability condition. - if newStatus.AvailableReplicas >= config.Spec.Replicas-deployutil.MaxUnavailable(config) && newStatus.AvailableReplicas > 0 { - minAvailability := deployutil.NewDeploymentCondition(deployapi.DeploymentAvailable, kapi.ConditionTrue, "", "Deployment config has minimum availability.") - deployutil.SetDeploymentCondition(newStatus, *minAvailability) + if newStatus.AvailableReplicas >= config.Spec.Replicas-appsutil.MaxUnavailable(config) && newStatus.AvailableReplicas > 0 { + minAvailability := appsutil.NewDeploymentCondition(appsapi.DeploymentAvailable, kapi.ConditionTrue, "", "Deployment config has minimum availability.") + appsutil.SetDeploymentCondition(newStatus, *minAvailability) } else { - noMinAvailability := deployutil.NewDeploymentCondition(deployapi.DeploymentAvailable, kapi.ConditionFalse, "", "Deployment config does not have minimum availability.") - deployutil.SetDeploymentCondition(newStatus, *noMinAvailability) + noMinAvailability := appsutil.NewDeploymentCondition(appsapi.DeploymentAvailable, kapi.ConditionFalse, "", "Deployment config does not have minimum availability.") + appsutil.SetDeploymentCondition(newStatus, *noMinAvailability) } // Condition about progress. if latestRC != nil { - switch deployutil.DeploymentStatusFor(latestRC) { - case deployapi.DeploymentStatusPending: - msg := fmt.Sprintf("replication controller %q is waiting for pod %q to run", latestRC.Name, deployutil.DeployerPodNameForDeployment(latestRC.Name)) - condition := deployutil.NewDeploymentCondition(deployapi.DeploymentProgressing, kapi.ConditionUnknown, "", msg) - deployutil.SetDeploymentCondition(newStatus, *condition) - case deployapi.DeploymentStatusRunning: - if deployutil.IsProgressing(config, newStatus) { - deployutil.RemoveDeploymentCondition(newStatus, deployapi.DeploymentProgressing) + switch appsutil.DeploymentStatusFor(latestRC) { + case appsapi.DeploymentStatusPending: + msg := fmt.Sprintf("replication controller %q is waiting for pod %q to run", latestRC.Name, appsutil.DeployerPodNameForDeployment(latestRC.Name)) + condition := appsutil.NewDeploymentCondition(appsapi.DeploymentProgressing, kapi.ConditionUnknown, "", msg) + appsutil.SetDeploymentCondition(newStatus, *condition) + case appsapi.DeploymentStatusRunning: + if appsutil.IsProgressing(config, newStatus) { + appsutil.RemoveDeploymentCondition(newStatus, appsapi.DeploymentProgressing) msg := fmt.Sprintf("replication controller %q is progressing", latestRC.Name) - condition := deployutil.NewDeploymentCondition(deployapi.DeploymentProgressing, kapi.ConditionTrue, deployapi.ReplicationControllerUpdatedReason, msg) + condition := appsutil.NewDeploymentCondition(appsapi.DeploymentProgressing, kapi.ConditionTrue, appsapi.ReplicationControllerUpdatedReason, msg) // TODO: Right now, we use lastTransitionTime for storing the last time we had any progress instead // of the last time the condition transitioned to a new status. We should probably change that. - deployutil.SetDeploymentCondition(newStatus, *condition) + appsutil.SetDeploymentCondition(newStatus, *condition) } - case deployapi.DeploymentStatusFailed: - var condition *deployapi.DeploymentCondition - if deployutil.IsDeploymentCancelled(latestRC) { + case appsapi.DeploymentStatusFailed: + var condition *appsapi.DeploymentCondition + if appsutil.IsDeploymentCancelled(latestRC) { msg := fmt.Sprintf("rollout of replication controller %q was cancelled", latestRC.Name) - condition = deployutil.NewDeploymentCondition(deployapi.DeploymentProgressing, kapi.ConditionFalse, deployapi.CancelledRolloutReason, msg) + condition = appsutil.NewDeploymentCondition(appsapi.DeploymentProgressing, kapi.ConditionFalse, appsapi.CancelledRolloutReason, msg) } else { msg := fmt.Sprintf("replication controller %q has failed progressing", latestRC.Name) - condition = deployutil.NewDeploymentCondition(deployapi.DeploymentProgressing, kapi.ConditionFalse, deployapi.TimedOutReason, msg) + condition = appsutil.NewDeploymentCondition(appsapi.DeploymentProgressing, kapi.ConditionFalse, appsapi.TimedOutReason, msg) } - deployutil.SetDeploymentCondition(newStatus, *condition) - case deployapi.DeploymentStatusComplete: + appsutil.SetDeploymentCondition(newStatus, *condition) + case appsapi.DeploymentStatusComplete: msg := fmt.Sprintf("replication controller %q successfully rolled out", latestRC.Name) - condition := deployutil.NewDeploymentCondition(deployapi.DeploymentProgressing, kapi.ConditionTrue, deployapi.NewRcAvailableReason, msg) - deployutil.SetDeploymentCondition(newStatus, *condition) + condition := appsutil.NewDeploymentCondition(appsapi.DeploymentProgressing, kapi.ConditionTrue, appsapi.NewRcAvailableReason, msg) + appsutil.SetDeploymentCondition(newStatus, *condition) } } } @@ -493,13 +493,13 @@ func (c *DeploymentConfigController) handleErr(err error, key interface{}) { } // cleanupOldDeployments deletes old replication controller deployments if their quota has been reached -func (c *DeploymentConfigController) cleanupOldDeployments(existingDeployments []*v1.ReplicationController, deploymentConfig *deployapi.DeploymentConfig) error { +func (c *DeploymentConfigController) cleanupOldDeployments(existingDeployments []*v1.ReplicationController, deploymentConfig *appsapi.DeploymentConfig) error { if deploymentConfig.Spec.RevisionHistoryLimit == nil { // there is no past deplyoment quota set return nil } - prunableDeployments := deployutil.DeploymentsForCleanup(deploymentConfig, existingDeployments) + prunableDeployments := appsutil.DeploymentsForCleanup(deploymentConfig, existingDeployments) if len(prunableDeployments) <= int(*deploymentConfig.Spec.RevisionHistoryLimit) { // the past deployment quota has not been exceeded return nil @@ -530,12 +530,12 @@ func (c *DeploymentConfigController) cleanupOldDeployments(existingDeployments [ // triggers were activated (config change or image change). The first bool indicates that // the triggers are active and second indicates if we should skip the rollout because we // are waiting for the trigger to complete update (waiting for image for example). -func triggerActivated(config *deployapi.DeploymentConfig, latestIsDeployed bool, latestDeployment *v1.ReplicationController, codec runtime.Codec) (bool, bool) { +func triggerActivated(config *appsapi.DeploymentConfig, latestIsDeployed bool, latestDeployment *v1.ReplicationController, codec runtime.Codec) (bool, bool) { if config.Spec.Paused { return false, false } - imageTrigger := deployutil.HasImageChangeTrigger(config) - configTrigger := deployutil.HasChangeTrigger(config) + imageTrigger := appsutil.HasImageChangeTrigger(config) + configTrigger := appsutil.HasChangeTrigger(config) hasTrigger := imageTrigger || configTrigger // no-op when no triggers are defined. @@ -544,15 +544,15 @@ func triggerActivated(config *deployapi.DeploymentConfig, latestIsDeployed bool, } // Handle initial rollouts - if deployutil.IsInitialDeployment(config) { - hasAvailableImages := deployutil.HasLastTriggeredImage(config) + if appsutil.IsInitialDeployment(config) { + hasAvailableImages := appsutil.HasLastTriggeredImage(config) // When config has an image trigger, wait until its images are available to trigger. if imageTrigger { if hasAvailableImages { glog.V(4).Infof("Rolling out initial deployment for %s/%s as it now have images available", config.Namespace, config.Name) // TODO: Technically this is not a config change cause, but we will have to report the image that caused the trigger. // In some cases it might be difficult because config can have multiple ICT. - deployutil.RecordConfigChangeCause(config) + appsutil.RecordConfigChangeCause(config) return true, false } glog.V(4).Infof("Rolling out initial deployment for %s/%s deferred until its images are ready", config.Namespace, config.Name) @@ -561,7 +561,7 @@ func triggerActivated(config *deployapi.DeploymentConfig, latestIsDeployed bool, // Rollout if we only have config change trigger. if configTrigger { glog.V(4).Infof("Rolling out initial deployment for %s/%s", config.Namespace, config.Name) - deployutil.RecordConfigChangeCause(config) + appsutil.RecordConfigChangeCause(config) return true, false } // We are waiting for the initial RC to be created. @@ -579,22 +579,22 @@ func triggerActivated(config *deployapi.DeploymentConfig, latestIsDeployed bool, } if imageTrigger { - if ok, imageNames := deployutil.HasUpdatedImages(config, latestDeployment); ok { + if ok, imageNames := appsutil.HasUpdatedImages(config, latestDeployment); ok { glog.V(4).Infof("Rolling out #%d deployment for %s/%s caused by image changes (%s)", config.Status.LatestVersion+1, config.Namespace, config.Name, strings.Join(imageNames, ",")) - deployutil.RecordImageChangeCauses(config, imageNames) + appsutil.RecordImageChangeCauses(config, imageNames) return true, false } } if configTrigger { - isLatest, changes, err := deployutil.HasLatestPodTemplate(config, latestDeployment, codec) + isLatest, changes, err := appsutil.HasLatestPodTemplate(config, latestDeployment, codec) if err != nil { glog.Errorf("Error while checking for latest pod template in replication controller: %v", err) return false, true } if !isLatest { glog.V(4).Infof("Rolling out #%d deployment for %s/%s caused by config change, diff: %s", config.Status.LatestVersion+1, config.Namespace, config.Name, changes) - deployutil.RecordConfigChangeCause(config) + appsutil.RecordConfigChangeCause(config) return true, false } } diff --git a/pkg/apps/controller/deploymentconfig/deploymentconfig_controller_test.go b/pkg/apps/controller/deploymentconfig/deploymentconfig_controller_test.go index 96bd5d50c2bb..2110ae8959db 100644 --- a/pkg/apps/controller/deploymentconfig/deploymentconfig_controller_test.go +++ b/pkg/apps/controller/deploymentconfig/deploymentconfig_controller_test.go @@ -20,13 +20,13 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kapihelper "k8s.io/kubernetes/pkg/api/helper" - deployv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" _ "github.com/openshift/origin/pkg/apps/apis/apps/install" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" appsfake "github.com/openshift/origin/pkg/apps/generated/internalclientset/fake" "github.com/openshift/origin/pkg/apps/generated/listers/apps/internalversion" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" ) func alwaysReady() bool { return true } @@ -42,26 +42,26 @@ func TestHandleScenarios(t *testing.T) { // replicasA is the annotated replica value for backwards compat checks replicasA *int32 desiredA *int32 - status deployapi.DeploymentStatus + status appsapi.DeploymentStatus cancelled bool } mkdeployment := func(d deployment) *v1.ReplicationController { - config := deploytest.OkDeploymentConfig(d.version) + config := appstest.OkDeploymentConfig(d.version) if d.test { - config = deploytest.TestDeploymentConfig(config) + config = appstest.TestDeploymentConfig(config) } config.Namespace = "test" - deployment, _ := deployutil.MakeDeploymentV1(config, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(d.status) + deployment, _ := appsutil.MakeDeploymentV1(config, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(d.status) if d.cancelled { - deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue - deployment.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledNewerDeploymentExists + deployment.Annotations[appsapi.DeploymentCancelledAnnotation] = appsapi.DeploymentCancelledAnnotationValue + deployment.Annotations[appsapi.DeploymentStatusReasonAnnotation] = appsapi.DeploymentCancelledNewerDeploymentExists } if d.desiredA != nil { - deployment.Annotations[deployapi.DesiredReplicasAnnotation] = strconv.Itoa(int(*d.desiredA)) + deployment.Annotations[appsapi.DesiredReplicasAnnotation] = strconv.Itoa(int(*d.desiredA)) } else { - delete(deployment.Annotations, deployapi.DesiredReplicasAnnotation) + delete(deployment.Annotations, appsapi.DesiredReplicasAnnotation) } deployment.Spec.Replicas = &d.replicas return deployment @@ -100,7 +100,7 @@ func TestHandleScenarios(t *testing.T) { expectedReplicas: 1, before: []deployment{}, after: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusNew, cancelled: false}, + {version: 1, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusNew, cancelled: false}, }, errExpected: false, }, @@ -110,10 +110,10 @@ func TestHandleScenarios(t *testing.T) { newVersion: 1, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusNew, cancelled: false}, + {version: 1, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusNew, cancelled: false}, }, after: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusNew, cancelled: false}, + {version: 1, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusNew, cancelled: false}, }, errExpected: false, }, @@ -123,11 +123,11 @@ func TestHandleScenarios(t *testing.T) { newVersion: 2, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, + {version: 1, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, }, after: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusNew, cancelled: false}, + {version: 1, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusNew, cancelled: false}, }, errExpected: false, }, @@ -137,12 +137,12 @@ func TestHandleScenarios(t *testing.T) { newVersion: 2, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusNew, cancelled: false}, + {version: 1, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusNew, cancelled: false}, }, after: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusNew, cancelled: false}, + {version: 1, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusNew, cancelled: false}, }, errExpected: false, }, @@ -152,10 +152,10 @@ func TestHandleScenarios(t *testing.T) { newVersion: 1, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, + {version: 1, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, }, after: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, + {version: 1, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, }, errExpected: false, }, @@ -165,12 +165,12 @@ func TestHandleScenarios(t *testing.T) { newVersion: 3, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(1), desiredA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusRunning, cancelled: false}, + {version: 1, replicas: 1, replicasA: newInt32(1), desiredA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusRunning, cancelled: false}, }, after: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(1), desiredA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusRunning, cancelled: true}, + {version: 1, replicas: 1, replicasA: newInt32(1), desiredA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusRunning, cancelled: true}, }, errExpected: true, }, @@ -180,10 +180,10 @@ func TestHandleScenarios(t *testing.T) { newVersion: 2, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusRunning, cancelled: true}, + {version: 1, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusRunning, cancelled: true}, }, after: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusRunning, cancelled: true}, + {version: 1, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusRunning, cancelled: true}, }, errExpected: true, }, @@ -193,18 +193,18 @@ func TestHandleScenarios(t *testing.T) { newVersion: 5, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 3, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true}, - {version: 4, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false}, - {version: 5, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, + {version: 1, replicas: 0, replicasA: newInt32(0), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 3, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: true}, + {version: 4, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: false}, + {version: 5, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, }, after: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 3, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true}, - {version: 4, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false}, - {version: 5, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, + {version: 1, replicas: 0, replicasA: newInt32(0), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 3, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: true}, + {version: 4, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: false}, + {version: 5, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, }, errExpected: false, }, @@ -214,18 +214,18 @@ func TestHandleScenarios(t *testing.T) { newVersion: 5, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 3, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true}, - {version: 4, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 5, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false}, + {version: 1, replicas: 0, replicasA: newInt32(0), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 3, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: true}, + {version: 4, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 5, replicas: 1, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: false}, }, after: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 3, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true}, - {version: 4, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 5, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false}, + {version: 1, replicas: 0, replicasA: newInt32(0), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 3, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: true}, + {version: 4, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 5, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: false}, }, errExpected: false, }, @@ -235,12 +235,12 @@ func TestHandleScenarios(t *testing.T) { newVersion: 2, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false}, + {version: 1, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: false}, }, after: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: false}, + {version: 1, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: false}, }, errExpected: false, }, @@ -250,12 +250,12 @@ func TestHandleScenarios(t *testing.T) { newVersion: 2, expectedReplicas: 5, before: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, + {version: 1, replicas: 0, replicasA: newInt32(0), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, }, after: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 5, replicasA: newInt32(5), status: deployapi.DeploymentStatusComplete, cancelled: false}, + {version: 1, replicas: 0, replicasA: newInt32(0), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 5, replicasA: newInt32(5), status: appsapi.DeploymentStatusComplete, cancelled: false}, }, errExpected: false, }, @@ -265,12 +265,12 @@ func TestHandleScenarios(t *testing.T) { newVersion: 2, expectedReplicas: 5, before: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true}, + {version: 1, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: true}, }, after: []deployment{ - {version: 1, replicas: 5, replicasA: newInt32(5), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true}, + {version: 1, replicas: 5, replicasA: newInt32(5), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: true}, }, errExpected: false, }, @@ -280,12 +280,12 @@ func TestHandleScenarios(t *testing.T) { newVersion: 2, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 5, replicasA: newInt32(5), status: deployapi.DeploymentStatusComplete, cancelled: false}, + {version: 1, replicas: 0, replicasA: newInt32(0), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 5, replicasA: newInt32(5), status: appsapi.DeploymentStatusComplete, cancelled: false}, }, after: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(0), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, + {version: 1, replicas: 0, replicasA: newInt32(0), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, }, errExpected: false, }, @@ -295,12 +295,12 @@ func TestHandleScenarios(t *testing.T) { newVersion: 2, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 5, replicasA: newInt32(5), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true}, + {version: 1, replicas: 5, replicasA: newInt32(5), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: true}, }, after: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true}, + {version: 1, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: true}, }, errExpected: false, }, @@ -310,12 +310,12 @@ func TestHandleScenarios(t *testing.T) { newVersion: 2, expectedReplicas: 1, before: []deployment{ - {version: 1, replicas: 0, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true}, + {version: 1, replicas: 0, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: true}, }, after: []deployment{ - {version: 1, replicas: 1, replicasA: newInt32(1), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: deployapi.DeploymentStatusFailed, cancelled: true}, + {version: 1, replicas: 1, replicasA: newInt32(1), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(1), status: appsapi.DeploymentStatusFailed, cancelled: true}, }, errExpected: false, }, @@ -325,12 +325,12 @@ func TestHandleScenarios(t *testing.T) { newVersion: 2, expectedReplicas: 5, before: []deployment{ - {version: 1, replicas: 2, replicasA: newInt32(5), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 2, replicasA: newInt32(0), desiredA: newInt32(5), status: deployapi.DeploymentStatusFailed, cancelled: true}, + {version: 1, replicas: 2, replicasA: newInt32(5), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 2, replicasA: newInt32(0), desiredA: newInt32(5), status: appsapi.DeploymentStatusFailed, cancelled: true}, }, after: []deployment{ - {version: 1, replicas: 5, replicasA: newInt32(5), status: deployapi.DeploymentStatusComplete, cancelled: false}, - {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(5), status: deployapi.DeploymentStatusFailed, cancelled: true}, + {version: 1, replicas: 5, replicasA: newInt32(5), status: appsapi.DeploymentStatusComplete, cancelled: false}, + {version: 2, replicas: 0, replicasA: newInt32(0), desiredA: newInt32(5), status: appsapi.DeploymentStatusFailed, cancelled: true}, }, errExpected: false, }, @@ -339,7 +339,7 @@ func TestHandleScenarios(t *testing.T) { for _, test := range tests { t.Logf("evaluating test: %s", test.name) - var updatedConfig *deployapi.DeploymentConfig + var updatedConfig *appsapi.DeploymentConfig deployments := map[string]*v1.ReplicationController{} toStore := []*v1.ReplicationController{} for _, template := range test.before { @@ -350,7 +350,7 @@ func TestHandleScenarios(t *testing.T) { oc := &appsfake.Clientset{} oc.AddReactor("update", "deploymentconfigs", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - dc := action.(clientgotesting.UpdateAction).GetObject().(*deployapi.DeploymentConfig) + dc := action.(clientgotesting.UpdateAction).GetObject().(*appsapi.DeploymentConfig) updatedConfig = dc return true, dc, nil }) @@ -365,7 +365,7 @@ func TestHandleScenarios(t *testing.T) { deployments[rc.Name] = rc return true, rc, nil }) - codec := kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion) + codec := kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion) dcInformer := &fakeDeploymentConfigInformer{ informer: cache.NewSharedIndexInformer( @@ -377,7 +377,7 @@ func TestHandleScenarios(t *testing.T) { return oc.Apps().DeploymentConfigs(metav1.NamespaceAll).Watch(options) }, }, - &deployapi.DeploymentConfig{}, + &appsapi.DeploymentConfig{}, 2*time.Minute, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, ), @@ -393,9 +393,9 @@ func TestHandleScenarios(t *testing.T) { rcInformer.Informer().GetStore().Add(toStore[i]) } - config := deploytest.OkDeploymentConfig(test.newVersion) + config := appstest.OkDeploymentConfig(test.newVersion) if test.test { - config = deploytest.TestDeploymentConfig(config) + config = appstest.TestDeploymentConfig(config) } config.Spec.Replicas = test.replicas config.Namespace = "test" @@ -413,8 +413,8 @@ func TestHandleScenarios(t *testing.T) { for _, deployment := range deployments { actualDeployments = append(actualDeployments, deployment) } - sort.Sort(deployutil.ByLatestVersionDescV1(expectedDeployments)) - sort.Sort(deployutil.ByLatestVersionDescV1(actualDeployments)) + sort.Sort(appsutil.ByLatestVersionDescV1(expectedDeployments)) + sort.Sort(appsutil.ByLatestVersionDescV1(actualDeployments)) if updatedConfig != nil { config = updatedConfig @@ -449,21 +449,21 @@ func newInt32(i int32) *int32 { return &i } -func newDC(version, replicas, maxUnavailable int, cond deployapi.DeploymentCondition) *deployapi.DeploymentConfig { - return &deployapi.DeploymentConfig{ - Spec: deployapi.DeploymentConfigSpec{ +func newDC(version, replicas, maxUnavailable int, cond appsapi.DeploymentCondition) *appsapi.DeploymentConfig { + return &appsapi.DeploymentConfig{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: int32(replicas), - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRolling, - RollingParams: &deployapi.RollingDeploymentStrategyParams{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRolling, + RollingParams: &appsapi.RollingDeploymentStrategyParams{ MaxUnavailable: intstr.FromInt(maxUnavailable), MaxSurge: intstr.FromInt(1), }, }, }, - Status: deployapi.DeploymentConfigStatus{ + Status: appsapi.DeploymentConfigStatus{ LatestVersion: int64(version), - Conditions: []deployapi.DeploymentCondition{ + Conditions: []appsapi.DeploymentCondition{ cond, }, }, @@ -471,12 +471,12 @@ func newDC(version, replicas, maxUnavailable int, cond deployapi.DeploymentCondi } var ( - availableCond = deployapi.DeploymentCondition{ - Type: deployapi.DeploymentAvailable, + availableCond = appsapi.DeploymentCondition{ + Type: appsapi.DeploymentAvailable, Status: kapi.ConditionTrue, } - unavailableCond = deployapi.DeploymentCondition{ - Type: deployapi.DeploymentAvailable, + unavailableCond = appsapi.DeploymentCondition{ + Type: appsapi.DeploymentAvailable, Status: kapi.ConditionFalse, } ) @@ -484,7 +484,7 @@ var ( func newRC(version, desired, current, ready, available int32) *v1.ReplicationController { return &v1.ReplicationController{ ObjectMeta: metav1.ObjectMeta{ - Annotations: map[string]string{deployapi.DeploymentVersionAnnotation: strconv.Itoa(int(version))}, + Annotations: map[string]string{appsapi.DeploymentVersionAnnotation: strconv.Itoa(int(version))}, }, Spec: v1.ReplicationControllerSpec{ Replicas: &desired, @@ -501,10 +501,10 @@ func TestCalculateStatus(t *testing.T) { tests := []struct { name string - dc *deployapi.DeploymentConfig + dc *appsapi.DeploymentConfig rcs []*v1.ReplicationController - expected deployapi.DeploymentConfigStatus + expected appsapi.DeploymentConfigStatus }{ { name: "available deployment", @@ -516,13 +516,13 @@ func TestCalculateStatus(t *testing.T) { newRC(1, 0, 1, 1, 1), }, - expected: deployapi.DeploymentConfigStatus{ + expected: appsapi.DeploymentConfigStatus{ LatestVersion: int64(3), Replicas: int32(3), ReadyReplicas: int32(2), AvailableReplicas: int32(2), UpdatedReplicas: int32(2), - Conditions: []deployapi.DeploymentCondition{ + Conditions: []appsapi.DeploymentCondition{ availableCond, }, }, @@ -536,14 +536,14 @@ func TestCalculateStatus(t *testing.T) { newRC(1, 0, 1, 1, 1), }, - expected: deployapi.DeploymentConfigStatus{ + expected: appsapi.DeploymentConfigStatus{ LatestVersion: int64(2), Replicas: int32(1), ReadyReplicas: int32(1), AvailableReplicas: int32(1), UpdatedReplicas: int32(0), UnavailableReplicas: int32(1), - Conditions: []deployapi.DeploymentCondition{ + Conditions: []appsapi.DeploymentCondition{ unavailableCond, }, }, diff --git a/pkg/apps/controller/deploymentconfig/factory.go b/pkg/apps/controller/deploymentconfig/factory.go index 76256944dc6b..115d073b4986 100644 --- a/pkg/apps/controller/deploymentconfig/factory.go +++ b/pkg/apps/controller/deploymentconfig/factory.go @@ -19,7 +19,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kcontroller "k8s.io/kubernetes/pkg/controller" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsinformer "github.com/openshift/origin/pkg/apps/generated/informers/internalversion/apps/internalversion" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset" metrics "github.com/openshift/origin/pkg/apps/metrics/prometheus" @@ -97,15 +97,15 @@ func (c *DeploymentConfigController) Run(workers int, stopCh <-chan struct{}) { } func (c *DeploymentConfigController) addDeploymentConfig(obj interface{}) { - dc := obj.(*deployapi.DeploymentConfig) + dc := obj.(*appsapi.DeploymentConfig) glog.V(4).Infof("Adding deployment config %q", dc.Name) c.enqueueDeploymentConfig(dc) } func (c *DeploymentConfigController) updateDeploymentConfig(old, cur interface{}) { // A periodic relist will send update events for all known configs. - newDc := cur.(*deployapi.DeploymentConfig) - oldDc := old.(*deployapi.DeploymentConfig) + newDc := cur.(*appsapi.DeploymentConfig) + oldDc := old.(*appsapi.DeploymentConfig) if newDc.ResourceVersion == oldDc.ResourceVersion { return } @@ -115,14 +115,14 @@ func (c *DeploymentConfigController) updateDeploymentConfig(old, cur interface{} } func (c *DeploymentConfigController) deleteDeploymentConfig(obj interface{}) { - dc, ok := obj.(*deployapi.DeploymentConfig) + dc, ok := obj.(*appsapi.DeploymentConfig) if !ok { tombstone, ok := obj.(cache.DeletedFinalStateUnknown) if !ok { utilruntime.HandleError(fmt.Errorf("Couldn't get object from tombstone %+v", obj)) return } - dc, ok = tombstone.Obj.(*deployapi.DeploymentConfig) + dc, ok = tombstone.Obj.(*appsapi.DeploymentConfig) if !ok { utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a deployment config: %+v", obj)) return @@ -173,7 +173,7 @@ func (c *DeploymentConfigController) deleteReplicationController(obj interface{} } } -func (c *DeploymentConfigController) enqueueDeploymentConfig(dc *deployapi.DeploymentConfig) { +func (c *DeploymentConfigController) enqueueDeploymentConfig(dc *appsapi.DeploymentConfig) { key, err := kcontroller.KeyFunc(dc) if err != nil { utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %v", dc, err)) diff --git a/pkg/apps/controller/test/fake_deployment_config_store.go b/pkg/apps/controller/test/fake_deployment_config_store.go index 750e13db6baf..9816bfbe5f7e 100644 --- a/pkg/apps/controller/test/fake_deployment_config_store.go +++ b/pkg/apps/controller/test/fake_deployment_config_store.go @@ -3,15 +3,15 @@ package test import ( "k8s.io/apimachinery/pkg/util/sets" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) type FakeDeploymentConfigStore struct { - DeploymentConfig *deployapi.DeploymentConfig + DeploymentConfig *appsapi.DeploymentConfig Err error } -func NewFakeDeploymentConfigStore(deployment *deployapi.DeploymentConfig) FakeDeploymentConfigStore { +func NewFakeDeploymentConfigStore(deployment *appsapi.DeploymentConfig) FakeDeploymentConfigStore { return FakeDeploymentConfigStore{DeploymentConfig: deployment} } diff --git a/pkg/apps/graph/analysis/dc.go b/pkg/apps/graph/analysis/dc.go index 97e70a673048..b762dcf4fd3a 100644 --- a/pkg/apps/graph/analysis/dc.go +++ b/pkg/apps/graph/analysis/dc.go @@ -10,8 +10,8 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployedges "github.com/openshift/origin/pkg/apps/graph" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsedges "github.com/openshift/origin/pkg/apps/graph" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" buildedges "github.com/openshift/origin/pkg/build/graph" buildutil "github.com/openshift/origin/pkg/build/util" imageedges "github.com/openshift/origin/pkg/image/graph" @@ -36,8 +36,8 @@ const ( func FindDeploymentConfigTriggerErrors(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker { markers := []osgraph.Marker{} - for _, uncastDcNode := range g.NodesByKind(deploygraph.DeploymentConfigNodeKind) { - dcNode := uncastDcNode.(*deploygraph.DeploymentConfigNode) + for _, uncastDcNode := range g.NodesByKind(appsgraph.DeploymentConfigNodeKind) { + dcNode := uncastDcNode.(*appsgraph.DeploymentConfigNode) marker := ictMarker(g, f, dcNode) if marker != nil { markers = append(markers, *marker) @@ -53,8 +53,8 @@ func FindDeploymentConfigTriggerErrors(g osgraph.Graph, f osgraph.Namer) []osgra // 1. The image stream pointed by the dc trigger doen not exist. // 2. The image stream tag pointed by the dc trigger does not exist and there is no build in // flight that could push to the tag. -func ictMarker(g osgraph.Graph, f osgraph.Namer, dcNode *deploygraph.DeploymentConfigNode) *osgraph.Marker { - for _, uncastIstNode := range g.PredecessorNodesByEdgeKind(dcNode, deployedges.TriggersDeploymentEdgeKind) { +func ictMarker(g osgraph.Graph, f osgraph.Namer, dcNode *appsgraph.DeploymentConfigNode) *osgraph.Marker { + for _, uncastIstNode := range g.PredecessorNodesByEdgeKind(dcNode, appsedges.TriggersDeploymentEdgeKind) { if istNode := uncastIstNode.(*imagegraph.ImageStreamTagNode); !istNode.Found() { // The image stream for the tag of interest does not exist. if isNode, exists := doesImageStreamExist(g, uncastIstNode); !exists { @@ -108,8 +108,8 @@ func FindDeploymentConfigReadinessWarnings(g osgraph.Graph, f osgraph.Namer, set markers := []osgraph.Marker{} Node: - for _, uncastDcNode := range g.NodesByKind(deploygraph.DeploymentConfigNodeKind) { - dcNode := uncastDcNode.(*deploygraph.DeploymentConfigNode) + for _, uncastDcNode := range g.NodesByKind(appsgraph.DeploymentConfigNodeKind) { + dcNode := uncastDcNode.(*appsgraph.DeploymentConfigNode) if t := dcNode.DeploymentConfig.Spec.Template; t != nil && len(t.Spec.Containers) > 0 { for _, container := range t.Spec.Containers { if container.ReadinessProbe != nil { @@ -135,8 +135,8 @@ Node: func FindPersistentVolumeClaimWarnings(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker { markers := []osgraph.Marker{} - for _, uncastDcNode := range g.NodesByKind(deploygraph.DeploymentConfigNodeKind) { - dcNode := uncastDcNode.(*deploygraph.DeploymentConfigNode) + for _, uncastDcNode := range g.NodesByKind(appsgraph.DeploymentConfigNodeKind) { + dcNode := uncastDcNode.(*appsgraph.DeploymentConfigNode) marker := pvcMarker(g, f, dcNode) if marker != nil { markers = append(markers, *marker) @@ -146,8 +146,8 @@ func FindPersistentVolumeClaimWarnings(g osgraph.Graph, f osgraph.Namer) []osgra return markers } -func pvcMarker(g osgraph.Graph, f osgraph.Namer, dcNode *deploygraph.DeploymentConfigNode) *osgraph.Marker { - for _, uncastPvcNode := range g.SuccessorNodesByEdgeKind(dcNode, deployedges.VolumeClaimEdgeKind) { +func pvcMarker(g osgraph.Graph, f osgraph.Namer, dcNode *appsgraph.DeploymentConfigNode) *osgraph.Marker { + for _, uncastPvcNode := range g.SuccessorNodesByEdgeKind(dcNode, appsedges.VolumeClaimEdgeKind) { pvcNode := uncastPvcNode.(*kubegraph.PersistentVolumeClaimNode) if !pvcNode.Found() { diff --git a/pkg/apps/graph/analysis/dc_test.go b/pkg/apps/graph/analysis/dc_test.go index c17a4d7f3809..da22922d95fe 100644 --- a/pkg/apps/graph/analysis/dc_test.go +++ b/pkg/apps/graph/analysis/dc_test.go @@ -5,7 +5,7 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" osgraphtest "github.com/openshift/origin/pkg/api/graph/test" - deployedges "github.com/openshift/origin/pkg/apps/graph" + appsedges "github.com/openshift/origin/pkg/apps/graph" buildedges "github.com/openshift/origin/pkg/build/graph" imageedges "github.com/openshift/origin/pkg/image/graph" ) @@ -16,7 +16,7 @@ func TestMissingImageStreamTag(t *testing.T) { t.Fatalf("unexpected error: %v", err) } buildedges.AddAllInputOutputEdges(g) - deployedges.AddAllTriggerEdges(g) + appsedges.AddAllTriggerEdges(g) imageedges.AddAllImageStreamRefEdges(g) imageedges.AddAllImageStreamImageRefEdges(g) @@ -36,7 +36,7 @@ func TestMissingImageStream(t *testing.T) { t.Fatalf("unexpected error: %v", err) } buildedges.AddAllInputOutputEdges(g) - deployedges.AddAllTriggerEdges(g) + appsedges.AddAllTriggerEdges(g) imageedges.AddAllImageStreamRefEdges(g) imageedges.AddAllImageStreamImageRefEdges(g) @@ -56,7 +56,7 @@ func TestMissingReadinessProbe(t *testing.T) { t.Fatalf("unexpected error: %v", err) } buildedges.AddAllInputOutputEdges(g) - deployedges.AddAllTriggerEdges(g) + appsedges.AddAllTriggerEdges(g) imageedges.AddAllImageStreamRefEdges(g) markers := FindDeploymentConfigReadinessWarnings(g, osgraph.DefaultNamer, "command probe") @@ -74,7 +74,7 @@ func TestSingleHostVolumeError(t *testing.T) { if err != nil { t.Fatalf("unexpected error: %v", err) } - deployedges.AddAllVolumeClaimEdges(g) + appsedges.AddAllVolumeClaimEdges(g) markers := FindPersistentVolumeClaimWarnings(g, osgraph.DefaultNamer) if e, a := 1, len(markers); e != a { diff --git a/pkg/apps/graph/edge_test.go b/pkg/apps/graph/edge_test.go index b0003199ed6f..928e84ab89a3 100644 --- a/pkg/apps/graph/edge_test.go +++ b/pkg/apps/graph/edge_test.go @@ -12,7 +12,7 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" nodes "github.com/openshift/origin/pkg/apps/graph/nodes" ) @@ -24,7 +24,7 @@ func TestNamespaceEdgeMatching(t *testing.T) { g := osgraph.New() fn := func(namespace string, g osgraph.Interface) { - dc := &deployapi.DeploymentConfig{} + dc := &appsapi.DeploymentConfig{} dc.Namespace = namespace dc.Name = "the-dc" dc.Spec.Selector = map[string]string{"a": "1"} @@ -33,7 +33,7 @@ func TestNamespaceEdgeMatching(t *testing.T) { rc := &kapi.ReplicationController{} rc.Namespace = namespace rc.Name = "the-rc" - rc.Annotations = map[string]string{deployapi.DeploymentConfigAnnotation: "the-dc"} + rc.Annotations = map[string]string{appsapi.DeploymentConfigAnnotation: "the-dc"} kubegraph.EnsureReplicationControllerNode(g, rc) } diff --git a/pkg/apps/graph/edges.go b/pkg/apps/graph/edges.go index 6ba502a57523..bd94b0131358 100644 --- a/pkg/apps/graph/edges.go +++ b/pkg/apps/graph/edges.go @@ -9,8 +9,8 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" kubeedges "github.com/openshift/origin/pkg/api/kubegraph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" imageapi "github.com/openshift/origin/pkg/image/apis/image" imagegraph "github.com/openshift/origin/pkg/image/graph/nodes" ) @@ -27,16 +27,16 @@ const ( ) // AddTriggerEdges creates edges that point to named Docker image repositories for each image used in the deployment. -func AddTriggerEdges(g osgraph.MutableUniqueGraph, node *deploygraph.DeploymentConfigNode) *deploygraph.DeploymentConfigNode { +func AddTriggerEdges(g osgraph.MutableUniqueGraph, node *appsgraph.DeploymentConfigNode) *appsgraph.DeploymentConfigNode { podTemplate := node.DeploymentConfig.Spec.Template if podTemplate == nil { return node } - deployapi.EachTemplateImage( + appsapi.EachTemplateImage( &podTemplate.Spec, - deployapi.DeploymentConfigHasTrigger(node.DeploymentConfig), - func(image deployapi.TemplateImage, err error) { + appsapi.DeploymentConfigHasTrigger(node.DeploymentConfig), + func(image appsapi.TemplateImage, err error) { if err != nil { return } @@ -61,13 +61,13 @@ func AddTriggerEdges(g osgraph.MutableUniqueGraph, node *deploygraph.DeploymentC func AddAllTriggerEdges(g osgraph.MutableUniqueGraph) { for _, node := range g.(graph.Graph).Nodes() { - if dcNode, ok := node.(*deploygraph.DeploymentConfigNode); ok { + if dcNode, ok := node.(*appsgraph.DeploymentConfigNode); ok { AddTriggerEdges(g, dcNode) } } } -func AddDeploymentEdges(g osgraph.MutableUniqueGraph, node *deploygraph.DeploymentConfigNode) *deploygraph.DeploymentConfigNode { +func AddDeploymentEdges(g osgraph.MutableUniqueGraph, node *appsgraph.DeploymentConfigNode) *appsgraph.DeploymentConfigNode { for _, n := range g.(graph.Graph).Nodes() { if rcNode, ok := n.(*kubegraph.ReplicationControllerNode); ok { if rcNode.ReplicationController.Namespace != node.DeploymentConfig.Namespace { @@ -85,13 +85,13 @@ func AddDeploymentEdges(g osgraph.MutableUniqueGraph, node *deploygraph.Deployme func AddAllDeploymentEdges(g osgraph.MutableUniqueGraph) { for _, node := range g.(graph.Graph).Nodes() { - if dcNode, ok := node.(*deploygraph.DeploymentConfigNode); ok { + if dcNode, ok := node.(*appsgraph.DeploymentConfigNode); ok { AddDeploymentEdges(g, dcNode) } } } -func AddVolumeClaimEdges(g osgraph.Graph, dcNode *deploygraph.DeploymentConfigNode) { +func AddVolumeClaimEdges(g osgraph.Graph, dcNode *appsgraph.DeploymentConfigNode) { for _, volume := range dcNode.DeploymentConfig.Spec.Template.Spec.Volumes { source := volume.VolumeSource if source.PersistentVolumeClaim == nil { @@ -113,7 +113,7 @@ func AddVolumeClaimEdges(g osgraph.Graph, dcNode *deploygraph.DeploymentConfigNo func AddAllVolumeClaimEdges(g osgraph.Graph) { for _, node := range g.Nodes() { - if dcNode, ok := node.(*deploygraph.DeploymentConfigNode); ok { + if dcNode, ok := node.(*appsgraph.DeploymentConfigNode); ok { AddVolumeClaimEdges(g, dcNode) } } diff --git a/pkg/apps/graph/helpers.go b/pkg/apps/graph/helpers.go index fb47743fe76c..8e4e96059b26 100644 --- a/pkg/apps/graph/helpers.go +++ b/pkg/apps/graph/helpers.go @@ -7,13 +7,13 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsutil "github.com/openshift/origin/pkg/apps/util" ) // RelevantDeployments returns the active deployment and a list of inactive deployments (in order from newest to oldest) -func RelevantDeployments(g osgraph.Graph, dcNode *deploygraph.DeploymentConfigNode) (*kubegraph.ReplicationControllerNode, []*kubegraph.ReplicationControllerNode) { +func RelevantDeployments(g osgraph.Graph, dcNode *appsgraph.DeploymentConfigNode) (*kubegraph.ReplicationControllerNode, []*kubegraph.ReplicationControllerNode) { allDeployments := []*kubegraph.ReplicationControllerNode{} uncastDeployments := g.SuccessorNodesByEdgeKind(dcNode, DeploymentEdgeKind) if len(uncastDeployments) == 0 { @@ -26,16 +26,16 @@ func RelevantDeployments(g osgraph.Graph, dcNode *deploygraph.DeploymentConfigNo sort.Sort(RecentDeploymentReferences(allDeployments)) - if dcNode.DeploymentConfig.Status.LatestVersion == deployutil.DeploymentVersionFor(allDeployments[0].ReplicationController) { + if dcNode.DeploymentConfig.Status.LatestVersion == appsutil.DeploymentVersionFor(allDeployments[0].ReplicationController) { return allDeployments[0], allDeployments[1:] } return nil, allDeployments } -func BelongsToDeploymentConfig(config *deployapi.DeploymentConfig, b *kapi.ReplicationController) bool { +func BelongsToDeploymentConfig(config *appsapi.DeploymentConfig, b *kapi.ReplicationController) bool { if b.Annotations != nil { - return config.Name == deployutil.DeploymentConfigNameFor(b) + return config.Name == appsutil.DeploymentConfigNameFor(b) } return false } @@ -45,5 +45,5 @@ type RecentDeploymentReferences []*kubegraph.ReplicationControllerNode func (m RecentDeploymentReferences) Len() int { return len(m) } func (m RecentDeploymentReferences) Swap(i, j int) { m[i], m[j] = m[j], m[i] } func (m RecentDeploymentReferences) Less(i, j int) bool { - return deployutil.DeploymentVersionFor(m[i].ReplicationController) > deployutil.DeploymentVersionFor(m[j].ReplicationController) + return appsutil.DeploymentVersionFor(m[i].ReplicationController) > appsutil.DeploymentVersionFor(m[j].ReplicationController) } diff --git a/pkg/apps/graph/nodes/nodes.go b/pkg/apps/graph/nodes/nodes.go index 880644704fee..998e80b034ca 100644 --- a/pkg/apps/graph/nodes/nodes.go +++ b/pkg/apps/graph/nodes/nodes.go @@ -7,7 +7,7 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) // EnsureDaemonSetNode adds the provided daemon set to the graph if it does not exist @@ -65,7 +65,7 @@ func FindOrCreateSyntheticDeploymentNode(g osgraph.MutableUniqueGraph, deploymen } // EnsureDeploymentConfigNode adds the provided deployment config to the graph if it does not exist -func EnsureDeploymentConfigNode(g osgraph.MutableUniqueGraph, dc *deployapi.DeploymentConfig) *DeploymentConfigNode { +func EnsureDeploymentConfigNode(g osgraph.MutableUniqueGraph, dc *appsapi.DeploymentConfig) *DeploymentConfigNode { dcName := DeploymentConfigNodeName(dc) dcNode := osgraph.EnsureUnique( g, @@ -83,7 +83,7 @@ func EnsureDeploymentConfigNode(g osgraph.MutableUniqueGraph, dc *deployapi.Depl return dcNode } -func FindOrCreateSyntheticDeploymentConfigNode(g osgraph.MutableUniqueGraph, dc *deployapi.DeploymentConfig) *DeploymentConfigNode { +func FindOrCreateSyntheticDeploymentConfigNode(g osgraph.MutableUniqueGraph, dc *appsapi.DeploymentConfig) *DeploymentConfigNode { return osgraph.EnsureUnique( g, DeploymentConfigNodeName(dc), diff --git a/pkg/apps/graph/nodes/nodes_test.go b/pkg/apps/graph/nodes/nodes_test.go index 8fb8ea8c5dcb..a42a87634193 100644 --- a/pkg/apps/graph/nodes/nodes_test.go +++ b/pkg/apps/graph/nodes/nodes_test.go @@ -7,14 +7,14 @@ import ( osgraph "github.com/openshift/origin/pkg/api/graph" kubetypes "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/apps/apis/apps/test" ) func TestDCPodTemplateSpecNode(t *testing.T) { g := osgraph.New() - dc := &deployapi.DeploymentConfig{} + dc := &appsapi.DeploymentConfig{} dc.Namespace = "ns" dc.Name = "foo" dc.Spec.Template = test.OkPodTemplate() diff --git a/pkg/apps/graph/nodes/types.go b/pkg/apps/graph/nodes/types.go index 580809d9a3cc..c436eb2b0945 100644 --- a/pkg/apps/graph/nodes/types.go +++ b/pkg/apps/graph/nodes/types.go @@ -6,13 +6,13 @@ import ( kapisext "k8s.io/kubernetes/pkg/apis/extensions" osgraph "github.com/openshift/origin/pkg/api/graph" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) var ( DaemonSetNodeKind = reflect.TypeOf(kapisext.DaemonSet{}).Name() DeploymentNodeKind = reflect.TypeOf(kapisext.Deployment{}).Name() - DeploymentConfigNodeKind = reflect.TypeOf(deployapi.DeploymentConfig{}).Name() + DeploymentConfigNodeKind = reflect.TypeOf(appsapi.DeploymentConfig{}).Name() ReplicaSetNodeKind = reflect.TypeOf(kapisext.ReplicaSet{}).Name() ) @@ -70,13 +70,13 @@ func (*DeploymentNode) Kind() string { return DeploymentNodeKind } -func DeploymentConfigNodeName(o *deployapi.DeploymentConfig) osgraph.UniqueName { +func DeploymentConfigNodeName(o *appsapi.DeploymentConfig) osgraph.UniqueName { return osgraph.GetUniqueRuntimeObjectNodeName(DeploymentConfigNodeKind, o) } type DeploymentConfigNode struct { osgraph.Node - DeploymentConfig *deployapi.DeploymentConfig + DeploymentConfig *appsapi.DeploymentConfig IsFound bool } diff --git a/pkg/apps/prune/data.go b/pkg/apps/prune/data.go index 71341642a95d..3a1538405b9c 100644 --- a/pkg/apps/prune/data.go +++ b/pkg/apps/prune/data.go @@ -8,8 +8,8 @@ import ( "k8s.io/client-go/tools/cache" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" ) // DeploymentByDeploymentConfigIndexFunc indexes Deployment items by their associated DeploymentConfig, if none, index with key "orphan" @@ -18,7 +18,7 @@ func DeploymentByDeploymentConfigIndexFunc(obj interface{}) ([]string, error) { if !ok { return nil, fmt.Errorf("not a replication controller: %v", obj) } - name := deployutil.DeploymentConfigNameFor(controller) + name := appsutil.DeploymentConfigNameFor(controller) if len(name) == 0 { return []string{"orphan"}, nil } @@ -64,7 +64,7 @@ func NewFilterBeforePredicate(d time.Duration) FilterPredicate { // FilterDeploymentsPredicate is a function that returns true if the replication controller is associated with a DeploymentConfig func FilterDeploymentsPredicate(item *kapi.ReplicationController) bool { - return len(deployutil.DeploymentConfigNameFor(item)) > 0 + return len(appsutil.DeploymentConfigNameFor(item)) > 0 } // FilterZeroReplicaSize is a function that returns true if the replication controller size is 0 @@ -74,10 +74,10 @@ func FilterZeroReplicaSize(item *kapi.ReplicationController) bool { // DataSet provides functions for working with deployment data type DataSet interface { - GetDeploymentConfig(deployment *kapi.ReplicationController) (*deployapi.DeploymentConfig, bool, error) - ListDeploymentConfigs() ([]*deployapi.DeploymentConfig, error) + GetDeploymentConfig(deployment *kapi.ReplicationController) (*appsapi.DeploymentConfig, bool, error) + ListDeploymentConfigs() ([]*appsapi.DeploymentConfig, error) ListDeployments() ([]*kapi.ReplicationController, error) - ListDeploymentsByDeploymentConfig(config *deployapi.DeploymentConfig) ([]*kapi.ReplicationController, error) + ListDeploymentsByDeploymentConfig(config *appsapi.DeploymentConfig) ([]*kapi.ReplicationController, error) } type dataSet struct { @@ -86,7 +86,7 @@ type dataSet struct { } // NewDataSet returns a DataSet over the specified items -func NewDataSet(deploymentConfigs []*deployapi.DeploymentConfig, deployments []*kapi.ReplicationController) DataSet { +func NewDataSet(deploymentConfigs []*appsapi.DeploymentConfig, deployments []*kapi.ReplicationController) DataSet { deploymentConfigStore := cache.NewStore(cache.MetaNamespaceKeyFunc) for _, deploymentConfig := range deploymentConfigs { deploymentConfigStore.Add(deploymentConfig) @@ -106,26 +106,26 @@ func NewDataSet(deploymentConfigs []*deployapi.DeploymentConfig, deployments []* } // GetDeploymentConfig gets the configuration for the given deployment -func (d *dataSet) GetDeploymentConfig(controller *kapi.ReplicationController) (*deployapi.DeploymentConfig, bool, error) { - name := deployutil.DeploymentConfigNameFor(controller) +func (d *dataSet) GetDeploymentConfig(controller *kapi.ReplicationController) (*appsapi.DeploymentConfig, bool, error) { + name := appsutil.DeploymentConfigNameFor(controller) if len(name) == 0 { return nil, false, nil } - var deploymentConfig *deployapi.DeploymentConfig - key := &deployapi.DeploymentConfig{ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: controller.Namespace}} + var deploymentConfig *appsapi.DeploymentConfig + key := &appsapi.DeploymentConfig{ObjectMeta: metav1.ObjectMeta{Name: name, Namespace: controller.Namespace}} item, exists, err := d.deploymentConfigStore.Get(key) if exists { - deploymentConfig = item.(*deployapi.DeploymentConfig) + deploymentConfig = item.(*appsapi.DeploymentConfig) } return deploymentConfig, exists, err } // ListDeploymentConfigs returns a list of DeploymentConfigs -func (d *dataSet) ListDeploymentConfigs() ([]*deployapi.DeploymentConfig, error) { - results := []*deployapi.DeploymentConfig{} +func (d *dataSet) ListDeploymentConfigs() ([]*appsapi.DeploymentConfig, error) { + results := []*appsapi.DeploymentConfig{} for _, item := range d.deploymentConfigStore.List() { - results = append(results, item.(*deployapi.DeploymentConfig)) + results = append(results, item.(*appsapi.DeploymentConfig)) } return results, nil } @@ -140,12 +140,12 @@ func (d *dataSet) ListDeployments() ([]*kapi.ReplicationController, error) { } // ListDeploymentsByDeploymentConfig returns a list of deployments for the provided configuration -func (d *dataSet) ListDeploymentsByDeploymentConfig(deploymentConfig *deployapi.DeploymentConfig) ([]*kapi.ReplicationController, error) { +func (d *dataSet) ListDeploymentsByDeploymentConfig(deploymentConfig *appsapi.DeploymentConfig) ([]*kapi.ReplicationController, error) { results := []*kapi.ReplicationController{} key := &kapi.ReplicationController{ ObjectMeta: metav1.ObjectMeta{ Namespace: deploymentConfig.Namespace, - Annotations: map[string]string{deployapi.DeploymentConfigAnnotation: deploymentConfig.Name}, + Annotations: map[string]string{appsapi.DeploymentConfigAnnotation: deploymentConfig.Name}, }, } items, err := d.deploymentIndexer.Index("deploymentConfig", key) diff --git a/pkg/apps/prune/data_test.go b/pkg/apps/prune/data_test.go index 0a107085c4d2..130e05a64204 100644 --- a/pkg/apps/prune/data_test.go +++ b/pkg/apps/prune/data_test.go @@ -9,11 +9,11 @@ import ( "k8s.io/apimachinery/pkg/util/sets" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) -func mockDeploymentConfig(namespace, name string) *deployapi.DeploymentConfig { - return &deployapi.DeploymentConfig{ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: name}} +func mockDeploymentConfig(namespace, name string) *appsapi.DeploymentConfig { + return &appsapi.DeploymentConfig{ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: name}} } func withSize(item *kapi.ReplicationController, replicas int) *kapi.ReplicationController { @@ -27,17 +27,17 @@ func withCreated(item *kapi.ReplicationController, creationTimestamp metav1.Time return item } -func withStatus(item *kapi.ReplicationController, status deployapi.DeploymentStatus) *kapi.ReplicationController { - item.Annotations[deployapi.DeploymentStatusAnnotation] = string(status) +func withStatus(item *kapi.ReplicationController, status appsapi.DeploymentStatus) *kapi.ReplicationController { + item.Annotations[appsapi.DeploymentStatusAnnotation] = string(status) return item } -func mockDeployment(namespace, name string, deploymentConfig *deployapi.DeploymentConfig) *kapi.ReplicationController { +func mockDeployment(namespace, name string, deploymentConfig *appsapi.DeploymentConfig) *kapi.ReplicationController { item := &kapi.ReplicationController{ObjectMeta: metav1.ObjectMeta{Namespace: namespace, Name: name, Annotations: map[string]string{}}} if deploymentConfig != nil { - item.Annotations[deployapi.DeploymentConfigAnnotation] = deploymentConfig.Name + item.Annotations[appsapi.DeploymentConfigAnnotation] = deploymentConfig.Name } - item.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) + item.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) return item } @@ -84,7 +84,7 @@ func TestFilterBeforePredicate(t *testing.T) { func TestEmptyDataSet(t *testing.T) { deployments := []*kapi.ReplicationController{} - deploymentConfigs := []*deployapi.DeploymentConfig{} + deploymentConfigs := []*appsapi.DeploymentConfig{} dataSet := NewDataSet(deploymentConfigs, deployments) _, exists, err := dataSet.GetDeploymentConfig(&kapi.ReplicationController{}) if exists || err != nil { @@ -104,7 +104,7 @@ func TestEmptyDataSet(t *testing.T) { if len(deploymentResults) != 0 { t.Errorf("Unexpected result %v", deploymentResults) } - deploymentResults, err = dataSet.ListDeploymentsByDeploymentConfig(&deployapi.DeploymentConfig{}) + deploymentResults, err = dataSet.ListDeploymentsByDeploymentConfig(&appsapi.DeploymentConfig{}) if err != nil { t.Errorf("Unexpected result %v", err) } @@ -114,7 +114,7 @@ func TestEmptyDataSet(t *testing.T) { } func TestPopulatedDataSet(t *testing.T) { - deploymentConfigs := []*deployapi.DeploymentConfig{ + deploymentConfigs := []*appsapi.DeploymentConfig{ mockDeploymentConfig("a", "deployment-config-1"), mockDeploymentConfig("b", "deployment-config-2"), } @@ -127,7 +127,7 @@ func TestPopulatedDataSet(t *testing.T) { dataSet := NewDataSet(deploymentConfigs, deployments) for _, deployment := range deployments { deploymentConfig, exists, err := dataSet.GetDeploymentConfig(deployment) - config, hasConfig := deployment.Annotations[deployapi.DeploymentConfigAnnotation] + config, hasConfig := deployment.Annotations[appsapi.DeploymentConfigAnnotation] if hasConfig { if err != nil { t.Errorf("Item %v, unexpected error: %v", deployment, err) diff --git a/pkg/apps/prune/prune.go b/pkg/apps/prune/prune.go index 3664efc4b875..3f9a8c8151dd 100644 --- a/pkg/apps/prune/prune.go +++ b/pkg/apps/prune/prune.go @@ -9,8 +9,8 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" ) type Pruner interface { @@ -43,7 +43,7 @@ type PrunerOptions struct { // KeepFailed is per DeploymentConfig how many of the most recent failed deployments should be preserved. KeepFailed int // DeploymentConfigs is the entire list of deploymentconfigs across all namespaces in the cluster. - DeploymentConfigs []*deployapi.DeploymentConfig + DeploymentConfigs []*appsapi.DeploymentConfig // Deployments is the entire list of deployments across all namespaces in the cluster. Deployments []*kapi.ReplicationController } @@ -66,9 +66,9 @@ func NewPruner(options PrunerOptions) Pruner { resolvers := []Resolver{} if options.Orphans { - inactiveDeploymentStatus := []deployapi.DeploymentStatus{ - deployapi.DeploymentStatusComplete, - deployapi.DeploymentStatusFailed, + inactiveDeploymentStatus := []appsapi.DeploymentStatus{ + appsapi.DeploymentStatusComplete, + appsapi.DeploymentStatusFailed, } resolvers = append(resolvers, NewOrphanDeploymentResolver(dataSet, inactiveDeploymentStatus)) } @@ -112,8 +112,8 @@ func NewDeploymentDeleter(deployments kcoreclient.ReplicationControllersGetter, func (p *deploymentDeleter) DeleteDeployment(deployment *kapi.ReplicationController) error { glog.V(4).Infof("Deleting deployment %q", deployment.Name) // If the deployment is failed we need to remove its deployer pods, too. - if deployutil.IsFailedDeployment(deployment) { - dpSelector := deployutil.DeployerPodSelector(deployment.Name) + if appsutil.IsFailedDeployment(deployment) { + dpSelector := appsutil.DeployerPodSelector(deployment.Name) deployers, err := p.pods.Pods(deployment.Namespace).List(metav1.ListOptions{LabelSelector: dpSelector.String()}) if err != nil { glog.Warningf("Cannot list deployer pods for %q: %v\n", deployment.Name, err) diff --git a/pkg/apps/prune/prune_test.go b/pkg/apps/prune/prune_test.go index ae4c3ef89c86..dc5205f40ba2 100644 --- a/pkg/apps/prune/prune_test.go +++ b/pkg/apps/prune/prune_test.go @@ -9,7 +9,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) type mockDeleteRecorder struct { @@ -35,16 +35,16 @@ func (m *mockDeleteRecorder) Verify(t *testing.T, expected sets.String) { } func TestPruneTask(t *testing.T) { - deploymentStatusOptions := []deployapi.DeploymentStatus{ - deployapi.DeploymentStatusComplete, - deployapi.DeploymentStatusFailed, - deployapi.DeploymentStatusNew, - deployapi.DeploymentStatusPending, - deployapi.DeploymentStatusRunning, + deploymentStatusOptions := []appsapi.DeploymentStatus{ + appsapi.DeploymentStatusComplete, + appsapi.DeploymentStatusFailed, + appsapi.DeploymentStatusNew, + appsapi.DeploymentStatusPending, + appsapi.DeploymentStatusRunning, } - deploymentStatusFilter := []deployapi.DeploymentStatus{ - deployapi.DeploymentStatusComplete, - deployapi.DeploymentStatusFailed, + deploymentStatusFilter := []appsapi.DeploymentStatus{ + appsapi.DeploymentStatusComplete, + appsapi.DeploymentStatusFailed, } deploymentStatusFilterSet := sets.String{} for _, deploymentStatus := range deploymentStatusFilter { @@ -58,7 +58,7 @@ func TestPruneTask(t *testing.T) { now := metav1.Now() old := metav1.NewTime(now.Time.Add(-1 * keepYoungerThan)) - deploymentConfigs := []*deployapi.DeploymentConfig{} + deploymentConfigs := []*appsapi.DeploymentConfig{} deployments := []*kapi.ReplicationController{} deploymentConfig := mockDeploymentConfig("a", "deployment-config") diff --git a/pkg/apps/prune/resolvers.go b/pkg/apps/prune/resolvers.go index 92b830163752..9326a760a78f 100644 --- a/pkg/apps/prune/resolvers.go +++ b/pkg/apps/prune/resolvers.go @@ -6,8 +6,8 @@ import ( "k8s.io/apimachinery/pkg/util/sets" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" ) // Resolver knows how to resolve the set of candidate objects to prune @@ -33,7 +33,7 @@ func (m *mergeResolver) Resolve() ([]*kapi.ReplicationController, error) { } // NewOrphanDeploymentResolver returns a Resolver that matches objects with no associated DeploymentConfig and has a DeploymentStatus in filter -func NewOrphanDeploymentResolver(dataSet DataSet, deploymentStatusFilter []deployapi.DeploymentStatus) Resolver { +func NewOrphanDeploymentResolver(dataSet DataSet, deploymentStatusFilter []appsapi.DeploymentStatus) Resolver { filter := sets.NewString() for _, deploymentStatus := range deploymentStatusFilter { filter.Insert(string(deploymentStatus)) @@ -59,7 +59,7 @@ func (o *orphanDeploymentResolver) Resolve() ([]*kapi.ReplicationController, err results := []*kapi.ReplicationController{} for _, deployment := range deployments { - deploymentStatus := deployutil.DeploymentStatusFor(deployment) + deploymentStatus := appsutil.DeploymentStatusFor(deployment) if !o.deploymentStatusFilter.Has(string(deploymentStatus)) { continue } @@ -92,8 +92,8 @@ func (o *perDeploymentConfigResolver) Resolve() ([]*kapi.ReplicationController, return nil, err } - completeStates := sets.NewString(string(deployapi.DeploymentStatusComplete)) - failedStates := sets.NewString(string(deployapi.DeploymentStatusFailed)) + completeStates := sets.NewString(string(appsapi.DeploymentStatusComplete)) + failedStates := sets.NewString(string(appsapi.DeploymentStatusFailed)) results := []*kapi.ReplicationController{} for _, deploymentConfig := range deploymentConfigs { @@ -104,15 +104,15 @@ func (o *perDeploymentConfigResolver) Resolve() ([]*kapi.ReplicationController, completeDeployments, failedDeployments := []*kapi.ReplicationController{}, []*kapi.ReplicationController{} for _, deployment := range deployments { - status := deployutil.DeploymentStatusFor(deployment) + status := appsutil.DeploymentStatusFor(deployment) if completeStates.Has(string(status)) { completeDeployments = append(completeDeployments, deployment) } else if failedStates.Has(string(status)) { failedDeployments = append(failedDeployments, deployment) } } - sort.Sort(deployutil.ByMostRecent(completeDeployments)) - sort.Sort(deployutil.ByMostRecent(failedDeployments)) + sort.Sort(appsutil.ByMostRecent(completeDeployments)) + sort.Sort(appsutil.ByMostRecent(failedDeployments)) if o.keepComplete >= 0 && o.keepComplete < len(completeDeployments) { results = append(results, completeDeployments[o.keepComplete:]...) diff --git a/pkg/apps/prune/resolvers_test.go b/pkg/apps/prune/resolvers_test.go index 4bbec6323f01..a8a1b04b7cdc 100644 --- a/pkg/apps/prune/resolvers_test.go +++ b/pkg/apps/prune/resolvers_test.go @@ -10,8 +10,8 @@ import ( "k8s.io/apimachinery/pkg/util/sets" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" ) type mockResolver struct { @@ -54,21 +54,21 @@ func TestOrphanDeploymentResolver(t *testing.T) { activeDeploymentConfig := mockDeploymentConfig("a", "active-deployment-config") inactiveDeploymentConfig := mockDeploymentConfig("a", "inactive-deployment-config") - deploymentConfigs := []*deployapi.DeploymentConfig{activeDeploymentConfig} + deploymentConfigs := []*appsapi.DeploymentConfig{activeDeploymentConfig} deployments := []*kapi.ReplicationController{} expectedNames := sets.String{} - deploymentStatusOptions := []deployapi.DeploymentStatus{ - deployapi.DeploymentStatusComplete, - deployapi.DeploymentStatusFailed, - deployapi.DeploymentStatusNew, - deployapi.DeploymentStatusPending, - deployapi.DeploymentStatusRunning, + deploymentStatusOptions := []appsapi.DeploymentStatus{ + appsapi.DeploymentStatusComplete, + appsapi.DeploymentStatusFailed, + appsapi.DeploymentStatusNew, + appsapi.DeploymentStatusPending, + appsapi.DeploymentStatusRunning, } - deploymentStatusFilter := []deployapi.DeploymentStatus{ - deployapi.DeploymentStatusComplete, - deployapi.DeploymentStatusFailed, + deploymentStatusFilter := []appsapi.DeploymentStatus{ + appsapi.DeploymentStatusComplete, + appsapi.DeploymentStatusFailed, } deploymentStatusFilterSet := sets.String{} for _, deploymentStatus := range deploymentStatusFilter { @@ -101,14 +101,14 @@ func TestOrphanDeploymentResolver(t *testing.T) { } func TestPerDeploymentConfigResolver(t *testing.T) { - deploymentStatusOptions := []deployapi.DeploymentStatus{ - deployapi.DeploymentStatusComplete, - deployapi.DeploymentStatusFailed, - deployapi.DeploymentStatusNew, - deployapi.DeploymentStatusPending, - deployapi.DeploymentStatusRunning, - } - deploymentConfigs := []*deployapi.DeploymentConfig{ + deploymentStatusOptions := []appsapi.DeploymentStatus{ + appsapi.DeploymentStatusComplete, + appsapi.DeploymentStatusFailed, + appsapi.DeploymentStatusNew, + appsapi.DeploymentStatusPending, + appsapi.DeploymentStatusRunning, + } + deploymentConfigs := []*appsapi.DeploymentConfig{ mockDeploymentConfig("a", "deployment-config-1"), mockDeploymentConfig("b", "deployment-config-2"), } @@ -134,8 +134,8 @@ func TestPerDeploymentConfigResolver(t *testing.T) { dataSet := NewDataSet(deploymentConfigs, deployments) expectedNames := sets.String{} - deploymentCompleteStatusFilterSet := sets.NewString(string(deployapi.DeploymentStatusComplete)) - deploymentFailedStatusFilterSet := sets.NewString(string(deployapi.DeploymentStatusFailed)) + deploymentCompleteStatusFilterSet := sets.NewString(string(appsapi.DeploymentStatusComplete)) + deploymentFailedStatusFilterSet := sets.NewString(string(appsapi.DeploymentStatusFailed)) for _, deploymentConfig := range deploymentConfigs { deploymentItems, err := dataSet.ListDeploymentsByDeploymentConfig(deploymentConfig) @@ -144,15 +144,15 @@ func TestPerDeploymentConfigResolver(t *testing.T) { } completedDeployments, failedDeployments := []*kapi.ReplicationController{}, []*kapi.ReplicationController{} for _, deployment := range deploymentItems { - status := deployment.Annotations[deployapi.DeploymentStatusAnnotation] + status := deployment.Annotations[appsapi.DeploymentStatusAnnotation] if deploymentCompleteStatusFilterSet.Has(status) { completedDeployments = append(completedDeployments, deployment) } else if deploymentFailedStatusFilterSet.Has(status) { failedDeployments = append(failedDeployments, deployment) } } - sort.Sort(deployutil.ByMostRecent(completedDeployments)) - sort.Sort(deployutil.ByMostRecent(failedDeployments)) + sort.Sort(appsutil.ByMostRecent(completedDeployments)) + sort.Sort(appsutil.ByMostRecent(failedDeployments)) purgeCompleted := []*kapi.ReplicationController{} purgeFailed := []*kapi.ReplicationController{} if keep >= 0 && keep < len(completedDeployments) { diff --git a/pkg/apps/registry/deployconfig/etcd/etcd.go b/pkg/apps/registry/deployconfig/etcd/etcd.go index 9b04eceda788..5eeadb23b684 100644 --- a/pkg/apps/registry/deployconfig/etcd/etcd.go +++ b/pkg/apps/registry/deployconfig/etcd/etcd.go @@ -14,7 +14,7 @@ import ( "k8s.io/kubernetes/pkg/apis/extensions" extvalidation "k8s.io/kubernetes/pkg/apis/extensions/validation" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/apps/registry/deployconfig" "github.com/openshift/origin/pkg/util/restoptions" ) @@ -44,9 +44,9 @@ func (r *REST) ShortNames() []string { func NewREST(optsGetter restoptions.Getter) (*REST, *StatusREST, *ScaleREST, error) { store := ®istry.Store{ Copier: kapi.Scheme, - NewFunc: func() runtime.Object { return &deployapi.DeploymentConfig{} }, - NewListFunc: func() runtime.Object { return &deployapi.DeploymentConfigList{} }, - DefaultQualifiedResource: deployapi.Resource("deploymentconfigs"), + NewFunc: func() runtime.Object { return &appsapi.DeploymentConfig{} }, + NewListFunc: func() runtime.Object { return &appsapi.DeploymentConfigList{} }, + DefaultQualifiedResource: appsapi.Resource("deploymentconfigs"), CreateStrategy: deployconfig.GroupStrategy, UpdateStrategy: deployconfig.GroupStrategy, @@ -89,7 +89,7 @@ func (r *ScaleREST) Get(ctx apirequest.Context, name string, options *metav1.Get return nil, err } - return deployapi.ScaleFromConfig(deploymentConfig.(*deployapi.DeploymentConfig)), nil + return appsapi.ScaleFromConfig(deploymentConfig.(*appsapi.DeploymentConfig)), nil } // Update scales the DeploymentConfig for the given Scale subresource, returning the updated Scale. @@ -98,9 +98,9 @@ func (r *ScaleREST) Update(ctx apirequest.Context, name string, objInfo rest.Upd if err != nil { return nil, false, errors.NewNotFound(extensions.Resource("scale"), name) } - deploymentConfig := uncastObj.(*deployapi.DeploymentConfig) + deploymentConfig := uncastObj.(*appsapi.DeploymentConfig) - old := deployapi.ScaleFromConfig(deploymentConfig) + old := appsapi.ScaleFromConfig(deploymentConfig) obj, err := objInfo.UpdatedObject(ctx, old) if err != nil { return nil, false, err @@ -132,7 +132,7 @@ type StatusREST struct { var _ = rest.Patcher(&StatusREST{}) func (r *StatusREST) New() runtime.Object { - return &deployapi.DeploymentConfig{} + return &appsapi.DeploymentConfig{} } // Get retrieves the object from the storage. It is required to support Patch. diff --git a/pkg/apps/registry/deployconfig/strategy.go b/pkg/apps/registry/deployconfig/strategy.go index dcf387989558..1c0b1957fb68 100644 --- a/pkg/apps/registry/deployconfig/strategy.go +++ b/pkg/apps/registry/deployconfig/strategy.go @@ -11,7 +11,7 @@ import ( "k8s.io/apiserver/pkg/storage/names" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/apps/apis/apps/validation" ) @@ -53,9 +53,9 @@ func (s strategy) Export(ctx apirequest.Context, obj runtime.Object, exact bool) // PrepareForCreate clears fields that are not allowed to be set by end users on creation. func (strategy) PrepareForCreate(ctx apirequest.Context, obj runtime.Object) { - dc := obj.(*deployapi.DeploymentConfig) + dc := obj.(*appsapi.DeploymentConfig) dc.Generation = 1 - dc.Status = deployapi.DeploymentConfigStatus{} + dc.Status = appsapi.DeploymentConfigStatus{} for i := range dc.Spec.Triggers { if params := dc.Spec.Triggers[i].ImageChangeParams; params != nil { @@ -66,8 +66,8 @@ func (strategy) PrepareForCreate(ctx apirequest.Context, obj runtime.Object) { // PrepareForUpdate clears fields that are not allowed to be set by end users on update. func (strategy) PrepareForUpdate(ctx apirequest.Context, obj, old runtime.Object) { - newDc := obj.(*deployapi.DeploymentConfig) - oldDc := old.(*deployapi.DeploymentConfig) + newDc := obj.(*appsapi.DeploymentConfig) + oldDc := old.(*appsapi.DeploymentConfig) newVersion := newDc.Status.LatestVersion oldVersion := oldDc.Status.LatestVersion @@ -97,12 +97,12 @@ func (strategy) Canonicalize(obj runtime.Object) { // Validate validates a new policy. func (strategy) Validate(ctx apirequest.Context, obj runtime.Object) field.ErrorList { - return validation.ValidateDeploymentConfig(obj.(*deployapi.DeploymentConfig)) + return validation.ValidateDeploymentConfig(obj.(*appsapi.DeploymentConfig)) } // ValidateUpdate is the default update validation for an end user. func (strategy) ValidateUpdate(ctx apirequest.Context, obj, old runtime.Object) field.ErrorList { - return validation.ValidateDeploymentConfigUpdate(obj.(*deployapi.DeploymentConfig), old.(*deployapi.DeploymentConfig)) + return validation.ValidateDeploymentConfigUpdate(obj.(*appsapi.DeploymentConfig), old.(*appsapi.DeploymentConfig)) } // CheckGracefulDelete allows a deployment config to be gracefully deleted. @@ -134,7 +134,7 @@ type groupStrategy struct { func (s groupStrategy) PrepareForCreate(ctx apirequest.Context, obj runtime.Object) { s.strategy.PrepareForCreate(ctx, obj) - dc := obj.(*deployapi.DeploymentConfig) + dc := obj.(*appsapi.DeploymentConfig) appsV1DeploymentConfigLayeredDefaults(dc) } @@ -147,24 +147,24 @@ var StatusStrategy = statusStrategy{CommonStrategy} // PrepareForUpdate clears fields that are not allowed to be set by end users on update of status. func (statusStrategy) PrepareForUpdate(ctx apirequest.Context, obj, old runtime.Object) { - newDc := obj.(*deployapi.DeploymentConfig) - oldDc := old.(*deployapi.DeploymentConfig) + newDc := obj.(*appsapi.DeploymentConfig) + oldDc := old.(*appsapi.DeploymentConfig) newDc.Spec = oldDc.Spec newDc.Labels = oldDc.Labels } // ValidateUpdate is the default update validation for an end user updating status. func (statusStrategy) ValidateUpdate(ctx apirequest.Context, obj, old runtime.Object) field.ErrorList { - return validation.ValidateDeploymentConfigStatusUpdate(obj.(*deployapi.DeploymentConfig), old.(*deployapi.DeploymentConfig)) + return validation.ValidateDeploymentConfigStatusUpdate(obj.(*appsapi.DeploymentConfig), old.(*appsapi.DeploymentConfig)) } // Applies defaults only for API group "apps.openshift.io" and not for the legacy API. // This function is called from storage layer where differentiation // between legacy and group API can be made and is not related to other functions here // which are called fom auto-generated code. -func appsV1DeploymentConfigLayeredDefaults(dc *deployapi.DeploymentConfig) { +func appsV1DeploymentConfigLayeredDefaults(dc *appsapi.DeploymentConfig) { if dc.Spec.RevisionHistoryLimit == nil { - v := deployapi.DefaultRevisionHistoryLimit + v := appsapi.DefaultRevisionHistoryLimit dc.Spec.RevisionHistoryLimit = &v } } diff --git a/pkg/apps/registry/deployconfig/strategy_test.go b/pkg/apps/registry/deployconfig/strategy_test.go index 748194f3d370..e92905d4c84b 100644 --- a/pkg/apps/registry/deployconfig/strategy_test.go +++ b/pkg/apps/registry/deployconfig/strategy_test.go @@ -10,12 +10,12 @@ import ( apirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/rest" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" ) var ( - nonDefaultRevisionHistoryLimit = deployapi.DefaultRevisionHistoryLimit + 42 + nonDefaultRevisionHistoryLimit = appsapi.DefaultRevisionHistoryLimit + 42 ) func int32ptr(v int32) *int32 { @@ -30,18 +30,18 @@ func TestDeploymentConfigStrategy(t *testing.T) { if CommonStrategy.AllowCreateOnUpdate() { t.Errorf("DeploymentConfig should not allow create on update") } - deploymentConfig := &deployapi.DeploymentConfig{ + deploymentConfig := &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "default"}, - Spec: deploytest.OkDeploymentConfigSpec(), + Spec: appstest.OkDeploymentConfigSpec(), } CommonStrategy.PrepareForCreate(ctx, deploymentConfig) errs := CommonStrategy.Validate(ctx, deploymentConfig) if len(errs) != 0 { t.Errorf("Unexpected error validating %v", errs) } - updatedDeploymentConfig := &deployapi.DeploymentConfig{ + updatedDeploymentConfig := &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "bar", Namespace: "default", Generation: 1}, - Spec: deploytest.OkDeploymentConfigSpec(), + Spec: appstest.OkDeploymentConfigSpec(), } errs = CommonStrategy.ValidateUpdate(ctx, updatedDeploymentConfig, deploymentConfig) if len(errs) == 0 { @@ -54,7 +54,7 @@ func TestDeploymentConfigStrategy(t *testing.T) { if len(errs) != 0 { t.Errorf("Unexpected error validating %v", errs) } - invalidDeploymentConfig := &deployapi.DeploymentConfig{} + invalidDeploymentConfig := &appsapi.DeploymentConfig{} errs = CommonStrategy.Validate(ctx, invalidDeploymentConfig) if len(errs) == 0 { t.Errorf("Expected error validating") @@ -94,58 +94,58 @@ func TestPrepareForUpdate(t *testing.T) { } // prevDeployment is the old object tested for both old and new client updates. -func prevDeployment() *deployapi.DeploymentConfig { - return &deployapi.DeploymentConfig{ +func prevDeployment() *appsapi.DeploymentConfig { + return &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "default", Generation: 4, Annotations: make(map[string]string)}, - Spec: deploytest.OkDeploymentConfigSpec(), - Status: deploytest.OkDeploymentConfigStatus(1), + Spec: appstest.OkDeploymentConfigSpec(), + Status: appstest.OkDeploymentConfigStatus(1), } } // afterDeployment is used for a spec change check. -func afterDeployment() *deployapi.DeploymentConfig { +func afterDeployment() *appsapi.DeploymentConfig { dc := prevDeployment() dc.Spec.Replicas++ return dc } // expectedAfterDeployment is used for a spec change check. -func expectedAfterDeployment() *deployapi.DeploymentConfig { +func expectedAfterDeployment() *appsapi.DeploymentConfig { dc := afterDeployment() dc.Generation++ return dc } // afterDeploymentVersionBump is a deployment config updated to a newer version. -func afterDeploymentVersionBump() *deployapi.DeploymentConfig { +func afterDeploymentVersionBump() *appsapi.DeploymentConfig { dc := prevDeployment() dc.Status.LatestVersion++ return dc } // expectedAfterVersionBump is the object we expect after a version bump. -func expectedAfterVersionBump() *deployapi.DeploymentConfig { +func expectedAfterVersionBump() *appsapi.DeploymentConfig { dc := afterDeploymentVersionBump() dc.Generation++ return dc } -func setRevisionHistoryLimit(v *int32, dc *deployapi.DeploymentConfig) *deployapi.DeploymentConfig { +func setRevisionHistoryLimit(v *int32, dc *appsapi.DeploymentConfig) *appsapi.DeploymentConfig { dc.Spec.RevisionHistoryLimit = v return dc } -func okDeploymentConfig(generation int64) *deployapi.DeploymentConfig { - dc := deploytest.OkDeploymentConfig(0) +func okDeploymentConfig(generation int64) *appsapi.DeploymentConfig { + dc := appstest.OkDeploymentConfig(0) dc.ObjectMeta.Generation = generation return dc } func TestLegacyStrategy_PrepareForCreate(t *testing.T) { - nonDefaultRevisionHistoryLimit := deployapi.DefaultRevisionHistoryLimit + 42 + nonDefaultRevisionHistoryLimit := appsapi.DefaultRevisionHistoryLimit + 42 tt := []struct { - obj *deployapi.DeploymentConfig - expected *deployapi.DeploymentConfig + obj *appsapi.DeploymentConfig + expected *appsapi.DeploymentConfig }{ { obj: setRevisionHistoryLimit(nil, okDeploymentConfig(0)), @@ -185,13 +185,13 @@ func TestLegacyStrategy_DefaultGarbageCollectionPolicy(t *testing.T) { func TestGroupStrategy_PrepareForCreate(t *testing.T) { tt := []struct { - obj *deployapi.DeploymentConfig - expected *deployapi.DeploymentConfig + obj *appsapi.DeploymentConfig + expected *appsapi.DeploymentConfig }{ { obj: setRevisionHistoryLimit(nil, okDeploymentConfig(0)), // Group API should default RevisionHistoryLimit - expected: setRevisionHistoryLimit(int32ptr(deployapi.DefaultRevisionHistoryLimit), okDeploymentConfig(1)), + expected: setRevisionHistoryLimit(int32ptr(appsapi.DefaultRevisionHistoryLimit), okDeploymentConfig(1)), }, { obj: setRevisionHistoryLimit(&nonDefaultRevisionHistoryLimit, okDeploymentConfig(0)), diff --git a/pkg/apps/registry/deploylog/rest.go b/pkg/apps/registry/deploylog/rest.go index 14f23d0cf65f..1c0a606e330d 100644 --- a/pkg/apps/registry/deploylog/rest.go +++ b/pkg/apps/registry/deploylog/rest.go @@ -22,11 +22,11 @@ import ( kubeletclient "k8s.io/kubernetes/pkg/kubelet/client" "k8s.io/kubernetes/pkg/registry/core/pod" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/apps/apis/apps/validation" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" "github.com/openshift/origin/pkg/apps/registry" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" ) const ( @@ -81,12 +81,12 @@ func NewREST(dn appsclient.DeploymentConfigsGetter, rn kcoreclient.ReplicationCo // NewGetOptions returns a new options object for deployment logs func (r *REST) NewGetOptions() (runtime.Object, bool, string) { - return &deployapi.DeploymentLogOptions{}, false, "" + return &appsapi.DeploymentLogOptions{}, false, "" } // New creates an empty DeploymentLog resource func (r *REST) New() runtime.Object { - return &deployapi.DeploymentLog{} + return &appsapi.DeploymentLog{} } // Get returns a streamer resource with the contents of the deployment log @@ -98,19 +98,19 @@ func (r *REST) Get(ctx apirequest.Context, name string, opts runtime.Object) (ru } // Validate DeploymentLogOptions - deployLogOpts, ok := opts.(*deployapi.DeploymentLogOptions) + deployLogOpts, ok := opts.(*appsapi.DeploymentLogOptions) if !ok { return nil, errors.NewBadRequest("did not get an expected options.") } if errs := validation.ValidateDeploymentLogOptions(deployLogOpts); len(errs) > 0 { - return nil, errors.NewInvalid(deployapi.Kind("DeploymentLogOptions"), "", errs) + return nil, errors.NewInvalid(appsapi.Kind("DeploymentLogOptions"), "", errs) } // Fetch deploymentConfig and check latest version; if 0, there are no deployments // for this config config, err := r.dn.DeploymentConfigs(namespace).Get(name, metav1.GetOptions{}) if err != nil { - return nil, errors.NewNotFound(deployapi.Resource("deploymentconfig"), name) + return nil, errors.NewNotFound(appsapi.Resource("deploymentconfig"), name) } desiredVersion := config.Status.LatestVersion if desiredVersion == 0 { @@ -135,50 +135,50 @@ func (r *REST) Get(ctx apirequest.Context, name string, opts runtime.Object) (ru } // Get desired deployment - targetName := deployutil.DeploymentNameForConfigVersion(config.Name, desiredVersion) + targetName := appsutil.DeploymentNameForConfigVersion(config.Name, desiredVersion) target, err := r.waitForExistingDeployment(namespace, targetName) if err != nil { return nil, err } - podName := deployutil.DeployerPodNameForDeployment(target.Name) + podName := appsutil.DeployerPodNameForDeployment(target.Name) // Check for deployment status; if it is new or pending, we will wait for it. If it is complete, // the deployment completed successfully and the deployer pod will be deleted so we will return a // success message. If it is running or failed, retrieve the log from the deployer pod. - status := deployutil.DeploymentStatusFor(target) + status := appsutil.DeploymentStatusFor(target) switch status { - case deployapi.DeploymentStatusNew, deployapi.DeploymentStatusPending: + case appsapi.DeploymentStatusNew, appsapi.DeploymentStatusPending: if deployLogOpts.NoWait { - glog.V(4).Infof("Deployment %s is in %s state. No logs to retrieve yet.", deployutil.LabelForDeployment(target), status) + glog.V(4).Infof("Deployment %s is in %s state. No logs to retrieve yet.", appsutil.LabelForDeployment(target), status) return &genericrest.LocationStreamer{}, nil } - glog.V(4).Infof("Deployment %s is in %s state, waiting for it to start...", deployutil.LabelForDeployment(target), status) + glog.V(4).Infof("Deployment %s is in %s state, waiting for it to start...", appsutil.LabelForDeployment(target), status) - if err := deployutil.WaitForRunningDeployerPod(r.pn, target, r.timeout); err != nil { + if err := appsutil.WaitForRunningDeployerPod(r.pn, target, r.timeout); err != nil { return nil, errors.NewBadRequest(fmt.Sprintf("failed to run deployer pod %s: %v", podName, err)) } latest, ok, err := registry.WaitForRunningDeployment(r.rn, target, r.timeout) if err != nil { - return nil, errors.NewBadRequest(fmt.Sprintf("unable to wait for deployment %s to run: %v", deployutil.LabelForDeployment(target), err)) + return nil, errors.NewBadRequest(fmt.Sprintf("unable to wait for deployment %s to run: %v", appsutil.LabelForDeployment(target), err)) } if !ok { return nil, errors.NewServerTimeout(kapi.Resource("ReplicationController"), "get", 2) } - if deployutil.IsCompleteDeployment(latest) { + if appsutil.IsCompleteDeployment(latest) { podName, err = r.returnApplicationPodName(target) if err != nil { return nil, err } } - case deployapi.DeploymentStatusComplete: + case appsapi.DeploymentStatusComplete: podName, err = r.returnApplicationPodName(target) if err != nil { return nil, err } } - logOpts := deployapi.DeploymentToPodLogOptions(deployLogOpts) + logOpts := appsapi.DeploymentToPodLogOptions(deployLogOpts) location, transport, err := pod.LogLocation(&podGetter{r.pn}, r.connInfo, ctx, podName, logOpts) if err != nil { return nil, errors.NewBadRequest(err.Error()) diff --git a/pkg/apps/registry/deploylog/rest_test.go b/pkg/apps/registry/deploylog/rest_test.go index 496f7ef9ee0e..9be7e96b05cf 100644 --- a/pkg/apps/registry/deploylog/rest_test.go +++ b/pkg/apps/registry/deploylog/rest_test.go @@ -18,10 +18,10 @@ import ( "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" kubeletclient "k8s.io/kubernetes/pkg/kubelet/client" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" appsfake "github.com/openshift/origin/pkg/apps/generated/internalclientset/fake" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" // install all APIs _ "github.com/openshift/origin/pkg/api/install" @@ -30,7 +30,7 @@ import ( var testSelector = map[string]string{"test": "rest"} func makeDeployment(version int64) kapi.ReplicationController { - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(appsapi.SchemeGroupVersion)) deployment.Namespace = metav1.NamespaceDefault deployment.Spec.Selector = testSelector return *deployment @@ -94,9 +94,9 @@ func (*fakeConnectionInfoGetter) GetConnectionInfo(nodeName types.NodeName) (*ku } // mockREST mocks a DeploymentLog REST -func mockREST(version, desired int64, status deployapi.DeploymentStatus) *REST { +func mockREST(version, desired int64, status appsapi.DeploymentStatus) *REST { // Fake deploymentConfig - config := deploytest.OkDeploymentConfig(version) + config := appstest.OkDeploymentConfig(version) fakeDn := appsfake.NewSimpleClientset(config) fakeDn.PrependReactor("get", "deploymentconfigs", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { return true, config, nil @@ -122,11 +122,11 @@ func mockREST(version, desired int64, status deployapi.DeploymentStatus) *REST { fakeWatch := watch.NewFake() fakeRn.PrependWatchReactor("replicationcontrollers", clientgotesting.DefaultWatchReactor(fakeWatch, nil)) obj := &fakeDeployments.Items[desired-1] - obj.Annotations[deployapi.DeploymentStatusAnnotation] = string(status) + obj.Annotations[appsapi.DeploymentStatusAnnotation] = string(status) go fakeWatch.Add(obj) fakePn := fake.NewSimpleClientset() - if status == deployapi.DeploymentStatusComplete { + if status == appsapi.DeploymentStatusComplete { // If the deployment is complete, we will try to get the logs from the oldest // application pod... fakePn.PrependReactor("list", "pods", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { @@ -139,13 +139,13 @@ func mockREST(version, desired int64, status deployapi.DeploymentStatus) *REST { // ...otherwise try to get the logs from the deployer pod. fakeDeployer := &kapi.Pod{ ObjectMeta: metav1.ObjectMeta{ - Name: deployutil.DeployerPodNameForDeployment(obj.Name), + Name: appsutil.DeployerPodNameForDeployment(obj.Name), Namespace: metav1.NamespaceDefault, }, Spec: kapi.PodSpec{ Containers: []kapi.Container{ { - Name: deployutil.DeployerPodNameForDeployment(obj.Name) + "-container", + Name: appsutil.DeployerPodNameForDeployment(obj.Name) + "-container", }, }, NodeName: "some-host", @@ -181,9 +181,9 @@ func TestRESTGet(t *testing.T) { }{ { testName: "running deployment", - rest: mockREST(1, 1, deployapi.DeploymentStatusRunning), + rest: mockREST(1, 1, appsapi.DeploymentStatusRunning), name: "config", - opts: &deployapi.DeploymentLogOptions{Follow: true, Version: intp(1)}, + opts: &appsapi.DeploymentLogOptions{Follow: true, Version: intp(1)}, expected: &genericrest.LocationStreamer{ Location: &url.URL{ Scheme: "https", @@ -200,9 +200,9 @@ func TestRESTGet(t *testing.T) { }, { testName: "complete deployment", - rest: mockREST(5, 5, deployapi.DeploymentStatusComplete), + rest: mockREST(5, 5, appsapi.DeploymentStatusComplete), name: "config", - opts: &deployapi.DeploymentLogOptions{Follow: true, Version: intp(5)}, + opts: &appsapi.DeploymentLogOptions{Follow: true, Version: intp(5)}, expected: &genericrest.LocationStreamer{ Location: &url.URL{ Scheme: "https", @@ -219,9 +219,9 @@ func TestRESTGet(t *testing.T) { }, { testName: "previous failed deployment", - rest: mockREST(3, 2, deployapi.DeploymentStatusFailed), + rest: mockREST(3, 2, appsapi.DeploymentStatusFailed), name: "config", - opts: &deployapi.DeploymentLogOptions{Follow: false, Version: intp(2)}, + opts: &appsapi.DeploymentLogOptions{Follow: false, Version: intp(2)}, expected: &genericrest.LocationStreamer{ Location: &url.URL{ Scheme: "https", @@ -237,9 +237,9 @@ func TestRESTGet(t *testing.T) { }, { testName: "previous deployment", - rest: mockREST(3, 2, deployapi.DeploymentStatusFailed), + rest: mockREST(3, 2, appsapi.DeploymentStatusFailed), name: "config", - opts: &deployapi.DeploymentLogOptions{Follow: false, Previous: true}, + opts: &appsapi.DeploymentLogOptions{Follow: false, Previous: true}, expected: &genericrest.LocationStreamer{ Location: &url.URL{ Scheme: "https", @@ -257,7 +257,7 @@ func TestRESTGet(t *testing.T) { testName: "non-existent previous deployment", rest: mockREST(1 /* won't be used */, 101, ""), name: "config", - opts: &deployapi.DeploymentLogOptions{Follow: false, Previous: true}, + opts: &appsapi.DeploymentLogOptions{Follow: false, Previous: true}, expected: nil, expectedErr: errors.NewBadRequest("no previous deployment exists for deploymentConfig \"config\""), }, diff --git a/pkg/apps/registry/instantiate/rest.go b/pkg/apps/registry/instantiate/rest.go index bb094e84e587..ffb290b49c90 100644 --- a/pkg/apps/registry/instantiate/rest.go +++ b/pkg/apps/registry/instantiate/rest.go @@ -20,9 +20,9 @@ import ( kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/apps/apis/apps/validation" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" imageapi "github.com/openshift/origin/pkg/image/apis/image" imageclientinternal "github.com/openshift/origin/pkg/image/generated/internalclientset" images "github.com/openshift/origin/pkg/image/generated/internalclientset/typed/image/internalversion" @@ -46,12 +46,12 @@ type REST struct { } func (s *REST) New() runtime.Object { - return &deployapi.DeploymentRequest{} + return &appsapi.DeploymentRequest{} } // Create instantiates a deployment config func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runtime.Object, error) { - req, ok := obj.(*deployapi.DeploymentRequest) + req, ok := obj.(*appsapi.DeploymentRequest) if !ok { return nil, errors.NewInternalError(fmt.Errorf("wrong object passed for requesting a new rollout: %#v", obj)) } @@ -61,11 +61,11 @@ func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runti if err != nil { return err } - config := configObj.(*deployapi.DeploymentConfig) + config := configObj.(*appsapi.DeploymentConfig) old := config if errs := validation.ValidateRequestForDeploymentConfig(req, config); len(errs) > 0 { - return errors.NewInvalid(deployapi.Kind("DeploymentRequest"), req.Name, errs) + return errors.NewInvalid(appsapi.Kind("DeploymentRequest"), req.Name, errs) } // We need to process the deployment config before we can determine if it is possible to trigger @@ -90,20 +90,20 @@ func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runti } glog.V(4).Infof("New deployment for %q caused by %#v", config.Name, causes) - config.Status.Details = new(deployapi.DeploymentDetails) + config.Status.Details = new(appsapi.DeploymentDetails) config.Status.Details.Causes = causes switch causes[0].Type { - case deployapi.DeploymentTriggerOnConfigChange: + case appsapi.DeploymentTriggerOnConfigChange: config.Status.Details.Message = "config change" - case deployapi.DeploymentTriggerOnImageChange: + case appsapi.DeploymentTriggerOnImageChange: config.Status.Details.Message = "image change" - case deployapi.DeploymentTriggerManual: + case appsapi.DeploymentTriggerManual: config.Status.Details.Message = "manual change" } config.Status.LatestVersion++ userInfo, _ := apirequest.UserFrom(ctx) - attrs := admission.NewAttributesRecord(config, old, deployapi.Kind("DeploymentConfig").WithVersion(""), config.Namespace, config.Name, deployapi.Resource("DeploymentConfig").WithVersion(""), "", admission.Update, userInfo) + attrs := admission.NewAttributesRecord(config, old, appsapi.Kind("DeploymentConfig").WithVersion(""), config.Namespace, config.Name, appsapi.Resource("DeploymentConfig").WithVersion(""), "", admission.Update, userInfo) if err := r.admit.Admit(attrs); err != nil { return err } @@ -118,12 +118,12 @@ func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runti // processTriggers will go over all deployment triggers that require processing and update // the deployment config accordingly. This contains the work that the image change controller // had been doing up to the point we got the /instantiate endpoint. -func processTriggers(config *deployapi.DeploymentConfig, is images.ImageStreamsGetter, force bool, exclude []deployapi.DeploymentTriggerType) error { +func processTriggers(config *appsapi.DeploymentConfig, is images.ImageStreamsGetter, force bool, exclude []appsapi.DeploymentTriggerType) error { errs := []error{} // Process any image change triggers. for _, trigger := range config.Spec.Triggers { - if trigger.Type != deployapi.DeploymentTriggerOnImageChange { + if trigger.Type != appsapi.DeploymentTriggerOnImageChange { continue } @@ -195,7 +195,7 @@ func processTriggers(config *deployapi.DeploymentConfig, is images.ImageStreamsG return nil } -func containsTriggerType(types []deployapi.DeploymentTriggerType, triggerType deployapi.DeploymentTriggerType) bool { +func containsTriggerType(types []appsapi.DeploymentTriggerType, triggerType appsapi.DeploymentTriggerType) bool { for _, t := range types { if t == triggerType { return true @@ -206,11 +206,11 @@ func containsTriggerType(types []deployapi.DeploymentTriggerType, triggerType de // canTrigger determines if we can trigger a new deployment for config based on the various deployment triggers. func canTrigger( - config *deployapi.DeploymentConfig, + config *appsapi.DeploymentConfig, rn kcoreclient.ReplicationControllersGetter, decoder runtime.Decoder, force bool, -) (bool, []deployapi.DeploymentCause, error) { +) (bool, []appsapi.DeploymentCause, error) { decoded, err := decodeFromLatestDeployment(config, rn, decoder) if err != nil { @@ -218,10 +218,10 @@ func canTrigger( } ictCount, resolved, canTriggerByImageChange := 0, 0, false - var causes []deployapi.DeploymentCause + var causes []appsapi.DeploymentCause for _, t := range config.Spec.Triggers { - if t.Type != deployapi.DeploymentTriggerOnImageChange { + if t.Type != appsapi.DeploymentTriggerOnImageChange { continue } ictCount++ @@ -251,9 +251,9 @@ func canTrigger( continue } - causes = append(causes, deployapi.DeploymentCause{ - Type: deployapi.DeploymentTriggerOnImageChange, - ImageTrigger: &deployapi.DeploymentCauseImageTrigger{ + causes = append(causes, appsapi.DeploymentCause{ + Type: appsapi.DeploymentTriggerOnImageChange, + ImageTrigger: &appsapi.DeploymentCauseImageTrigger{ From: kapi.ObjectReference{ Name: t.ImageChangeParams.From.Name, Namespace: t.ImageChangeParams.From.Namespace, @@ -269,17 +269,17 @@ func canTrigger( } if force { - return true, []deployapi.DeploymentCause{{Type: deployapi.DeploymentTriggerManual}}, nil + return true, []appsapi.DeploymentCause{{Type: appsapi.DeploymentTriggerManual}}, nil } canTriggerByConfigChange := false - if deployutil.HasChangeTrigger(config) && // Our deployment config has a config change trigger + if appsutil.HasChangeTrigger(config) && // Our deployment config has a config change trigger len(causes) == 0 && // and no other trigger has triggered. (config.Status.LatestVersion == 0 || // Either it's the initial deployment !kapihelper.Semantic.DeepEqual(config.Spec.Template, decoded.Spec.Template)) /* or a config change happened so we need to trigger */ { canTriggerByConfigChange = true - causes = []deployapi.DeploymentCause{{Type: deployapi.DeploymentTriggerOnConfigChange}} + causes = []appsapi.DeploymentCause{{Type: appsapi.DeploymentTriggerOnConfigChange}} } return canTriggerByConfigChange || canTriggerByImageChange, causes, nil @@ -288,12 +288,12 @@ func canTrigger( // decodeFromLatestDeployment will try to return the decoded version of the current deploymentconfig // found in the annotations of its latest deployment. If there is no previous deploymentconfig (ie. // latestVersion == 0), the returned deploymentconfig will be the same. -func decodeFromLatestDeployment(config *deployapi.DeploymentConfig, rn kcoreclient.ReplicationControllersGetter, decoder runtime.Decoder) (*deployapi.DeploymentConfig, error) { +func decodeFromLatestDeployment(config *appsapi.DeploymentConfig, rn kcoreclient.ReplicationControllersGetter, decoder runtime.Decoder) (*appsapi.DeploymentConfig, error) { if config.Status.LatestVersion == 0 { return config, nil } - latestDeploymentName := deployutil.LatestDeploymentNameForConfig(config) + latestDeploymentName := appsutil.LatestDeploymentNameForConfig(config) deployment, err := rn.ReplicationControllers(config.Namespace).Get(latestDeploymentName, metav1.GetOptions{}) if err != nil { // If there's no deployment for the latest config, we have no basis of @@ -301,7 +301,7 @@ func decodeFromLatestDeployment(config *deployapi.DeploymentConfig, rn kcoreclie // to make the deployment for the config, so return early. return nil, err } - decoded, err := deployutil.DecodeDeploymentConfig(deployment, decoder) + decoded, err := appsutil.DecodeDeploymentConfig(deployment, decoder) if err != nil { return nil, errors.NewInternalError(err) } @@ -310,14 +310,14 @@ func decodeFromLatestDeployment(config *deployapi.DeploymentConfig, rn kcoreclie // hasUpdatedTriggers checks if there is an diffence between previous deployment config // trigger configuration and current one. -func hasUpdatedTriggers(current, previous deployapi.DeploymentConfig) bool { +func hasUpdatedTriggers(current, previous appsapi.DeploymentConfig) bool { for _, ct := range current.Spec.Triggers { found := false - if ct.Type != deployapi.DeploymentTriggerOnImageChange { + if ct.Type != appsapi.DeploymentTriggerOnImageChange { continue } for _, pt := range previous.Spec.Triggers { - if pt.Type != deployapi.DeploymentTriggerOnImageChange { + if pt.Type != appsapi.DeploymentTriggerOnImageChange { continue } if found = ct.ImageChangeParams.From.Namespace == pt.ImageChangeParams.From.Namespace && @@ -336,9 +336,9 @@ func hasUpdatedTriggers(current, previous deployapi.DeploymentConfig) bool { // triggeredByDifferentImage compares the provided image change parameters with those found in the // previous deployment config (the one we decoded from the annotations of its latest deployment) // and returns whether the two deployment configs have been triggered by a different image change. -func triggeredByDifferentImage(ictParams deployapi.DeploymentTriggerImageChangeParams, previous deployapi.DeploymentConfig) bool { +func triggeredByDifferentImage(ictParams appsapi.DeploymentTriggerImageChangeParams, previous appsapi.DeploymentConfig) bool { for _, t := range previous.Spec.Triggers { - if t.Type != deployapi.DeploymentTriggerOnImageChange { + if t.Type != appsapi.DeploymentTriggerOnImageChange { continue } diff --git a/pkg/apps/registry/instantiate/rest_test.go b/pkg/apps/registry/instantiate/rest_test.go index a4a907b76b63..2dc88b954d3f 100644 --- a/pkg/apps/registry/instantiate/rest_test.go +++ b/pkg/apps/registry/instantiate/rest_test.go @@ -11,16 +11,16 @@ import ( kapihelper "k8s.io/kubernetes/pkg/api/helper" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" - deployv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" _ "github.com/openshift/origin/pkg/apps/apis/apps/install" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" - deployutil "github.com/openshift/origin/pkg/apps/util" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsutil "github.com/openshift/origin/pkg/apps/util" imageapi "github.com/openshift/origin/pkg/image/apis/image" imagefake "github.com/openshift/origin/pkg/image/generated/internalclientset/fake" ) -var codec = kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion) +var codec = kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion) // TestProcess_changeForNonAutomaticTag ensures that an image update for which // there is a matching trigger results in a no-op due to the trigger's @@ -29,7 +29,7 @@ func TestProcess_changeForNonAutomaticTag(t *testing.T) { tests := []struct { name string force bool - excludes []deployapi.DeploymentTriggerType + excludes []appsapi.DeploymentTriggerType expected bool expectedErr bool @@ -44,7 +44,7 @@ func TestProcess_changeForNonAutomaticTag(t *testing.T) { { name: "forced update but excluded", force: true, - excludes: []deployapi.DeploymentTriggerType{deployapi.DeploymentTriggerOnImageChange}, + excludes: []appsapi.DeploymentTriggerType{appsapi.DeploymentTriggerOnImageChange}, expected: false, expectedErr: false, @@ -59,13 +59,13 @@ func TestProcess_changeForNonAutomaticTag(t *testing.T) { } for _, test := range tests { - config := deploytest.OkDeploymentConfig(1) + config := appstest.OkDeploymentConfig(1) config.Namespace = metav1.NamespaceDefault config.Spec.Triggers[0].ImageChangeParams.Automatic = false // The image has been resolved at least once before. - config.Spec.Triggers[0].ImageChangeParams.LastTriggeredImage = deploytest.DockerImageReference + config.Spec.Triggers[0].ImageChangeParams.LastTriggeredImage = appstest.DockerImageReference - stream := deploytest.OkStreamForConfig(config) + stream := appstest.OkStreamForConfig(config) config.Spec.Triggers[0].ImageChangeParams.LastTriggeredImage = "someotherresolveddockerimagereference" fake := &imagefake.Clientset{} @@ -100,8 +100,8 @@ func TestProcess_changeForNonAutomaticTag(t *testing.T) { // there is a matching trigger results in a no-op due to the tag specified on // the trigger not matching the tags defined on the image stream. func TestProcess_changeForUnregisteredTag(t *testing.T) { - config := deploytest.OkDeploymentConfig(0) - stream := deploytest.OkStreamForConfig(config) + config := appstest.OkDeploymentConfig(0) + stream := appstest.OkStreamForConfig(config) // The image has been resolved at least once before. config.Spec.Triggers[0].ImageChangeParams.From.Name = imageapi.JoinImageStreamTag(stream.Name, "unrelatedtag") @@ -135,7 +135,7 @@ func TestProcess_matchScenarios(t *testing.T) { tests := []struct { name string - param *deployapi.DeploymentTriggerImageChangeParams + param *appsapi.DeploymentTriggerImageChangeParams containerImageFunc func() string notFound bool @@ -144,10 +144,10 @@ func TestProcess_matchScenarios(t *testing.T) { { name: "automatic=true, initial trigger, explicit namespace", - param: &deployapi.DeploymentTriggerImageChangeParams{ + param: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: true, ContainerNames: []string{"container1"}, - From: kapi.ObjectReference{Namespace: metav1.NamespaceDefault, Name: imageapi.JoinImageStreamTag(deploytest.ImageStreamName, imageapi.DefaultImageTag)}, + From: kapi.ObjectReference{Namespace: metav1.NamespaceDefault, Name: imageapi.JoinImageStreamTag(appstest.ImageStreamName, imageapi.DefaultImageTag)}, LastTriggeredImage: "", }, @@ -156,10 +156,10 @@ func TestProcess_matchScenarios(t *testing.T) { { name: "automatic=true, initial trigger, implicit namespace", - param: &deployapi.DeploymentTriggerImageChangeParams{ + param: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: true, ContainerNames: []string{"container1"}, - From: kapi.ObjectReference{Name: imageapi.JoinImageStreamTag(deploytest.ImageStreamName, imageapi.DefaultImageTag)}, + From: kapi.ObjectReference{Name: imageapi.JoinImageStreamTag(appstest.ImageStreamName, imageapi.DefaultImageTag)}, LastTriggeredImage: "", }, @@ -168,10 +168,10 @@ func TestProcess_matchScenarios(t *testing.T) { { name: "automatic=false, initial trigger", - param: &deployapi.DeploymentTriggerImageChangeParams{ + param: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: false, ContainerNames: []string{"container1"}, - From: kapi.ObjectReference{Namespace: metav1.NamespaceDefault, Name: imageapi.JoinImageStreamTag(deploytest.ImageStreamName, imageapi.DefaultImageTag)}, + From: kapi.ObjectReference{Namespace: metav1.NamespaceDefault, Name: imageapi.JoinImageStreamTag(appstest.ImageStreamName, imageapi.DefaultImageTag)}, LastTriggeredImage: "", }, @@ -180,11 +180,11 @@ func TestProcess_matchScenarios(t *testing.T) { { name: "(no-op) automatic=false, already triggered", - param: &deployapi.DeploymentTriggerImageChangeParams{ + param: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: false, ContainerNames: []string{"container1"}, - From: kapi.ObjectReference{Namespace: metav1.NamespaceDefault, Name: imageapi.JoinImageStreamTag(deploytest.ImageStreamName, imageapi.DefaultImageTag)}, - LastTriggeredImage: deploytest.DockerImageReference, + From: kapi.ObjectReference{Namespace: metav1.NamespaceDefault, Name: imageapi.JoinImageStreamTag(appstest.ImageStreamName, imageapi.DefaultImageTag)}, + LastTriggeredImage: appstest.DockerImageReference, }, expected: false, @@ -192,11 +192,11 @@ func TestProcess_matchScenarios(t *testing.T) { { name: "(no-op) automatic=true, image is already deployed", - param: &deployapi.DeploymentTriggerImageChangeParams{ + param: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: true, ContainerNames: []string{"container1"}, - From: kapi.ObjectReference{Name: imageapi.JoinImageStreamTag(deploytest.ImageStreamName, imageapi.DefaultImageTag)}, - LastTriggeredImage: deploytest.DockerImageReference, + From: kapi.ObjectReference{Name: imageapi.JoinImageStreamTag(appstest.ImageStreamName, imageapi.DefaultImageTag)}, + LastTriggeredImage: appstest.DockerImageReference, }, expected: false, @@ -204,7 +204,7 @@ func TestProcess_matchScenarios(t *testing.T) { { name: "(no-op) trigger doesn't match the stream", - param: &deployapi.DeploymentTriggerImageChangeParams{ + param: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: true, ContainerNames: []string{"container1"}, From: kapi.ObjectReference{Namespace: metav1.NamespaceDefault, Name: imageapi.JoinImageStreamTag("other-stream", imageapi.DefaultImageTag)}, @@ -221,10 +221,10 @@ func TestProcess_matchScenarios(t *testing.T) { image := "registry:5000/openshift/test-image-stream@sha256:0000000000000000000000000000000000000000000000000000000000000001" return image }, - param: &deployapi.DeploymentTriggerImageChangeParams{ + param: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: true, ContainerNames: []string{"container1"}, - From: kapi.ObjectReference{Name: imageapi.JoinImageStreamTag(deploytest.ImageStreamName, imageapi.DefaultImageTag)}, + From: kapi.ObjectReference{Name: imageapi.JoinImageStreamTag(appstest.ImageStreamName, imageapi.DefaultImageTag)}, LastTriggeredImage: "", }, notFound: false, @@ -243,15 +243,15 @@ func TestProcess_matchScenarios(t *testing.T) { name := action.(clientgotesting.GetAction).GetName() return true, nil, errors.NewNotFound(imageapi.Resource("ImageStream"), name) } - stream := fakeStream(deploytest.ImageStreamName, imageapi.DefaultImageTag, deploytest.DockerImageReference, deploytest.ImageID) + stream := fakeStream(appstest.ImageStreamName, imageapi.DefaultImageTag, appstest.DockerImageReference, appstest.ImageID) return true, stream, nil }) - config := deploytest.OkDeploymentConfig(1) + config := appstest.OkDeploymentConfig(1) config.Namespace = metav1.NamespaceDefault - config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{ + config.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{ { - Type: deployapi.DeploymentTriggerOnImageChange, + Type: appsapi.DeploymentTriggerOnImageChange, ImageChangeParams: test.param, }, } @@ -302,32 +302,32 @@ func TestCanTrigger(t *testing.T) { tests := []struct { name string - config *deployapi.DeploymentConfig - decoded *deployapi.DeploymentConfig + config *appsapi.DeploymentConfig + decoded *appsapi.DeploymentConfig force bool expected bool - expectedCauses []deployapi.DeploymentCause + expectedCauses []appsapi.DeploymentCause expectedErr bool }{ { name: "no trigger [w/ podtemplate change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Triggers: []deployapi.DeploymentTriggerPolicy{}, - Template: deploytest.OkPodTemplateChanged(), + Spec: appsapi.DeploymentConfigSpec{ + Triggers: []appsapi.DeploymentTriggerPolicy{}, + Template: appstest.OkPodTemplateChanged(), }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Triggers: []deployapi.DeploymentTriggerPolicy{}, - Template: deploytest.OkPodTemplate(), + Spec: appsapi.DeploymentConfigSpec{ + Triggers: []appsapi.DeploymentTriggerPolicy{}, + Template: appstest.OkPodTemplate(), }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, force: false, @@ -337,103 +337,103 @@ func TestCanTrigger(t *testing.T) { { name: "forced updated", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplateChanged(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplateChanged(), }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, force: true, expected: true, - expectedCauses: []deployapi.DeploymentCause{{Type: deployapi.DeploymentTriggerManual}}, + expectedCauses: []appsapi.DeploymentCause{{Type: appsapi.DeploymentTriggerManual}}, }, { name: "config change trigger only [w/ podtemplate change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplateChanged(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplateChanged(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, force: false, expected: true, - expectedCauses: deploytest.OkConfigChangeDetails().Causes, + expectedCauses: appstest.OkConfigChangeDetails().Causes, }, { name: "config change trigger only [no change][initial]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), }, }, - Status: deploytest.OkDeploymentConfigStatus(0), + Status: appstest.OkDeploymentConfigStatus(0), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), }, }, - Status: deploytest.OkDeploymentConfigStatus(0), + Status: appstest.OkDeploymentConfigStatus(0), }, force: false, expected: true, - expectedCauses: deploytest.OkConfigChangeDetails().Causes, + expectedCauses: appstest.OkConfigChangeDetails().Causes, }, { name: "config change trigger only [no change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, force: false, @@ -443,25 +443,25 @@ func TestCanTrigger(t *testing.T) { { name: "image change trigger only [automatic=false][w/ podtemplate change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplateChanged(), // Irrelevant change - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkNonAutomaticICT(), // Image still to be resolved but it's false anyway + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplateChanged(), // Irrelevant change + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkNonAutomaticICT(), // Image still to be resolved but it's false anyway }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkNonAutomaticICT(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkNonAutomaticICT(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, force: false, @@ -472,25 +472,25 @@ func TestCanTrigger(t *testing.T) { { name: "image change trigger only [automatic=false][w/ image change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplateChanged(), // Image has been updated in the template but automatic=false - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkTriggeredNonAutomatic(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplateChanged(), // Image has been updated in the template but automatic=false + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkTriggeredNonAutomatic(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkNonAutomaticICT(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkNonAutomaticICT(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, force: false, @@ -500,53 +500,53 @@ func TestCanTrigger(t *testing.T) { { name: "image change trigger only [automatic=true][w/ image change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplateChanged(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkTriggeredImageChange(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplateChanged(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkTriggeredImageChange(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkImageChangeTrigger(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkImageChangeTrigger(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, force: false, expected: true, - expectedCauses: deploytest.OkImageChangeDetails().Causes, + expectedCauses: appstest.OkImageChangeDetails().Causes, }, { name: "image change trigger only [automatic=true][no change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplateChanged(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkTriggeredImageChange(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplateChanged(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkTriggeredImageChange(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplateChanged(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkTriggeredImageChange(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplateChanged(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkTriggeredImageChange(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, force: false, @@ -556,57 +556,57 @@ func TestCanTrigger(t *testing.T) { { name: "config change and image change trigger [automatic=false][initial][w/ image change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplateChanged(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), - deploytest.OkTriggeredNonAutomatic(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplateChanged(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), + appstest.OkTriggeredNonAutomatic(), }, }, - Status: deploytest.OkDeploymentConfigStatus(0), + Status: appstest.OkDeploymentConfigStatus(0), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), - deploytest.OkNonAutomaticICT(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), + appstest.OkNonAutomaticICT(), }, }, - Status: deploytest.OkDeploymentConfigStatus(0), + Status: appstest.OkDeploymentConfigStatus(0), }, force: false, expected: true, - expectedCauses: deploytest.OkConfigChangeDetails().Causes, + expectedCauses: appstest.OkConfigChangeDetails().Causes, }, { name: "config change and image change trigger [automatic=false][initial][no change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), - deploytest.OkNonAutomaticICT(), // Image is not resolved yet + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), + appstest.OkNonAutomaticICT(), // Image is not resolved yet }, }, - Status: deploytest.OkDeploymentConfigStatus(0), + Status: appstest.OkDeploymentConfigStatus(0), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), - deploytest.OkNonAutomaticICT(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), + appstest.OkNonAutomaticICT(), }, }, - Status: deploytest.OkDeploymentConfigStatus(0), + Status: appstest.OkDeploymentConfigStatus(0), }, force: false, @@ -617,27 +617,27 @@ func TestCanTrigger(t *testing.T) { { name: "config change and image change trigger [automatic=true][initial][w/ podtemplate change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplateChanged(), // Pod template has changed but the image in the template is yet to be updated - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), - deploytest.OkImageChangeTrigger(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplateChanged(), // Pod template has changed but the image in the template is yet to be updated + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), + appstest.OkImageChangeTrigger(), }, }, - Status: deploytest.OkDeploymentConfigStatus(0), + Status: appstest.OkDeploymentConfigStatus(0), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), - deploytest.OkImageChangeTrigger(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), + appstest.OkImageChangeTrigger(), }, }, - Status: deploytest.OkDeploymentConfigStatus(0), + Status: appstest.OkDeploymentConfigStatus(0), }, force: false, @@ -648,46 +648,46 @@ func TestCanTrigger(t *testing.T) { { name: "config change and image change trigger [automatic=true][initial][w/ image change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplateChanged(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), - deploytest.OkTriggeredImageChange(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplateChanged(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), + appstest.OkTriggeredImageChange(), }, }, - Status: deploytest.OkDeploymentConfigStatus(0), + Status: appstest.OkDeploymentConfigStatus(0), }, - decoded: &deployapi.DeploymentConfig{ + decoded: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplate(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), - deploytest.OkImageChangeTrigger(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplate(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), + appstest.OkImageChangeTrigger(), }, }, - Status: deploytest.OkDeploymentConfigStatus(0), + Status: appstest.OkDeploymentConfigStatus(0), }, force: false, expected: true, - expectedCauses: deploytest.OkImageChangeDetails().Causes, + expectedCauses: appstest.OkImageChangeDetails().Causes, }, { name: "config change and image change trigger [automatic=true][no change]", - config: &deployapi.DeploymentConfig{ + config: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "config"}, - Spec: deployapi.DeploymentConfigSpec{ - Template: deploytest.OkPodTemplateChanged(), - Triggers: []deployapi.DeploymentTriggerPolicy{ - deploytest.OkConfigChangeTrigger(), - deploytest.OkTriggeredImageChange(), + Spec: appsapi.DeploymentConfigSpec{ + Template: appstest.OkPodTemplateChanged(), + Triggers: []appsapi.DeploymentTriggerPolicy{ + appstest.OkConfigChangeTrigger(), + appstest.OkTriggeredImageChange(), }, }, - Status: deploytest.OkDeploymentConfigStatus(1), + Status: appstest.OkDeploymentConfigStatus(1), }, force: false, @@ -705,12 +705,12 @@ func TestCanTrigger(t *testing.T) { if config == nil { config = test.config } - config = deploytest.RoundTripConfig(t, config) - deployment, _ := deployutil.MakeDeployment(config, codec) + config = appstest.RoundTripConfig(t, config) + deployment, _ := appsutil.MakeDeployment(config, codec) return true, deployment, nil }) - test.config = deploytest.RoundTripConfig(t, test.config) + test.config = appstest.RoundTripConfig(t, test.config) got, gotCauses, err := canTrigger(test.config, client.Core(), codec, test.force) if err != nil && !test.expectedErr { diff --git a/pkg/apps/registry/instantiate/strategy.go b/pkg/apps/registry/instantiate/strategy.go index 7e55dafdfb06..e64f1f176e07 100644 --- a/pkg/apps/registry/instantiate/strategy.go +++ b/pkg/apps/registry/instantiate/strategy.go @@ -9,7 +9,7 @@ import ( apirequest "k8s.io/apiserver/pkg/endpoints/request" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/apps/apis/apps/validation" ) @@ -41,8 +41,8 @@ func (strategy) PrepareForCreate(ctx apirequest.Context, obj runtime.Object) { // PrepareForUpdate clears fields that are not allowed to be set by the instantiate endpoint. func (strategy) PrepareForUpdate(ctx apirequest.Context, obj, old runtime.Object) { - newDc := obj.(*deployapi.DeploymentConfig) - oldDc := old.(*deployapi.DeploymentConfig) + newDc := obj.(*appsapi.DeploymentConfig) + oldDc := old.(*appsapi.DeploymentConfig) // Allow the status fields that need to be updated in every instantiation. oldStatus := oldDc.Status @@ -66,10 +66,10 @@ func (strategy) CheckGracefulDelete(obj runtime.Object, options *metav1.DeleteOp // Validate is a no-op for the instantiate endpoint. func (strategy) Validate(ctx apirequest.Context, obj runtime.Object) field.ErrorList { - return validation.ValidateDeploymentConfig(obj.(*deployapi.DeploymentConfig)) + return validation.ValidateDeploymentConfig(obj.(*appsapi.DeploymentConfig)) } // ValidateUpdate is the default update validation for the instantiate endpoint. func (strategy) ValidateUpdate(ctx apirequest.Context, obj, old runtime.Object) field.ErrorList { - return validation.ValidateDeploymentConfigUpdate(obj.(*deployapi.DeploymentConfig), old.(*deployapi.DeploymentConfig)) + return validation.ValidateDeploymentConfigUpdate(obj.(*appsapi.DeploymentConfig), old.(*appsapi.DeploymentConfig)) } diff --git a/pkg/apps/registry/rest.go b/pkg/apps/registry/rest.go index e85cc787133d..564f91a62948 100644 --- a/pkg/apps/registry/rest.go +++ b/pkg/apps/registry/rest.go @@ -12,8 +12,8 @@ import ( kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" "github.com/golang/glog" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" ) var ( @@ -52,10 +52,10 @@ func WaitForRunningDeployment(rn kcoreclient.ReplicationControllersGetter, obser return false, fmt.Errorf("received unknown object while watching for deployments: %v", obj) } observed = obj - switch deployutil.DeploymentStatusFor(observed) { - case deployapi.DeploymentStatusRunning, deployapi.DeploymentStatusFailed, deployapi.DeploymentStatusComplete: + switch appsutil.DeploymentStatusFor(observed) { + case appsapi.DeploymentStatusRunning, appsapi.DeploymentStatusFailed, appsapi.DeploymentStatusComplete: return true, nil - case deployapi.DeploymentStatusNew, deployapi.DeploymentStatusPending: + case appsapi.DeploymentStatusNew, appsapi.DeploymentStatusPending: return false, nil default: return false, ErrUnknownDeploymentPhase diff --git a/pkg/apps/registry/rest_test.go b/pkg/apps/registry/rest_test.go index 82e0116b0c08..256a41643f05 100644 --- a/pkg/apps/registry/rest_test.go +++ b/pkg/apps/registry/rest_test.go @@ -11,7 +11,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) func TestWaitForRunningDeploymentSuccess(t *testing.T) { @@ -38,7 +38,7 @@ func TestWaitForRunningDeploymentSuccess(t *testing.T) { } }() - fakeController.Annotations = map[string]string{deployapi.DeploymentStatusAnnotation: string(deployapi.DeploymentStatusRunning)} + fakeController.Annotations = map[string]string{appsapi.DeploymentStatusAnnotation: string(appsapi.DeploymentStatusRunning)} fakeWatch.Modify(fakeController) <-stopChan } @@ -101,7 +101,7 @@ func TestWaitForRunningDeploymentRestartWatch(t *testing.T) { // running state. select { case <-watchCalledChan: - fakeController.Annotations = map[string]string{deployapi.DeploymentStatusAnnotation: string(deployapi.DeploymentStatusRunning)} + fakeController.Annotations = map[string]string{appsapi.DeploymentStatusAnnotation: string(appsapi.DeploymentStatusRunning)} fakeWatch.Modify(fakeController) <-stopChan case <-time.After(time.Second * 5): diff --git a/pkg/apps/registry/rollback/rest.go b/pkg/apps/registry/rollback/rest.go index a3d5ee1a31bd..e74cc2969974 100644 --- a/pkg/apps/registry/rollback/rest.go +++ b/pkg/apps/registry/rollback/rest.go @@ -12,11 +12,11 @@ import ( kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/apps/apis/apps/validation" appsclientinternal "github.com/openshift/origin/pkg/apps/generated/internalclientset" apps "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" ) // REST provides a rollback generation endpoint. Only the Create method is implemented. @@ -41,7 +41,7 @@ func NewREST(appsclient appsclientinternal.Interface, kc kclientset.Interface, c // New creates an empty DeploymentConfigRollback resource func (r *REST) New() runtime.Object { - return &deployapi.DeploymentConfigRollback{} + return &appsapi.DeploymentConfigRollback{} } // Create generates a new DeploymentConfig representing a rollback. @@ -50,13 +50,13 @@ func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runti if !ok { return nil, kerrors.NewBadRequest("namespace parameter required.") } - rollback, ok := obj.(*deployapi.DeploymentConfigRollback) + rollback, ok := obj.(*appsapi.DeploymentConfigRollback) if !ok { return nil, kerrors.NewBadRequest(fmt.Sprintf("not a rollback spec: %#v", obj)) } if errs := validation.ValidateDeploymentConfigRollback(rollback); len(errs) > 0 { - return nil, kerrors.NewInvalid(deployapi.Kind("DeploymentConfigRollback"), rollback.Name, errs) + return nil, kerrors.NewInvalid(appsapi.Kind("DeploymentConfigRollback"), rollback.Name, errs) } from, err := r.dn.DeploymentConfigs(namespace).Get(rollback.Name, metav1.GetOptions{}) @@ -68,7 +68,7 @@ func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runti case 0: return nil, newInvalidError(rollback, "cannot rollback an undeployed config") case 1: - return nil, newInvalidError(rollback, fmt.Sprintf("no previous deployment exists for %q", deployutil.LabelForDeploymentConfig(from))) + return nil, newInvalidError(rollback, fmt.Sprintf("no previous deployment exists for %q", appsutil.LabelForDeploymentConfig(from))) case rollback.Spec.Revision: return nil, newInvalidError(rollback, fmt.Sprintf("version %d is already the latest", rollback.Spec.Revision)) } @@ -79,13 +79,13 @@ func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runti } // Find the target deployment and decode its config. - name := deployutil.DeploymentNameForConfigVersion(from.Name, revision) + name := appsutil.DeploymentNameForConfigVersion(from.Name, revision) targetDeployment, err := r.rn.ReplicationControllers(namespace).Get(name, metav1.GetOptions{}) if err != nil { return nil, newInvalidError(rollback, err.Error()) } - to, err := deployutil.DecodeDeploymentConfig(targetDeployment, r.codec) + to, err := appsutil.DecodeDeploymentConfig(targetDeployment, r.codec) if err != nil { return nil, newInvalidError(rollback, fmt.Sprintf("couldn't decode deployment config from deployment: %v", err)) } @@ -100,7 +100,7 @@ func (r *REST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runti return r.generator.GenerateRollback(from, to, &rollback.Spec) } -func newInvalidError(rollback *deployapi.DeploymentConfigRollback, reason string) error { +func newInvalidError(rollback *appsapi.DeploymentConfigRollback, reason string) error { err := field.Invalid(field.NewPath("name"), rollback.Name, reason) - return kerrors.NewInvalid(deployapi.Kind("DeploymentConfigRollback"), rollback.Name, field.ErrorList{err}) + return kerrors.NewInvalid(appsapi.Kind("DeploymentConfigRollback"), rollback.Name, field.ErrorList{err}) } diff --git a/pkg/apps/registry/rollback/rest_deprecated.go b/pkg/apps/registry/rollback/rest_deprecated.go index d5421c16610f..87f1f78abbd9 100644 --- a/pkg/apps/registry/rollback/rest_deprecated.go +++ b/pkg/apps/registry/rollback/rest_deprecated.go @@ -12,10 +12,10 @@ import ( kapi "k8s.io/kubernetes/pkg/api" coreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/apps/apis/apps/validation" - deployclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" + appsutil "github.com/openshift/origin/pkg/apps/util" ) // REST provides a rollback generation endpoint. Only the Create method is implemented. @@ -28,18 +28,18 @@ var _ rest.Creater = &REST{} // GeneratorClient defines a local interface to a rollback generator for testability. type GeneratorClient interface { - GenerateRollback(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) + GenerateRollback(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) GetDeployment(ctx apirequest.Context, name string, options *metav1.GetOptions) (*kapi.ReplicationController, error) - GetDeploymentConfig(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error) + GetDeploymentConfig(ctx apirequest.Context, name string, options *metav1.GetOptions) (*appsapi.DeploymentConfig, error) } type Client struct { - GRFn func(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) - DeploymentConfigGetter deployclient.DeploymentConfigsGetter + GRFn func(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) + DeploymentConfigGetter appsclient.DeploymentConfigsGetter ReplicationControllerGetter coreclient.ReplicationControllersGetter } -func (c Client) GetDeploymentConfig(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error) { +func (c Client) GetDeploymentConfig(ctx apirequest.Context, name string, options *metav1.GetOptions) (*appsapi.DeploymentConfig, error) { return c.DeploymentConfigGetter.DeploymentConfigs(apirequest.NamespaceValue(ctx)).Get(name, *options) } @@ -47,7 +47,7 @@ func (c Client) GetDeployment(ctx apirequest.Context, name string, options *meta return c.ReplicationControllerGetter.ReplicationControllers(apirequest.NamespaceValue(ctx)).Get(name, *options) } -func (c Client) GenerateRollback(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) { +func (c Client) GenerateRollback(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) { return c.GRFn(from, to, spec) } @@ -61,18 +61,18 @@ func NewDeprecatedREST(generator GeneratorClient, codec runtime.Codec) *Deprecat // New creates an empty DeploymentConfigRollback resource func (s *DeprecatedREST) New() runtime.Object { - return &deployapi.DeploymentConfigRollback{} + return &appsapi.DeploymentConfigRollback{} } // Create generates a new DeploymentConfig representing a rollback. func (s *DeprecatedREST) Create(ctx apirequest.Context, obj runtime.Object, _ bool) (runtime.Object, error) { - rollback, ok := obj.(*deployapi.DeploymentConfigRollback) + rollback, ok := obj.(*appsapi.DeploymentConfigRollback) if !ok { return nil, kerrors.NewBadRequest(fmt.Sprintf("not a rollback spec: %#v", obj)) } if errs := validation.ValidateDeploymentConfigRollbackDeprecated(rollback); len(errs) > 0 { - return nil, kerrors.NewInvalid(deployapi.Kind("DeploymentConfigRollback"), "", errs) + return nil, kerrors.NewInvalid(appsapi.Kind("DeploymentConfigRollback"), "", errs) } // Roll back "from" the current deployment "to" a target deployment @@ -86,7 +86,7 @@ func (s *DeprecatedREST) Create(ctx apirequest.Context, obj runtime.Object, _ bo return nil, newInvalidDeploymentError(rollback, fmt.Sprintf("%v", err)) } - to, err := deployutil.DecodeDeploymentConfig(targetDeployment, s.codec) + to, err := appsutil.DecodeDeploymentConfig(targetDeployment, s.codec) if err != nil { return nil, newInvalidDeploymentError(rollback, fmt.Sprintf("couldn't decode DeploymentConfig from Deployment: %v", err)) @@ -106,7 +106,7 @@ func (s *DeprecatedREST) Create(ctx apirequest.Context, obj runtime.Object, _ bo return s.generator.GenerateRollback(from, to, &rollback.Spec) } -func newInvalidDeploymentError(rollback *deployapi.DeploymentConfigRollback, reason string) error { +func newInvalidDeploymentError(rollback *appsapi.DeploymentConfigRollback, reason string) error { err := field.Invalid(field.NewPath("spec").Child("from").Child("name"), rollback.Spec.From.Name, reason) - return kerrors.NewInvalid(deployapi.Kind("DeploymentConfigRollback"), "", field.ErrorList{err}) + return kerrors.NewInvalid(appsapi.Kind("DeploymentConfigRollback"), "", field.ErrorList{err}) } diff --git a/pkg/apps/registry/rollback/rest_deprecated_test.go b/pkg/apps/registry/rollback/rest_deprecated_test.go index 46dd4a6a118a..78b78bfc2548 100644 --- a/pkg/apps/registry/rollback/rest_deprecated_test.go +++ b/pkg/apps/registry/rollback/rest_deprecated_test.go @@ -11,16 +11,16 @@ import ( apirequest "k8s.io/apiserver/pkg/endpoints/request" kapi "k8s.io/kubernetes/pkg/api" - deployv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" _ "github.com/openshift/origin/pkg/apps/apis/apps/install" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" - deployutil "github.com/openshift/origin/pkg/apps/util" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsutil "github.com/openshift/origin/pkg/apps/util" ) func TestCreateErrorDepr(t *testing.T) { rest := DeprecatedREST{} - obj, err := rest.Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfig{}, false) + obj, err := rest.Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfig{}, false) if err == nil { t.Errorf("Expected an error") @@ -33,7 +33,7 @@ func TestCreateErrorDepr(t *testing.T) { func TestCreateInvalidDepr(t *testing.T) { rest := DeprecatedREST{} - obj, err := rest.Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{}, false) + obj, err := rest.Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{}, false) if err == nil { t.Errorf("Expected an error") @@ -47,22 +47,22 @@ func TestCreateInvalidDepr(t *testing.T) { func TestCreateOkDepr(t *testing.T) { rest := DeprecatedREST{ generator: TestClient{ - GRFn: func(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) { - return &deployapi.DeploymentConfig{}, nil + GRFn: func(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) { + return &appsapi.DeploymentConfig{}, nil }, RCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*kapi.ReplicationController, error) { - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) return deployment, nil }, - DCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error) { - return deploytest.OkDeploymentConfig(1), nil + DCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*appsapi.DeploymentConfig, error) { + return appstest.OkDeploymentConfig(1), nil }, }, - codec: kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion), + codec: kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion), } - obj, err := rest.Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{ - Spec: deployapi.DeploymentConfigRollbackSpec{ + obj, err := rest.Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{ + Spec: appsapi.DeploymentConfigRollbackSpec{ From: kapi.ObjectReference{ Name: "deployment", Namespace: metav1.NamespaceDefault, @@ -78,7 +78,7 @@ func TestCreateOkDepr(t *testing.T) { t.Errorf("Expected a result obj") } - if _, ok := obj.(*deployapi.DeploymentConfig); !ok { + if _, ok := obj.(*appsapi.DeploymentConfig); !ok { t.Errorf("expected a DeploymentConfig, got a %#v", obj) } } @@ -86,22 +86,22 @@ func TestCreateOkDepr(t *testing.T) { func TestCreateGeneratorErrorDepr(t *testing.T) { rest := DeprecatedREST{ generator: TestClient{ - GRFn: func(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) { + GRFn: func(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) { return nil, kerrors.NewInternalError(fmt.Errorf("something terrible happened")) }, RCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*kapi.ReplicationController, error) { - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) return deployment, nil }, - DCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error) { - return deploytest.OkDeploymentConfig(1), nil + DCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*appsapi.DeploymentConfig, error) { + return appstest.OkDeploymentConfig(1), nil }, }, - codec: kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion), + codec: kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion), } - _, err := rest.Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{ - Spec: deployapi.DeploymentConfigRollbackSpec{ + _, err := rest.Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{ + Spec: appsapi.DeploymentConfigRollbackSpec{ From: kapi.ObjectReference{ Name: "deployment", Namespace: metav1.NamespaceDefault, @@ -117,24 +117,24 @@ func TestCreateGeneratorErrorDepr(t *testing.T) { func TestCreateMissingDeploymentDepr(t *testing.T) { rest := DeprecatedREST{ generator: TestClient{ - GRFn: func(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) { + GRFn: func(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) { t.Fatal("unexpected call to generator") return nil, errors.New("something terrible happened") }, RCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*kapi.ReplicationController, error) { return nil, kerrors.NewNotFound(kapi.Resource("replicationController"), name) }, - DCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error) { + DCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*appsapi.DeploymentConfig, error) { namespace, _ := apirequest.NamespaceFrom(ctx) t.Fatalf("unexpected call to GetDeploymentConfig(%s/%s)", namespace, name) - return nil, kerrors.NewNotFound(deployapi.Resource("deploymentConfig"), name) + return nil, kerrors.NewNotFound(appsapi.Resource("deploymentConfig"), name) }, }, - codec: kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion), + codec: kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion), } - obj, err := rest.Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{ - Spec: deployapi.DeploymentConfigRollbackSpec{ + obj, err := rest.Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{ + Spec: appsapi.DeploymentConfigRollbackSpec{ From: kapi.ObjectReference{ Name: "deployment", Namespace: metav1.NamespaceDefault, @@ -154,27 +154,27 @@ func TestCreateMissingDeploymentDepr(t *testing.T) { func TestCreateInvalidDeploymentDepr(t *testing.T) { rest := DeprecatedREST{ generator: TestClient{ - GRFn: func(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) { + GRFn: func(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) { t.Fatal("unexpected call to generator") return nil, errors.New("something terrible happened") }, RCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*kapi.ReplicationController, error) { // invalidate the encoded config - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) - deployment.Annotations[deployapi.DeploymentEncodedConfigAnnotation] = "" + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) + deployment.Annotations[appsapi.DeploymentEncodedConfigAnnotation] = "" return deployment, nil }, - DCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error) { + DCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*appsapi.DeploymentConfig, error) { namespace, _ := apirequest.NamespaceFrom(ctx) t.Fatalf("unexpected call to GetDeploymentConfig(%s/%s)", namespace, name) - return nil, kerrors.NewNotFound(deployapi.Resource("deploymentConfig"), name) + return nil, kerrors.NewNotFound(appsapi.Resource("deploymentConfig"), name) }, }, - codec: kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion), + codec: kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion), } - obj, err := rest.Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{ - Spec: deployapi.DeploymentConfigRollbackSpec{ + obj, err := rest.Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{ + Spec: appsapi.DeploymentConfigRollbackSpec{ From: kapi.ObjectReference{ Name: "deployment", Namespace: metav1.NamespaceDefault, @@ -194,23 +194,23 @@ func TestCreateInvalidDeploymentDepr(t *testing.T) { func TestCreateMissingDeploymentConfigDepr(t *testing.T) { rest := DeprecatedREST{ generator: TestClient{ - GRFn: func(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) { + GRFn: func(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) { t.Fatal("unexpected call to generator") return nil, errors.New("something terrible happened") }, RCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*kapi.ReplicationController, error) { - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) return deployment, nil }, - DCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error) { - return nil, kerrors.NewNotFound(deployapi.Resource("deploymentConfig"), name) + DCFn: func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*appsapi.DeploymentConfig, error) { + return nil, kerrors.NewNotFound(appsapi.Resource("deploymentConfig"), name) }, }, - codec: kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion), + codec: kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion), } - obj, err := rest.Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{ - Spec: deployapi.DeploymentConfigRollbackSpec{ + obj, err := rest.Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{ + Spec: appsapi.DeploymentConfigRollbackSpec{ From: kapi.ObjectReference{ Name: "deployment", Namespace: metav1.NamespaceDefault, @@ -229,19 +229,19 @@ func TestCreateMissingDeploymentConfigDepr(t *testing.T) { func TestNewDepr(t *testing.T) { // :) - rest := NewDeprecatedREST(TestClient{}, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + rest := NewDeprecatedREST(TestClient{}, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) rest.New() } // Client provides an implementation of Generator client type TestClient struct { - GRFn func(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) + GRFn func(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) RCFn func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*kapi.ReplicationController, error) - DCFn func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error) + DCFn func(ctx apirequest.Context, name string, options *metav1.GetOptions) (*appsapi.DeploymentConfig, error) } // GetDeployment returns the deploymentConfig with the provided context and name -func (c TestClient) GetDeploymentConfig(ctx apirequest.Context, name string, options *metav1.GetOptions) (*deployapi.DeploymentConfig, error) { +func (c TestClient) GetDeploymentConfig(ctx apirequest.Context, name string, options *metav1.GetOptions) (*appsapi.DeploymentConfig, error) { return c.DCFn(ctx, name, options) } @@ -251,6 +251,6 @@ func (c TestClient) GetDeployment(ctx apirequest.Context, name string, options * } // GenerateRollback generates a new deploymentConfig by merging a pair of deploymentConfigs -func (c TestClient) GenerateRollback(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) { +func (c TestClient) GenerateRollback(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) { return c.GRFn(from, to, spec) } diff --git a/pkg/apps/registry/rollback/rest_test.go b/pkg/apps/registry/rollback/rest_test.go index 24fef13ec6bd..bbb95db0d994 100644 --- a/pkg/apps/registry/rollback/rest_test.go +++ b/pkg/apps/registry/rollback/rest_test.go @@ -12,19 +12,19 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" - deployv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" _ "github.com/openshift/origin/pkg/apps/apis/apps/install" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" appsfake "github.com/openshift/origin/pkg/apps/generated/internalclientset/fake" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" ) -var codec = kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion) +var codec = kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion) type terribleGenerator struct{} -func (tg *terribleGenerator) GenerateRollback(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) { +func (tg *terribleGenerator) GenerateRollback(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) { return nil, kerrors.NewInternalError(errors.New("something terrible happened")) } @@ -32,7 +32,7 @@ var _ RollbackGenerator = &terribleGenerator{} func TestCreateError(t *testing.T) { rest := REST{} - obj, err := rest.Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfig{}, false) + obj, err := rest.Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfig{}, false) if err == nil { t.Errorf("Expected an error") @@ -45,7 +45,7 @@ func TestCreateError(t *testing.T) { func TestCreateInvalid(t *testing.T) { rest := REST{} - obj, err := rest.Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{}, false) + obj, err := rest.Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{}, false) if err == nil { t.Errorf("Expected an error") @@ -59,17 +59,17 @@ func TestCreateInvalid(t *testing.T) { func TestCreateOk(t *testing.T) { oc := &appsfake.Clientset{} oc.AddReactor("get", "deploymentconfigs", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - return true, deploytest.OkDeploymentConfig(2), nil + return true, appstest.OkDeploymentConfig(2), nil }) kc := &fake.Clientset{} kc.AddReactor("get", "replicationcontrollers", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), codec) + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), codec) return true, deployment, nil }) - obj, err := NewREST(oc, kc, codec).Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{ + obj, err := NewREST(oc, kc, codec).Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{ Name: "config", - Spec: deployapi.DeploymentConfigRollbackSpec{ + Spec: appsapi.DeploymentConfigRollbackSpec{ Revision: 1, }, }, false) @@ -82,7 +82,7 @@ func TestCreateOk(t *testing.T) { t.Errorf("Expected a result obj") } - if _, ok := obj.(*deployapi.DeploymentConfig); !ok { + if _, ok := obj.(*appsapi.DeploymentConfig); !ok { t.Errorf("expected a deployment config, got a %#v", obj) } } @@ -90,12 +90,12 @@ func TestCreateOk(t *testing.T) { func TestCreateRollbackToLatest(t *testing.T) { oc := &appsfake.Clientset{} oc.AddReactor("get", "deploymentconfigs", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - return true, deploytest.OkDeploymentConfig(2), nil + return true, appstest.OkDeploymentConfig(2), nil }) - _, err := NewREST(oc, &fake.Clientset{}, codec).Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{ + _, err := NewREST(oc, &fake.Clientset{}, codec).Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{ Name: "config", - Spec: deployapi.DeploymentConfigRollbackSpec{ + Spec: appsapi.DeploymentConfigRollbackSpec{ Revision: 2, }, }, false) @@ -111,11 +111,11 @@ func TestCreateRollbackToLatest(t *testing.T) { func TestCreateGeneratorError(t *testing.T) { oc := &appsfake.Clientset{} oc.AddReactor("get", "deploymentconfigs", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - return true, deploytest.OkDeploymentConfig(2), nil + return true, appstest.OkDeploymentConfig(2), nil }) kc := &fake.Clientset{} kc.AddReactor("get", "replicationcontrollers", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), codec) + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), codec) return true, deployment, nil }) @@ -123,12 +123,12 @@ func TestCreateGeneratorError(t *testing.T) { generator: &terribleGenerator{}, dn: oc.Apps(), rn: kc.Core(), - codec: kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion), + codec: kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion), } - _, err := rest.Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{ + _, err := rest.Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{ Name: "config", - Spec: deployapi.DeploymentConfigRollbackSpec{ + Spec: appsapi.DeploymentConfigRollbackSpec{ Revision: 1, }, }, false) @@ -141,17 +141,17 @@ func TestCreateGeneratorError(t *testing.T) { func TestCreateMissingDeployment(t *testing.T) { oc := &appsfake.Clientset{} oc.AddReactor("get", "deploymentconfigs", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - return true, deploytest.OkDeploymentConfig(2), nil + return true, appstest.OkDeploymentConfig(2), nil }) kc := &fake.Clientset{} kc.AddReactor("get", "replicationcontrollers", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), codec) + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), codec) return true, nil, kerrors.NewNotFound(kapi.Resource("replicationController"), deployment.Name) }) - obj, err := NewREST(oc, kc, codec).Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{ + obj, err := NewREST(oc, kc, codec).Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{ Name: "config", - Spec: deployapi.DeploymentConfigRollbackSpec{ + Spec: appsapi.DeploymentConfigRollbackSpec{ Revision: 1, }, }, false) @@ -168,19 +168,19 @@ func TestCreateMissingDeployment(t *testing.T) { func TestCreateInvalidDeployment(t *testing.T) { oc := &appsfake.Clientset{} oc.AddReactor("get", "deploymentconfigs", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - return true, deploytest.OkDeploymentConfig(2), nil + return true, appstest.OkDeploymentConfig(2), nil }) kc := &fake.Clientset{} kc.AddReactor("get", "replicationcontrollers", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { // invalidate the encoded config - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), codec) - deployment.Annotations[deployapi.DeploymentEncodedConfigAnnotation] = "" + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), codec) + deployment.Annotations[appsapi.DeploymentEncodedConfigAnnotation] = "" return true, deployment, nil }) - obj, err := NewREST(oc, kc, codec).Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{ + obj, err := NewREST(oc, kc, codec).Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{ Name: "config", - Spec: deployapi.DeploymentConfigRollbackSpec{ + Spec: appsapi.DeploymentConfigRollbackSpec{ Revision: 1, }, }, false) @@ -197,18 +197,18 @@ func TestCreateInvalidDeployment(t *testing.T) { func TestCreateMissingDeploymentConfig(t *testing.T) { oc := &appsfake.Clientset{} oc.AddReactor("get", "deploymentconfigs", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - dc := deploytest.OkDeploymentConfig(2) - return true, nil, kerrors.NewNotFound(deployapi.Resource("deploymentConfig"), dc.Name) + dc := appstest.OkDeploymentConfig(2) + return true, nil, kerrors.NewNotFound(appsapi.Resource("deploymentConfig"), dc.Name) }) kc := &fake.Clientset{} kc.AddReactor("get", "replicationcontrollers", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), codec) + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), codec) return true, deployment, nil }) - obj, err := NewREST(oc, kc, codec).Create(apirequest.NewDefaultContext(), &deployapi.DeploymentConfigRollback{ + obj, err := NewREST(oc, kc, codec).Create(apirequest.NewDefaultContext(), &appsapi.DeploymentConfigRollback{ Name: "config", - Spec: deployapi.DeploymentConfigRollbackSpec{ + Spec: appsapi.DeploymentConfigRollbackSpec{ Revision: 1, }, }, false) diff --git a/pkg/apps/registry/rollback/rollback_generator.go b/pkg/apps/registry/rollback/rollback_generator.go index 55a35e199463..d0d6dfa2336f 100644 --- a/pkg/apps/registry/rollback/rollback_generator.go +++ b/pkg/apps/registry/rollback/rollback_generator.go @@ -5,7 +5,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) // RollbackGenerator generates a new deployment config by merging a pair of deployment @@ -19,7 +19,7 @@ type RollbackGenerator interface { // // Any image change triggers on the new config are disabled to prevent // triggered deployments from immediately replacing the rollback. - GenerateRollback(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) + GenerateRollback(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) } // NewRollbackGenerator returns a new rollback generator. @@ -29,8 +29,8 @@ func NewRollbackGenerator() RollbackGenerator { type rollbackGenerator struct{} -func (g *rollbackGenerator) GenerateRollback(from, to *deployapi.DeploymentConfig, spec *deployapi.DeploymentConfigRollbackSpec) (*deployapi.DeploymentConfig, error) { - rollback := &deployapi.DeploymentConfig{} +func (g *rollbackGenerator) GenerateRollback(from, to *appsapi.DeploymentConfig, spec *appsapi.DeploymentConfigRollbackSpec) (*appsapi.DeploymentConfig, error) { + rollback := &appsapi.DeploymentConfig{} if err := kapi.Scheme.Convert(&from, &rollback, nil); err != nil { return nil, fmt.Errorf("couldn't clone 'from' DeploymentConfig: %v", err) @@ -65,7 +65,7 @@ func (g *rollbackGenerator) GenerateRollback(from, to *deployapi.DeploymentConfi // Disable any image change triggers. for _, trigger := range rollback.Spec.Triggers { - if trigger.Type == deployapi.DeploymentTriggerOnImageChange { + if trigger.Type == appsapi.DeploymentTriggerOnImageChange { trigger.ImageChangeParams.Automatic = false } } diff --git a/pkg/apps/registry/rollback/rollback_generator_test.go b/pkg/apps/registry/rollback/rollback_generator_test.go index 77326e6d257d..fba00f40078c 100644 --- a/pkg/apps/registry/rollback/rollback_generator_test.go +++ b/pkg/apps/registry/rollback/rollback_generator_test.go @@ -7,17 +7,17 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kapihelper "k8s.io/kubernetes/pkg/api/helper" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" ) func TestGeneration(t *testing.T) { - from := deploytest.OkDeploymentConfig(2) - from.Spec.Strategy = deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeCustom, + from := appstest.OkDeploymentConfig(2) + from.Spec.Strategy = appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeCustom, } - from.Spec.Triggers = append(from.Spec.Triggers, deployapi.DeploymentTriggerPolicy{Type: deployapi.DeploymentTriggerOnConfigChange}) - from.Spec.Triggers = append(from.Spec.Triggers, deploytest.OkImageChangeTrigger()) + from.Spec.Triggers = append(from.Spec.Triggers, appsapi.DeploymentTriggerPolicy{Type: appsapi.DeploymentTriggerOnConfigChange}) + from.Spec.Triggers = append(from.Spec.Triggers, appstest.OkImageChangeTrigger()) from.Spec.Template.Spec.Containers[0].Name = "changed" from.Spec.Replicas = 5 from.Spec.Selector = map[string]string{ @@ -25,12 +25,12 @@ func TestGeneration(t *testing.T) { "new2": "new2", } - to := deploytest.OkDeploymentConfig(1) + to := appstest.OkDeploymentConfig(1) // Generate a rollback for every combination of flag (using 1 bit per flag). - rollbackSpecs := []*deployapi.DeploymentConfigRollbackSpec{} + rollbackSpecs := []*appsapi.DeploymentConfigRollbackSpec{} for i := 0; i < 15; i++ { - spec := &deployapi.DeploymentConfigRollbackSpec{ + spec := &appsapi.DeploymentConfigRollbackSpec{ From: kapi.ObjectReference{ Name: "deployment", Namespace: metav1.NamespaceDefault, @@ -69,7 +69,7 @@ func TestGeneration(t *testing.T) { } for i, trigger := range rollback.Spec.Triggers { - if trigger.Type == deployapi.DeploymentTriggerOnImageChange && trigger.ImageChangeParams.Automatic { + if trigger.Type == appsapi.DeploymentTriggerOnImageChange && trigger.ImageChangeParams.Automatic { t.Errorf("image change trigger %d should be disabled", i) } } @@ -77,11 +77,11 @@ func TestGeneration(t *testing.T) { } } -func hasStrategyDiff(a, b *deployapi.DeploymentConfig) bool { +func hasStrategyDiff(a, b *appsapi.DeploymentConfig) bool { return a.Spec.Strategy.Type != b.Spec.Strategy.Type } -func hasTriggerDiff(a, b *deployapi.DeploymentConfig) bool { +func hasTriggerDiff(a, b *appsapi.DeploymentConfig) bool { if len(a.Spec.Triggers) != len(b.Spec.Triggers) { return true } @@ -103,7 +103,7 @@ func hasTriggerDiff(a, b *deployapi.DeploymentConfig) bool { return false } -func hasReplicationMetaDiff(a, b *deployapi.DeploymentConfig) bool { +func hasReplicationMetaDiff(a, b *appsapi.DeploymentConfig) bool { if a.Spec.Replicas != b.Spec.Replicas { return true } @@ -117,7 +117,7 @@ func hasReplicationMetaDiff(a, b *deployapi.DeploymentConfig) bool { return false } -func hasPodTemplateDiff(a, b *deployapi.DeploymentConfig) bool { +func hasPodTemplateDiff(a, b *appsapi.DeploymentConfig) bool { specA, specB := a.Spec.Template.Spec, b.Spec.Template.Spec return !kapihelper.Semantic.DeepEqual(specA, specB) } diff --git a/pkg/apps/registry/test/deployconfig.go b/pkg/apps/registry/test/deployconfig.go index 6b5dac2200b9..6bccc1ad9282 100644 --- a/pkg/apps/registry/test/deployconfig.go +++ b/pkg/apps/registry/test/deployconfig.go @@ -3,7 +3,7 @@ package test import ( "sync" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" metainternal "k8s.io/apimachinery/pkg/apis/meta/internalversion" "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/labels" @@ -13,8 +13,8 @@ import ( type DeploymentConfigRegistry struct { Err error - DeploymentConfig *deployapi.DeploymentConfig - DeploymentConfigs *deployapi.DeploymentConfigList + DeploymentConfig *appsapi.DeploymentConfig + DeploymentConfigs *appsapi.DeploymentConfigList sync.Mutex } @@ -22,21 +22,21 @@ func NewDeploymentConfigRegistry() *DeploymentConfigRegistry { return &DeploymentConfigRegistry{} } -func (r *DeploymentConfigRegistry) ListDeploymentConfigs(ctx apirequest.Context, label labels.Selector, field fields.Selector) (*deployapi.DeploymentConfigList, error) { +func (r *DeploymentConfigRegistry) ListDeploymentConfigs(ctx apirequest.Context, label labels.Selector, field fields.Selector) (*appsapi.DeploymentConfigList, error) { r.Lock() defer r.Unlock() return r.DeploymentConfigs, r.Err } -func (r *DeploymentConfigRegistry) GetDeploymentConfig(ctx apirequest.Context, id string) (*deployapi.DeploymentConfig, error) { +func (r *DeploymentConfigRegistry) GetDeploymentConfig(ctx apirequest.Context, id string) (*appsapi.DeploymentConfig, error) { r.Lock() defer r.Unlock() return r.DeploymentConfig, r.Err } -func (r *DeploymentConfigRegistry) CreateDeploymentConfig(ctx apirequest.Context, image *deployapi.DeploymentConfig) error { +func (r *DeploymentConfigRegistry) CreateDeploymentConfig(ctx apirequest.Context, image *appsapi.DeploymentConfig) error { r.Lock() defer r.Unlock() @@ -44,7 +44,7 @@ func (r *DeploymentConfigRegistry) CreateDeploymentConfig(ctx apirequest.Context return r.Err } -func (r *DeploymentConfigRegistry) UpdateDeploymentConfig(ctx apirequest.Context, image *deployapi.DeploymentConfig) error { +func (r *DeploymentConfigRegistry) UpdateDeploymentConfig(ctx apirequest.Context, image *appsapi.DeploymentConfig) error { r.Lock() defer r.Unlock() diff --git a/pkg/apps/strategy/recreate/recreate.go b/pkg/apps/strategy/recreate/recreate.go index ac072c943757..e9a48ba13cbb 100644 --- a/pkg/apps/strategy/recreate/recreate.go +++ b/pkg/apps/strategy/recreate/recreate.go @@ -20,11 +20,11 @@ import ( kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" "k8s.io/kubernetes/pkg/kubectl" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" strat "github.com/openshift/origin/pkg/apps/strategy" stratsupport "github.com/openshift/origin/pkg/apps/strategy/support" stratutil "github.com/openshift/origin/pkg/apps/strategy/util" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" imageclient "github.com/openshift/origin/pkg/image/generated/internalclientset/typed/image/internalversion" ) @@ -103,12 +103,12 @@ func (s *RecreateDeploymentStrategy) Deploy(from *kapi.ReplicationController, to // This is currently only used in conjunction with the rolling update strategy // for initial deployments. func (s *RecreateDeploymentStrategy) DeployWithAcceptor(from *kapi.ReplicationController, to *kapi.ReplicationController, desiredReplicas int, updateAcceptor strat.UpdateAcceptor) error { - config, err := deployutil.DecodeDeploymentConfig(to, s.decoder) + config, err := appsutil.DecodeDeploymentConfig(to, s.decoder) if err != nil { return fmt.Errorf("couldn't decode config from deployment %s: %v", to.Name, err) } - retryTimeout := time.Duration(deployapi.DefaultRecreateTimeoutSeconds) * time.Second + retryTimeout := time.Duration(appsapi.DefaultRecreateTimeoutSeconds) * time.Second params := config.Spec.Strategy.RecreateParams rollingParams := config.Spec.Strategy.RollingParams @@ -131,7 +131,7 @@ func (s *RecreateDeploymentStrategy) DeployWithAcceptor(from *kapi.ReplicationCo // Execute any pre-hook. if params != nil && params.Pre != nil { - if err := s.hookExecutor.Execute(params.Pre, to, deployapi.PreHookPodSuffix, "pre"); err != nil { + if err := s.hookExecutor.Execute(params.Pre, to, appsapi.PreHookPodSuffix, "pre"); err != nil { return fmt.Errorf("pre hook failed: %s", err) } } @@ -160,7 +160,7 @@ func (s *RecreateDeploymentStrategy) DeployWithAcceptor(from *kapi.ReplicationCo } if params != nil && params.Mid != nil { - if err := s.hookExecutor.Execute(params.Mid, to, deployapi.MidHookPodSuffix, "mid"); err != nil { + if err := s.hookExecutor.Execute(params.Mid, to, appsapi.MidHookPodSuffix, "mid"); err != nil { return fmt.Errorf("mid hook failed: %s", err) } } @@ -216,7 +216,7 @@ func (s *RecreateDeploymentStrategy) DeployWithAcceptor(from *kapi.ReplicationCo // Execute any post-hook. if params != nil && params.Post != nil { - if err := s.hookExecutor.Execute(params.Post, to, deployapi.PostHookPodSuffix, "post"); err != nil { + if err := s.hookExecutor.Execute(params.Post, to, appsapi.PostHookPodSuffix, "post"); err != nil { return fmt.Errorf("post hook failed: %s", err) } } diff --git a/pkg/apps/strategy/recreate/recreate_test.go b/pkg/apps/strategy/recreate/recreate_test.go index 7d825059953a..0e4f2e2decbc 100644 --- a/pkg/apps/strategy/recreate/recreate_test.go +++ b/pkg/apps/strategy/recreate/recreate_test.go @@ -10,12 +10,12 @@ import ( "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" - deployv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" cmdtest "github.com/openshift/origin/pkg/apps/cmd/test" "github.com/openshift/origin/pkg/apps/strategy" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" _ "github.com/openshift/origin/pkg/api/install" ) @@ -41,10 +41,10 @@ func (c *fakePodClient) Pods(ns string) kcoreclient.PodInterface { } type hookExecutorImpl struct { - executeFunc func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error + executeFunc func(hook *appsapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error } -func (h *hookExecutorImpl) Execute(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error { +func (h *hookExecutorImpl) Execute(hook *appsapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error { return h.executeFunc(hook, rc, suffix, label) } @@ -61,12 +61,12 @@ func TestRecreate_initialDeployment(t *testing.T) { eventClient: fake.NewSimpleClientset().Core(), } - config := deploytest.OkDeploymentConfig(1) + config := appstest.OkDeploymentConfig(1) config.Spec.Strategy = recreateParams(30, "", "", "") - deployment, _ = deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + deployment, _ = appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) strategy.rcClient = &fakeControllerClient{deployment: deployment} - strategy.podClient = &fakePodClient{deployerName: deployutil.DeployerPodNameForDeployment(deployment.Name)} + strategy.podClient = &fakePodClient{deployerName: appsutil.DeployerPodNameForDeployment(deployment.Name)} err := strategy.Deploy(nil, deployment, 3) if err != nil { @@ -82,9 +82,9 @@ func TestRecreate_initialDeployment(t *testing.T) { } func TestRecreate_deploymentPreHookSuccess(t *testing.T) { - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = recreateParams(30, deployapi.LifecycleHookFailurePolicyAbort, "", "") - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = recreateParams(30, appsapi.LifecycleHookFailurePolicyAbort, "", "") + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) scaler := &cmdtest.FakeScaler{} hookExecuted := false @@ -97,14 +97,14 @@ func TestRecreate_deploymentPreHookSuccess(t *testing.T) { eventClient: fake.NewSimpleClientset().Core(), rcClient: &fakeControllerClient{deployment: deployment}, hookExecutor: &hookExecutorImpl{ - executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { + executeFunc: func(hook *appsapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { hookExecuted = true return nil }, }, scaler: scaler, } - strategy.podClient = &fakePodClient{deployerName: deployutil.DeployerPodNameForDeployment(deployment.Name)} + strategy.podClient = &fakePodClient{deployerName: appsutil.DeployerPodNameForDeployment(deployment.Name)} err := strategy.Deploy(nil, deployment, 2) if err != nil { @@ -116,9 +116,9 @@ func TestRecreate_deploymentPreHookSuccess(t *testing.T) { } func TestRecreate_deploymentPreHookFail(t *testing.T) { - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = recreateParams(30, deployapi.LifecycleHookFailurePolicyAbort, "", "") - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = recreateParams(30, appsapi.LifecycleHookFailurePolicyAbort, "", "") + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) scaler := &cmdtest.FakeScaler{} strategy := &RecreateDeploymentStrategy{ @@ -130,13 +130,13 @@ func TestRecreate_deploymentPreHookFail(t *testing.T) { eventClient: fake.NewSimpleClientset().Core(), rcClient: &fakeControllerClient{deployment: deployment}, hookExecutor: &hookExecutorImpl{ - executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { + executeFunc: func(hook *appsapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { return fmt.Errorf("hook execution failure") }, }, scaler: scaler, } - strategy.podClient = &fakePodClient{deployerName: deployutil.DeployerPodNameForDeployment(deployment.Name)} + strategy.podClient = &fakePodClient{deployerName: appsutil.DeployerPodNameForDeployment(deployment.Name)} err := strategy.Deploy(nil, deployment, 2) if err == nil { @@ -148,9 +148,9 @@ func TestRecreate_deploymentPreHookFail(t *testing.T) { } func TestRecreate_deploymentMidHookSuccess(t *testing.T) { - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = recreateParams(30, "", deployapi.LifecycleHookFailurePolicyAbort, "") - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = recreateParams(30, "", appsapi.LifecycleHookFailurePolicyAbort, "") + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) scaler := &cmdtest.FakeScaler{} strategy := &RecreateDeploymentStrategy{ @@ -162,13 +162,13 @@ func TestRecreate_deploymentMidHookSuccess(t *testing.T) { eventClient: fake.NewSimpleClientset().Core(), getUpdateAcceptor: getUpdateAcceptor, hookExecutor: &hookExecutorImpl{ - executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { + executeFunc: func(hook *appsapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { return fmt.Errorf("hook execution failure") }, }, scaler: scaler, } - strategy.podClient = &fakePodClient{deployerName: deployutil.DeployerPodNameForDeployment(deployment.Name)} + strategy.podClient = &fakePodClient{deployerName: appsutil.DeployerPodNameForDeployment(deployment.Name)} err := strategy.Deploy(nil, deployment, 2) if err == nil { @@ -179,9 +179,9 @@ func TestRecreate_deploymentMidHookSuccess(t *testing.T) { } } func TestRecreate_deploymentPostHookSuccess(t *testing.T) { - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = recreateParams(30, "", "", deployapi.LifecycleHookFailurePolicyAbort) - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = recreateParams(30, "", "", appsapi.LifecycleHookFailurePolicyAbort) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) scaler := &cmdtest.FakeScaler{} hookExecuted := false @@ -194,14 +194,14 @@ func TestRecreate_deploymentPostHookSuccess(t *testing.T) { eventClient: fake.NewSimpleClientset().Core(), getUpdateAcceptor: getUpdateAcceptor, hookExecutor: &hookExecutorImpl{ - executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { + executeFunc: func(hook *appsapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { hookExecuted = true return nil }, }, scaler: scaler, } - strategy.podClient = &fakePodClient{deployerName: deployutil.DeployerPodNameForDeployment(deployment.Name)} + strategy.podClient = &fakePodClient{deployerName: appsutil.DeployerPodNameForDeployment(deployment.Name)} err := strategy.Deploy(nil, deployment, 2) if err != nil { @@ -213,9 +213,9 @@ func TestRecreate_deploymentPostHookSuccess(t *testing.T) { } func TestRecreate_deploymentPostHookFail(t *testing.T) { - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = recreateParams(30, "", "", deployapi.LifecycleHookFailurePolicyAbort) - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = recreateParams(30, "", "", appsapi.LifecycleHookFailurePolicyAbort) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) scaler := &cmdtest.FakeScaler{} hookExecuted := false @@ -228,14 +228,14 @@ func TestRecreate_deploymentPostHookFail(t *testing.T) { eventClient: fake.NewSimpleClientset().Core(), getUpdateAcceptor: getUpdateAcceptor, hookExecutor: &hookExecutorImpl{ - executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { + executeFunc: func(hook *appsapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { hookExecuted = true return fmt.Errorf("post hook failure") }, }, scaler: scaler, } - strategy.podClient = &fakePodClient{deployerName: deployutil.DeployerPodNameForDeployment(deployment.Name)} + strategy.podClient = &fakePodClient{deployerName: appsutil.DeployerPodNameForDeployment(deployment.Name)} err := strategy.Deploy(nil, deployment, 2) if err == nil { @@ -267,10 +267,10 @@ func TestRecreate_acceptorSuccess(t *testing.T) { }, } - oldDeployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) - deployment, _ = deployutil.MakeDeployment(deploytest.OkDeploymentConfig(2), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + oldDeployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + deployment, _ = appsutil.MakeDeployment(appstest.OkDeploymentConfig(2), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) strategy.rcClient = &fakeControllerClient{deployment: deployment} - strategy.podClient = &fakePodClient{deployerName: deployutil.DeployerPodNameForDeployment(deployment.Name)} + strategy.podClient = &fakePodClient{deployerName: appsutil.DeployerPodNameForDeployment(deployment.Name)} err := strategy.DeployWithAcceptor(oldDeployment, deployment, 2, acceptor) if err != nil { @@ -313,10 +313,10 @@ func TestRecreate_acceptorSuccessWithColdCaches(t *testing.T) { }, } - oldDeployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) - deployment, _ = deployutil.MakeDeployment(deploytest.OkDeploymentConfig(2), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + oldDeployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + deployment, _ = appsutil.MakeDeployment(appstest.OkDeploymentConfig(2), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) strategy.rcClient = &fakeControllerClient{deployment: deployment} - strategy.podClient = &fakePodClient{deployerName: deployutil.DeployerPodNameForDeployment(deployment.Name)} + strategy.podClient = &fakePodClient{deployerName: appsutil.DeployerPodNameForDeployment(deployment.Name)} err := strategy.DeployWithAcceptor(oldDeployment, deployment, 2, acceptor) if err != nil { @@ -360,10 +360,10 @@ func TestRecreate_acceptorFail(t *testing.T) { }, } - oldDeployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) - deployment, _ = deployutil.MakeDeployment(deploytest.OkDeploymentConfig(2), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + oldDeployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(1), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + deployment, _ = appsutil.MakeDeployment(appstest.OkDeploymentConfig(2), kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) strategy.rcClient = &fakeControllerClient{deployment: deployment} - strategy.podClient = &fakePodClient{deployerName: deployutil.DeployerPodNameForDeployment(deployment.Name)} + strategy.podClient = &fakePodClient{deployerName: appsutil.DeployerPodNameForDeployment(deployment.Name)} err := strategy.DeployWithAcceptor(oldDeployment, deployment, 2, acceptor) if err == nil { t.Fatalf("expected a deployment failure") @@ -378,29 +378,29 @@ func TestRecreate_acceptorFail(t *testing.T) { } } -func recreateParams(timeout int64, preFailurePolicy, midFailurePolicy, postFailurePolicy deployapi.LifecycleHookFailurePolicy) deployapi.DeploymentStrategy { - var pre, mid, post *deployapi.LifecycleHook +func recreateParams(timeout int64, preFailurePolicy, midFailurePolicy, postFailurePolicy appsapi.LifecycleHookFailurePolicy) appsapi.DeploymentStrategy { + var pre, mid, post *appsapi.LifecycleHook if len(preFailurePolicy) > 0 { - pre = &deployapi.LifecycleHook{ + pre = &appsapi.LifecycleHook{ FailurePolicy: preFailurePolicy, - ExecNewPod: &deployapi.ExecNewPodHook{}, + ExecNewPod: &appsapi.ExecNewPodHook{}, } } if len(midFailurePolicy) > 0 { - mid = &deployapi.LifecycleHook{ + mid = &appsapi.LifecycleHook{ FailurePolicy: midFailurePolicy, - ExecNewPod: &deployapi.ExecNewPodHook{}, + ExecNewPod: &appsapi.ExecNewPodHook{}, } } if len(postFailurePolicy) > 0 { - post = &deployapi.LifecycleHook{ + post = &appsapi.LifecycleHook{ FailurePolicy: postFailurePolicy, - ExecNewPod: &deployapi.ExecNewPodHook{}, + ExecNewPod: &appsapi.ExecNewPodHook{}, } } - return deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, - RecreateParams: &deployapi.RecreateDeploymentStrategyParams{ + return appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapi.RecreateDeploymentStrategyParams{ TimeoutSeconds: &timeout, Pre: pre, diff --git a/pkg/apps/strategy/rolling/rolling.go b/pkg/apps/strategy/rolling/rolling.go index 8065c3ccf702..5fd0fde38418 100644 --- a/pkg/apps/strategy/rolling/rolling.go +++ b/pkg/apps/strategy/rolling/rolling.go @@ -18,11 +18,11 @@ import ( kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" "k8s.io/kubernetes/pkg/kubectl" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" strat "github.com/openshift/origin/pkg/apps/strategy" stratsupport "github.com/openshift/origin/pkg/apps/strategy/support" stratutil "github.com/openshift/origin/pkg/apps/strategy/util" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" imageclient "github.com/openshift/origin/pkg/image/generated/internalclientset/typed/image/internalversion" ) @@ -117,9 +117,9 @@ func NewRollingDeploymentStrategy(namespace string, client kclientset.Interface, } func (s *RollingDeploymentStrategy) Deploy(from *kapi.ReplicationController, to *kapi.ReplicationController, desiredReplicas int) error { - config, err := deployutil.DecodeDeploymentConfig(to, s.decoder) + config, err := appsutil.DecodeDeploymentConfig(to, s.decoder) if err != nil { - return fmt.Errorf("couldn't decode DeploymentConfig from deployment %s: %v", deployutil.LabelForDeployment(to), err) + return fmt.Errorf("couldn't decode DeploymentConfig from deployment %s: %v", appsutil.LabelForDeployment(to), err) } params := config.Spec.Strategy.RollingParams @@ -133,7 +133,7 @@ func (s *RollingDeploymentStrategy) Deploy(from *kapi.ReplicationController, to if from == nil { // Execute any pre-hook. if params.Pre != nil { - if err := s.hookExecutor.Execute(params.Pre, to, deployapi.PreHookPodSuffix, "pre"); err != nil { + if err := s.hookExecutor.Execute(params.Pre, to, appsapi.PreHookPodSuffix, "pre"); err != nil { return fmt.Errorf("Pre hook failed: %s", err) } } @@ -146,7 +146,7 @@ func (s *RollingDeploymentStrategy) Deploy(from *kapi.ReplicationController, to // Execute any post-hook. Errors are logged and ignored. if params.Post != nil { - if err := s.hookExecutor.Execute(params.Post, to, deployapi.PostHookPodSuffix, "post"); err != nil { + if err := s.hookExecutor.Execute(params.Post, to, appsapi.PostHookPodSuffix, "post"); err != nil { return fmt.Errorf("post hook failed: %s", err) } } @@ -162,7 +162,7 @@ func (s *RollingDeploymentStrategy) Deploy(from *kapi.ReplicationController, to // Prepare for a rolling update. // Execute any pre-hook. if params.Pre != nil { - if err := s.hookExecutor.Execute(params.Pre, to, deployapi.PreHookPodSuffix, "pre"); err != nil { + if err := s.hookExecutor.Execute(params.Pre, to, appsapi.PreHookPodSuffix, "pre"); err != nil { return fmt.Errorf("pre hook failed: %s", err) } } @@ -247,7 +247,7 @@ func (s *RollingDeploymentStrategy) Deploy(from *kapi.ReplicationController, to // Execute any post-hook. if params.Post != nil { - if err := s.hookExecutor.Execute(params.Post, to, deployapi.PostHookPodSuffix, "post"); err != nil { + if err := s.hookExecutor.Execute(params.Post, to, appsapi.PostHookPodSuffix, "post"); err != nil { return fmt.Errorf("post hook failed: %s", err) } } diff --git a/pkg/apps/strategy/rolling/rolling_test.go b/pkg/apps/strategy/rolling/rolling_test.go index 6beb116d5b45..619e9d0176cf 100644 --- a/pkg/apps/strategy/rolling/rolling_test.go +++ b/pkg/apps/strategy/rolling/rolling_test.go @@ -12,10 +12,10 @@ import ( "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" "k8s.io/kubernetes/pkg/kubectl" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" strat "github.com/openshift/origin/pkg/apps/strategy" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" _ "github.com/openshift/origin/pkg/api/install" ) @@ -42,9 +42,9 @@ func TestRolling_deployInitial(t *testing.T) { apiRetryTimeout: 10 * time.Millisecond, } - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = deploytest.OkRollingStrategy() - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = appstest.OkRollingStrategy() + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) strategy.out, strategy.errOut = &bytes.Buffer{}, &bytes.Buffer{} err := strategy.Deploy(nil, deployment, 2) if err != nil { @@ -56,12 +56,12 @@ func TestRolling_deployInitial(t *testing.T) { } func TestRolling_deployRolling(t *testing.T) { - latestConfig := deploytest.OkDeploymentConfig(1) - latestConfig.Spec.Strategy = deploytest.OkRollingStrategy() - latest, _ := deployutil.MakeDeployment(latestConfig, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) - config := deploytest.OkDeploymentConfig(2) - config.Spec.Strategy = deploytest.OkRollingStrategy() - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + latestConfig := appstest.OkDeploymentConfig(1) + latestConfig.Spec.Strategy = appstest.OkRollingStrategy() + latest, _ := appsutil.MakeDeployment(latestConfig, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + config := appstest.OkDeploymentConfig(2) + config.Spec.Strategy = appstest.OkRollingStrategy() + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) deployments := map[string]*kapi.ReplicationController{ latest.Name: latest, @@ -145,17 +145,17 @@ func TestRolling_deployRolling(t *testing.T) { } type hookExecutorImpl struct { - executeFunc func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error + executeFunc func(hook *appsapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error } -func (h *hookExecutorImpl) Execute(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error { +func (h *hookExecutorImpl) Execute(hook *appsapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error { return h.executeFunc(hook, rc, suffix, label) } func TestRolling_deployRollingHooks(t *testing.T) { - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = deploytest.OkRollingStrategy() - latest, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = appstest.OkRollingStrategy() + latest, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) var hookError error @@ -185,7 +185,7 @@ func TestRolling_deployRollingHooks(t *testing.T) { return nil }, hookExecutor: &hookExecutorImpl{ - executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { + executeFunc: func(hook *appsapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { return hookError }, }, @@ -195,20 +195,20 @@ func TestRolling_deployRollingHooks(t *testing.T) { } cases := []struct { - params *deployapi.RollingDeploymentStrategyParams + params *appsapi.RollingDeploymentStrategyParams hookShouldFail bool deploymentShouldFail bool }{ - {rollingParams(deployapi.LifecycleHookFailurePolicyAbort, ""), true, true}, - {rollingParams(deployapi.LifecycleHookFailurePolicyAbort, ""), false, false}, - {rollingParams("", deployapi.LifecycleHookFailurePolicyAbort), true, true}, - {rollingParams("", deployapi.LifecycleHookFailurePolicyAbort), false, false}, + {rollingParams(appsapi.LifecycleHookFailurePolicyAbort, ""), true, true}, + {rollingParams(appsapi.LifecycleHookFailurePolicyAbort, ""), false, false}, + {rollingParams("", appsapi.LifecycleHookFailurePolicyAbort), true, true}, + {rollingParams("", appsapi.LifecycleHookFailurePolicyAbort), false, false}, } for _, tc := range cases { - config := deploytest.OkDeploymentConfig(2) + config := appstest.OkDeploymentConfig(2) config.Spec.Strategy.RollingParams = tc.params - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) deployments[deployment.Name] = deployment hookError = nil if tc.hookShouldFail { @@ -246,7 +246,7 @@ func TestRolling_deployInitialHooks(t *testing.T) { return nil }, hookExecutor: &hookExecutorImpl{ - executeFunc: func(hook *deployapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { + executeFunc: func(hook *appsapi.LifecycleHook, deployment *kapi.ReplicationController, suffix, label string) error { return hookError }, }, @@ -256,20 +256,20 @@ func TestRolling_deployInitialHooks(t *testing.T) { } cases := []struct { - params *deployapi.RollingDeploymentStrategyParams + params *appsapi.RollingDeploymentStrategyParams hookShouldFail bool deploymentShouldFail bool }{ - {rollingParams(deployapi.LifecycleHookFailurePolicyAbort, ""), true, true}, - {rollingParams(deployapi.LifecycleHookFailurePolicyAbort, ""), false, false}, - {rollingParams("", deployapi.LifecycleHookFailurePolicyAbort), true, true}, - {rollingParams("", deployapi.LifecycleHookFailurePolicyAbort), false, false}, + {rollingParams(appsapi.LifecycleHookFailurePolicyAbort, ""), true, true}, + {rollingParams(appsapi.LifecycleHookFailurePolicyAbort, ""), false, false}, + {rollingParams("", appsapi.LifecycleHookFailurePolicyAbort), true, true}, + {rollingParams("", appsapi.LifecycleHookFailurePolicyAbort), false, false}, } for i, tc := range cases { - config := deploytest.OkDeploymentConfig(2) + config := appstest.OkDeploymentConfig(2) config.Spec.Strategy.RollingParams = tc.params - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(kapi.Registry.GroupOrDie(kapi.GroupName).GroupVersions[0])) hookError = nil if tc.hookShouldFail { hookError = fmt.Errorf("hook failure") @@ -301,23 +301,23 @@ func mkintp(i int) *int64 { return &v } -func rollingParams(preFailurePolicy, postFailurePolicy deployapi.LifecycleHookFailurePolicy) *deployapi.RollingDeploymentStrategyParams { - var pre *deployapi.LifecycleHook - var post *deployapi.LifecycleHook +func rollingParams(preFailurePolicy, postFailurePolicy appsapi.LifecycleHookFailurePolicy) *appsapi.RollingDeploymentStrategyParams { + var pre *appsapi.LifecycleHook + var post *appsapi.LifecycleHook if len(preFailurePolicy) > 0 { - pre = &deployapi.LifecycleHook{ + pre = &appsapi.LifecycleHook{ FailurePolicy: preFailurePolicy, - ExecNewPod: &deployapi.ExecNewPodHook{}, + ExecNewPod: &appsapi.ExecNewPodHook{}, } } if len(postFailurePolicy) > 0 { - post = &deployapi.LifecycleHook{ + post = &appsapi.LifecycleHook{ FailurePolicy: postFailurePolicy, - ExecNewPod: &deployapi.ExecNewPodHook{}, + ExecNewPod: &appsapi.ExecNewPodHook{}, } } - return &deployapi.RollingDeploymentStrategyParams{ + return &appsapi.RollingDeploymentStrategyParams{ UpdatePeriodSeconds: mkintp(1), IntervalSeconds: mkintp(1), TimeoutSeconds: mkintp(20), diff --git a/pkg/apps/strategy/support/lifecycle.go b/pkg/apps/strategy/support/lifecycle.go index 06f9f933faa2..9852d75ce1d6 100644 --- a/pkg/apps/strategy/support/lifecycle.go +++ b/pkg/apps/strategy/support/lifecycle.go @@ -20,9 +20,9 @@ import ( kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" "github.com/openshift/origin/pkg/api/apihelpers" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" strategyutil "github.com/openshift/origin/pkg/apps/strategy/util" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" imageapi "github.com/openshift/origin/pkg/image/apis/image" imageclient "github.com/openshift/origin/pkg/image/generated/internalclientset/typed/image/internalversion" "github.com/openshift/origin/pkg/util" @@ -33,7 +33,7 @@ const hookContainerName = "lifecycle" // HookExecutor knows how to execute a deployment lifecycle hook. type HookExecutor interface { - Execute(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error + Execute(hook *appsapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error } // hookExecutor implements the HookExecutor interface. @@ -77,7 +77,7 @@ func NewHookExecutor(pods kcoreclient.PodsGetter, tags imageclient.ImageStreamTa // Execute executes hook in the context of deployment. The suffix is used to // distinguish the kind of hook (e.g. pre, post). -func (e *hookExecutor) Execute(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error { +func (e *hookExecutor) Execute(hook *appsapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error { var err error switch { case len(hook.TagImages) > 0: @@ -105,11 +105,11 @@ func (e *hookExecutor) Execute(hook *deployapi.LifecycleHook, rc *kapi.Replicati // Retry failures are treated the same as Abort. switch hook.FailurePolicy { - case deployapi.LifecycleHookFailurePolicyAbort, deployapi.LifecycleHookFailurePolicyRetry: + case appsapi.LifecycleHookFailurePolicyAbort, appsapi.LifecycleHookFailurePolicyRetry: strategyutil.RecordConfigEvent(e.events, rc, e.decoder, kapi.EventTypeWarning, "Failed", fmt.Sprintf("The %s-hook failed: %v, aborting rollout of %s/%s", label, err, rc.Namespace, rc.Name)) return fmt.Errorf("the %s hook failed: %v, aborting rollout of %s/%s", label, err, rc.Namespace, rc.Name) - case deployapi.LifecycleHookFailurePolicyIgnore: + case appsapi.LifecycleHookFailurePolicyIgnore: strategyutil.RecordConfigEvent(e.events, rc, e.decoder, kapi.EventTypeWarning, "Failed", fmt.Sprintf("The %s-hook failed: %v (ignore), rollout of %s/%s will continue", label, err, rc.Namespace, rc.Name)) return nil @@ -133,7 +133,7 @@ func findContainerImage(rc *kapi.ReplicationController, containerName string) (s // tagImages tags images as part of the lifecycle of a rc. It uses an ImageStreamTag client // which will provision an ImageStream if it doesn't already exist. -func (e *hookExecutor) tagImages(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error { +func (e *hookExecutor) tagImages(hook *appsapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error { var errs []error for _, action := range hook.TagImages { value, ok := findContainerImage(rc, action.ContainerName) @@ -175,13 +175,13 @@ func (e *hookExecutor) tagImages(hook *deployapi.LifecycleHook, rc *kapi.Replica // * Environment (hook keys take precedence) // * Working directory // * Resources -func (e *hookExecutor) executeExecNewPod(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error { - config, err := deployutil.DecodeDeploymentConfig(rc, e.decoder) +func (e *hookExecutor) executeExecNewPod(hook *appsapi.LifecycleHook, rc *kapi.ReplicationController, suffix, label string) error { + config, err := appsutil.DecodeDeploymentConfig(rc, e.decoder) if err != nil { return err } - deployerPod, err := e.pods.Pods(rc.Namespace).Get(deployutil.DeployerPodNameForDeployment(rc.Name), metav1.GetOptions{}) + deployerPod, err := e.pods.Pods(rc.Namespace).Get(appsutil.DeployerPodNameForDeployment(rc.Name), metav1.GetOptions{}) if err != nil { return err } @@ -302,7 +302,7 @@ func (e *hookExecutor) readPodLogs(pod *kapi.Pod, wg *sync.WaitGroup) { } // makeHookPod makes a pod spec from a hook and replication controller. -func makeHookPod(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController, strategy *deployapi.DeploymentStrategy, suffix string, startTime time.Time) (*kapi.Pod, error) { +func makeHookPod(hook *appsapi.LifecycleHook, rc *kapi.ReplicationController, strategy *appsapi.DeploymentStrategy, suffix string, startTime time.Time) (*kapi.Pod, error) { exec := hook.ExecNewPod var baseContainer *kapi.Container for _, container := range rc.Spec.Template.Spec.Containers { @@ -338,7 +338,7 @@ func makeHookPod(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController, } // Assigning to a variable since its address is required - defaultActiveDeadline := deployapi.MaxDeploymentDurationSeconds + defaultActiveDeadline := appsapi.MaxDeploymentDurationSeconds if strategy.ActiveDeadlineSeconds != nil { defaultActiveDeadline = *(strategy.ActiveDeadlineSeconds) } @@ -346,7 +346,7 @@ func makeHookPod(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController, // Let the kubelet manage retries if requested restartPolicy := kapi.RestartPolicyNever - if hook.FailurePolicy == deployapi.LifecycleHookFailurePolicyRetry { + if hook.FailurePolicy == appsapi.LifecycleHookFailurePolicyRetry { restartPolicy = kapi.RestartPolicyOnFailure } @@ -388,11 +388,11 @@ func makeHookPod(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController, ObjectMeta: metav1.ObjectMeta{ Name: apihelpers.GetPodName(rc.Name, suffix), Annotations: map[string]string{ - deployapi.DeploymentAnnotation: rc.Name, + appsapi.DeploymentAnnotation: rc.Name, }, Labels: map[string]string{ - deployapi.DeploymentPodTypeLabel: suffix, - deployapi.DeployerPodForDeploymentLabel: rc.Name, + appsapi.DeploymentPodTypeLabel: suffix, + appsapi.DeployerPodForDeploymentLabel: rc.Name, }, }, Spec: kapi.PodSpec{ diff --git a/pkg/apps/strategy/support/lifecycle_test.go b/pkg/apps/strategy/support/lifecycle_test.go index 35f9d6d0e133..132bfba9a740 100644 --- a/pkg/apps/strategy/support/lifecycle_test.go +++ b/pkg/apps/strategy/support/lifecycle_test.go @@ -21,10 +21,10 @@ import ( kapihelper "k8s.io/kubernetes/pkg/api/helper" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" - deployv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsutil "github.com/openshift/origin/pkg/apps/util" "github.com/openshift/origin/pkg/api/apihelpers" _ "github.com/openshift/origin/pkg/api/install" @@ -34,7 +34,7 @@ func nowFunc() *metav1.Time { return &metav1.Time{Time: time.Now().Add(-5 * time.Second)} } -func newTestClient(config *deployapi.DeploymentConfig) *fake.Clientset { +func newTestClient(config *appsapi.DeploymentConfig) *fake.Clientset { client := &fake.Clientset{} // when creating a lifecycle pod, we query the deployer pod for the start time to // calculate the active deadline seconds for the lifecycle pod. @@ -56,14 +56,14 @@ func newTestClient(config *deployapi.DeploymentConfig) *fake.Clientset { } func TestHookExecutor_executeExecNewCreatePodFailure(t *testing.T) { - hook := &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyAbort, - ExecNewPod: &deployapi.ExecNewPodHook{ + hook := &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyAbort, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container1", }, } - dc := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeployment(dc, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + dc := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeployment(dc, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) client := newTestClient(dc) client.AddReactor("create", "pods", func(a clientgotesting.Action) (handled bool, ret runtime.Object, err error) { return true, nil, errors.New("could not create the pod") @@ -79,15 +79,15 @@ func TestHookExecutor_executeExecNewCreatePodFailure(t *testing.T) { } func TestHookExecutor_executeExecNewPodSucceeded(t *testing.T) { - hook := &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyAbort, - ExecNewPod: &deployapi.ExecNewPodHook{ + hook := &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyAbort, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container1", }, } - config := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) deployment.Spec.Template.Spec.NodeSelector = map[string]string{"labelKey1": "labelValue1", "labelKey2": "labelValue2"} client := newTestClient(config) @@ -141,21 +141,21 @@ func TestHookExecutor_executeExecNewPodSucceeded(t *testing.T) { t.Fatalf("expected ActiveDeadlineSeconds to be set on the deployment hook executor pod") } - if *createdPod.Spec.ActiveDeadlineSeconds >= deployapi.MaxDeploymentDurationSeconds { - t.Fatalf("expected ActiveDeadlineSeconds %+v to be lower than %+v", *createdPod.Spec.ActiveDeadlineSeconds, deployapi.MaxDeploymentDurationSeconds) + if *createdPod.Spec.ActiveDeadlineSeconds >= appsapi.MaxDeploymentDurationSeconds { + t.Fatalf("expected ActiveDeadlineSeconds %+v to be lower than %+v", *createdPod.Spec.ActiveDeadlineSeconds, appsapi.MaxDeploymentDurationSeconds) } } func TestHookExecutor_executeExecNewPodFailed(t *testing.T) { - hook := &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyAbort, - ExecNewPod: &deployapi.ExecNewPodHook{ + hook := &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyAbort, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container1", }, } - config := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) client := newTestClient(config) podCreated := make(chan struct{}) @@ -196,15 +196,15 @@ func TestHookExecutor_executeExecNewPodFailed(t *testing.T) { } func TestHookExecutor_makeHookPodInvalidContainerRef(t *testing.T) { - hook := &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyAbort, - ExecNewPod: &deployapi.ExecNewPodHook{ + hook := &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyAbort, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "undefined", }, } - config := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) _, err := makeHookPod(hook, deployment, &config.Spec.Strategy, "hook", nowFunc().Time) if err == nil { @@ -215,21 +215,21 @@ func TestHookExecutor_makeHookPodInvalidContainerRef(t *testing.T) { func TestHookExecutor_makeHookPod(t *testing.T) { deploymentName := "deployment-1" deploymentNamespace := "test" - maxDeploymentDurationSeconds := deployapi.MaxDeploymentDurationSeconds + maxDeploymentDurationSeconds := appsapi.MaxDeploymentDurationSeconds gracePeriod := int64(10) tests := []struct { name string - hook *deployapi.LifecycleHook + hook *appsapi.LifecycleHook expected *kapi.Pod strategyLabels map[string]string strategyAnnotations map[string]string }{ { name: "overrides", - hook: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyAbort, - ExecNewPod: &deployapi.ExecNewPodHook{ + hook: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyAbort, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container1", Command: []string{"overridden"}, Env: []kapi.EnvVar{ @@ -249,11 +249,11 @@ func TestHookExecutor_makeHookPod(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: apihelpers.GetPodName(deploymentName, "hook"), Labels: map[string]string{ - deployapi.DeploymentPodTypeLabel: "hook", - deployapi.DeployerPodForDeploymentLabel: deploymentName, + appsapi.DeploymentPodTypeLabel: "hook", + appsapi.DeployerPodForDeploymentLabel: deploymentName, }, Annotations: map[string]string{ - deployapi.DeploymentAnnotation: deploymentName, + appsapi.DeploymentAnnotation: deploymentName, }, }, Spec: kapi.PodSpec{ @@ -318,9 +318,9 @@ func TestHookExecutor_makeHookPod(t *testing.T) { }, { name: "no overrides", - hook: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyAbort, - ExecNewPod: &deployapi.ExecNewPodHook{ + hook: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyAbort, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container1", }, }, @@ -328,11 +328,11 @@ func TestHookExecutor_makeHookPod(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: apihelpers.GetPodName(deploymentName, "hook"), Labels: map[string]string{ - deployapi.DeploymentPodTypeLabel: "hook", - deployapi.DeployerPodForDeploymentLabel: deploymentName, + appsapi.DeploymentPodTypeLabel: "hook", + appsapi.DeployerPodForDeploymentLabel: deploymentName, }, Annotations: map[string]string{ - deployapi.DeploymentAnnotation: deploymentName, + appsapi.DeploymentAnnotation: deploymentName, }, }, Spec: kapi.PodSpec{ @@ -377,9 +377,9 @@ func TestHookExecutor_makeHookPod(t *testing.T) { }, { name: "labels and annotations", - hook: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyAbort, - ExecNewPod: &deployapi.ExecNewPodHook{ + hook: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyAbort, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container1", }, }, @@ -387,13 +387,13 @@ func TestHookExecutor_makeHookPod(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: apihelpers.GetPodName(deploymentName, "hook"), Labels: map[string]string{ - deployapi.DeploymentPodTypeLabel: "hook", - deployapi.DeployerPodForDeploymentLabel: deploymentName, + appsapi.DeploymentPodTypeLabel: "hook", + appsapi.DeployerPodForDeploymentLabel: deploymentName, "label1": "value1", }, Annotations: map[string]string{ - deployapi.DeploymentAnnotation: deploymentName, - "annotation2": "value2", + appsapi.DeploymentAnnotation: deploymentName, + "annotation2": "value2", }, }, Spec: kapi.PodSpec{ @@ -436,16 +436,16 @@ func TestHookExecutor_makeHookPod(t *testing.T) { }, }, strategyLabels: map[string]string{ - deployapi.DeployerPodForDeploymentLabel: "ignoredValue", + appsapi.DeployerPodForDeploymentLabel: "ignoredValue", "label1": "value1", }, strategyAnnotations: map[string]string{"annotation2": "value2"}, }, { name: "allways pull image", - hook: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyAbort, - ExecNewPod: &deployapi.ExecNewPodHook{ + hook: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyAbort, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container2", }, }, @@ -453,11 +453,11 @@ func TestHookExecutor_makeHookPod(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: apihelpers.GetPodName(deploymentName, "hook"), Labels: map[string]string{ - deployapi.DeploymentPodTypeLabel: "hook", - deployapi.DeployerPodForDeploymentLabel: deploymentName, + appsapi.DeploymentPodTypeLabel: "hook", + appsapi.DeployerPodForDeploymentLabel: deploymentName, }, Annotations: map[string]string{ - deployapi.DeploymentAnnotation: deploymentName, + appsapi.DeploymentAnnotation: deploymentName, }, }, Spec: kapi.PodSpec{ @@ -518,15 +518,15 @@ func TestHookExecutor_makeHookPod(t *testing.T) { } func TestHookExecutor_makeHookPodRestart(t *testing.T) { - hook := &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyRetry, - ExecNewPod: &deployapi.ExecNewPodHook{ + hook := &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyRetry, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container1", }, } - config := deploytest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) pod, err := makeHookPod(hook, deployment, &config.Spec.Strategy, "hook", nowFunc().Time) if err != nil { @@ -538,20 +538,20 @@ func TestHookExecutor_makeHookPodRestart(t *testing.T) { } } -func deployment(name, namespace string, strategyLabels, strategyAnnotations map[string]string) (*deployapi.DeploymentConfig, *kapi.ReplicationController) { - config := &deployapi.DeploymentConfig{ +func deployment(name, namespace string, strategyLabels, strategyAnnotations map[string]string) (*appsapi.DeploymentConfig, *kapi.ReplicationController) { + config := &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: name, Namespace: namespace, }, - Status: deployapi.DeploymentConfigStatus{ + Status: appsapi.DeploymentConfigStatus{ LatestVersion: 1, }, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, Selector: map[string]string{"a": "b"}, - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRecreate, + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRecreate, Resources: kapi.ResourceRequirements{ Limits: kapi.ResourceList{ kapi.ResourceName(kapi.ResourceCPU): resource.MustParse("10"), @@ -616,7 +616,7 @@ func deployment(name, namespace string, strategyLabels, strategyAnnotations map[ }, }, } - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) deployment.Namespace = namespace return config, deployment } diff --git a/pkg/apps/strategy/util/util.go b/pkg/apps/strategy/util/util.go index 77763abe707c..11827b4aff71 100644 --- a/pkg/apps/strategy/util/util.go +++ b/pkg/apps/strategy/util/util.go @@ -13,7 +13,7 @@ import ( kapiref "k8s.io/kubernetes/pkg/api/ref" kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" ) // RecordConfigEvent records an event for the deployment config referenced by the @@ -21,7 +21,7 @@ import ( func RecordConfigEvent(client kcoreclient.EventsGetter, deployment *kapi.ReplicationController, decoder runtime.Decoder, eventType, reason, msg string) { t := metav1.Time{Time: time.Now()} var obj runtime.Object = deployment - if config, err := deployutil.DecodeDeploymentConfig(deployment, decoder); err == nil { + if config, err := appsutil.DecodeDeploymentConfig(deployment, decoder); err == nil { obj = config } else { glog.Errorf("Unable to decode deployment config from %s/%s: %v", deployment.Namespace, deployment.Name, err) @@ -40,7 +40,7 @@ func RecordConfigEvent(client kcoreclient.EventsGetter, deployment *kapi.Replica Reason: reason, Message: msg, Source: kapi.EventSource{ - Component: deployutil.DeployerPodNameFor(deployment), + Component: appsutil.DeployerPodNameFor(deployment), }, FirstTimestamp: t, LastTimestamp: t, diff --git a/pkg/apps/util/util.go b/pkg/apps/util/util.go index a5a563f8b556..ab9f42a01406 100644 --- a/pkg/apps/util/util.go +++ b/pkg/apps/util/util.go @@ -23,21 +23,21 @@ import ( kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" kdeplutil "k8s.io/kubernetes/pkg/controller/deployment/util" - deployapiv1 "github.com/openshift/api/apps/v1" + appsapiv1 "github.com/openshift/api/apps/v1" "github.com/openshift/origin/pkg/api/apihelpers" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) var ( // DeploymentConfigControllerRefKind contains the schema.GroupVersionKind for the // deployment config. This is used in the ownerRef and GC client picks the appropriate // client to get the deployment config. - DeploymentConfigControllerRefKind = deployapiv1.SchemeGroupVersion.WithKind("DeploymentConfig") + DeploymentConfigControllerRefKind = appsapiv1.SchemeGroupVersion.WithKind("DeploymentConfig") ) // NewDeploymentCondition creates a new deployment condition. -func NewDeploymentCondition(condType deployapi.DeploymentConditionType, status api.ConditionStatus, reason deployapi.DeploymentConditionReason, message string) *deployapi.DeploymentCondition { - return &deployapi.DeploymentCondition{ +func NewDeploymentCondition(condType appsapi.DeploymentConditionType, status api.ConditionStatus, reason appsapi.DeploymentConditionReason, message string) *appsapi.DeploymentCondition { + return &appsapi.DeploymentCondition{ Type: condType, Status: status, LastUpdateTime: metav1.Now(), @@ -48,7 +48,7 @@ func NewDeploymentCondition(condType deployapi.DeploymentConditionType, status a } // GetDeploymentCondition returns the condition with the provided type. -func GetDeploymentCondition(status deployapi.DeploymentConfigStatus, condType deployapi.DeploymentConditionType) *deployapi.DeploymentCondition { +func GetDeploymentCondition(status appsapi.DeploymentConfigStatus, condType appsapi.DeploymentConditionType) *appsapi.DeploymentCondition { for i := range status.Conditions { c := status.Conditions[i] if c.Type == condType { @@ -60,7 +60,7 @@ func GetDeploymentCondition(status deployapi.DeploymentConfigStatus, condType de // SetDeploymentCondition updates the deployment to include the provided condition. If the condition that // we are about to add already exists and has the same status and reason then we are not going to update. -func SetDeploymentCondition(status *deployapi.DeploymentConfigStatus, condition deployapi.DeploymentCondition) { +func SetDeploymentCondition(status *appsapi.DeploymentConfigStatus, condition appsapi.DeploymentCondition) { currentCond := GetDeploymentCondition(*status, condition.Type) if currentCond != nil && currentCond.Status == condition.Status && currentCond.Reason == condition.Reason { return @@ -74,13 +74,13 @@ func SetDeploymentCondition(status *deployapi.DeploymentConfigStatus, condition } // RemoveDeploymentCondition removes the deployment condition with the provided type. -func RemoveDeploymentCondition(status *deployapi.DeploymentConfigStatus, condType deployapi.DeploymentConditionType) { +func RemoveDeploymentCondition(status *appsapi.DeploymentConfigStatus, condType appsapi.DeploymentConditionType) { status.Conditions = filterOutCondition(status.Conditions, condType) } // filterOutCondition returns a new slice of deployment conditions without conditions with the provided type. -func filterOutCondition(conditions []deployapi.DeploymentCondition, condType deployapi.DeploymentConditionType) []deployapi.DeploymentCondition { - var newConditions []deployapi.DeploymentCondition +func filterOutCondition(conditions []appsapi.DeploymentCondition, condType appsapi.DeploymentConditionType) []appsapi.DeploymentCondition { + var newConditions []appsapi.DeploymentCondition for _, c := range conditions { if c.Type == condType { continue @@ -91,14 +91,14 @@ func filterOutCondition(conditions []deployapi.DeploymentCondition, condType dep } // LatestDeploymentNameForConfig returns a stable identifier for config based on its version. -func LatestDeploymentNameForConfig(config *deployapi.DeploymentConfig) string { +func LatestDeploymentNameForConfig(config *appsapi.DeploymentConfig) string { return fmt.Sprintf("%s-%d", config.Name, config.Status.LatestVersion) } // LatestDeploymentInfo returns info about the latest deployment for a config, // or nil if there is no latest deployment. The latest deployment is not // always the same as the active deployment. -func LatestDeploymentInfo(config *deployapi.DeploymentConfig, deployments []*v1.ReplicationController) (bool, *v1.ReplicationController) { +func LatestDeploymentInfo(config *appsapi.DeploymentConfig, deployments []*v1.ReplicationController) (bool, *v1.ReplicationController) { if config.Status.LatestVersion == 0 || len(deployments) == 0 { return false, nil } @@ -160,7 +160,7 @@ func LabelForDeploymentV1(deployment *v1.ReplicationController) string { } // LabelForDeploymentConfig builds a string identifier for a DeploymentConfig. -func LabelForDeploymentConfig(config *deployapi.DeploymentConfig) string { +func LabelForDeploymentConfig(config *appsapi.DeploymentConfig) string { return fmt.Sprintf("%s/%s", config.Namespace, config.Name) } @@ -176,28 +176,28 @@ func DeploymentNameForConfigVersion(name string, version int64) string { // TODO: Using the annotation constant for now since the value is correct // but we could consider adding a new constant to the public types. func ConfigSelector(name string) labels.Selector { - return labels.Set{deployapi.DeploymentConfigAnnotation: name}.AsSelector() + return labels.Set{appsapi.DeploymentConfigAnnotation: name}.AsSelector() } // DeployerPodSelector returns a label Selector which can be used to find all // deployer pods associated with a deployment with name. func DeployerPodSelector(name string) labels.Selector { - return labels.Set{deployapi.DeployerPodForDeploymentLabel: name}.AsSelector() + return labels.Set{appsapi.DeployerPodForDeploymentLabel: name}.AsSelector() } // AnyDeployerPodSelector returns a label Selector which can be used to find // all deployer pods across all deployments, including hook and custom // deployer pods. func AnyDeployerPodSelector() labels.Selector { - sel, _ := labels.Parse(deployapi.DeployerPodForDeploymentLabel) + sel, _ := labels.Parse(appsapi.DeployerPodForDeploymentLabel) return sel } // HasChangeTrigger returns whether the provided deployment configuration has // a config change trigger or not -func HasChangeTrigger(config *deployapi.DeploymentConfig) bool { +func HasChangeTrigger(config *appsapi.DeploymentConfig) bool { for _, trigger := range config.Spec.Triggers { - if trigger.Type == deployapi.DeploymentTriggerOnConfigChange { + if trigger.Type == appsapi.DeploymentTriggerOnConfigChange { return true } } @@ -206,9 +206,9 @@ func HasChangeTrigger(config *deployapi.DeploymentConfig) bool { // HasImageChangeTrigger returns whether the provided deployment configuration has // an image change trigger or not. -func HasImageChangeTrigger(config *deployapi.DeploymentConfig) bool { +func HasImageChangeTrigger(config *appsapi.DeploymentConfig) bool { for _, trigger := range config.Spec.Triggers { - if trigger.Type == deployapi.DeploymentTriggerOnImageChange { + if trigger.Type == appsapi.DeploymentTriggerOnImageChange { return true } } @@ -217,17 +217,17 @@ func HasImageChangeTrigger(config *deployapi.DeploymentConfig) bool { // HasTrigger returns whether the provided deployment configuration has any trigger // defined or not. -func HasTrigger(config *deployapi.DeploymentConfig) bool { +func HasTrigger(config *appsapi.DeploymentConfig) bool { return HasChangeTrigger(config) || HasImageChangeTrigger(config) } // HasLastTriggeredImage returns whether all image change triggers in provided deployment // configuration has the lastTriggerImage field set (iow. all images were updated for // them). Returns false if deployment configuration has no image change trigger defined. -func HasLastTriggeredImage(config *deployapi.DeploymentConfig) bool { +func HasLastTriggeredImage(config *appsapi.DeploymentConfig) bool { hasImageTrigger := false for _, trigger := range config.Spec.Triggers { - if trigger.Type == deployapi.DeploymentTriggerOnImageChange { + if trigger.Type == appsapi.DeploymentTriggerOnImageChange { hasImageTrigger = true if len(trigger.ImageChangeParams.LastTriggeredImage) == 0 { return false @@ -239,16 +239,16 @@ func HasLastTriggeredImage(config *deployapi.DeploymentConfig) bool { // IsInitialDeployment returns whether the deployment configuration is the first version // of this configuration. -func IsInitialDeployment(config *deployapi.DeploymentConfig) bool { +func IsInitialDeployment(config *appsapi.DeploymentConfig) bool { return config.Status.LatestVersion == 0 } // RecordConfigChangeCause sets a deployment config cause for config change. -func RecordConfigChangeCause(config *deployapi.DeploymentConfig) { - config.Status.Details = &deployapi.DeploymentDetails{ - Causes: []deployapi.DeploymentCause{ +func RecordConfigChangeCause(config *appsapi.DeploymentConfig) { + config.Status.Details = &appsapi.DeploymentDetails{ + Causes: []appsapi.DeploymentCause{ { - Type: deployapi.DeploymentTriggerOnConfigChange, + Type: appsapi.DeploymentTriggerOnConfigChange, }, }, Message: "config change", @@ -257,14 +257,14 @@ func RecordConfigChangeCause(config *deployapi.DeploymentConfig) { // RecordImageChangeCauses sets a deployment config cause for image change. It // takes a list of changed images and record an cause for each image. -func RecordImageChangeCauses(config *deployapi.DeploymentConfig, imageNames []string) { - config.Status.Details = &deployapi.DeploymentDetails{ +func RecordImageChangeCauses(config *appsapi.DeploymentConfig, imageNames []string) { + config.Status.Details = &appsapi.DeploymentDetails{ Message: "image change", } for _, imageName := range imageNames { - config.Status.Details.Causes = append(config.Status.Details.Causes, deployapi.DeploymentCause{ - Type: deployapi.DeploymentTriggerOnImageChange, - ImageTrigger: &deployapi.DeploymentCauseImageTrigger{From: api.ObjectReference{Kind: "DockerImage", Name: imageName}}, + config.Status.Details.Causes = append(config.Status.Details.Causes, appsapi.DeploymentCause{ + Type: appsapi.DeploymentTriggerOnImageChange, + ImageTrigger: &appsapi.DeploymentCauseImageTrigger{From: api.ObjectReference{Kind: "DockerImage", Name: imageName}}, }) } } @@ -314,7 +314,7 @@ func CopyPodTemplateSpecToV1PodTemplateSpec(spec *api.PodTemplateSpec) *v1.PodTe // template and deployment config template encoded in the latest replication // controller. If they are different it will return an string diff containing // the change. -func HasLatestPodTemplate(currentConfig *deployapi.DeploymentConfig, rc *v1.ReplicationController, codec runtime.Codec) (bool, string, error) { +func HasLatestPodTemplate(currentConfig *appsapi.DeploymentConfig, rc *v1.ReplicationController, codec runtime.Codec) (bool, string, error) { latestConfig, err := DecodeDeploymentConfig(rc, codec) if err != nil { return true, "", err @@ -333,7 +333,7 @@ func HasLatestPodTemplate(currentConfig *deployapi.DeploymentConfig, rc *v1.Repl } // HasUpdatedImages indicates if the deployment configuration images were updated. -func HasUpdatedImages(dc *deployapi.DeploymentConfig, rc *v1.ReplicationController) (bool, []string) { +func HasUpdatedImages(dc *appsapi.DeploymentConfig, rc *v1.ReplicationController) (bool, []string) { updatedImages := []string{} rcImages := sets.NewString() for _, c := range rc.Spec.Template.Spec.Containers { @@ -352,13 +352,13 @@ func HasUpdatedImages(dc *deployapi.DeploymentConfig, rc *v1.ReplicationControll // DecodeDeploymentConfig decodes a DeploymentConfig from controller using codec. An error is returned // if the controller doesn't contain an encoded config. -func DecodeDeploymentConfig(controller runtime.Object, decoder runtime.Decoder) (*deployapi.DeploymentConfig, error) { +func DecodeDeploymentConfig(controller runtime.Object, decoder runtime.Decoder) (*appsapi.DeploymentConfig, error) { encodedConfig := []byte(EncodedDeploymentConfigFor(controller)) decoded, err := runtime.Decode(decoder, encodedConfig) if err != nil { return nil, fmt.Errorf("failed to decode DeploymentConfig from controller: %v", err) } - config, ok := decoded.(*deployapi.DeploymentConfig) + config, ok := decoded.(*appsapi.DeploymentConfig) if !ok { return nil, fmt.Errorf("decoded object from controller is not a DeploymentConfig") } @@ -366,7 +366,7 @@ func DecodeDeploymentConfig(controller runtime.Object, decoder runtime.Decoder) } // EncodeDeploymentConfig encodes config as a string using codec. -func EncodeDeploymentConfig(config *deployapi.DeploymentConfig, codec runtime.Codec) (string, error) { +func EncodeDeploymentConfig(config *appsapi.DeploymentConfig, codec runtime.Codec) (string, error) { bytes, err := runtime.Encode(codec, config) if err != nil { return "", err @@ -374,7 +374,7 @@ func EncodeDeploymentConfig(config *deployapi.DeploymentConfig, codec runtime.Co return string(bytes[:]), nil } -func NewControllerRef(config *deployapi.DeploymentConfig) *metav1.OwnerReference { +func NewControllerRef(config *appsapi.DeploymentConfig) *metav1.OwnerReference { blockOwnerDeletion := true isController := true return &metav1.OwnerReference{ @@ -390,7 +390,7 @@ func NewControllerRef(config *deployapi.DeploymentConfig) *metav1.OwnerReference // MakeDeployment creates a deployment represented as an internal ReplicationController and based on the given // DeploymentConfig. The controller replica count will be zero. // DEPRECATED: Will be replaced with external version eventually. -func MakeDeployment(config *deployapi.DeploymentConfig, codec runtime.Codec) (*api.ReplicationController, error) { +func MakeDeployment(config *appsapi.DeploymentConfig, codec runtime.Codec) (*api.ReplicationController, error) { obj, err := MakeDeploymentV1(config, codec) if err != nil { return nil, err @@ -406,7 +406,7 @@ func MakeDeployment(config *deployapi.DeploymentConfig, codec runtime.Codec) (*a // MakeDeploymentV1 creates a deployment represented as a ReplicationController and based on the given // DeploymentConfig. The controller replica count will be zero. -func MakeDeploymentV1(config *deployapi.DeploymentConfig, codec runtime.Codec) (*v1.ReplicationController, error) { +func MakeDeploymentV1(config *appsapi.DeploymentConfig, codec runtime.Codec) (*v1.ReplicationController, error) { var err error var encodedConfig string @@ -435,7 +435,7 @@ func MakeDeploymentV1(config *deployapi.DeploymentConfig, codec runtime.Codec) ( // Correlate the deployment with the config. // TODO: Using the annotation constant for now since the value is correct // but we could consider adding a new constant to the public types. - controllerLabels[deployapi.DeploymentConfigAnnotation] = config.Name + controllerLabels[appsapi.DeploymentConfigAnnotation] = config.Name // Ensure that pods created by this deployment controller can be safely associated back // to the controller, and that multiple deployment controllers for the same config don't @@ -444,23 +444,23 @@ func MakeDeploymentV1(config *deployapi.DeploymentConfig, codec runtime.Codec) ( for k, v := range config.Spec.Selector { selector[k] = v } - selector[deployapi.DeploymentConfigLabel] = config.Name - selector[deployapi.DeploymentLabel] = deploymentName + selector[appsapi.DeploymentConfigLabel] = config.Name + selector[appsapi.DeploymentLabel] = deploymentName podLabels := make(labels.Set) for k, v := range config.Spec.Template.Labels { podLabels[k] = v } - podLabels[deployapi.DeploymentConfigLabel] = config.Name - podLabels[deployapi.DeploymentLabel] = deploymentName + podLabels[appsapi.DeploymentConfigLabel] = config.Name + podLabels[appsapi.DeploymentLabel] = deploymentName podAnnotations := make(labels.Set) for k, v := range config.Spec.Template.Annotations { podAnnotations[k] = v } - podAnnotations[deployapi.DeploymentAnnotation] = deploymentName - podAnnotations[deployapi.DeploymentConfigAnnotation] = config.Name - podAnnotations[deployapi.DeploymentVersionAnnotation] = strconv.FormatInt(config.Status.LatestVersion, 10) + podAnnotations[appsapi.DeploymentAnnotation] = deploymentName + podAnnotations[appsapi.DeploymentConfigAnnotation] = config.Name + podAnnotations[appsapi.DeploymentVersionAnnotation] = strconv.FormatInt(config.Status.LatestVersion, 10) controllerRef := NewControllerRef(config) zero := int32(0) @@ -469,13 +469,13 @@ func MakeDeploymentV1(config *deployapi.DeploymentConfig, codec runtime.Codec) ( Name: deploymentName, Namespace: config.Namespace, Annotations: map[string]string{ - deployapi.DeploymentConfigAnnotation: config.Name, - deployapi.DeploymentStatusAnnotation: string(deployapi.DeploymentStatusNew), - deployapi.DeploymentEncodedConfigAnnotation: encodedConfig, - deployapi.DeploymentVersionAnnotation: strconv.FormatInt(config.Status.LatestVersion, 10), + appsapi.DeploymentConfigAnnotation: config.Name, + appsapi.DeploymentStatusAnnotation: string(appsapi.DeploymentStatusNew), + appsapi.DeploymentEncodedConfigAnnotation: encodedConfig, + appsapi.DeploymentVersionAnnotation: strconv.FormatInt(config.Status.LatestVersion, 10), // This is the target replica count for the new deployment. - deployapi.DesiredReplicasAnnotation: strconv.Itoa(int(config.Spec.Replicas)), - deployapi.DeploymentReplicasAnnotation: strconv.Itoa(0), + appsapi.DesiredReplicasAnnotation: strconv.Itoa(int(config.Spec.Replicas)), + appsapi.DeploymentReplicasAnnotation: strconv.Itoa(0), }, Labels: controllerLabels, OwnerReferences: []metav1.OwnerReference{*controllerRef}, @@ -495,10 +495,10 @@ func MakeDeploymentV1(config *deployapi.DeploymentConfig, codec runtime.Codec) ( }, } if config.Status.Details != nil && len(config.Status.Details.Message) > 0 { - deployment.Annotations[deployapi.DeploymentStatusReasonAnnotation] = config.Status.Details.Message + deployment.Annotations[appsapi.DeploymentStatusReasonAnnotation] = config.Status.Details.Message } - if value, ok := config.Annotations[deployapi.DeploymentIgnorePodAnnotation]; ok { - deployment.Annotations[deployapi.DeploymentIgnorePodAnnotation] = value + if value, ok := config.Annotations[appsapi.DeploymentIgnorePodAnnotation]; ok { + deployment.Annotations[appsapi.DeploymentIgnorePodAnnotation] = value } return deployment, nil @@ -553,39 +553,39 @@ func GetAvailableReplicaCountForReplicationControllers(replicationControllers [] } func DeploymentConfigNameFor(obj runtime.Object) string { - return annotationFor(obj, deployapi.DeploymentConfigAnnotation) + return annotationFor(obj, appsapi.DeploymentConfigAnnotation) } func DeploymentNameFor(obj runtime.Object) string { - return annotationFor(obj, deployapi.DeploymentAnnotation) + return annotationFor(obj, appsapi.DeploymentAnnotation) } func DeployerPodNameFor(obj runtime.Object) string { - return annotationFor(obj, deployapi.DeploymentPodAnnotation) + return annotationFor(obj, appsapi.DeploymentPodAnnotation) } -func DeploymentStatusFor(obj runtime.Object) deployapi.DeploymentStatus { - return deployapi.DeploymentStatus(annotationFor(obj, deployapi.DeploymentStatusAnnotation)) +func DeploymentStatusFor(obj runtime.Object) appsapi.DeploymentStatus { + return appsapi.DeploymentStatus(annotationFor(obj, appsapi.DeploymentStatusAnnotation)) } func DeploymentStatusReasonFor(obj runtime.Object) string { - return annotationFor(obj, deployapi.DeploymentStatusReasonAnnotation) + return annotationFor(obj, appsapi.DeploymentStatusReasonAnnotation) } func DeploymentDesiredReplicas(obj runtime.Object) (int32, bool) { - return int32AnnotationFor(obj, deployapi.DesiredReplicasAnnotation) + return int32AnnotationFor(obj, appsapi.DesiredReplicasAnnotation) } func DeploymentReplicas(obj runtime.Object) (int32, bool) { - return int32AnnotationFor(obj, deployapi.DeploymentReplicasAnnotation) + return int32AnnotationFor(obj, appsapi.DeploymentReplicasAnnotation) } func EncodedDeploymentConfigFor(obj runtime.Object) string { - return annotationFor(obj, deployapi.DeploymentEncodedConfigAnnotation) + return annotationFor(obj, appsapi.DeploymentEncodedConfigAnnotation) } func DeploymentVersionFor(obj runtime.Object) int64 { - v, err := strconv.ParseInt(annotationFor(obj, deployapi.DeploymentVersionAnnotation), 10, 64) + v, err := strconv.ParseInt(annotationFor(obj, appsapi.DeploymentVersionAnnotation), 10, 64) if err != nil { return -1 } @@ -593,13 +593,13 @@ func DeploymentVersionFor(obj runtime.Object) int64 { } func IsDeploymentCancelled(deployment runtime.Object) bool { - value := annotationFor(deployment, deployapi.DeploymentCancelledAnnotation) - return strings.EqualFold(value, deployapi.DeploymentCancelledAnnotationValue) + value := annotationFor(deployment, appsapi.DeploymentCancelledAnnotation) + return strings.EqualFold(value, appsapi.DeploymentCancelledAnnotationValue) } // HasSynced checks if the provided deployment config has been noticed by the deployment // config controller. -func HasSynced(dc *deployapi.DeploymentConfig, generation int64) bool { +func HasSynced(dc *appsapi.DeploymentConfig, generation int64) bool { return dc.Status.ObservedGeneration >= generation } @@ -607,7 +607,7 @@ func HasSynced(dc *deployapi.DeploymentConfig, generation int64) bool { // deployment configuration. // TODO: Switch to use owner references once we got those working. func IsOwnedByConfig(obj metav1.Object) bool { - _, ok := obj.GetAnnotations()[deployapi.DeploymentConfigAnnotation] + _, ok := obj.GetAnnotations()[appsapi.DeploymentConfigAnnotation] return ok } @@ -620,42 +620,42 @@ func IsTerminatedDeployment(deployment runtime.Object) bool { // IsNewDeployment returns true if the passed deployment is in new state. func IsNewDeployment(deployment runtime.Object) bool { current := DeploymentStatusFor(deployment) - return current == deployapi.DeploymentStatusNew + return current == appsapi.DeploymentStatusNew } // IsCompleteDeployment returns true if the passed deployment is in state complete. func IsCompleteDeployment(deployment runtime.Object) bool { current := DeploymentStatusFor(deployment) - return current == deployapi.DeploymentStatusComplete + return current == appsapi.DeploymentStatusComplete } // IsFailedDeployment returns true if the passed deployment failed. func IsFailedDeployment(deployment runtime.Object) bool { current := DeploymentStatusFor(deployment) - return current == deployapi.DeploymentStatusFailed + return current == appsapi.DeploymentStatusFailed } // CanTransitionPhase returns whether it is allowed to go from the current to the next phase. -func CanTransitionPhase(current, next deployapi.DeploymentStatus) bool { +func CanTransitionPhase(current, next appsapi.DeploymentStatus) bool { switch current { - case deployapi.DeploymentStatusNew: + case appsapi.DeploymentStatusNew: switch next { - case deployapi.DeploymentStatusPending, - deployapi.DeploymentStatusRunning, - deployapi.DeploymentStatusFailed, - deployapi.DeploymentStatusComplete: + case appsapi.DeploymentStatusPending, + appsapi.DeploymentStatusRunning, + appsapi.DeploymentStatusFailed, + appsapi.DeploymentStatusComplete: return true } - case deployapi.DeploymentStatusPending: + case appsapi.DeploymentStatusPending: switch next { - case deployapi.DeploymentStatusRunning, - deployapi.DeploymentStatusFailed, - deployapi.DeploymentStatusComplete: + case appsapi.DeploymentStatusRunning, + appsapi.DeploymentStatusFailed, + appsapi.DeploymentStatusComplete: return true } - case deployapi.DeploymentStatusRunning: + case appsapi.DeploymentStatusRunning: switch next { - case deployapi.DeploymentStatusFailed, deployapi.DeploymentStatusComplete: + case appsapi.DeploymentStatusFailed, appsapi.DeploymentStatusComplete: return true } } @@ -663,13 +663,13 @@ func CanTransitionPhase(current, next deployapi.DeploymentStatus) bool { } // IsRollingConfig returns true if the strategy type is a rolling update. -func IsRollingConfig(config *deployapi.DeploymentConfig) bool { - return config.Spec.Strategy.Type == deployapi.DeploymentStrategyTypeRolling +func IsRollingConfig(config *appsapi.DeploymentConfig) bool { + return config.Spec.Strategy.Type == appsapi.DeploymentStrategyTypeRolling } // IsProgressing expects a state deployment config and its updated status in order to // determine if there is any progress. -func IsProgressing(config *deployapi.DeploymentConfig, newStatus *deployapi.DeploymentConfigStatus) bool { +func IsProgressing(config *appsapi.DeploymentConfig, newStatus *appsapi.DeploymentConfigStatus) bool { oldStatusOldReplicas := config.Status.Replicas - config.Status.UpdatedReplicas newStatusOldReplicas := newStatus.Replicas - newStatus.UpdatedReplicas @@ -677,7 +677,7 @@ func IsProgressing(config *deployapi.DeploymentConfig, newStatus *deployapi.Depl } // MaxUnavailable returns the maximum unavailable pods a rolling deployment config can take. -func MaxUnavailable(config *deployapi.DeploymentConfig) int32 { +func MaxUnavailable(config *appsapi.DeploymentConfig) int32 { if !IsRollingConfig(config) { return int32(0) } @@ -687,7 +687,7 @@ func MaxUnavailable(config *deployapi.DeploymentConfig) int32 { } // MaxSurge returns the maximum surge pods a rolling deployment config can take. -func MaxSurge(config deployapi.DeploymentConfig) int32 { +func MaxSurge(config appsapi.DeploymentConfig) int32 { if !IsRollingConfig(&config) { return int32(0) } @@ -722,7 +722,7 @@ func int32AnnotationFor(obj runtime.Object, key string) (int32, bool) { // DeploymentsForCleanup determines which deployments for a configuration are relevant for the // revision history limit quota -func DeploymentsForCleanup(configuration *deployapi.DeploymentConfig, deployments []*v1.ReplicationController) []v1.ReplicationController { +func DeploymentsForCleanup(configuration *appsapi.DeploymentConfig, deployments []*v1.ReplicationController) []v1.ReplicationController { // if the past deployment quota has been exceeded, we need to prune the oldest deployments // until we are not exceeding the quota any longer, so we sort oldest first sort.Sort(ByLatestVersionAscV1(deployments)) @@ -755,21 +755,21 @@ func DeploymentsForCleanup(configuration *deployapi.DeploymentConfig, deployment // GetTimeoutSecondsForStrategy returns the timeout in seconds defined in the // deployment config strategy. -func GetTimeoutSecondsForStrategy(config *deployapi.DeploymentConfig) int64 { +func GetTimeoutSecondsForStrategy(config *appsapi.DeploymentConfig) int64 { var timeoutSeconds int64 switch config.Spec.Strategy.Type { - case deployapi.DeploymentStrategyTypeRolling: - timeoutSeconds = deployapi.DefaultRollingTimeoutSeconds + case appsapi.DeploymentStrategyTypeRolling: + timeoutSeconds = appsapi.DefaultRollingTimeoutSeconds if t := config.Spec.Strategy.RollingParams.TimeoutSeconds; t != nil { timeoutSeconds = *t } - case deployapi.DeploymentStrategyTypeRecreate: - timeoutSeconds = deployapi.DefaultRecreateTimeoutSeconds + case appsapi.DeploymentStrategyTypeRecreate: + timeoutSeconds = appsapi.DefaultRecreateTimeoutSeconds if t := config.Spec.Strategy.RecreateParams.TimeoutSeconds; t != nil { timeoutSeconds = *t } - case deployapi.DeploymentStrategyTypeCustom: - timeoutSeconds = deployapi.DefaultRecreateTimeoutSeconds + case appsapi.DeploymentStrategyTypeCustom: + timeoutSeconds = appsapi.DefaultRecreateTimeoutSeconds } return timeoutSeconds } @@ -780,7 +780,7 @@ func GetTimeoutSecondsForStrategy(config *deployapi.DeploymentConfig) int64 { // set for the deployer pod. In some cases, the deployer pod cannot be created // (like quota, etc...). In that case deployer controller use this function to // measure if the created deployment (RC) exceeded the timeout. -func RolloutExceededTimeoutSeconds(config *deployapi.DeploymentConfig, latestRC *v1.ReplicationController) bool { +func RolloutExceededTimeoutSeconds(config *appsapi.DeploymentConfig, latestRC *v1.ReplicationController) bool { timeoutSeconds := GetTimeoutSecondsForStrategy(config) // If user set the timeoutSeconds to 0, we assume there should be no timeout. if timeoutSeconds <= 0 { diff --git a/pkg/apps/util/util_test.go b/pkg/apps/util/util_test.go index f0454848064e..d2ac9abf7e35 100644 --- a/pkg/apps/util/util_test.go +++ b/pkg/apps/util/util_test.go @@ -10,15 +10,15 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kapi "k8s.io/kubernetes/pkg/api" - deployv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" _ "github.com/openshift/origin/pkg/api/install" ) func podTemplateA() *kapi.PodTemplateSpec { - t := deploytest.OkPodTemplate() + t := appstest.OkPodTemplate() t.Spec.Containers = append(t.Spec.Containers, kapi.Container{ Name: "container1", Image: "registry:8080/repo1:ref1", @@ -66,17 +66,17 @@ func TestPodName(t *testing.T) { } func TestMakeDeploymentOk(t *testing.T) { - config := deploytest.OkDeploymentConfig(1) - deployment, err := MakeDeployment(config, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + config := appstest.OkDeploymentConfig(1) + deployment, err := MakeDeployment(config, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) if err != nil { t.Fatalf("unexpected error: %#v", err) } expectedAnnotations := map[string]string{ - deployapi.DeploymentConfigAnnotation: config.Name, - deployapi.DeploymentStatusAnnotation: string(deployapi.DeploymentStatusNew), - deployapi.DeploymentVersionAnnotation: strconv.FormatInt(config.Status.LatestVersion, 10), + appsapi.DeploymentConfigAnnotation: config.Name, + appsapi.DeploymentStatusAnnotation: string(appsapi.DeploymentStatusNew), + appsapi.DeploymentVersionAnnotation: strconv.FormatInt(config.Status.LatestVersion, 10), } for key, expected := range expectedAnnotations { @@ -86,9 +86,9 @@ func TestMakeDeploymentOk(t *testing.T) { } expectedAnnotations = map[string]string{ - deployapi.DeploymentAnnotation: deployment.Name, - deployapi.DeploymentConfigAnnotation: config.Name, - deployapi.DeploymentVersionAnnotation: strconv.FormatInt(config.Status.LatestVersion, 10), + appsapi.DeploymentAnnotation: deployment.Name, + appsapi.DeploymentConfigAnnotation: config.Name, + appsapi.DeploymentVersionAnnotation: strconv.FormatInt(config.Status.LatestVersion, 10), } for key, expected := range expectedAnnotations { @@ -101,7 +101,7 @@ func TestMakeDeploymentOk(t *testing.T) { t.Fatalf("expected deployment with DeploymentEncodedConfigAnnotation annotation") } - if decodedConfig, err := DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)); err != nil { + if decodedConfig, err := DecodeDeploymentConfig(deployment, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)); err != nil { t.Fatalf("invalid encoded config on deployment: %v", err) } else { if e, a := config.Name, decodedConfig.Name; e != a { @@ -114,30 +114,30 @@ func TestMakeDeploymentOk(t *testing.T) { t.Fatalf("expected deployment replicas to be 0") } - if l, e, a := deployapi.DeploymentConfigAnnotation, config.Name, deployment.Labels[deployapi.DeploymentConfigAnnotation]; e != a { + if l, e, a := appsapi.DeploymentConfigAnnotation, config.Name, deployment.Labels[appsapi.DeploymentConfigAnnotation]; e != a { t.Fatalf("expected label %s=%s, got %s", l, e, a) } - if e, a := config.Name, deployment.Spec.Template.Labels[deployapi.DeploymentConfigLabel]; e != a { + if e, a := config.Name, deployment.Spec.Template.Labels[appsapi.DeploymentConfigLabel]; e != a { t.Fatalf("expected label DeploymentConfigLabel=%s, got %s", e, a) } - if e, a := deployment.Name, deployment.Spec.Template.Labels[deployapi.DeploymentLabel]; e != a { + if e, a := deployment.Name, deployment.Spec.Template.Labels[appsapi.DeploymentLabel]; e != a { t.Fatalf("expected label DeploymentLabel=%s, got %s", e, a) } - if e, a := config.Name, deployment.Spec.Selector[deployapi.DeploymentConfigLabel]; e != a { + if e, a := config.Name, deployment.Spec.Selector[appsapi.DeploymentConfigLabel]; e != a { t.Fatalf("expected selector DeploymentConfigLabel=%s, got %s", e, a) } - if e, a := deployment.Name, deployment.Spec.Selector[deployapi.DeploymentLabel]; e != a { + if e, a := deployment.Name, deployment.Spec.Selector[appsapi.DeploymentLabel]; e != a { t.Fatalf("expected selector DeploymentLabel=%s, got %s", e, a) } } func TestDeploymentsByLatestVersion_sorting(t *testing.T) { mkdeployment := func(version int64) *kapi.ReplicationController { - deployment, _ := MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + deployment, _ := MakeDeployment(appstest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) return deployment } deployments := []*kapi.ReplicationController{ @@ -190,157 +190,157 @@ func TestSort(t *testing.T) { func TestCanTransitionPhase(t *testing.T) { tests := []struct { name string - current, next deployapi.DeploymentStatus + current, next appsapi.DeploymentStatus expected bool }{ { name: "New->New", - current: deployapi.DeploymentStatusNew, - next: deployapi.DeploymentStatusNew, + current: appsapi.DeploymentStatusNew, + next: appsapi.DeploymentStatusNew, expected: false, }, { name: "New->Pending", - current: deployapi.DeploymentStatusNew, - next: deployapi.DeploymentStatusPending, + current: appsapi.DeploymentStatusNew, + next: appsapi.DeploymentStatusPending, expected: true, }, { name: "New->Running", - current: deployapi.DeploymentStatusNew, - next: deployapi.DeploymentStatusRunning, + current: appsapi.DeploymentStatusNew, + next: appsapi.DeploymentStatusRunning, expected: true, }, { name: "New->Complete", - current: deployapi.DeploymentStatusNew, - next: deployapi.DeploymentStatusComplete, + current: appsapi.DeploymentStatusNew, + next: appsapi.DeploymentStatusComplete, expected: true, }, { name: "New->Failed", - current: deployapi.DeploymentStatusNew, - next: deployapi.DeploymentStatusFailed, + current: appsapi.DeploymentStatusNew, + next: appsapi.DeploymentStatusFailed, expected: true, }, { name: "Pending->New", - current: deployapi.DeploymentStatusPending, - next: deployapi.DeploymentStatusNew, + current: appsapi.DeploymentStatusPending, + next: appsapi.DeploymentStatusNew, expected: false, }, { name: "Pending->Pending", - current: deployapi.DeploymentStatusPending, - next: deployapi.DeploymentStatusPending, + current: appsapi.DeploymentStatusPending, + next: appsapi.DeploymentStatusPending, expected: false, }, { name: "Pending->Running", - current: deployapi.DeploymentStatusPending, - next: deployapi.DeploymentStatusRunning, + current: appsapi.DeploymentStatusPending, + next: appsapi.DeploymentStatusRunning, expected: true, }, { name: "Pending->Failed", - current: deployapi.DeploymentStatusPending, - next: deployapi.DeploymentStatusFailed, + current: appsapi.DeploymentStatusPending, + next: appsapi.DeploymentStatusFailed, expected: true, }, { name: "Pending->Complete", - current: deployapi.DeploymentStatusPending, - next: deployapi.DeploymentStatusComplete, + current: appsapi.DeploymentStatusPending, + next: appsapi.DeploymentStatusComplete, expected: true, }, { name: "Running->New", - current: deployapi.DeploymentStatusRunning, - next: deployapi.DeploymentStatusNew, + current: appsapi.DeploymentStatusRunning, + next: appsapi.DeploymentStatusNew, expected: false, }, { name: "Running->Pending", - current: deployapi.DeploymentStatusRunning, - next: deployapi.DeploymentStatusPending, + current: appsapi.DeploymentStatusRunning, + next: appsapi.DeploymentStatusPending, expected: false, }, { name: "Running->Running", - current: deployapi.DeploymentStatusRunning, - next: deployapi.DeploymentStatusRunning, + current: appsapi.DeploymentStatusRunning, + next: appsapi.DeploymentStatusRunning, expected: false, }, { name: "Running->Failed", - current: deployapi.DeploymentStatusRunning, - next: deployapi.DeploymentStatusFailed, + current: appsapi.DeploymentStatusRunning, + next: appsapi.DeploymentStatusFailed, expected: true, }, { name: "Running->Complete", - current: deployapi.DeploymentStatusRunning, - next: deployapi.DeploymentStatusComplete, + current: appsapi.DeploymentStatusRunning, + next: appsapi.DeploymentStatusComplete, expected: true, }, { name: "Complete->New", - current: deployapi.DeploymentStatusComplete, - next: deployapi.DeploymentStatusNew, + current: appsapi.DeploymentStatusComplete, + next: appsapi.DeploymentStatusNew, expected: false, }, { name: "Complete->Pending", - current: deployapi.DeploymentStatusComplete, - next: deployapi.DeploymentStatusPending, + current: appsapi.DeploymentStatusComplete, + next: appsapi.DeploymentStatusPending, expected: false, }, { name: "Complete->Running", - current: deployapi.DeploymentStatusComplete, - next: deployapi.DeploymentStatusRunning, + current: appsapi.DeploymentStatusComplete, + next: appsapi.DeploymentStatusRunning, expected: false, }, { name: "Complete->Failed", - current: deployapi.DeploymentStatusComplete, - next: deployapi.DeploymentStatusFailed, + current: appsapi.DeploymentStatusComplete, + next: appsapi.DeploymentStatusFailed, expected: false, }, { name: "Complete->Complete", - current: deployapi.DeploymentStatusComplete, - next: deployapi.DeploymentStatusComplete, + current: appsapi.DeploymentStatusComplete, + next: appsapi.DeploymentStatusComplete, expected: false, }, { name: "Failed->New", - current: deployapi.DeploymentStatusFailed, - next: deployapi.DeploymentStatusNew, + current: appsapi.DeploymentStatusFailed, + next: appsapi.DeploymentStatusNew, expected: false, }, { name: "Failed->Pending", - current: deployapi.DeploymentStatusFailed, - next: deployapi.DeploymentStatusPending, + current: appsapi.DeploymentStatusFailed, + next: appsapi.DeploymentStatusPending, expected: false, }, { name: "Failed->Running", - current: deployapi.DeploymentStatusFailed, - next: deployapi.DeploymentStatusRunning, + current: appsapi.DeploymentStatusFailed, + next: appsapi.DeploymentStatusRunning, expected: false, }, { name: "Failed->Complete", - current: deployapi.DeploymentStatusFailed, - next: deployapi.DeploymentStatusComplete, + current: appsapi.DeploymentStatusFailed, + next: appsapi.DeploymentStatusComplete, expected: false, }, { name: "Failed->Failed", - current: deployapi.DeploymentStatusFailed, - next: deployapi.DeploymentStatusFailed, + current: appsapi.DeploymentStatusFailed, + next: appsapi.DeploymentStatusFailed, expected: false, }, } @@ -358,60 +358,60 @@ var ( later = metav1.Time{Time: now.Add(time.Minute)} earlier = metav1.Time{Time: now.Add(-time.Minute)} - condProgressing = func() deployapi.DeploymentCondition { - return deployapi.DeploymentCondition{ - Type: deployapi.DeploymentProgressing, + condProgressing = func() appsapi.DeploymentCondition { + return appsapi.DeploymentCondition{ + Type: appsapi.DeploymentProgressing, Status: kapi.ConditionTrue, LastTransitionTime: now, } } - condProgressingDifferentTime = func() deployapi.DeploymentCondition { - return deployapi.DeploymentCondition{ - Type: deployapi.DeploymentProgressing, + condProgressingDifferentTime = func() appsapi.DeploymentCondition { + return appsapi.DeploymentCondition{ + Type: appsapi.DeploymentProgressing, Status: kapi.ConditionTrue, LastTransitionTime: later, } } - condProgressingDifferentReason = func() deployapi.DeploymentCondition { - return deployapi.DeploymentCondition{ - Type: deployapi.DeploymentProgressing, + condProgressingDifferentReason = func() appsapi.DeploymentCondition { + return appsapi.DeploymentCondition{ + Type: appsapi.DeploymentProgressing, Status: kapi.ConditionTrue, LastTransitionTime: later, - Reason: deployapi.NewReplicationControllerReason, + Reason: appsapi.NewReplicationControllerReason, } } - condNotProgressing = func() deployapi.DeploymentCondition { - return deployapi.DeploymentCondition{ - Type: deployapi.DeploymentProgressing, + condNotProgressing = func() appsapi.DeploymentCondition { + return appsapi.DeploymentCondition{ + Type: appsapi.DeploymentProgressing, Status: kapi.ConditionFalse, LastUpdateTime: earlier, LastTransitionTime: earlier, } } - condAvailable = func() deployapi.DeploymentCondition { - return deployapi.DeploymentCondition{ - Type: deployapi.DeploymentAvailable, + condAvailable = func() appsapi.DeploymentCondition { + return appsapi.DeploymentCondition{ + Type: appsapi.DeploymentAvailable, Status: kapi.ConditionTrue, } } ) func TestGetCondition(t *testing.T) { - exampleStatus := func() deployapi.DeploymentConfigStatus { - return deployapi.DeploymentConfigStatus{ - Conditions: []deployapi.DeploymentCondition{condProgressing(), condAvailable()}, + exampleStatus := func() appsapi.DeploymentConfigStatus { + return appsapi.DeploymentConfigStatus{ + Conditions: []appsapi.DeploymentCondition{condProgressing(), condAvailable()}, } } tests := []struct { name string - status deployapi.DeploymentConfigStatus - condType deployapi.DeploymentConditionType + status appsapi.DeploymentConfigStatus + condType appsapi.DeploymentConditionType condStatus kapi.ConditionStatus expected bool @@ -420,7 +420,7 @@ func TestGetCondition(t *testing.T) { name: "condition exists", status: exampleStatus(), - condType: deployapi.DeploymentAvailable, + condType: appsapi.DeploymentAvailable, expected: true, }, @@ -428,7 +428,7 @@ func TestGetCondition(t *testing.T) { name: "condition does not exist", status: exampleStatus(), - condType: deployapi.DeploymentReplicaFailure, + condType: appsapi.DeploymentReplicaFailure, expected: false, }, @@ -447,19 +447,19 @@ func TestSetCondition(t *testing.T) { tests := []struct { name string - status *deployapi.DeploymentConfigStatus - cond deployapi.DeploymentCondition + status *appsapi.DeploymentConfigStatus + cond appsapi.DeploymentCondition - expectedStatus *deployapi.DeploymentConfigStatus + expectedStatus *appsapi.DeploymentConfigStatus }{ { name: "set for the first time", - status: &deployapi.DeploymentConfigStatus{}, + status: &appsapi.DeploymentConfigStatus{}, cond: condAvailable(), - expectedStatus: &deployapi.DeploymentConfigStatus{ - Conditions: []deployapi.DeploymentCondition{ + expectedStatus: &appsapi.DeploymentConfigStatus{ + Conditions: []appsapi.DeploymentCondition{ condAvailable(), }, }, @@ -467,15 +467,15 @@ func TestSetCondition(t *testing.T) { { name: "simple set", - status: &deployapi.DeploymentConfigStatus{ - Conditions: []deployapi.DeploymentCondition{ + status: &appsapi.DeploymentConfigStatus{ + Conditions: []appsapi.DeploymentCondition{ condProgressing(), }, }, cond: condAvailable(), - expectedStatus: &deployapi.DeploymentConfigStatus{ - Conditions: []deployapi.DeploymentCondition{ + expectedStatus: &appsapi.DeploymentConfigStatus{ + Conditions: []appsapi.DeploymentCondition{ condProgressing(), condAvailable(), }, }, @@ -483,34 +483,34 @@ func TestSetCondition(t *testing.T) { { name: "replace if status changes", - status: &deployapi.DeploymentConfigStatus{ - Conditions: []deployapi.DeploymentCondition{ + status: &appsapi.DeploymentConfigStatus{ + Conditions: []appsapi.DeploymentCondition{ condNotProgressing(), }, }, cond: condProgressing(), - expectedStatus: &deployapi.DeploymentConfigStatus{Conditions: []deployapi.DeploymentCondition{condProgressing()}}, + expectedStatus: &appsapi.DeploymentConfigStatus{Conditions: []appsapi.DeploymentCondition{condProgressing()}}, }, { name: "replace if reason changes", - status: &deployapi.DeploymentConfigStatus{ - Conditions: []deployapi.DeploymentCondition{ + status: &appsapi.DeploymentConfigStatus{ + Conditions: []appsapi.DeploymentCondition{ condProgressing(), }, }, cond: condProgressingDifferentReason(), - expectedStatus: &deployapi.DeploymentConfigStatus{ - Conditions: []deployapi.DeploymentCondition{ + expectedStatus: &appsapi.DeploymentConfigStatus{ + Conditions: []appsapi.DeploymentCondition{ { - Type: deployapi.DeploymentProgressing, + Type: appsapi.DeploymentProgressing, Status: kapi.ConditionTrue, // Note that LastTransitionTime stays the same. LastTransitionTime: now, // Only the reason changes. - Reason: deployapi.NewReplicationControllerReason, + Reason: appsapi.NewReplicationControllerReason, }, }, }, @@ -518,14 +518,14 @@ func TestSetCondition(t *testing.T) { { name: "don't replace if status and reason don't change", - status: &deployapi.DeploymentConfigStatus{ - Conditions: []deployapi.DeploymentCondition{ + status: &appsapi.DeploymentConfigStatus{ + Conditions: []appsapi.DeploymentCondition{ condProgressing(), }, }, cond: condProgressingDifferentTime(), - expectedStatus: &deployapi.DeploymentConfigStatus{Conditions: []deployapi.DeploymentCondition{condProgressing()}}, + expectedStatus: &appsapi.DeploymentConfigStatus{Conditions: []appsapi.DeploymentCondition{condProgressing()}}, }, } @@ -539,41 +539,41 @@ func TestSetCondition(t *testing.T) { } func TestRemoveCondition(t *testing.T) { - exampleStatus := func() *deployapi.DeploymentConfigStatus { - return &deployapi.DeploymentConfigStatus{ - Conditions: []deployapi.DeploymentCondition{condProgressing(), condAvailable()}, + exampleStatus := func() *appsapi.DeploymentConfigStatus { + return &appsapi.DeploymentConfigStatus{ + Conditions: []appsapi.DeploymentCondition{condProgressing(), condAvailable()}, } } tests := []struct { name string - status *deployapi.DeploymentConfigStatus - condType deployapi.DeploymentConditionType + status *appsapi.DeploymentConfigStatus + condType appsapi.DeploymentConditionType - expectedStatus *deployapi.DeploymentConfigStatus + expectedStatus *appsapi.DeploymentConfigStatus }{ { name: "remove from empty status", - status: &deployapi.DeploymentConfigStatus{}, - condType: deployapi.DeploymentProgressing, + status: &appsapi.DeploymentConfigStatus{}, + condType: appsapi.DeploymentProgressing, - expectedStatus: &deployapi.DeploymentConfigStatus{}, + expectedStatus: &appsapi.DeploymentConfigStatus{}, }, { name: "simple remove", - status: &deployapi.DeploymentConfigStatus{Conditions: []deployapi.DeploymentCondition{condProgressing()}}, - condType: deployapi.DeploymentProgressing, + status: &appsapi.DeploymentConfigStatus{Conditions: []appsapi.DeploymentCondition{condProgressing()}}, + condType: appsapi.DeploymentProgressing, - expectedStatus: &deployapi.DeploymentConfigStatus{}, + expectedStatus: &appsapi.DeploymentConfigStatus{}, }, { name: "doesn't remove anything", status: exampleStatus(), - condType: deployapi.DeploymentReplicaFailure, + condType: appsapi.DeploymentReplicaFailure, expectedStatus: exampleStatus(), }, @@ -591,15 +591,15 @@ func TestRolloutExceededTimeoutSeconds(t *testing.T) { now := time.Now() tests := []struct { name string - config *deployapi.DeploymentConfig + config *appsapi.DeploymentConfig deploymentCreationTime time.Time expectTimeout bool }{ // Recreate strategy with deployment running for 20s (exceeding 10s timeout) { name: "recreate timeout", - config: func(timeoutSeconds int64) *deployapi.DeploymentConfig { - config := deploytest.OkDeploymentConfig(1) + config: func(timeoutSeconds int64) *appsapi.DeploymentConfig { + config := appstest.OkDeploymentConfig(1) config.Spec.Strategy.RecreateParams.TimeoutSeconds = &timeoutSeconds return config }(int64(10)), @@ -609,8 +609,8 @@ func TestRolloutExceededTimeoutSeconds(t *testing.T) { // Recreate strategy with no timeout { name: "recreate no timeout", - config: func(timeoutSeconds int64) *deployapi.DeploymentConfig { - config := deploytest.OkDeploymentConfig(1) + config: func(timeoutSeconds int64) *appsapi.DeploymentConfig { + config := appstest.OkDeploymentConfig(1) config.Spec.Strategy.RecreateParams.TimeoutSeconds = &timeoutSeconds return config }(int64(0)), @@ -621,9 +621,9 @@ func TestRolloutExceededTimeoutSeconds(t *testing.T) { // Rolling strategy with deployment running for 20s (exceeding 10s timeout) { name: "rolling timeout", - config: func(timeoutSeconds int64) *deployapi.DeploymentConfig { - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = deploytest.OkRollingStrategy() + config: func(timeoutSeconds int64) *appsapi.DeploymentConfig { + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = appstest.OkRollingStrategy() config.Spec.Strategy.RollingParams.TimeoutSeconds = &timeoutSeconds return config }(int64(10)), @@ -633,9 +633,9 @@ func TestRolloutExceededTimeoutSeconds(t *testing.T) { // Rolling strategy with deployment with no timeout specified. { name: "rolling using default timeout", - config: func(timeoutSeconds int64) *deployapi.DeploymentConfig { - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = deploytest.OkRollingStrategy() + config: func(timeoutSeconds int64) *appsapi.DeploymentConfig { + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = appstest.OkRollingStrategy() config.Spec.Strategy.RollingParams.TimeoutSeconds = nil return config }(0), @@ -645,8 +645,8 @@ func TestRolloutExceededTimeoutSeconds(t *testing.T) { // Recreate strategy with deployment with no timeout specified. { name: "recreate using default timeout", - config: func(timeoutSeconds int64) *deployapi.DeploymentConfig { - config := deploytest.OkDeploymentConfig(1) + config: func(timeoutSeconds int64) *appsapi.DeploymentConfig { + config := appstest.OkDeploymentConfig(1) config.Spec.Strategy.RecreateParams.TimeoutSeconds = nil return config }(0), @@ -656,9 +656,9 @@ func TestRolloutExceededTimeoutSeconds(t *testing.T) { // Custom strategy with deployment with no timeout specified. { name: "custom using default timeout", - config: func(timeoutSeconds int64) *deployapi.DeploymentConfig { - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = deploytest.OkCustomStrategy() + config: func(timeoutSeconds int64) *appsapi.DeploymentConfig { + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = appstest.OkCustomStrategy() return config }(0), deploymentCreationTime: now.Add(-20 * time.Second), @@ -667,9 +667,9 @@ func TestRolloutExceededTimeoutSeconds(t *testing.T) { // Custom strategy use default timeout exceeding it. { name: "custom using default timeout timing out", - config: func(timeoutSeconds int64) *deployapi.DeploymentConfig { - config := deploytest.OkDeploymentConfig(1) - config.Spec.Strategy = deploytest.OkCustomStrategy() + config: func(timeoutSeconds int64) *appsapi.DeploymentConfig { + config := appstest.OkDeploymentConfig(1) + config.Spec.Strategy = appstest.OkCustomStrategy() return config }(0), deploymentCreationTime: now.Add(-700 * time.Second), @@ -679,7 +679,7 @@ func TestRolloutExceededTimeoutSeconds(t *testing.T) { for _, tc := range tests { config := tc.config - deployment, err := MakeDeploymentV1(config, kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) + deployment, err := MakeDeploymentV1(config, kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) if err != nil { t.Fatalf("unexpected error: %v", err) } diff --git a/pkg/cmd/infra/deployer/deployer.go b/pkg/cmd/infra/deployer/deployer.go index 8a33104a6efa..2ecd8c3f7624 100644 --- a/pkg/cmd/infra/deployer/deployer.go +++ b/pkg/cmd/infra/deployer/deployer.go @@ -18,11 +18,11 @@ import ( "k8s.io/kubernetes/pkg/kubectl/cmd/templates" kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/apps/strategy" "github.com/openshift/origin/pkg/apps/strategy/recreate" "github.com/openshift/origin/pkg/apps/strategy/rolling" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" "github.com/openshift/origin/pkg/cmd/util" cmdversion "github.com/openshift/origin/pkg/cmd/version" imageclientinternal "github.com/openshift/origin/pkg/image/generated/internalclientset" @@ -128,14 +128,14 @@ func NewDeployer(client kclientset.Interface, images imageclientinternal.Interfa return client.Core().ReplicationControllers(namespace).Get(name, metav1.GetOptions{}) }, getDeployments: func(namespace, configName string) (*kapi.ReplicationControllerList, error) { - return client.Core().ReplicationControllers(namespace).List(metav1.ListOptions{LabelSelector: deployutil.ConfigSelector(configName).String()}) + return client.Core().ReplicationControllers(namespace).List(metav1.ListOptions{LabelSelector: appsutil.ConfigSelector(configName).String()}) }, scaler: scaler, - strategyFor: func(config *deployapi.DeploymentConfig) (strategy.DeploymentStrategy, error) { + strategyFor: func(config *appsapi.DeploymentConfig) (strategy.DeploymentStrategy, error) { switch config.Spec.Strategy.Type { - case deployapi.DeploymentStrategyTypeRecreate: + case appsapi.DeploymentStrategyTypeRecreate: return recreate.NewRecreateDeploymentStrategy(client, images.Image(), &kv1core.EventSinkImpl{Interface: kv1core.New(client.Core().RESTClient()).Events("")}, kapi.Codecs.UniversalDecoder(), out, errOut, until), nil - case deployapi.DeploymentStrategyTypeRolling: + case appsapi.DeploymentStrategyTypeRolling: recreate := recreate.NewRecreateDeploymentStrategy(client, images.Image(), &kv1core.EventSinkImpl{Interface: kv1core.New(client.Core().RESTClient()).Events("")}, kapi.Codecs.UniversalDecoder(), out, errOut, until) return rolling.NewRollingDeploymentStrategy(config.Namespace, client, images.Image(), &kv1core.EventSinkImpl{Interface: kv1core.New(client.Core().RESTClient()).Events("")}, kapi.Codecs.UniversalDecoder(), recreate, out, errOut, until), nil default: @@ -159,7 +159,7 @@ type Deployer struct { // until is a condition to run until until string // strategyFor returns a DeploymentStrategy for config. - strategyFor func(config *deployapi.DeploymentConfig) (strategy.DeploymentStrategy, error) + strategyFor func(config *appsapi.DeploymentConfig) (strategy.DeploymentStrategy, error) // getDeployment finds the named deployment. getDeployment func(namespace, name string) (*kapi.ReplicationController, error) // getDeployments finds all deployments associated with a config. @@ -177,7 +177,7 @@ func (d *Deployer) Deploy(namespace, rcName string) error { } // Decode the config from the deployment. - config, err := deployutil.DecodeDeploymentConfig(to, kapi.Codecs.UniversalDecoder()) + config, err := appsutil.DecodeDeploymentConfig(to, kapi.Codecs.UniversalDecoder()) if err != nil { return fmt.Errorf("couldn't decode deployment config from deployment %s: %v", to.Name, err) } @@ -189,7 +189,7 @@ func (d *Deployer) Deploy(namespace, rcName string) error { } // New deployments must have a desired replica count. - desiredReplicas, hasDesired := deployutil.DeploymentDesiredReplicas(to) + desiredReplicas, hasDesired := appsutil.DeploymentDesiredReplicas(to) if !hasDesired { return fmt.Errorf("deployment %s has already run to completion", to.Name) } @@ -205,7 +205,7 @@ func (d *Deployer) Deploy(namespace, rcName string) error { } // Sort all the deployments by version. - sort.Sort(deployutil.ByLatestVersionDesc(deployments)) + sort.Sort(appsutil.ByLatestVersionDesc(deployments)) // Find any last completed deployment. var from *kapi.ReplicationController @@ -213,13 +213,13 @@ func (d *Deployer) Deploy(namespace, rcName string) error { if candidate.Name == to.Name { continue } - if deployutil.IsCompleteDeployment(candidate) { + if appsutil.IsCompleteDeployment(candidate) { from = candidate break } } - if deployutil.DeploymentVersionFor(to) < deployutil.DeploymentVersionFor(from) { + if appsutil.DeploymentVersionFor(to) < appsutil.DeploymentVersionFor(from) { return fmt.Errorf("deployment %s is older than %s", to.Name, from.Name) } @@ -239,7 +239,7 @@ func (d *Deployer) Deploy(namespace, rcName string) error { // Scale the deployment down to zero. retryWaitParams := kubectl.NewRetryParams(1*time.Second, 120*time.Second) if err := d.scaler.Scale(candidate.Namespace, candidate.Name, uint(0), &kubectl.ScalePrecondition{Size: -1, ResourceVersion: ""}, retryWaitParams, retryWaitParams); err != nil { - fmt.Fprintf(d.errOut, "error: Couldn't scale down prior deployment %s: %v\n", deployutil.LabelForDeployment(candidate), err) + fmt.Fprintf(d.errOut, "error: Couldn't scale down prior deployment %s: %v\n", appsutil.LabelForDeployment(candidate), err) } else { fmt.Fprintf(d.out, "--> Scaled older deployment %s down\n", candidate.Name) } diff --git a/pkg/cmd/infra/deployer/deployer_test.go b/pkg/cmd/infra/deployer/deployer_test.go index f971e39b8533..a0594df22805 100644 --- a/pkg/cmd/infra/deployer/deployer_test.go +++ b/pkg/cmd/infra/deployer/deployer_test.go @@ -8,12 +8,12 @@ import ( kapi "k8s.io/kubernetes/pkg/api" - deployv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" cmdtest "github.com/openshift/origin/pkg/apps/cmd/test" "github.com/openshift/origin/pkg/apps/strategy" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" // install all APIs _ "github.com/openshift/origin/pkg/api/install" @@ -22,7 +22,7 @@ import ( func TestDeployer_getDeploymentFail(t *testing.T) { deployer := &Deployer{ - strategyFor: func(config *deployapi.DeploymentConfig) (strategy.DeploymentStrategy, error) { + strategyFor: func(config *appsapi.DeploymentConfig) (strategy.DeploymentStrategy, error) { t.Fatal("unexpected call") return nil, nil }, @@ -44,11 +44,11 @@ func TestDeployer_getDeploymentFail(t *testing.T) { } func TestDeployer_deployScenarios(t *testing.T) { - mkd := func(version int64, status deployapi.DeploymentStatus, replicas int32, desired int32) *kapi.ReplicationController { + mkd := func(version int64, status appsapi.DeploymentStatus, replicas int32, desired int32) *kapi.ReplicationController { deployment := mkdeployment(version, status) deployment.Spec.Replicas = int32(replicas) if desired > 0 { - deployment.Annotations[deployapi.DesiredReplicasAnnotation] = strconv.Itoa(int(desired)) + deployment.Annotations[appsapi.DesiredReplicasAnnotation] = strconv.Itoa(int(desired)) } return deployment } @@ -67,7 +67,7 @@ func TestDeployer_deployScenarios(t *testing.T) { "initial deployment", // existing deployments []*kapi.ReplicationController{ - mkd(1, deployapi.DeploymentStatusNew, 0, 3), + mkd(1, appsapi.DeploymentStatusNew, 0, 3), }, // from and to version 0, 1, @@ -78,9 +78,9 @@ func TestDeployer_deployScenarios(t *testing.T) { "last deploy failed", // existing deployments []*kapi.ReplicationController{ - mkd(1, deployapi.DeploymentStatusComplete, 3, 0), - mkd(2, deployapi.DeploymentStatusFailed, 1, 3), - mkd(3, deployapi.DeploymentStatusNew, 0, 3), + mkd(1, appsapi.DeploymentStatusComplete, 3, 0), + mkd(2, appsapi.DeploymentStatusFailed, 1, 3), + mkd(3, appsapi.DeploymentStatusNew, 0, 3), }, // from and to version 1, 3, @@ -93,9 +93,9 @@ func TestDeployer_deployScenarios(t *testing.T) { "sequential complete", // existing deployments []*kapi.ReplicationController{ - mkd(1, deployapi.DeploymentStatusComplete, 0, 0), - mkd(2, deployapi.DeploymentStatusComplete, 3, 0), - mkd(3, deployapi.DeploymentStatusNew, 0, 3), + mkd(1, appsapi.DeploymentStatusComplete, 0, 0), + mkd(2, appsapi.DeploymentStatusComplete, 3, 0), + mkd(3, appsapi.DeploymentStatusNew, 0, 3), }, // from and to version 2, 3, @@ -106,9 +106,9 @@ func TestDeployer_deployScenarios(t *testing.T) { "sequential failure", // existing deployments []*kapi.ReplicationController{ - mkd(1, deployapi.DeploymentStatusFailed, 1, 3), - mkd(2, deployapi.DeploymentStatusFailed, 1, 3), - mkd(3, deployapi.DeploymentStatusNew, 0, 3), + mkd(1, appsapi.DeploymentStatusFailed, 1, 3), + mkd(2, appsapi.DeploymentStatusFailed, 1, 3), + mkd(3, appsapi.DeploymentStatusNew, 0, 3), }, // from and to version 0, 3, @@ -122,9 +122,9 @@ func TestDeployer_deployScenarios(t *testing.T) { "version mismatch", // existing deployments []*kapi.ReplicationController{ - mkd(1, deployapi.DeploymentStatusComplete, 0, 0), - mkd(2, deployapi.DeploymentStatusNew, 3, 0), - mkd(3, deployapi.DeploymentStatusComplete, 0, 3), + mkd(1, appsapi.DeploymentStatusComplete, 0, 0), + mkd(2, appsapi.DeploymentStatusNew, 3, 0), + mkd(3, appsapi.DeploymentStatusComplete, 0, 3), }, // from and to version 3, 2, @@ -137,7 +137,7 @@ func TestDeployer_deployScenarios(t *testing.T) { t.Logf("executing scenario %s", s.name) findDeployment := func(version int64) *kapi.ReplicationController { for _, d := range s.deployments { - if deployutil.DeploymentVersionFor(d) == version { + if appsutil.DeploymentVersionFor(d) == version { return d } } @@ -152,7 +152,7 @@ func TestDeployer_deployScenarios(t *testing.T) { deployer := &Deployer{ out: &bytes.Buffer{}, errOut: &bytes.Buffer{}, - strategyFor: func(config *deployapi.DeploymentConfig) (strategy.DeploymentStrategy, error) { + strategyFor: func(config *appsapi.DeploymentConfig) (strategy.DeploymentStrategy, error) { return &testStrategy{ deployFunc: func(from *kapi.ReplicationController, to *kapi.ReplicationController, desiredReplicas int) error { actualFrom = from @@ -187,11 +187,11 @@ func TestDeployer_deployScenarios(t *testing.T) { } if s.fromVersion > 0 { - if e, a := s.fromVersion, deployutil.DeploymentVersionFor(actualFrom); e != a { + if e, a := s.fromVersion, appsutil.DeploymentVersionFor(actualFrom); e != a { t.Fatalf("expected from.latestVersion %d, got %d", e, a) } } - if e, a := s.toVersion, deployutil.DeploymentVersionFor(actualTo); e != a { + if e, a := s.toVersion, appsutil.DeploymentVersionFor(actualTo); e != a { t.Fatalf("expected to.latestVersion %d, got %d", e, a) } if e, a := len(s.scaleEvents), len(scaler.Events); e != a { @@ -216,9 +216,9 @@ func TestDeployer_deployScenarios(t *testing.T) { } } -func mkdeployment(version int64, status deployapi.DeploymentStatus) *kapi.ReplicationController { - deployment, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion)) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(status) +func mkdeployment(version int64, status appsapi.DeploymentStatus) *kapi.ReplicationController { + deployment, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(version), kapi.Codecs.LegacyCodec(appsv1.SchemeGroupVersion)) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(status) return deployment } diff --git a/pkg/cmd/server/bootstrappolicy/policy.go b/pkg/cmd/server/bootstrappolicy/policy.go index 532a992d7a4e..5ad1267c5d6f 100644 --- a/pkg/cmd/server/bootstrappolicy/policy.go +++ b/pkg/cmd/server/bootstrappolicy/policy.go @@ -22,7 +22,7 @@ import ( "k8s.io/kubernetes/plugin/pkg/auth/authorizer/rbac/bootstrappolicy" oapi "github.com/openshift/origin/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -69,8 +69,8 @@ var ( legacyAuthzGroup = authorizationapi.LegacyGroupName buildGroup = buildapi.GroupName legacyBuildGroup = buildapi.LegacyGroupName - deployGroup = deployapi.GroupName - legacyDeployGroup = deployapi.LegacyGroupName + deployGroup = appsapi.GroupName + legacyDeployGroup = appsapi.LegacyGroupName imageGroup = imageapi.GroupName legacyImageGroup = imageapi.LegacyGroupName projectGroup = projectapi.GroupName diff --git a/pkg/cmd/server/origin/controller/unidling.go b/pkg/cmd/server/origin/controller/unidling.go index 9ffd8a615495..924f79af00ac 100644 --- a/pkg/cmd/server/origin/controller/unidling.go +++ b/pkg/cmd/server/origin/controller/unidling.go @@ -5,7 +5,7 @@ import ( appstypedclient "github.com/openshift/client-go/apps/clientset/versioned/typed/apps/v1" appsv1client "github.com/openshift/origin/pkg/apps/client/v1" - deployclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" + appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" "github.com/openshift/origin/pkg/cmd/server/bootstrappolicy" unidlingcontroller "github.com/openshift/origin/pkg/unidling/controller" ) @@ -29,7 +29,7 @@ func (c *UnidlingControllerConfig) RunController(ctx ControllerContext) (bool, e scaleNamespacer, coreClient, coreClient, - deployclient.NewForConfigOrDie(ctx.ClientBuilder.ConfigOrDie(bootstrappolicy.InfraUnidlingControllerServiceAccountName)), + appsclient.NewForConfigOrDie(ctx.ClientBuilder.ConfigOrDie(bootstrappolicy.InfraUnidlingControllerServiceAccountName)), coreClient, c.ResyncPeriod, ) diff --git a/pkg/cmd/server/origin/reststorage_validation_test.go b/pkg/cmd/server/origin/reststorage_validation_test.go index fe40dc00168c..ca7911b1247c 100644 --- a/pkg/cmd/server/origin/reststorage_validation_test.go +++ b/pkg/cmd/server/origin/reststorage_validation_test.go @@ -15,7 +15,7 @@ import ( kubeletclient "k8s.io/kubernetes/pkg/kubelet/client" _ "github.com/openshift/origin/pkg/api/install" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" quotaapi "github.com/openshift/origin/pkg/quota/apis/quota" "github.com/openshift/origin/pkg/quota/controller/clusterquotamapping" quotainformer "github.com/openshift/origin/pkg/quota/generated/informers/internalversion" @@ -31,7 +31,7 @@ import ( var KnownUpdateValidationExceptions = []reflect.Type{ reflect.TypeOf(&extapi.Scale{}), // scale operation uses the ValidateScale() function for both create and update reflect.TypeOf("aapi.AppliedClusterResourceQuota{}), // this only retrieved, never created. its a virtual projection of ClusterResourceQuota - reflect.TypeOf(&deployapi.DeploymentRequest{}), // request for deployments already use ValidateDeploymentRequest() + reflect.TypeOf(&appsapi.DeploymentRequest{}), // request for deployments already use ValidateDeploymentRequest() } // TestValidationRegistration makes sure that any RESTStorage that allows create or update has the correct validation register. diff --git a/pkg/generate/app/app.go b/pkg/generate/app/app.go index b78ad807c36c..c31a9ebf5030 100644 --- a/pkg/generate/app/app.go +++ b/pkg/generate/app/app.go @@ -17,7 +17,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" "github.com/openshift/origin/pkg/generate" "github.com/openshift/origin/pkg/generate/git" @@ -316,7 +316,7 @@ type DeploymentConfigRef struct { // DeploymentConfig creates a deploymentConfig resource from the deployment configuration reference // // TODO: take a pod template spec as argument -func (r *DeploymentConfigRef) DeploymentConfig() (*deployapi.DeploymentConfig, error) { +func (r *DeploymentConfigRef) DeploymentConfig() (*appsapi.DeploymentConfig, error) { if len(r.Name) == 0 { suggestions := NameSuggestions{} for i := range r.Images { @@ -338,10 +338,10 @@ func (r *DeploymentConfigRef) DeploymentConfig() (*deployapi.DeploymentConfig, e } } - triggers := []deployapi.DeploymentTriggerPolicy{ + triggers := []appsapi.DeploymentTriggerPolicy{ // By default, always deploy on change { - Type: deployapi.DeploymentTriggerOnConfigChange, + Type: appsapi.DeploymentTriggerOnConfigChange, }, } @@ -371,11 +371,11 @@ func (r *DeploymentConfigRef) DeploymentConfig() (*deployapi.DeploymentConfig, e template.Containers[i].Env = append(template.Containers[i].Env, r.Env.List()...) } - dc := &deployapi.DeploymentConfig{ + dc := &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: r.Name, }, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, Test: r.AsTest, Selector: selector, @@ -391,9 +391,9 @@ func (r *DeploymentConfigRef) DeploymentConfig() (*deployapi.DeploymentConfig, e if r.PostHook != nil { //dc.Spec.Strategy.Type = "Rolling" if len(r.PostHook.Shell) > 0 { - dc.Spec.Strategy.RecreateParams = &deployapi.RecreateDeploymentStrategyParams{ - Post: &deployapi.LifecycleHook{ - ExecNewPod: &deployapi.ExecNewPodHook{ + dc.Spec.Strategy.RecreateParams = &appsapi.RecreateDeploymentStrategyParams{ + Post: &appsapi.LifecycleHook{ + ExecNewPod: &appsapi.ExecNewPodHook{ Command: []string{"/bin/sh", "-c", r.PostHook.Shell}, }, }, diff --git a/pkg/generate/app/imageref.go b/pkg/generate/app/imageref.go index 32c29c1ad91b..f129a8f712f7 100644 --- a/pkg/generate/app/imageref.go +++ b/pkg/generate/app/imageref.go @@ -14,7 +14,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "github.com/openshift/origin/pkg/api/apihelpers" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" "github.com/openshift/origin/pkg/util/docker/dockerfile" @@ -350,16 +350,16 @@ func (r *ImageRef) ImageStreamTag() (*imageapi.ImageStreamTag, error) { } // DeployableContainer sets up a container for the image ready for deployment -func (r *ImageRef) DeployableContainer() (container *kapi.Container, triggers []deployapi.DeploymentTriggerPolicy, err error) { +func (r *ImageRef) DeployableContainer() (container *kapi.Container, triggers []appsapi.DeploymentTriggerPolicy, err error) { name, ok := r.SuggestName() if !ok { return nil, nil, fmt.Errorf("unable to suggest a container name for the image %q", r.Reference.String()) } if r.AsImageStream { - triggers = []deployapi.DeploymentTriggerPolicy{ + triggers = []appsapi.DeploymentTriggerPolicy{ { - Type: deployapi.DeploymentTriggerOnImageChange, - ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ + Type: appsapi.DeploymentTriggerOnImageChange, + ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: true, ContainerNames: []string{name}, From: r.ObjectReference(), diff --git a/pkg/generate/app/imageref_test.go b/pkg/generate/app/imageref_test.go index 51a4eb9f2238..fb398f1ce186 100644 --- a/pkg/generate/app/imageref_test.go +++ b/pkg/generate/app/imageref_test.go @@ -7,7 +7,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" "github.com/openshift/origin/pkg/generate" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -105,7 +105,7 @@ func TestSimpleDeploymentConfig(t *testing.T) { t.Errorf("unexpected value: %#v", config) } for _, trigger := range config.Spec.Triggers { - if trigger.Type == deployapi.DeploymentTriggerOnImageChange { + if trigger.Type == appsapi.DeploymentTriggerOnImageChange { from := trigger.ImageChangeParams.From if from.Kind != "ImageStreamTag" { t.Errorf("unexpected from.kind in image change trigger: %s", from.Kind) diff --git a/pkg/generate/app/pipeline.go b/pkg/generate/app/pipeline.go index 5455469d83a4..4219693abc15 100644 --- a/pkg/generate/app/pipeline.go +++ b/pkg/generate/app/pipeline.go @@ -17,12 +17,12 @@ import ( "k8s.io/kubernetes/pkg/api/validation" extensions "k8s.io/kubernetes/pkg/apis/extensions" - deploy "github.com/openshift/origin/pkg/apps/apis/apps" - build "github.com/openshift/origin/pkg/build/apis/build" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + buildapi "github.com/openshift/origin/pkg/build/apis/build" "github.com/openshift/origin/pkg/generate" - image "github.com/openshift/origin/pkg/image/apis/image" + imageapi "github.com/openshift/origin/pkg/image/apis/image" imageclient "github.com/openshift/origin/pkg/image/generated/internalclientset/typed/image/internalversion" - route "github.com/openshift/origin/pkg/route/apis/route" + routeapi "github.com/openshift/origin/pkg/route/apis/route" "github.com/openshift/origin/pkg/util/docker/dockerfile" ) @@ -40,7 +40,7 @@ type PipelineBuilder interface { // The pipelines created with a PipelineBuilder will have access to the given // environment. The boolean outputDocker controls whether builds will output to // an image stream tag or docker image reference. -func NewPipelineBuilder(name string, environment Environment, dockerStrategyOptions *build.DockerStrategyOptions, outputDocker bool) PipelineBuilder { +func NewPipelineBuilder(name string, environment Environment, dockerStrategyOptions *buildapi.DockerStrategyOptions, outputDocker bool) PipelineBuilder { return &pipelineBuilder{ nameGenerator: NewUniqueNameGenerator(name), environment: environment, @@ -54,7 +54,7 @@ type pipelineBuilder struct { environment Environment outputDocker bool to string - dockerStrategyOptions *build.DockerStrategyOptions + dockerStrategyOptions *buildapi.DockerStrategyOptions } func (pb *pipelineBuilder) To(name string) PipelineBuilder { @@ -76,7 +76,7 @@ func (pb *pipelineBuilder) NewBuildPipeline(from string, input *ImageRef, source AsImageStream: !pb.outputDocker, } if len(pb.to) > 0 { - outputImageRef, err := image.ParseDockerImageReference(pb.to) + outputImageRef, err := imageapi.ParseDockerImageReference(pb.to) if err != nil { return nil, err } @@ -90,9 +90,9 @@ func (pb *pipelineBuilder) NewBuildPipeline(from string, input *ImageRef, source if err != nil { return nil, err } - output.Reference = image.DockerImageReference{ + output.Reference = imageapi.DockerImageReference{ Name: name, - Tag: image.DefaultImageTag, + Tag: imageapi.DefaultImageTag, } } source.Name = name @@ -103,8 +103,8 @@ func (pb *pipelineBuilder) NewBuildPipeline(from string, input *ImageRef, source ports := dockerfile.LastExposedPorts(node) if len(ports) > 0 { if input.Info == nil { - input.Info = &image.DockerImage{ - Config: &image.DockerConfig{}, + input.Info = &imageapi.DockerImage{ + Config: &imageapi.DockerConfig{}, } } input.Info.Config.ExposedPorts = map[string]struct{}{} @@ -367,7 +367,7 @@ func AddServices(objects Objects, firstPortOnly bool) Objects { svcs := []runtime.Object{} for _, o := range objects { switch t := o.(type) { - case *deploy.DeploymentConfig: + case *appsapi.DeploymentConfig: svc := addServiceInternal(t.Spec.Template.Spec.Containers, t.ObjectMeta, t.Spec.Selector, firstPortOnly) if svc != nil { svcs = append(svcs, svc) @@ -402,13 +402,13 @@ func AddRoutes(objects Objects) Objects { for _, o := range objects { switch t := o.(type) { case *kapi.Service: - routes = append(routes, &route.Route{ + routes = append(routes, &routeapi.Route{ ObjectMeta: metav1.ObjectMeta{ Name: t.Name, Labels: t.Labels, }, - Spec: route.RouteSpec{ - To: route.RouteTargetReference{ + Spec: routeapi.RouteSpec{ + To: routeapi.RouteTargetReference{ Name: t.Name, }, }, @@ -486,10 +486,10 @@ func (a *acceptNonExistentImageStream) Accept(from interface{}) bool { return false } gk := gvk[0].GroupKind() - if !image.IsKindOrLegacy("ImageStream", gk) { + if !imageapi.IsKindOrLegacy("ImageStream", gk) { return true } - is, ok := from.(*image.ImageStream) + is, ok := from.(*imageapi.ImageStream) if !ok { glog.V(4).Infof("type cast to image stream %#v not right for an unanticipated reason", from) return true @@ -531,10 +531,10 @@ func (a *acceptNonExistentImageStreamTag) Accept(from interface{}) bool { return false } gk := gvk[0].GroupKind() - if !image.IsKindOrLegacy("ImageStreamTag", gk) { + if !imageapi.IsKindOrLegacy("ImageStreamTag", gk) { return true } - ist, ok := from.(*image.ImageStreamTag) + ist, ok := from.(*imageapi.ImageStreamTag) if !ok { glog.V(4).Infof("type cast to imagestreamtag %#v not right for an unanticipated reason", from) return true @@ -585,7 +585,7 @@ func (a *acceptBuildConfigs) Accept(from interface{}) bool { return false } gk := gvk[0].GroupKind() - return build.IsKindOrLegacy("BuildConfig", gk) || image.IsKindOrLegacy("ImageStream", gk) + return buildapi.IsKindOrLegacy("BuildConfig", gk) || imageapi.IsKindOrLegacy("ImageStream", gk) } // NewAcceptBuildConfigs creates an acceptor accepting BuildConfig objects diff --git a/pkg/generate/app/pipeline_test.go b/pkg/generate/app/pipeline_test.go index 45573f5af3c9..5686c872a3a9 100644 --- a/pkg/generate/app/pipeline_test.go +++ b/pkg/generate/app/pipeline_test.go @@ -11,7 +11,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" imageapi "github.com/openshift/origin/pkg/image/apis/image" ) @@ -25,7 +25,7 @@ type containerDesc struct { ports []portDesc } -func fakeDeploymentConfig(name string, containers ...containerDesc) *deployapi.DeploymentConfig { +func fakeDeploymentConfig(name string, containers ...containerDesc) *appsapi.DeploymentConfig { specContainers := []kapi.Container{} for _, c := range containers { container := kapi.Container{ @@ -43,11 +43,11 @@ func fakeDeploymentConfig(name string, containers ...containerDesc) *deployapi.D specContainers = append(specContainers, container) } - return &deployapi.DeploymentConfig{ + return &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: name, }, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: 1, Selector: map[string]string{"name": "test"}, Template: &kapi.PodTemplateSpec{ @@ -109,8 +109,8 @@ func TestAcceptUnique(t *testing.T) { obj.Namespace = ns return obj } - dc := func(name, ns string) *deployapi.DeploymentConfig { - obj := &deployapi.DeploymentConfig{} + dc := func(name, ns string) *appsapi.DeploymentConfig { + obj := &appsapi.DeploymentConfig{} obj.Name = name obj.Namespace = ns return obj diff --git a/pkg/generate/appjson/appjson.go b/pkg/generate/appjson/appjson.go index 197fc16db9dc..08c9b256f078 100644 --- a/pkg/generate/appjson/appjson.go +++ b/pkg/generate/appjson/appjson.go @@ -15,7 +15,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/generate" "github.com/openshift/origin/pkg/generate/app" templateapi "github.com/openshift/origin/pkg/template/apis/template" @@ -304,7 +304,7 @@ func (g *Generator) Generate(body []byte) (*templateapi.Template, error) { var services []*kapi.Service for _, obj := range objects { switch t := obj.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: ports := app.UniqueContainerToServicePorts(app.AllContainerPorts(t.Spec.Template.Spec.Containers...)) if len(ports) == 0 { continue diff --git a/pkg/image/controller/trigger/image_trigger_controller_test.go b/pkg/image/controller/trigger/image_trigger_controller_test.go index 80b2aa973f66..dc094d24df0b 100644 --- a/pkg/image/controller/trigger/image_trigger_controller_test.go +++ b/pkg/image/controller/trigger/image_trigger_controller_test.go @@ -24,7 +24,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildgenerator "github.com/openshift/origin/pkg/build/generator" "github.com/openshift/origin/pkg/cmd/server/bootstrappolicy" @@ -504,7 +504,7 @@ func TestBuildConfigTriggerIndexer(t *testing.T) { func TestDeploymentConfigTriggerIndexer(t *testing.T) { stopCh := make(chan struct{}) defer close(stopCh) - informer, fw := newFakeInformer(&deployapi.DeploymentConfig{}, &deployapi.DeploymentConfigList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}) + informer, fw := newFakeInformer(&appsapi.DeploymentConfig{}, &appsapi.DeploymentConfigList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}) c := NewTriggerCache() r := &mockTagRetriever{} @@ -650,18 +650,18 @@ func scenario_1_buildConfig_strategy_cacheEntry() *trigger.CacheEntry { } } -func scenario_1_deploymentConfig_imageSource() *deployapi.DeploymentConfig { - return &deployapi.DeploymentConfig{ +func scenario_1_deploymentConfig_imageSource() *appsapi.DeploymentConfig { + return &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "deploy1", Namespace: "test"}, - Spec: deployapi.DeploymentConfigSpec{ - Triggers: []deployapi.DeploymentTriggerPolicy{ - {ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ + Spec: appsapi.DeploymentConfigSpec{ + Triggers: []appsapi.DeploymentTriggerPolicy{ + {ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: true, ContainerNames: []string{"first", "second"}, From: kapi.ObjectReference{Kind: "ImageStreamTag", Name: "stream:1"}, LastTriggeredImage: "image/result:2", }}, - {ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ + {ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: true, ContainerNames: []string{"third"}, From: kapi.ObjectReference{Kind: "DockerImage", Name: "mysql", Namespace: "other"}, @@ -895,19 +895,19 @@ func benchmark_1_pod(r *rand.Rand, identity, maxStreams, maxTags, containers int return pod } -func benchmark_1_deploymentConfig(r *rand.Rand, identity, maxStreams, maxTags, containers int32) *deployapi.DeploymentConfig { - dc := &deployapi.DeploymentConfig{ +func benchmark_1_deploymentConfig(r *rand.Rand, identity, maxStreams, maxTags, containers int32) *appsapi.DeploymentConfig { + dc := &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: fmt.Sprintf("dc-%d", identity), Namespace: "test", }, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Template: &kapi.PodTemplateSpec{}, }, } for i := int32(0); i < containers; i++ { - dc.Spec.Triggers = append(dc.Spec.Triggers, deployapi.DeploymentTriggerPolicy{ - ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ + dc.Spec.Triggers = append(dc.Spec.Triggers, appsapi.DeploymentTriggerPolicy{ + ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: true, ContainerNames: []string{fmt.Sprintf("container-%d", i)}, From: kapi.ObjectReference{Kind: "ImageStreamTag", Name: randomStreamTag(r, maxStreams, maxTags)}, @@ -983,7 +983,7 @@ func alterBuildConfigFromTriggers(bcWatch *consistentWatch) imageReactorFunc { func alterDeploymentConfigFromTriggers(dcWatch *consistentWatch) imageReactorFunc { return imageReactorFunc(func(obj runtime.Object, tagRetriever trigger.TagRetriever) error { dc := obj.DeepCopyObject() - updated, resolvable, err := deploymentconfigs.UpdateDeploymentConfigImages(dc.(*deployapi.DeploymentConfig), tagRetriever) + updated, resolvable, err := deploymentconfigs.UpdateDeploymentConfigImages(dc.(*appsapi.DeploymentConfig), tagRetriever) if err != nil { return err } @@ -1096,7 +1096,7 @@ func TestTriggerController(t *testing.T) { isInformer, isFakeWatch := newFakeInformer(&imageapi.ImageStream{}, &imageapi.ImageStreamList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}) isWatch := &consistentWatch{watch: isFakeWatch} podInformer, podWatch := newFakeInformer(&kapi.Pod{}, &kapi.PodList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}) - dcInformer, dcFakeWatch := newFakeInformer(&deployapi.DeploymentConfig{}, &deployapi.DeploymentConfigList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}) + dcInformer, dcFakeWatch := newFakeInformer(&appsapi.DeploymentConfig{}, &appsapi.DeploymentConfigList{ListMeta: metav1.ListMeta{ResourceVersion: "1"}}) dcWatch := &consistentWatch{watch: dcFakeWatch} buildReactorFn := alterBuildConfigFromTriggers(bcWatch) @@ -1287,8 +1287,8 @@ func verifyState( for i := 0; i < times; i++ { var failures []string for _, obj := range dcInformer.GetStore().List() { - if updated, resolved, err := deploymentconfigs.UpdateDeploymentConfigImages(obj.(*deployapi.DeploymentConfig), c.tagRetriever); updated != nil || !resolved || err != nil { - failures = append(failures, fmt.Sprintf("%s is not fully resolved: %v", obj.(*deployapi.DeploymentConfig).Name, err)) + if updated, resolved, err := deploymentconfigs.UpdateDeploymentConfigImages(obj.(*appsapi.DeploymentConfig), c.tagRetriever); updated != nil || !resolved || err != nil { + failures = append(failures, fmt.Sprintf("%s is not fully resolved: %v", obj.(*appsapi.DeploymentConfig).Name, err)) continue } } diff --git a/pkg/image/prune/prune.go b/pkg/image/prune/prune.go index a68f2274cf85..1bb183678891 100644 --- a/pkg/image/prune/prune.go +++ b/pkg/image/prune/prune.go @@ -27,8 +27,8 @@ import ( "github.com/openshift/origin/pkg/api/graph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildgraph "github.com/openshift/origin/pkg/build/graph/nodes" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -141,7 +141,7 @@ type PrunerOptions struct { // Deployments is the entire list of kube's deployments across all namespaces in the cluster. Deployments *kapisext.DeploymentList // DCs is the entire list of deployment configs across all namespaces in the cluster. - DCs *deployapi.DeploymentConfigList + DCs *appsapi.DeploymentConfigList // RSs is the entire list of replica sets across all namespaces in the cluster. RSs *kapisext.ReplicaSetList // LimitRanges is a map of LimitRanges across namespaces, being keys in this map. @@ -550,7 +550,7 @@ func (p *pruner) addDaemonSetsToGraph(dss *kapisext.DaemonSetList) []error { ds := &dss.Items[i] desc := fmt.Sprintf("DaemonSet %s", getName(ds)) glog.V(4).Infof("Examining %s", desc) - dsNode := deploygraph.EnsureDaemonSetNode(p.g, ds) + dsNode := appsgraph.EnsureDaemonSetNode(p.g, ds) errs = append(errs, p.addPodSpecToGraph(getRef(ds), &ds.Spec.Template.Spec, dsNode)...) } @@ -568,7 +568,7 @@ func (p *pruner) addDeploymentsToGraph(dmnts *kapisext.DeploymentList) []error { d := &dmnts.Items[i] ref := getRef(d) glog.V(4).Infof("Examining %s", getKindName(ref)) - dNode := deploygraph.EnsureDeploymentNode(p.g, d) + dNode := appsgraph.EnsureDeploymentNode(p.g, d) errs = append(errs, p.addPodSpecToGraph(ref, &d.Spec.Template.Spec, dNode)...) } @@ -580,14 +580,14 @@ func (p *pruner) addDeploymentsToGraph(dmnts *kapisext.DeploymentList) []error { // Edges are added to the graph from each deployment config to the images // specified by its pod spec's list of containers, as long as the image is // managed by OpenShift. -func (p *pruner) addDeploymentConfigsToGraph(dcs *deployapi.DeploymentConfigList) []error { +func (p *pruner) addDeploymentConfigsToGraph(dcs *appsapi.DeploymentConfigList) []error { var errs []error for i := range dcs.Items { dc := &dcs.Items[i] ref := getRef(dc) glog.V(4).Infof("Examining %s", getKindName(ref)) - dcNode := deploygraph.EnsureDeploymentConfigNode(p.g, dc) + dcNode := appsgraph.EnsureDeploymentConfigNode(p.g, dc) errs = append(errs, p.addPodSpecToGraph(getRef(dc), &dc.Spec.Template.Spec, dcNode)...) } @@ -605,7 +605,7 @@ func (p *pruner) addReplicaSetsToGraph(rss *kapisext.ReplicaSetList) []error { rs := &rss.Items[i] ref := getRef(rs) glog.V(4).Infof("Examining %s", getKindName(ref)) - rsNode := deploygraph.EnsureReplicaSetNode(p.g, rs) + rsNode := appsgraph.EnsureReplicaSetNode(p.g, rs) errs = append(errs, p.addPodSpecToGraph(ref, &rs.Spec.Template.Spec, rsNode)...) } diff --git a/pkg/image/prune/prune_test.go b/pkg/image/prune/prune_test.go index e022d468b8fd..9bc7afb88e2a 100644 --- a/pkg/image/prune/prune_test.go +++ b/pkg/image/prune/prune_test.go @@ -21,7 +21,7 @@ import ( "k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/diff" "github.com/openshift/origin/pkg/api/graph" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" imageclient "github.com/openshift/origin/pkg/image/generated/internalclientset/fake" @@ -57,7 +57,7 @@ func TestImagePruning(t *testing.T) { builds buildapi.BuildList dss kapisext.DaemonSetList deployments kapisext.DeploymentList - dcs deployapi.DeploymentConfigList + dcs appsapi.DeploymentConfigList rss kapisext.ReplicaSetList limits map[string][]*kapi.LimitRange expectedImageDeletions []string @@ -1146,7 +1146,7 @@ func TestRegistryPruning(t *testing.T) { Builds: &buildapi.BuildList{}, DSs: &kapisext.DaemonSetList{}, Deployments: &kapisext.DeploymentList{}, - DCs: &deployapi.DeploymentConfigList{}, + DCs: &appsapi.DeploymentConfigList{}, RSs: &kapisext.ReplicaSetList{}, RegistryURL: &url.URL{Scheme: "https", Host: "registry1.io"}, } diff --git a/pkg/image/prune/testutil/util.go b/pkg/image/prune/testutil/util.go index 8cd6cfc63d47..21592e614e34 100644 --- a/pkg/image/prune/testutil/util.go +++ b/pkg/image/prune/testutil/util.go @@ -12,7 +12,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kapisext "k8s.io/kubernetes/pkg/apis/extensions" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" ) @@ -300,21 +300,21 @@ func Deployment(namespace, name string, containerImages ...string) kapisext.Depl } // DCList turns the given deployment configs into DeploymentConfigList. -func DCList(dcs ...deployapi.DeploymentConfig) deployapi.DeploymentConfigList { - return deployapi.DeploymentConfigList{ +func DCList(dcs ...appsapi.DeploymentConfig) appsapi.DeploymentConfigList { + return appsapi.DeploymentConfigList{ Items: dcs, } } // DC creates and returns a DeploymentConfig object. -func DC(namespace, name string, containerImages ...string) deployapi.DeploymentConfig { - return deployapi.DeploymentConfig{ +func DC(namespace, name string, containerImages ...string) appsapi.DeploymentConfig { + return appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Namespace: namespace, Name: name, SelfLink: "/dc/" + name, }, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Template: &kapi.PodTemplateSpec{ Spec: PodSpec(containerImages...), }, diff --git a/pkg/ipfailover/keepalived/plugin.go b/pkg/ipfailover/keepalived/plugin.go index e907a3905dc5..062f172b8332 100644 --- a/pkg/ipfailover/keepalived/plugin.go +++ b/pkg/ipfailover/keepalived/plugin.go @@ -10,7 +10,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/generate/app" "github.com/openshift/origin/pkg/ipfailover" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" @@ -84,7 +84,8 @@ func (p *KeepalivedPlugin) GetNamespace() (string, error) { } // GetDeploymentConfig gets the deployment config associated with this IP Failover configurator plugin. -func (p *KeepalivedPlugin) GetDeploymentConfig() (*deployapi.DeploymentConfig, error) { + +func (p *KeepalivedPlugin) GetDeploymentConfig() (*appsapi.DeploymentConfig, error) { appsClient, err := p.Factory.OpenshiftInternalAppsClient() if err != nil { return nil, fmt.Errorf("error getting client: %v", err) diff --git a/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/deploymentconfigs.go b/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/deploymentconfigs.go index b65237fe22d6..0a7a0a3692eb 100644 --- a/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/deploymentconfigs.go +++ b/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/deploymentconfigs.go @@ -9,7 +9,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) const ( @@ -91,7 +91,7 @@ func checkDeploymentConfigs(r diagnosticReporter, adapter deploymentConfigAdapte checkDeploymentConfigPods(r, adapter, *dcList, project) } -func checkDeploymentConfigPods(r diagnosticReporter, adapter deploymentConfigAdapter, dcs deployapi.DeploymentConfigList, project string) { +func checkDeploymentConfigPods(r diagnosticReporter, adapter deploymentConfigAdapter, dcs appsapi.DeploymentConfigList, project string) { compReq, _ := labels.NewRequirement(componentKey, selection.In, loggingComponents.List()) provReq, _ := labels.NewRequirement(providerKey, selection.Equals, []string{openshiftValue}) podSelector := labels.NewSelector().Add(*compReq, *provReq) @@ -112,7 +112,7 @@ func checkDeploymentConfigPods(r diagnosticReporter, adapter deploymentConfigAda for _, pod := range podList.Items { r.Debug("AGL0082", fmt.Sprintf("Checking status of Pod '%s'...", pod.ObjectMeta.Name)) - dcName, hasDcName := pod.ObjectMeta.Annotations[deployapi.DeploymentConfigAnnotation] + dcName, hasDcName := pod.ObjectMeta.Annotations[appsapi.DeploymentConfigAnnotation] if !hasDcName { r.Warn("AGL0085", nil, fmt.Sprintf("Found Pod '%s' that that does not reference a logging deployment config which may be acceptable. Skipping check to see if its running.", pod.ObjectMeta.Name)) continue diff --git a/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/deploymentconfigs_test.go b/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/deploymentconfigs_test.go index 256c1de68695..3032ae8804b0 100644 --- a/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/deploymentconfigs_test.go +++ b/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/deploymentconfigs_test.go @@ -7,7 +7,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/log" ) @@ -20,7 +20,7 @@ const ( type fakeDeploymentConfigsDiagnostic struct { fakeDiagnostic fakePods kapi.PodList - fakeDcs deployapi.DeploymentConfigList + fakeDcs appsapi.DeploymentConfigList clienterrors map[string]error } @@ -32,7 +32,7 @@ func newFakeDeploymentConfigsDiagnostic(t *testing.T) *fakeDeploymentConfigsDiag } func (f *fakeDeploymentConfigsDiagnostic) addDeployConfigFor(component string) { labels := map[string]string{componentKey: component} - dc := deployapi.DeploymentConfig{ + dc := appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: component + "Name", Labels: labels, @@ -44,7 +44,7 @@ func (f *fakeDeploymentConfigsDiagnostic) addDeployConfigFor(component string) { func (f *fakeDeploymentConfigsDiagnostic) addPodFor(comp string, state kapi.PodPhase) { annotations := map[string]string{} if comp != testSkipAnnotation { - annotations[deployapi.DeploymentConfigAnnotation] = comp + annotations[appsapi.DeploymentConfigAnnotation] = comp } pod := kapi.Pod{ ObjectMeta: metav1.ObjectMeta{ @@ -59,7 +59,7 @@ func (f *fakeDeploymentConfigsDiagnostic) addPodFor(comp string, state kapi.PodP f.fakePods.Items = append(f.fakePods.Items, pod) } -func (f *fakeDeploymentConfigsDiagnostic) deploymentconfigs(project string, options metav1.ListOptions) (*deployapi.DeploymentConfigList, error) { +func (f *fakeDeploymentConfigsDiagnostic) deploymentconfigs(project string, options metav1.ListOptions) (*appsapi.DeploymentConfigList, error) { f.test.Logf(">> calling deploymentconfigs: %s", f.clienterrors) value, ok := f.clienterrors[testDcKey] if ok { diff --git a/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/diagnostic.go b/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/diagnostic.go index 470cc4868ca1..f1204f9b5086 100644 --- a/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/diagnostic.go +++ b/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/diagnostic.go @@ -11,7 +11,7 @@ import ( kapisext "k8s.io/kubernetes/pkg/apis/extensions" kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appstypedclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" authapi "github.com/openshift/origin/pkg/authorization/apis/authorization" oauthorizationtypedclient "github.com/openshift/origin/pkg/authorization/generated/internalclientset/typed/authorization/internalversion" @@ -116,7 +116,7 @@ func (d *AggregatedLogging) nodes(options metav1.ListOptions) (*kapi.NodeList, e func (d *AggregatedLogging) pods(project string, options metav1.ListOptions) (*kapi.PodList, error) { return d.KubeClient.Core().Pods(project).List(options) } -func (d *AggregatedLogging) deploymentconfigs(project string, options metav1.ListOptions) (*deployapi.DeploymentConfigList, error) { +func (d *AggregatedLogging) deploymentconfigs(project string, options metav1.ListOptions) (*appsapi.DeploymentConfigList, error) { return d.DCClient.DeploymentConfigs(project).List(options) } diff --git a/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/interfaces.go b/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/interfaces.go index 06432dd7ed42..1b1255d2a293 100644 --- a/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/interfaces.go +++ b/pkg/oc/admin/diagnostics/diagnostics/cluster/aggregated_logging/interfaces.go @@ -5,7 +5,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kapisext "k8s.io/kubernetes/pkg/apis/extensions" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" authapi "github.com/openshift/origin/pkg/authorization/apis/authorization" routesapi "github.com/openshift/origin/pkg/route/apis/route" securityapi "github.com/openshift/origin/pkg/security/apis/security" @@ -34,7 +34,7 @@ type clusterRoleBindingsAdapter interface { //deploymentConfigAdapter is an abstraction to retrieve resource for validating dcs //for aggregated logging diagnostics type deploymentConfigAdapter interface { - deploymentconfigs(project string, options metav1.ListOptions) (*deployapi.DeploymentConfigList, error) + deploymentconfigs(project string, options metav1.ListOptions) (*appsapi.DeploymentConfigList, error) podsAdapter } diff --git a/pkg/oc/admin/diagnostics/diagnostics/cluster/router.go b/pkg/oc/admin/diagnostics/diagnostics/cluster/router.go index eca97da1cb5b..1be8a8948a79 100644 --- a/pkg/oc/admin/diagnostics/diagnostics/cluster/router.go +++ b/pkg/oc/admin/diagnostics/diagnostics/cluster/router.go @@ -15,7 +15,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appstypedclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" "github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/types" "k8s.io/kubernetes/pkg/apis/authorization" @@ -98,7 +98,7 @@ func (d *ClusterRouter) CanRun() (bool, error) { can, err := userCan(d.KubeClient.Authorization(), &authorization.ResourceAttributes{ Namespace: metav1.NamespaceDefault, Verb: "get", - Group: deployapi.GroupName, + Group: appsapi.GroupName, Resource: "deploymentconfigs", Name: routerName, }) @@ -124,7 +124,7 @@ func (d *ClusterRouter) Check() types.DiagnosticResult { return r } -func (d *ClusterRouter) getRouterDC(r types.DiagnosticResult) *deployapi.DeploymentConfig { +func (d *ClusterRouter) getRouterDC(r types.DiagnosticResult) *appsapi.DeploymentConfig { dc, err := d.DCClient.DeploymentConfigs(metav1.NamespaceDefault).Get(routerName, metav1.GetOptions{}) if err != nil && reflect.TypeOf(err) == reflect.TypeOf(&kerrs.StatusError{}) { r.Warn("DClu2001", err, fmt.Sprintf(clGetRtNone, routerName)) @@ -137,7 +137,7 @@ func (d *ClusterRouter) getRouterDC(r types.DiagnosticResult) *deployapi.Deploym return dc } -func (d *ClusterRouter) getRouterPods(dc *deployapi.DeploymentConfig, r types.DiagnosticResult) *kapi.PodList { +func (d *ClusterRouter) getRouterPods(dc *appsapi.DeploymentConfig, r types.DiagnosticResult) *kapi.PodList { pods, err := d.KubeClient.Core().Pods(metav1.NamespaceDefault).List(metav1.ListOptions{LabelSelector: labels.SelectorFromSet(dc.Spec.Selector).String()}) if err != nil { r.Error("DClu2004", err, fmt.Sprintf("Finding pods for '%s' DeploymentConfig failed. This should never happen. Error: (%[2]T) %[2]v", routerName, err)) diff --git a/pkg/oc/admin/migrate/images/imagerefs_test.go b/pkg/oc/admin/migrate/images/imagerefs_test.go index 8e27ac2e3257..ce5b1c3303a5 100644 --- a/pkg/oc/admin/migrate/images/imagerefs_test.go +++ b/pkg/oc/admin/migrate/images/imagerefs_test.go @@ -10,7 +10,7 @@ import ( kbatch "k8s.io/kubernetes/pkg/apis/batch" kextensions "k8s.io/kubernetes/pkg/apis/extensions" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" @@ -225,8 +225,8 @@ func TestTransform(t *testing.T) { }, }, { - obj: &deployapi.DeploymentConfig{ - Spec: deployapi.DeploymentConfigSpec{ + obj: &appsapi.DeploymentConfig{ + Spec: appsapi.DeploymentConfigSpec{ Template: &kapi.PodTemplateSpec{ Spec: kapi.PodSpec{ Containers: []kapi.Container{ @@ -238,8 +238,8 @@ func TestTransform(t *testing.T) { }, }, changed: true, - expected: &deployapi.DeploymentConfig{ - Spec: deployapi.DeploymentConfigSpec{ + expected: &appsapi.DeploymentConfig{ + Spec: appsapi.DeploymentConfigSpec{ Template: &kapi.PodTemplateSpec{ Spec: kapi.PodSpec{ Containers: []kapi.Container{ diff --git a/pkg/oc/admin/prune/deployments.go b/pkg/oc/admin/prune/deployments.go index 5df180deee73..e75df2fe9ef2 100644 --- a/pkg/oc/admin/prune/deployments.go +++ b/pkg/oc/admin/prune/deployments.go @@ -15,7 +15,7 @@ import ( "k8s.io/kubernetes/pkg/kubectl/cmd/templates" kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsclientinternal "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" "github.com/openshift/origin/pkg/apps/prune" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" @@ -134,7 +134,7 @@ func (o PruneDeploymentsOptions) Run() error { if err != nil { return err } - deploymentConfigs := []*deployapi.DeploymentConfig{} + deploymentConfigs := []*appsapi.DeploymentConfig{} for i := range deploymentConfigList.Items { deploymentConfigs = append(deploymentConfigs, &deploymentConfigList.Items[i]) } diff --git a/pkg/oc/admin/registry/registry.go b/pkg/oc/admin/registry/registry.go index 9332aff2f614..5f5f21c7546d 100644 --- a/pkg/oc/admin/registry/registry.go +++ b/pkg/oc/admin/registry/registry.go @@ -28,7 +28,7 @@ import ( "github.com/openshift/origin/pkg/cmd/util/variable" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" configcmd "github.com/openshift/origin/pkg/config/cmd" "github.com/openshift/origin/pkg/generate/app" ) @@ -428,16 +428,16 @@ func (opts *RegistryOptions) RunCmdRegistry() error { }, }) } else { - objects = append(objects, &deployapi.DeploymentConfig{ + objects = append(objects, &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: name, Labels: opts.label, }, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: opts.Config.Replicas, Selector: opts.label, - Triggers: []deployapi.DeploymentTriggerPolicy{ - {Type: deployapi.DeploymentTriggerOnConfigChange}, + Triggers: []appsapi.DeploymentTriggerPolicy{ + {Type: appsapi.DeploymentTriggerOnConfigChange}, }, Template: podTemplate, }, diff --git a/pkg/oc/admin/router/router.go b/pkg/oc/admin/router/router.go index 2a9dfc968829..00c02cb18dc6 100644 --- a/pkg/oc/admin/router/router.go +++ b/pkg/oc/admin/router/router.go @@ -29,7 +29,7 @@ import ( cmdutil "github.com/openshift/origin/pkg/cmd/util" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/cmd/util/variable" configcmd "github.com/openshift/origin/pkg/config/cmd" "github.com/openshift/origin/pkg/generate/app" @@ -760,20 +760,20 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out, errout io.Write }, ) - objects = append(objects, &deployapi.DeploymentConfig{ + objects = append(objects, &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: name, Labels: label, }, - Spec: deployapi.DeploymentConfigSpec{ - Strategy: deployapi.DeploymentStrategy{ - Type: deployapi.DeploymentStrategyTypeRolling, - RollingParams: &deployapi.RollingDeploymentStrategyParams{MaxUnavailable: intstr.FromString("25%")}, + Spec: appsapi.DeploymentConfigSpec{ + Strategy: appsapi.DeploymentStrategy{ + Type: appsapi.DeploymentStrategyTypeRolling, + RollingParams: &appsapi.RollingDeploymentStrategyParams{MaxUnavailable: intstr.FromString("25%")}, }, Replicas: cfg.Replicas, Selector: label, - Triggers: []deployapi.DeploymentTriggerPolicy{ - {Type: deployapi.DeploymentTriggerOnConfigChange}, + Triggers: []appsapi.DeploymentTriggerPolicy{ + {Type: appsapi.DeploymentTriggerOnConfigChange}, }, Template: &kapi.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{Labels: label}, diff --git a/pkg/oc/admin/top/images.go b/pkg/oc/admin/top/images.go index c92bcc075211..bc7a73028a4d 100644 --- a/pkg/oc/admin/top/images.go +++ b/pkg/oc/admin/top/images.go @@ -17,7 +17,7 @@ import ( "github.com/openshift/origin/pkg/api/graph" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" imagegraph "github.com/openshift/origin/pkg/image/graph/nodes" @@ -268,10 +268,10 @@ func getController(pod *kapi.Pod) string { if bc, ok := pod.Annotations[buildapi.BuildAnnotation]; ok { return fmt.Sprintf("Build: %s/%s", pod.Namespace, bc) } - if dc, ok := pod.Annotations[deployapi.DeploymentAnnotation]; ok { + if dc, ok := pod.Annotations[appsapi.DeploymentAnnotation]; ok { return fmt.Sprintf("Deployment: %s/%s", pod.Namespace, dc) } - if dc, ok := pod.Annotations[deployapi.DeploymentPodAnnotation]; ok { + if dc, ok := pod.Annotations[appsapi.DeploymentPodAnnotation]; ok { return fmt.Sprintf("Deployer: %s/%s", pod.Namespace, dc) } diff --git a/pkg/oc/admin/top/images_test.go b/pkg/oc/admin/top/images_test.go index f86b748e369c..e9e2458eeb78 100644 --- a/pkg/oc/admin/top/images_test.go +++ b/pkg/oc/admin/top/images_test.go @@ -6,7 +6,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" ) @@ -463,7 +463,7 @@ func TestImagesTop(t *testing.T) { pods: &kapi.PodList{ Items: []kapi.Pod{ { - ObjectMeta: metav1.ObjectMeta{Namespace: "ns1", Annotations: map[string]string{deployapi.DeploymentPodAnnotation: "deployer1"}}, + ObjectMeta: metav1.ObjectMeta{Namespace: "ns1", Annotations: map[string]string{appsapi.DeploymentPodAnnotation: "deployer1"}}, Spec: kapi.PodSpec{Containers: []kapi.Container{{Image: "image@sha256:08151bf2fc92355f236918bb16905921e6f66e1d03100fb9b18d60125db3df3a"}}}, Status: kapi.PodStatus{Phase: kapi.PodPending}, }, @@ -502,7 +502,7 @@ func TestImagesTop(t *testing.T) { pods: &kapi.PodList{ Items: []kapi.Pod{ { - ObjectMeta: metav1.ObjectMeta{Namespace: "ns1", Annotations: map[string]string{deployapi.DeploymentPodAnnotation: "deployer1"}}, + ObjectMeta: metav1.ObjectMeta{Namespace: "ns1", Annotations: map[string]string{appsapi.DeploymentPodAnnotation: "deployer1"}}, Spec: kapi.PodSpec{Containers: []kapi.Container{{Image: "image@sha256:08151bf2fc92355f236918bb16905921e6f66e1d03100fb9b18d60125db3df3a"}}}, Status: kapi.PodStatus{Phase: kapi.PodRunning}, }, @@ -541,7 +541,7 @@ func TestImagesTop(t *testing.T) { pods: &kapi.PodList{ Items: []kapi.Pod{ { - ObjectMeta: metav1.ObjectMeta{Namespace: "ns1", Annotations: map[string]string{deployapi.DeploymentAnnotation: "deplyment1"}}, + ObjectMeta: metav1.ObjectMeta{Namespace: "ns1", Annotations: map[string]string{appsapi.DeploymentAnnotation: "deplyment1"}}, Spec: kapi.PodSpec{Containers: []kapi.Container{{Image: "image@sha256:08151bf2fc92355f236918bb16905921e6f66e1d03100fb9b18d60125db3df3a"}}}, Status: kapi.PodStatus{Phase: kapi.PodPending}, }, @@ -580,7 +580,7 @@ func TestImagesTop(t *testing.T) { pods: &kapi.PodList{ Items: []kapi.Pod{ { - ObjectMeta: metav1.ObjectMeta{Namespace: "ns1", Annotations: map[string]string{deployapi.DeploymentAnnotation: "deplyment1"}}, + ObjectMeta: metav1.ObjectMeta{Namespace: "ns1", Annotations: map[string]string{appsapi.DeploymentAnnotation: "deplyment1"}}, Spec: kapi.PodSpec{Containers: []kapi.Container{{Image: "image@sha256:08151bf2fc92355f236918bb16905921e6f66e1d03100fb9b18d60125db3df3a"}}}, Status: kapi.PodStatus{Phase: kapi.PodRunning}, }, diff --git a/pkg/oc/cli/cmd/create/deploymentconfig.go b/pkg/oc/cli/cmd/create/deploymentconfig.go index 4c6e0d239b3e..7d96dc06b747 100644 --- a/pkg/oc/cli/cmd/create/deploymentconfig.go +++ b/pkg/oc/cli/cmd/create/deploymentconfig.go @@ -13,7 +13,7 @@ import ( "k8s.io/kubernetes/pkg/kubectl/cmd/templates" cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsinternalversion "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" ) @@ -32,7 +32,7 @@ var ( ) type CreateDeploymentConfigOptions struct { - DC *deployapi.DeploymentConfig + DC *appsapi.DeploymentConfig Client appsinternalversion.DeploymentConfigsGetter DryRun bool @@ -80,9 +80,9 @@ func (o *CreateDeploymentConfigOptions) Complete(cmd *cobra.Command, f *clientcm labels := map[string]string{"deployment-config.name": args[0]} o.DryRun = cmdutil.GetFlagBool(cmd, "dry-run") - o.DC = &deployapi.DeploymentConfig{ + o.DC = &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: args[0]}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Selector: labels, Replicas: 1, Template: &kapi.PodTemplateSpec{ diff --git a/pkg/oc/cli/cmd/debug.go b/pkg/oc/cli/cmd/debug.go index 3fa6c97940bf..e9b7d2f22582 100644 --- a/pkg/oc/cli/cmd/debug.go +++ b/pkg/oc/cli/cmd/debug.go @@ -26,7 +26,7 @@ import ( "k8s.io/kubernetes/pkg/kubectl/util/term" "k8s.io/kubernetes/pkg/util/interrupt" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" cmdutil "github.com/openshift/origin/pkg/cmd/util" generateapp "github.com/openshift/origin/pkg/generate/app" @@ -415,7 +415,7 @@ func (o *DebugOptions) getContainerImageViaDeploymentConfig(pod *kapi.Pod, conta return nil, nil // ID is needed for later lookup } - dcname := pod.Annotations[deployapi.DeploymentConfigAnnotation] + dcname := pod.Annotations[appsapi.DeploymentConfigAnnotation] if dcname == "" { return nil, nil // Pod doesn't appear to have been created by a DeploymentConfig } @@ -426,7 +426,7 @@ func (o *DebugOptions) getContainerImageViaDeploymentConfig(pod *kapi.Pod, conta } for _, trigger := range dc.Spec.Triggers { - if trigger.Type == deployapi.DeploymentTriggerOnImageChange && + if trigger.Type == appsapi.DeploymentTriggerOnImageChange && trigger.ImageChangeParams != nil && trigger.ImageChangeParams.From.Kind == "ImageStreamTag" { diff --git a/pkg/oc/cli/cmd/deploy.go b/pkg/oc/cli/cmd/deploy.go index 97428e9a8508..a8adba06dc70 100644 --- a/pkg/oc/cli/cmd/deploy.go +++ b/pkg/oc/cli/cmd/deploy.go @@ -21,10 +21,10 @@ import ( kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" "k8s.io/kubernetes/pkg/kubectl/resource" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsinternalclient "github.com/openshift/origin/pkg/apps/client/internalversion" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" "github.com/openshift/origin/pkg/oc/cli/describe" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" ) @@ -205,7 +205,7 @@ func (o DeployOptions) RunDeploy() error { if err != nil { return err } - config, ok := resultObj.(*deployapi.DeploymentConfig) + config, ok := resultObj.(*appsapi.DeploymentConfig) if !ok { return fmt.Errorf("%s is not a valid deployment config", o.deploymentConfigName) } @@ -236,7 +236,7 @@ func (o DeployOptions) RunDeploy() error { // deploy launches a new deployment unless there's already a deployment // process in progress for config. -func (o DeployOptions) deploy(config *deployapi.DeploymentConfig) error { +func (o DeployOptions) deploy(config *appsapi.DeploymentConfig) error { if config.Spec.Paused { return fmt.Errorf("cannot deploy a paused deployment config") } @@ -245,18 +245,18 @@ func (o DeployOptions) deploy(config *deployapi.DeploymentConfig) error { // Clients should be acting either on spec or on annotations and status updates should be a // responsibility of the main controller. We need to start by unplugging this assumption from // our client tools. - deploymentName := deployutil.LatestDeploymentNameForConfig(config) + deploymentName := appsutil.LatestDeploymentNameForConfig(config) deployment, err := o.kubeClient.Core().ReplicationControllers(config.Namespace).Get(deploymentName, metav1.GetOptions{}) - if err == nil && !deployutil.IsTerminatedDeployment(deployment) { + if err == nil && !appsutil.IsTerminatedDeployment(deployment) { // Reject attempts to start a concurrent deployment. return fmt.Errorf("#%d is already in progress (%s).\nOptionally, you can cancel this deployment using 'oc rollout cancel dc/%s'.", - config.Status.LatestVersion, deployutil.DeploymentStatusFor(deployment), config.Name) + config.Status.LatestVersion, appsutil.DeploymentStatusFor(deployment), config.Name) } if err != nil && !kerrors.IsNotFound(err) { return err } - request := &deployapi.DeploymentRequest{ + request := &appsapi.DeploymentRequest{ Name: config.Name, Latest: false, Force: true, @@ -286,7 +286,7 @@ func (o DeployOptions) deploy(config *deployapi.DeploymentConfig) error { // retry resets the status of the latest deployment to New, which will cause // the deployment to be retried. An error is returned if the deployment is not // currently in a failed state. -func (o DeployOptions) retry(config *deployapi.DeploymentConfig) error { +func (o DeployOptions) retry(config *appsapi.DeploymentConfig) error { if config.Spec.Paused { return fmt.Errorf("cannot retry a paused deployment config") } @@ -298,7 +298,7 @@ func (o DeployOptions) retry(config *deployapi.DeploymentConfig) error { // Clients should be acting either on spec or on annotations and status updates should be a // responsibility of the main controller. We need to start by unplugging this assumption from // our client tools. - deploymentName := deployutil.LatestDeploymentNameForConfig(config) + deploymentName := appsutil.LatestDeploymentNameForConfig(config) deployment, err := o.kubeClient.Core().ReplicationControllers(config.Namespace).Get(deploymentName, metav1.GetOptions{}) if err != nil { if kerrors.IsNotFound(err) { @@ -307,9 +307,9 @@ func (o DeployOptions) retry(config *deployapi.DeploymentConfig) error { return err } - if !deployutil.IsFailedDeployment(deployment) { - message := fmt.Sprintf("#%d is %s; only failed deployments can be retried.\n", config.Status.LatestVersion, deployutil.DeploymentStatusFor(deployment)) - if deployutil.IsCompleteDeployment(deployment) { + if !appsutil.IsFailedDeployment(deployment) { + message := fmt.Sprintf("#%d is %s; only failed deployments can be retried.\n", config.Status.LatestVersion, appsutil.DeploymentStatusFor(deployment)) + if appsutil.IsCompleteDeployment(deployment) { message += fmt.Sprintf("You can start a new deployment with 'oc deploy --latest dc/%s'.", config.Name) } else { message += fmt.Sprintf("Optionally, you can cancel this deployment with 'oc rollout cancel dc/%s'.", config.Name) @@ -319,7 +319,7 @@ func (o DeployOptions) retry(config *deployapi.DeploymentConfig) error { } // Delete the deployer pod as well as the deployment hooks pods, if any - pods, err := o.kubeClient.Core().Pods(config.Namespace).List(metav1.ListOptions{LabelSelector: deployutil.DeployerPodSelector(deploymentName).String()}) + pods, err := o.kubeClient.Core().Pods(config.Namespace).List(metav1.ListOptions{LabelSelector: appsutil.DeployerPodSelector(deploymentName).String()}) if err != nil { return fmt.Errorf("failed to list deployer/hook pods for deployment #%d: %v", config.Status.LatestVersion, err) } @@ -330,10 +330,10 @@ func (o DeployOptions) retry(config *deployapi.DeploymentConfig) error { } } - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) // clear out the cancellation flag as well as any previous status-reason annotation - delete(deployment.Annotations, deployapi.DeploymentStatusReasonAnnotation) - delete(deployment.Annotations, deployapi.DeploymentCancelledAnnotation) + delete(deployment.Annotations, appsapi.DeploymentStatusReasonAnnotation) + delete(deployment.Annotations, appsapi.DeploymentCancelledAnnotation) _, err = o.kubeClient.Core().ReplicationControllers(deployment.Namespace).Update(deployment) if err != nil { return err @@ -348,11 +348,11 @@ func (o DeployOptions) retry(config *deployapi.DeploymentConfig) error { // cancel cancels any deployment process in progress for config. // TODO: this code will be deprecated -func (o DeployOptions) cancel(config *deployapi.DeploymentConfig) error { +func (o DeployOptions) cancel(config *appsapi.DeploymentConfig) error { if config.Spec.Paused { return fmt.Errorf("cannot cancel a paused deployment config") } - deploymentList, err := o.kubeClient.Core().ReplicationControllers(config.Namespace).List(metav1.ListOptions{LabelSelector: deployutil.ConfigSelector(config.Name).String()}) + deploymentList, err := o.kubeClient.Core().ReplicationControllers(config.Namespace).List(metav1.ListOptions{LabelSelector: appsutil.ConfigSelector(config.Name).String()}) if err != nil { return err } @@ -364,29 +364,29 @@ func (o DeployOptions) cancel(config *deployapi.DeploymentConfig) error { for i := range deploymentList.Items { deployments = append(deployments, &deploymentList.Items[i]) } - sort.Sort(deployutil.ByLatestVersionDesc(deployments)) + sort.Sort(appsutil.ByLatestVersionDesc(deployments)) failedCancellations := []string{} anyCancelled := false for _, deployment := range deployments { - status := deployutil.DeploymentStatusFor(deployment) + status := appsutil.DeploymentStatusFor(deployment) switch status { - case deployapi.DeploymentStatusNew, - deployapi.DeploymentStatusPending, - deployapi.DeploymentStatusRunning: + case appsapi.DeploymentStatusNew, + appsapi.DeploymentStatusPending, + appsapi.DeploymentStatusRunning: - if deployutil.IsDeploymentCancelled(deployment) { + if appsutil.IsDeploymentCancelled(deployment) { continue } - deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue - deployment.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledByUser + deployment.Annotations[appsapi.DeploymentCancelledAnnotation] = appsapi.DeploymentCancelledAnnotationValue + deployment.Annotations[appsapi.DeploymentStatusReasonAnnotation] = appsapi.DeploymentCancelledByUser _, err := o.kubeClient.Core().ReplicationControllers(deployment.Namespace).Update(deployment) if err == nil { fmt.Fprintf(o.out, "Cancelled deployment #%d\n", config.Status.LatestVersion) anyCancelled = true } else { - fmt.Fprintf(o.out, "Couldn't cancel deployment #%d (status: %s): %v\n", deployutil.DeploymentVersionFor(deployment), status, err) - failedCancellations = append(failedCancellations, strconv.FormatInt(deployutil.DeploymentVersionFor(deployment), 10)) + fmt.Fprintf(o.out, "Couldn't cancel deployment #%d (status: %s): %v\n", appsutil.DeploymentVersionFor(deployment), status, err) + failedCancellations = append(failedCancellations, strconv.FormatInt(appsutil.DeploymentVersionFor(deployment), 10)) } } } @@ -396,13 +396,13 @@ func (o DeployOptions) cancel(config *deployapi.DeploymentConfig) error { if !anyCancelled { latest := deployments[0] maybeCancelling := "" - if deployutil.IsDeploymentCancelled(latest) && !deployutil.IsTerminatedDeployment(latest) { + if appsutil.IsDeploymentCancelled(latest) && !appsutil.IsTerminatedDeployment(latest) { maybeCancelling = " (cancelling)" } timeAt := strings.ToLower(units.HumanDuration(time.Now().Sub(latest.CreationTimestamp.Time))) fmt.Fprintf(o.out, "No deployments are in progress (latest deployment #%d %s%s %s ago)\n", - deployutil.DeploymentVersionFor(latest), - strings.ToLower(string(deployutil.DeploymentStatusFor(latest))), + appsutil.DeploymentVersionFor(latest), + strings.ToLower(string(appsutil.DeploymentStatusFor(latest))), maybeCancelling, timeAt) } @@ -410,10 +410,10 @@ func (o DeployOptions) cancel(config *deployapi.DeploymentConfig) error { } // reenableTriggers enables all image triggers and then persists config. -func (o DeployOptions) reenableTriggers(config *deployapi.DeploymentConfig) error { +func (o DeployOptions) reenableTriggers(config *appsapi.DeploymentConfig) error { enabled := []string{} for _, trigger := range config.Spec.Triggers { - if trigger.Type == deployapi.DeploymentTriggerOnImageChange { + if trigger.Type == appsapi.DeploymentTriggerOnImageChange { trigger.ImageChangeParams.Automatic = true enabled = append(enabled, trigger.ImageChangeParams.From.Name) } @@ -430,8 +430,8 @@ func (o DeployOptions) reenableTriggers(config *deployapi.DeploymentConfig) erro return nil } -func (o DeployOptions) getLogs(config *deployapi.DeploymentConfig) error { - opts := deployapi.DeploymentLogOptions{ +func (o DeployOptions) getLogs(config *appsapi.DeploymentConfig) error { + opts := appsapi.DeploymentLogOptions{ Follow: true, } logClient := appsinternalclient.NewRolloutLogClient(o.appsClient.RESTClient(), config.Namespace) diff --git a/pkg/oc/cli/cmd/deploy_test.go b/pkg/oc/cli/cmd/deploy_test.go index c969bab86374..5b17b8ef8c7b 100644 --- a/pkg/oc/cli/cmd/deploy_test.go +++ b/pkg/oc/cli/cmd/deploy_test.go @@ -14,34 +14,34 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" appsfake "github.com/openshift/origin/pkg/apps/generated/internalclientset/fake" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" // install all APIs _ "github.com/openshift/origin/pkg/api/install" _ "k8s.io/kubernetes/pkg/api/install" ) -func deploymentFor(config *deployapi.DeploymentConfig, status deployapi.DeploymentStatus) *kapi.ReplicationController { - d, err := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) +func deploymentFor(config *appsapi.DeploymentConfig, status appsapi.DeploymentStatus) *kapi.ReplicationController { + d, err := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(appsapi.SchemeGroupVersion)) if err != nil { panic(err) } - d.Annotations[deployapi.DeploymentStatusAnnotation] = string(status) + d.Annotations[appsapi.DeploymentStatusAnnotation] = string(status) return d } // TestCmdDeploy_latestOk ensures that attempts to start a new deployment // succeeds given an existing deployment in a terminal state. func TestCmdDeploy_latestOk(t *testing.T) { - validStatusList := []deployapi.DeploymentStatus{ - deployapi.DeploymentStatusComplete, - deployapi.DeploymentStatusFailed, + validStatusList := []appsapi.DeploymentStatus{ + appsapi.DeploymentStatusComplete, + appsapi.DeploymentStatusFailed, } for _, status := range validStatusList { - config := deploytest.OkDeploymentConfig(1) + config := appstest.OkDeploymentConfig(1) updatedConfig := config osClient := &appsfake.Clientset{} @@ -76,14 +76,14 @@ func TestCmdDeploy_latestOk(t *testing.T) { // TestCmdDeploy_latestConcurrentRejection ensures that attempts to start a // deployment concurrent with a running deployment are rejected. func TestCmdDeploy_latestConcurrentRejection(t *testing.T) { - invalidStatusList := []deployapi.DeploymentStatus{ - deployapi.DeploymentStatusNew, - deployapi.DeploymentStatusPending, - deployapi.DeploymentStatusRunning, + invalidStatusList := []appsapi.DeploymentStatus{ + appsapi.DeploymentStatusNew, + appsapi.DeploymentStatusPending, + appsapi.DeploymentStatusRunning, } for _, status := range invalidStatusList { - config := deploytest.OkDeploymentConfig(1) + config := appstest.OkDeploymentConfig(1) existingDeployment := deploymentFor(config, status) kubeClient := fake.NewSimpleClientset(existingDeployment) o := &DeployOptions{kubeClient: kubeClient, out: ioutil.Discard} @@ -103,7 +103,7 @@ func TestCmdDeploy_latestLookupError(t *testing.T) { return true, nil, kerrors.NewInternalError(fmt.Errorf("internal error")) }) - config := deploytest.OkDeploymentConfig(1) + config := appstest.OkDeploymentConfig(1) o := &DeployOptions{kubeClient: kubeClient, out: ioutil.Discard} err := o.deploy(config) @@ -115,19 +115,19 @@ func TestCmdDeploy_latestLookupError(t *testing.T) { // TestCmdDeploy_retryOk ensures that a failed deployment can be retried. func TestCmdDeploy_retryOk(t *testing.T) { deletedPods := []string{} - config := deploytest.OkDeploymentConfig(1) + config := appstest.OkDeploymentConfig(1) var updatedDeployment *kapi.ReplicationController - existingDeployment := deploymentFor(config, deployapi.DeploymentStatusFailed) - existingDeployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue - existingDeployment.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledByUser + existingDeployment := deploymentFor(config, appsapi.DeploymentStatusFailed) + existingDeployment.Annotations[appsapi.DeploymentCancelledAnnotation] = appsapi.DeploymentCancelledAnnotationValue + existingDeployment.Annotations[appsapi.DeploymentStatusReasonAnnotation] = appsapi.DeploymentCancelledByUser mkpod := func(name string) kapi.Pod { return kapi.Pod{ ObjectMeta: metav1.ObjectMeta{ Name: name, Labels: map[string]string{ - deployapi.DeployerPodForDeploymentLabel: existingDeployment.Name, + appsapi.DeployerPodForDeploymentLabel: existingDeployment.Name, }, }, } @@ -163,11 +163,11 @@ func TestCmdDeploy_retryOk(t *testing.T) { t.Fatalf("expected updated config") } - if deployutil.IsDeploymentCancelled(updatedDeployment) { + if appsutil.IsDeploymentCancelled(updatedDeployment) { t.Fatalf("deployment should not have the cancelled flag set anymore") } - if deployutil.DeploymentStatusReasonFor(updatedDeployment) != "" { + if appsutil.DeploymentStatusReasonFor(updatedDeployment) != "" { t.Fatalf("deployment status reason should be empty") } @@ -177,7 +177,7 @@ func TestCmdDeploy_retryOk(t *testing.T) { t.Fatalf("Not all deployer pods for the failed deployment were deleted.\nEXPECTED: %v\nACTUAL: %v", e, a) } - if e, a := deployapi.DeploymentStatusNew, deployutil.DeploymentStatusFor(updatedDeployment); e != a { + if e, a := appsapi.DeploymentStatusNew, appsutil.DeploymentStatusFor(updatedDeployment); e != a { t.Fatalf("expected deployment status %s, got %s", e, a) } } @@ -185,15 +185,15 @@ func TestCmdDeploy_retryOk(t *testing.T) { // TestCmdDeploy_retryRejectNonFailed ensures that attempts to retry a non- // failed deployment are rejected. func TestCmdDeploy_retryRejectNonFailed(t *testing.T) { - invalidStatusList := []deployapi.DeploymentStatus{ - deployapi.DeploymentStatusNew, - deployapi.DeploymentStatusPending, - deployapi.DeploymentStatusRunning, - deployapi.DeploymentStatusComplete, + invalidStatusList := []appsapi.DeploymentStatus{ + appsapi.DeploymentStatusNew, + appsapi.DeploymentStatusPending, + appsapi.DeploymentStatusRunning, + appsapi.DeploymentStatusComplete, } for _, status := range invalidStatusList { - config := deploytest.OkDeploymentConfig(1) + config := appstest.OkDeploymentConfig(1) existingDeployment := deploymentFor(config, status) kubeClient := fake.NewSimpleClientset(existingDeployment) o := &DeployOptions{kubeClient: kubeClient, out: ioutil.Discard} @@ -210,7 +210,7 @@ func TestCmdDeploy_retryRejectNonFailed(t *testing.T) { func TestCmdDeploy_cancelOk(t *testing.T) { type existing struct { version int64 - status deployapi.DeploymentStatus + status appsapi.DeploymentStatus shouldCancel bool } type scenario struct { @@ -220,30 +220,30 @@ func TestCmdDeploy_cancelOk(t *testing.T) { scenarios := []scenario{ // No existing deployments - {1, []existing{{1, deployapi.DeploymentStatusComplete, false}}}, + {1, []existing{{1, appsapi.DeploymentStatusComplete, false}}}, // A single existing failed deployment - {1, []existing{{1, deployapi.DeploymentStatusFailed, false}}}, + {1, []existing{{1, appsapi.DeploymentStatusFailed, false}}}, // Multiple existing completed/failed deployments - {2, []existing{{2, deployapi.DeploymentStatusFailed, false}, {1, deployapi.DeploymentStatusComplete, false}}}, + {2, []existing{{2, appsapi.DeploymentStatusFailed, false}, {1, appsapi.DeploymentStatusComplete, false}}}, // A single existing new deployment - {1, []existing{{1, deployapi.DeploymentStatusNew, true}}}, + {1, []existing{{1, appsapi.DeploymentStatusNew, true}}}, // A single existing pending deployment - {1, []existing{{1, deployapi.DeploymentStatusPending, true}}}, + {1, []existing{{1, appsapi.DeploymentStatusPending, true}}}, // A single existing running deployment - {1, []existing{{1, deployapi.DeploymentStatusRunning, true}}}, + {1, []existing{{1, appsapi.DeploymentStatusRunning, true}}}, // Multiple existing deployments with one in new/pending/running - {3, []existing{{3, deployapi.DeploymentStatusRunning, true}, {2, deployapi.DeploymentStatusComplete, false}, {1, deployapi.DeploymentStatusFailed, false}}}, + {3, []existing{{3, appsapi.DeploymentStatusRunning, true}, {2, appsapi.DeploymentStatusComplete, false}, {1, appsapi.DeploymentStatusFailed, false}}}, // Multiple existing deployments with more than one in new/pending/running - {3, []existing{{3, deployapi.DeploymentStatusNew, true}, {2, deployapi.DeploymentStatusRunning, true}, {1, deployapi.DeploymentStatusFailed, false}}}, + {3, []existing{{3, appsapi.DeploymentStatusNew, true}, {2, appsapi.DeploymentStatusRunning, true}, {1, appsapi.DeploymentStatusFailed, false}}}, } for _, scenario := range scenarios { updatedDeployments := []kapi.ReplicationController{} - config := deploytest.OkDeploymentConfig(scenario.version) + config := appstest.OkDeploymentConfig(scenario.version) existingDeployments := &kapi.ReplicationControllerList{} for _, e := range scenario.existing { - d, _ := deployutil.MakeDeployment(deploytest.OkDeploymentConfig(e.version), kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) - d.Annotations[deployapi.DeploymentStatusAnnotation] = string(e.status) + d, _ := appsutil.MakeDeployment(appstest.OkDeploymentConfig(e.version), kapi.Codecs.LegacyCodec(appsapi.SchemeGroupVersion)) + d.Annotations[appsapi.DeploymentStatusAnnotation] = string(e.status) existingDeployments.Items = append(existingDeployments.Items, *d) } @@ -272,7 +272,7 @@ func TestCmdDeploy_cancelOk(t *testing.T) { } } for _, d := range updatedDeployments { - actualCancellations = append(actualCancellations, deployutil.DeploymentVersionFor(&d)) + actualCancellations = append(actualCancellations, appsutil.DeploymentVersionFor(&d)) } sort.Sort(Int64Slice(actualCancellations)) @@ -290,22 +290,22 @@ func (p Int64Slice) Less(i, j int) bool { return p[i] < p[j] } func (p Int64Slice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } func TestDeploy_reenableTriggers(t *testing.T) { - mktrigger := func() deployapi.DeploymentTriggerPolicy { - t := deploytest.OkImageChangeTrigger() + mktrigger := func() appsapi.DeploymentTriggerPolicy { + t := appstest.OkImageChangeTrigger() t.ImageChangeParams.Automatic = false return t } - var updated *deployapi.DeploymentConfig + var updated *appsapi.DeploymentConfig osClient := &appsfake.Clientset{} osClient.AddReactor("update", "deploymentconfigs", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { - updated = action.(clientgotesting.UpdateAction).GetObject().(*deployapi.DeploymentConfig) + updated = action.(clientgotesting.UpdateAction).GetObject().(*appsapi.DeploymentConfig) return true, updated, nil }) - config := deploytest.OkDeploymentConfig(1) - config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{} + config := appstest.OkDeploymentConfig(1) + config.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{} count := 3 for i := 0; i < count; i++ { config.Spec.Triggers = append(config.Spec.Triggers, mktrigger()) diff --git a/pkg/oc/cli/cmd/exporter.go b/pkg/oc/cli/cmd/exporter.go index 33cdeb57e30e..faa9d22b4889 100644 --- a/pkg/oc/cli/cmd/exporter.go +++ b/pkg/oc/cli/cmd/exporter.go @@ -24,7 +24,7 @@ import ( "k8s.io/kubernetes/pkg/registry/core/secret" "k8s.io/kubernetes/pkg/registry/core/serviceaccount" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" deployrest "github.com/openshift/origin/pkg/apps/registry/deployconfig" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildrest "github.com/openshift/origin/pkg/build/registry/build" @@ -145,7 +145,7 @@ func (e *DefaultExporter) Export(obj runtime.Object, exact bool) error { } t.Secrets = newMountableSecrets - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: return deployrest.CommonStrategy.Export(ctx, obj, exact) case *buildapi.BuildConfig: diff --git a/pkg/oc/cli/cmd/exporter_test.go b/pkg/oc/cli/cmd/exporter_test.go index 742504549a9e..e670a3946e5f 100644 --- a/pkg/oc/cli/cmd/exporter_test.go +++ b/pkg/oc/cli/cmd/exporter_test.go @@ -8,8 +8,8 @@ import ( "k8s.io/apimachinery/pkg/runtime" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" imageapi "github.com/openshift/origin/pkg/image/apis/image" osautil "github.com/openshift/origin/pkg/serviceaccounts/util" ) @@ -29,14 +29,14 @@ func TestExport(t *testing.T) { }{ { name: "export deploymentConfig", - object: deploytest.OkDeploymentConfig(1), - expectedObj: &deployapi.DeploymentConfig{ + object: appstest.OkDeploymentConfig(1), + expectedObj: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: "config", Generation: 1, }, - Spec: deploytest.OkDeploymentConfigSpec(), - Status: deployapi.DeploymentConfigStatus{}, + Spec: appstest.OkDeploymentConfigSpec(), + Status: appsapi.DeploymentConfigStatus{}, }, expectedErr: nil, }, diff --git a/pkg/oc/cli/cmd/idle.go b/pkg/oc/cli/cmd/idle.go index c2ce11fc16eb..c3e1bab4c0d2 100644 --- a/pkg/oc/cli/cmd/idle.go +++ b/pkg/oc/cli/cmd/idle.go @@ -24,7 +24,7 @@ import ( "k8s.io/kubernetes/pkg/kubectl/resource" appsv1client "github.com/openshift/client-go/apps/clientset/versioned/typed/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsmanualclient "github.com/openshift/origin/pkg/apps/client/v1" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" unidlingapi "github.com/openshift/origin/pkg/unidling/api" @@ -305,7 +305,7 @@ func getControllerRef(obj runtime.Object, decoder runtime.Decoder) (*kapi.Object creatorRefRaw, creatorListed := annotations[kapi.CreatedByAnnotation] if !creatorListed { // if we don't have a creator listed, try the openshift-specific Deployment annotation - dcName, dcNameListed := annotations[deployapi.DeploymentConfigAnnotation] + dcName, dcNameListed := annotations[appsapi.DeploymentConfigAnnotation] if !dcNameListed { return nil, nil } diff --git a/pkg/oc/cli/cmd/idle_test.go b/pkg/oc/cli/cmd/idle_test.go index a853a6ba60ee..3abedb6466da 100644 --- a/pkg/oc/cli/cmd/idle_test.go +++ b/pkg/oc/cli/cmd/idle_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" unidlingapi "github.com/openshift/origin/pkg/unidling/api" kerrors "k8s.io/apimachinery/pkg/api/errors" @@ -75,7 +75,7 @@ func makeRC(name, dcName, createdByDCName string, t *testing.T) *kapi.Replicatio } if dcName != "" { - rc.Annotations[deployapi.DeploymentConfigAnnotation] = dcName + rc.Annotations[appsapi.DeploymentConfigAnnotation] = dcName } return &rc diff --git a/pkg/oc/cli/cmd/logs.go b/pkg/oc/cli/cmd/logs.go index 007026958630..9e7ef30739e0 100644 --- a/pkg/oc/cli/cmd/logs.go +++ b/pkg/oc/cli/cmd/logs.go @@ -15,7 +15,7 @@ import ( "k8s.io/kubernetes/pkg/kubectl/cmd/templates" kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildclient "github.com/openshift/origin/pkg/build/generated/internalclientset/typed/build/internalversion" buildutil "github.com/openshift/origin/pkg/build/util" @@ -165,8 +165,8 @@ func (o *OpenShiftLogsOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command } o.Options = bopts - case deployapi.IsResourceOrLegacy("deploymentconfig", gr): - dopts := &deployapi.DeploymentLogOptions{ + case appsapi.IsResourceOrLegacy("deploymentconfig", gr): + dopts := &appsapi.DeploymentLogOptions{ Follow: podLogOptions.Follow, Previous: podLogOptions.Previous, SinceSeconds: podLogOptions.SinceSeconds, @@ -200,7 +200,7 @@ func (o OpenShiftLogsOptions) Validate() error { if t.Previous && t.Version != nil { return errors.New("cannot use both --previous and --version") } - case *deployapi.DeploymentLogOptions: + case *appsapi.DeploymentLogOptions: if t.Previous && t.Version != nil { return errors.New("cannot use both --previous and --version") } diff --git a/pkg/oc/cli/cmd/logs_test.go b/pkg/oc/cli/cmd/logs_test.go index 1f6d665eaedd..75989ef53eba 100644 --- a/pkg/oc/cli/cmd/logs_test.go +++ b/pkg/oc/cli/cmd/logs_test.go @@ -12,7 +12,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" kcmd "k8s.io/kubernetes/pkg/kubectl/cmd" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildfake "github.com/openshift/origin/pkg/build/generated/internalclientset/fake" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" @@ -163,7 +163,7 @@ func TestIsPipelineBuild(t *testing.T) { isPipeline: false, }, { - o: &deployapi.DeploymentConfig{}, + o: &appsapi.DeploymentConfig{}, isPipeline: false, }, } diff --git a/pkg/oc/cli/cmd/rollback_test.go b/pkg/oc/cli/cmd/rollback_test.go index 3b364df62523..bc0b18b8c0a6 100644 --- a/pkg/oc/cli/cmd/rollback_test.go +++ b/pkg/oc/cli/cmd/rollback_test.go @@ -6,15 +6,15 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsutil "github.com/openshift/origin/pkg/apps/util" ) func TestRollbackOptions_findTargetDeployment(t *testing.T) { type existingDeployment struct { version int64 - status deployapi.DeploymentStatus + status appsapi.DeploymentStatus } tests := []struct { name string @@ -28,9 +28,9 @@ func TestRollbackOptions_findTargetDeployment(t *testing.T) { name: "desired found", configVersion: 3, existing: []existingDeployment{ - {1, deployapi.DeploymentStatusComplete}, - {2, deployapi.DeploymentStatusComplete}, - {3, deployapi.DeploymentStatusComplete}, + {1, appsapi.DeploymentStatusComplete}, + {2, appsapi.DeploymentStatusComplete}, + {3, appsapi.DeploymentStatusComplete}, }, desiredVersion: 1, expectedVersion: 1, @@ -40,8 +40,8 @@ func TestRollbackOptions_findTargetDeployment(t *testing.T) { name: "desired not found", configVersion: 3, existing: []existingDeployment{ - {2, deployapi.DeploymentStatusComplete}, - {3, deployapi.DeploymentStatusComplete}, + {2, appsapi.DeploymentStatusComplete}, + {3, appsapi.DeploymentStatusComplete}, }, desiredVersion: 1, errorExpected: true, @@ -50,9 +50,9 @@ func TestRollbackOptions_findTargetDeployment(t *testing.T) { name: "desired not supplied, target found", configVersion: 3, existing: []existingDeployment{ - {1, deployapi.DeploymentStatusComplete}, - {2, deployapi.DeploymentStatusFailed}, - {3, deployapi.DeploymentStatusComplete}, + {1, appsapi.DeploymentStatusComplete}, + {2, appsapi.DeploymentStatusFailed}, + {3, appsapi.DeploymentStatusComplete}, }, desiredVersion: 0, expectedVersion: 1, @@ -62,9 +62,9 @@ func TestRollbackOptions_findTargetDeployment(t *testing.T) { name: "desired not supplied, target not found", configVersion: 3, existing: []existingDeployment{ - {1, deployapi.DeploymentStatusFailed}, - {2, deployapi.DeploymentStatusFailed}, - {3, deployapi.DeploymentStatusComplete}, + {1, appsapi.DeploymentStatusFailed}, + {2, appsapi.DeploymentStatusFailed}, + {3, appsapi.DeploymentStatusComplete}, }, desiredVersion: 0, errorExpected: true, @@ -76,9 +76,9 @@ func TestRollbackOptions_findTargetDeployment(t *testing.T) { existingControllers := &kapi.ReplicationControllerList{} for _, existing := range test.existing { - config := deploytest.OkDeploymentConfig(existing.version) - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.SchemeGroupVersion)) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(existing.status) + config := appstest.OkDeploymentConfig(existing.version) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(appsapi.SchemeGroupVersion)) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(existing.status) existingControllers.Items = append(existingControllers.Items, *deployment) } @@ -87,7 +87,7 @@ func TestRollbackOptions_findTargetDeployment(t *testing.T) { kc: fakekc, } - config := deploytest.OkDeploymentConfig(test.configVersion) + config := appstest.OkDeploymentConfig(test.configVersion) target, err := opts.findTargetDeployment(config, test.desiredVersion) if err != nil { if !test.errorExpected { @@ -103,7 +103,7 @@ func TestRollbackOptions_findTargetDeployment(t *testing.T) { if target == nil { t.Fatalf("expected a target deployment") } - if e, a := test.expectedVersion, deployutil.DeploymentVersionFor(target); e != a { + if e, a := test.expectedVersion, appsutil.DeploymentVersionFor(target); e != a { t.Errorf("expected target version %d, got %d", e, a) } } diff --git a/pkg/oc/cli/cmd/rollout/cancel.go b/pkg/oc/cli/cmd/rollout/cancel.go index e826c3234b96..528bcd88f9fe 100644 --- a/pkg/oc/cli/cmd/rollout/cancel.go +++ b/pkg/oc/cli/cmd/rollout/cancel.go @@ -15,8 +15,8 @@ import ( "k8s.io/kubernetes/pkg/kubectl/resource" units "github.com/docker/go-units" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" "github.com/spf13/cobra" utilerrors "k8s.io/apimachinery/pkg/util/errors" @@ -109,7 +109,7 @@ func (o *CancelOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command, out i func (o CancelOptions) Run() error { allErrs := []error{} for _, info := range o.Infos { - config, ok := info.Object.(*deployapi.DeploymentConfig) + config, ok := info.Object.(*appsapi.DeploymentConfig) if !ok { allErrs = append(allErrs, kcmdutil.AddSourceToErr("cancelling", info.Source, fmt.Errorf("expected deployment configuration, got %s", info.Mapping.Resource))) continue @@ -124,14 +124,14 @@ func (o CancelOptions) Run() error { } mutateFn := func(rc *kapi.ReplicationController) bool { - if deployutil.IsDeploymentCancelled(rc) { + if appsutil.IsDeploymentCancelled(rc) { kcmdutil.PrintSuccess(o.Mapper, false, o.Out, info.Mapping.Resource, info.Name, false, "already cancelled") return false } patches := set.CalculatePatches([]*resource.Info{{Object: rc, Mapping: mapping}}, o.Encoder, func(*resource.Info) ([]byte, error) { - rc.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue - rc.Annotations[deployapi.DeploymentStatusReasonAnnotation] = deployapi.DeploymentCancelledByUser + rc.Annotations[appsapi.DeploymentCancelledAnnotation] = appsapi.DeploymentCancelledAnnotationValue + rc.Annotations[appsapi.DeploymentStatusReasonAnnotation] = appsapi.DeploymentCancelledByUser return runtime.Encode(o.Encoder, rc) }) @@ -158,13 +158,13 @@ func (o CancelOptions) Run() error { if !cancelled { latest := deployments[0] maybeCancelling := "" - if deployutil.IsDeploymentCancelled(latest) && !deployutil.IsTerminatedDeployment(latest) { + if appsutil.IsDeploymentCancelled(latest) && !appsutil.IsTerminatedDeployment(latest) { maybeCancelling = " (cancelling)" } timeAt := strings.ToLower(units.HumanDuration(time.Now().Sub(latest.CreationTimestamp.Time))) fmt.Fprintf(o.Out, "No rollout is in progress (latest rollout #%d %s%s %s ago)\n", - deployutil.DeploymentVersionFor(latest), - strings.ToLower(string(deployutil.DeploymentStatusFor(latest))), + appsutil.DeploymentVersionFor(latest), + strings.ToLower(string(appsutil.DeploymentStatusFor(latest))), maybeCancelling, timeAt) } @@ -174,7 +174,7 @@ func (o CancelOptions) Run() error { } func (o CancelOptions) forEachControllerInConfig(namespace, name string, mutateFunc func(*kapi.ReplicationController) bool) ([]*kapi.ReplicationController, bool, error) { - deploymentList, err := o.Clientset.Core().ReplicationControllers(namespace).List(metav1.ListOptions{LabelSelector: deployutil.ConfigSelector(name).String()}) + deploymentList, err := o.Clientset.Core().ReplicationControllers(namespace).List(metav1.ListOptions{LabelSelector: appsutil.ConfigSelector(name).String()}) if err != nil { return nil, false, err } @@ -185,16 +185,16 @@ func (o CancelOptions) forEachControllerInConfig(namespace, name string, mutateF for i := range deploymentList.Items { deployments = append(deployments, &deploymentList.Items[i]) } - sort.Sort(deployutil.ByLatestVersionDesc(deployments)) + sort.Sort(appsutil.ByLatestVersionDesc(deployments)) allErrs := []error{} cancelled := false for _, deployment := range deployments { - status := deployutil.DeploymentStatusFor(deployment) + status := appsutil.DeploymentStatusFor(deployment) switch status { - case deployapi.DeploymentStatusNew, - deployapi.DeploymentStatusPending, - deployapi.DeploymentStatusRunning: + case appsapi.DeploymentStatusNew, + appsapi.DeploymentStatusPending, + appsapi.DeploymentStatusRunning: cancelled = mutateFunc(deployment) } } diff --git a/pkg/oc/cli/cmd/rollout/latest.go b/pkg/oc/cli/cmd/rollout/latest.go index d8d58e2be366..c04b5b93294e 100644 --- a/pkg/oc/cli/cmd/rollout/latest.go +++ b/pkg/oc/cli/cmd/rollout/latest.go @@ -15,9 +15,9 @@ import ( kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" "k8s.io/kubernetes/pkg/kubectl/resource" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsclientinternal "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" ) @@ -133,7 +133,7 @@ func (o RolloutLatestOptions) Validate() error { func (o RolloutLatestOptions) RunRolloutLatest() error { info := o.infos[0] - config, ok := info.Object.(*deployapi.DeploymentConfig) + config, ok := info.Object.(*appsapi.DeploymentConfig) if !ok { return fmt.Errorf("%s is not a deployment config", info.Name) } @@ -144,13 +144,13 @@ func (o RolloutLatestOptions) RunRolloutLatest() error { return fmt.Errorf("cannot deploy a paused deployment config") } - deploymentName := deployutil.LatestDeploymentNameForConfig(config) + deploymentName := appsutil.LatestDeploymentNameForConfig(config) deployment, err := o.kc.Core().ReplicationControllers(config.Namespace).Get(deploymentName, metav1.GetOptions{}) switch { case err == nil: // Reject attempts to start a concurrent deployment. - if !deployutil.IsTerminatedDeployment(deployment) { - status := deployutil.DeploymentStatusFor(deployment) + if !appsutil.IsTerminatedDeployment(deployment) { + status := appsutil.DeploymentStatusFor(deployment) return fmt.Errorf("#%d is already in progress (%s).", config.Status.LatestVersion, status) } case !kerrors.IsNotFound(err): @@ -159,7 +159,7 @@ func (o RolloutLatestOptions) RunRolloutLatest() error { dc := config if !o.DryRun { - request := &deployapi.DeploymentRequest{ + request := &appsapi.DeploymentRequest{ Name: config.Name, Latest: !o.again, Force: true, diff --git a/pkg/oc/cli/cmd/rollout/retry.go b/pkg/oc/cli/cmd/rollout/retry.go index 318f10e06718..00df91e94c78 100644 --- a/pkg/oc/cli/cmd/rollout/retry.go +++ b/pkg/oc/cli/cmd/rollout/retry.go @@ -13,8 +13,8 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/kubectl/resource" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" "github.com/spf13/cobra" kerrors "k8s.io/apimachinery/pkg/api/errors" @@ -114,7 +114,7 @@ func (o RetryOptions) Run() error { return err } for _, info := range o.Infos { - config, ok := info.Object.(*deployapi.DeploymentConfig) + config, ok := info.Object.(*appsapi.DeploymentConfig) if !ok { allErrs = append(allErrs, kcmdutil.AddSourceToErr("retrying", info.Source, fmt.Errorf("expected deployment configuration, got %T", info.Object))) continue @@ -128,7 +128,7 @@ func (o RetryOptions) Run() error { continue } - latestDeploymentName := deployutil.LatestDeploymentNameForConfig(config) + latestDeploymentName := appsutil.LatestDeploymentNameForConfig(config) rc, err := o.Clientset.Core().ReplicationControllers(config.Namespace).Get(latestDeploymentName, metav1.GetOptions{}) if err != nil { if kerrors.IsNotFound(err) { @@ -139,9 +139,9 @@ func (o RetryOptions) Run() error { continue } - if !deployutil.IsFailedDeployment(rc) { - message := fmt.Sprintf("rollout #%d is %s; only failed deployments can be retried.\n", config.Status.LatestVersion, strings.ToLower(string(deployutil.DeploymentStatusFor(rc)))) - if deployutil.IsCompleteDeployment(rc) { + if !appsutil.IsFailedDeployment(rc) { + message := fmt.Sprintf("rollout #%d is %s; only failed deployments can be retried.\n", config.Status.LatestVersion, strings.ToLower(string(appsutil.DeploymentStatusFor(rc)))) + if appsutil.IsCompleteDeployment(rc) { message += fmt.Sprintf("You can start a new deployment with 'oc rollout latest dc/%s'.", config.Name) } else { message += fmt.Sprintf("Optionally, you can cancel this deployment with 'oc rollout cancel dc/%s'.", config.Name) @@ -151,7 +151,7 @@ func (o RetryOptions) Run() error { } // Delete the deployer pod as well as the deployment hooks pods, if any - pods, err := o.Clientset.Core().Pods(config.Namespace).List(metav1.ListOptions{LabelSelector: deployutil.DeployerPodSelector(latestDeploymentName).String()}) + pods, err := o.Clientset.Core().Pods(config.Namespace).List(metav1.ListOptions{LabelSelector: appsutil.DeployerPodSelector(latestDeploymentName).String()}) if err != nil { allErrs = append(allErrs, kcmdutil.AddSourceToErr("retrying", info.Source, fmt.Errorf("failed to list deployer/hook pods for deployment #%d: %v", config.Status.LatestVersion, err))) continue @@ -169,9 +169,9 @@ func (o RetryOptions) Run() error { } patches := set.CalculatePatches([]*resource.Info{{Object: rc, Mapping: mapping}}, o.Encoder, func(*resource.Info) ([]byte, error) { - rc.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) - delete(rc.Annotations, deployapi.DeploymentStatusReasonAnnotation) - delete(rc.Annotations, deployapi.DeploymentCancelledAnnotation) + rc.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) + delete(rc.Annotations, appsapi.DeploymentStatusReasonAnnotation) + delete(rc.Annotations, appsapi.DeploymentCancelledAnnotation) return runtime.Encode(o.Encoder, rc) }) diff --git a/pkg/oc/cli/cmd/set/deploymenthook.go b/pkg/oc/cli/cmd/set/deploymenthook.go index b21c3ceb01ae..25fb9d9e83f4 100644 --- a/pkg/oc/cli/cmd/set/deploymenthook.go +++ b/pkg/oc/cli/cmd/set/deploymenthook.go @@ -13,7 +13,7 @@ import ( kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" "k8s.io/kubernetes/pkg/kubectl/resource" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" cmdutil "github.com/openshift/origin/pkg/cmd/util" "github.com/openshift/origin/pkg/oc/cli/util/clientcmd" ) @@ -87,7 +87,7 @@ type DeploymentHookOptions struct { Environment []string Volumes []string - FailurePolicy deployapi.LifecycleHookFailurePolicy + FailurePolicy appsapi.LifecycleHookFailurePolicy } // NewCmdDeploymentHook implements the set deployment-hook command @@ -185,11 +185,11 @@ func (o *DeploymentHookOptions) Complete(f *clientcmd.Factory, cmd *cobra.Comman if len(failurePolicyString) > 0 { switch failurePolicyString { case "abort": - o.FailurePolicy = deployapi.LifecycleHookFailurePolicyAbort + o.FailurePolicy = appsapi.LifecycleHookFailurePolicyAbort case "ignore": - o.FailurePolicy = deployapi.LifecycleHookFailurePolicyIgnore + o.FailurePolicy = appsapi.LifecycleHookFailurePolicyIgnore case "retry": - o.FailurePolicy = deployapi.LifecycleHookFailurePolicyRetry + o.FailurePolicy = appsapi.LifecycleHookFailurePolicyRetry default: return kcmdutil.UsageErrorf(cmd, "valid values for --failure-policy are: abort, retry, ignore") } @@ -248,7 +248,7 @@ func (o *DeploymentHookOptions) Run() error { } patches := CalculatePatches(infos, o.Encoder, func(info *resource.Info) (bool, error) { - dc, ok := info.Object.(*deployapi.DeploymentConfig) + dc, ok := info.Object.(*appsapi.DeploymentConfig) if !ok { return false, nil } @@ -293,7 +293,7 @@ func (o *DeploymentHookOptions) Run() error { return nil } -func (o *DeploymentHookOptions) updateDeploymentConfig(dc *deployapi.DeploymentConfig) (bool, error) { +func (o *DeploymentHookOptions) updateDeploymentConfig(dc *appsapi.DeploymentConfig) (bool, error) { var ( err error updatedRecreate bool @@ -315,7 +315,7 @@ func (o *DeploymentHookOptions) updateDeploymentConfig(dc *deployapi.DeploymentC return updatedRecreate || updatedRolling, nil } -func (o *DeploymentHookOptions) updateRecreateParams(dc *deployapi.DeploymentConfig, strategyParams *deployapi.RecreateDeploymentStrategyParams) (bool, error) { +func (o *DeploymentHookOptions) updateRecreateParams(dc *appsapi.DeploymentConfig, strategyParams *appsapi.RecreateDeploymentStrategyParams) (bool, error) { var updated bool if o.Remove { if o.Pre && strategyParams.Pre != nil { @@ -347,7 +347,7 @@ func (o *DeploymentHookOptions) updateRecreateParams(dc *deployapi.DeploymentCon return true, nil } -func (o *DeploymentHookOptions) updateRollingParams(dc *deployapi.DeploymentConfig, strategyParams *deployapi.RollingDeploymentStrategyParams) (bool, error) { +func (o *DeploymentHookOptions) updateRollingParams(dc *appsapi.DeploymentConfig, strategyParams *appsapi.RollingDeploymentStrategyParams) (bool, error) { var updated bool if o.Remove { if o.Pre && strategyParams.Pre != nil { @@ -373,10 +373,10 @@ func (o *DeploymentHookOptions) updateRollingParams(dc *deployapi.DeploymentConf return true, nil } -func (o *DeploymentHookOptions) lifecycleHook(dc *deployapi.DeploymentConfig) (*deployapi.LifecycleHook, error) { - hook := &deployapi.LifecycleHook{ +func (o *DeploymentHookOptions) lifecycleHook(dc *appsapi.DeploymentConfig) (*appsapi.LifecycleHook, error) { + hook := &appsapi.LifecycleHook{ FailurePolicy: o.FailurePolicy, - ExecNewPod: &deployapi.ExecNewPodHook{ + ExecNewPod: &appsapi.ExecNewPodHook{ Command: o.Command, }, } diff --git a/pkg/oc/cli/cmd/set/triggers.go b/pkg/oc/cli/cmd/set/triggers.go index beb45769313d..c189e15a4511 100644 --- a/pkg/oc/cli/cmd/set/triggers.go +++ b/pkg/oc/cli/cmd/set/triggers.go @@ -25,7 +25,7 @@ import ( "k8s.io/kubernetes/pkg/kubectl/resource" ometa "github.com/openshift/origin/pkg/api/meta" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" "github.com/openshift/origin/pkg/generate/app" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -563,13 +563,13 @@ func NewAnnotationTriggers(obj runtime.Object) (*TriggerDefinition, error) { } // NewDeploymentConfigTriggers creates a trigger definition from a deployment config. -func NewDeploymentConfigTriggers(config *deployapi.DeploymentConfig) *TriggerDefinition { +func NewDeploymentConfigTriggers(config *appsapi.DeploymentConfig) *TriggerDefinition { t := &TriggerDefinition{} for _, trigger := range config.Spec.Triggers { switch trigger.Type { - case deployapi.DeploymentTriggerOnConfigChange: + case appsapi.DeploymentTriggerOnConfigChange: t.ConfigChange = true - case deployapi.DeploymentTriggerOnImageChange: + case appsapi.DeploymentTriggerOnImageChange: t.ImageChange = append(t.ImageChange, ImageChangeTrigger{ Auto: trigger.ImageChangeParams.Automatic, Names: trigger.ImageChangeParams.ContainerNames, @@ -627,7 +627,7 @@ func NewBuildConfigTriggers(config *buildapi.BuildConfig) *TriggerDefinition { // Apply writes a trigger definition back to an object. func (t *TriggerDefinition) Apply(obj runtime.Object) error { switch c := obj.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: if len(t.GitHubWebHooks) > 0 { return fmt.Errorf("deployment configs do not support GitHub web hooks") } @@ -641,10 +641,10 @@ func (t *TriggerDefinition) Apply(obj runtime.Object) error { return fmt.Errorf("deployment configs do not support Bitbucket web hooks") } - existingTriggers := filterDeploymentTriggers(c.Spec.Triggers, deployapi.DeploymentTriggerOnConfigChange) - var triggers []deployapi.DeploymentTriggerPolicy + existingTriggers := filterDeploymentTriggers(c.Spec.Triggers, appsapi.DeploymentTriggerOnConfigChange) + var triggers []appsapi.DeploymentTriggerPolicy if t.ConfigChange { - triggers = append(triggers, deployapi.DeploymentTriggerPolicy{Type: deployapi.DeploymentTriggerOnConfigChange}) + triggers = append(triggers, appsapi.DeploymentTriggerPolicy{Type: appsapi.DeploymentTriggerOnConfigChange}) } allNames := sets.NewString() for _, container := range c.Spec.Template.Spec.Containers { @@ -664,9 +664,9 @@ func (t *TriggerDefinition) Apply(obj runtime.Object) error { strings.Join(allNames.List(), ", "), ) } - triggers = append(triggers, deployapi.DeploymentTriggerPolicy{ - Type: deployapi.DeploymentTriggerOnImageChange, - ImageChangeParams: &deployapi.DeploymentTriggerImageChangeParams{ + triggers = append(triggers, appsapi.DeploymentTriggerPolicy{ + Type: appsapi.DeploymentTriggerOnImageChange, + ImageChangeParams: &appsapi.DeploymentTriggerImageChangeParams{ Automatic: trigger.Auto, From: kapi.ObjectReference{ Kind: "ImageStreamTag", @@ -868,8 +868,8 @@ func filterBuildImageTriggers(src []buildapi.BuildTriggerPolicy, trigger ImageCh } // filterDeploymentTriggers returns only triggers that do not have one of the provided types. -func filterDeploymentTriggers(src []deployapi.DeploymentTriggerPolicy, types ...deployapi.DeploymentTriggerType) []deployapi.DeploymentTriggerPolicy { - var dst []deployapi.DeploymentTriggerPolicy +func filterDeploymentTriggers(src []appsapi.DeploymentTriggerPolicy, types ...appsapi.DeploymentTriggerType) []appsapi.DeploymentTriggerPolicy { + var dst []appsapi.DeploymentTriggerPolicy Outer: for i := range src { for _, t := range types { @@ -896,9 +896,9 @@ func strategyTrigger(config *buildapi.BuildConfig) *ImageChangeTrigger { } // mergeDeployTriggers returns an array of DeploymentTriggerPolicies that have no duplicates. -func mergeDeployTriggers(dst, src []deployapi.DeploymentTriggerPolicy) []deployapi.DeploymentTriggerPolicy { +func mergeDeployTriggers(dst, src []appsapi.DeploymentTriggerPolicy) []appsapi.DeploymentTriggerPolicy { // never return an empty map, because the triggers on a deployment config default when the map is empty - result := []deployapi.DeploymentTriggerPolicy{} + result := []appsapi.DeploymentTriggerPolicy{} for _, current := range dst { if findDeployTrigger(src, current) != -1 { result = append(result, current) @@ -914,7 +914,7 @@ func mergeDeployTriggers(dst, src []deployapi.DeploymentTriggerPolicy) []deploya // findDeployTrigger finds the position of a deployment trigger in the provided array, or -1 if no such // matching trigger is found. -func findDeployTrigger(dst []deployapi.DeploymentTriggerPolicy, trigger deployapi.DeploymentTriggerPolicy) int { +func findDeployTrigger(dst []appsapi.DeploymentTriggerPolicy, trigger appsapi.DeploymentTriggerPolicy) int { for i := range dst { if reflect.DeepEqual(dst[i], trigger) { return i @@ -965,7 +965,7 @@ func findBuildTrigger(dst []buildapi.BuildTriggerPolicy, trigger buildapi.BuildT func UpdateTriggersForObject(obj runtime.Object, fn func(*TriggerDefinition) error) (bool, error) { // TODO: replace with a swagger schema based approach (identify pod template via schema introspection) switch t := obj.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: triggers := NewDeploymentConfigTriggers(t) if err := fn(triggers); err != nil { return true, err diff --git a/pkg/oc/cli/describe/deployments.go b/pkg/oc/cli/describe/deployments.go index 1dfda9c88691..e9736f6248c0 100644 --- a/pkg/oc/cli/describe/deployments.go +++ b/pkg/oc/cli/describe/deployments.go @@ -22,9 +22,9 @@ import ( kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsinternalversion "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" - deployedges "github.com/openshift/origin/pkg/apps/graph" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsedges "github.com/openshift/origin/pkg/apps/graph" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsutil "github.com/openshift/origin/pkg/apps/util" imageapi "github.com/openshift/origin/pkg/image/apis/image" ) @@ -80,7 +80,7 @@ func (d *DeploymentConfigDescriber) Describe(namespace, name string, settings kp ) if d.config == nil { - if rcs, err := d.kubeClient.Core().ReplicationControllers(namespace).List(metav1.ListOptions{LabelSelector: deployutil.ConfigSelector(deploymentConfig.Name).String()}); err == nil { + if rcs, err := d.kubeClient.Core().ReplicationControllers(namespace).List(metav1.ListOptions{LabelSelector: appsutil.ConfigSelector(deploymentConfig.Name).String()}); err == nil { deploymentsHistory = make([]*kapi.ReplicationController, 0, len(rcs.Items)) for i := range rcs.Items { deploymentsHistory = append(deploymentsHistory, &rcs.Items[i]) @@ -97,8 +97,8 @@ func (d *DeploymentConfigDescriber) Describe(namespace, name string, settings kp printDeploymentConfigSpec(d.kubeClient, *deploymentConfig, out) fmt.Fprintln(out) - latestDeploymentName := deployutil.LatestDeploymentNameForConfig(deploymentConfig) - if activeDeployment := deployutil.ActiveDeployment(deploymentsHistory); activeDeployment != nil { + latestDeploymentName := appsutil.LatestDeploymentNameForConfig(deploymentConfig) + if activeDeployment := appsutil.ActiveDeployment(deploymentsHistory); activeDeployment != nil { activeDeploymentName = activeDeployment.Name } @@ -116,7 +116,7 @@ func (d *DeploymentConfigDescriber) Describe(namespace, name string, settings kp if isNotDeployed { formatString(out, "Latest Deployment", "") } else { - header := fmt.Sprintf("Deployment #%d (latest)", deployutil.DeploymentVersionFor(deployment)) + header := fmt.Sprintf("Deployment #%d (latest)", appsutil.DeploymentVersionFor(deployment)) // Show details if the current deployment is the active one or it is the // initial deployment. printDeploymentRc(deployment, d.kubeClient, out, header, (deployment.Name == activeDeploymentName) || len(deploymentsHistory) == 1) @@ -132,8 +132,8 @@ func (d *DeploymentConfigDescriber) Describe(namespace, name string, settings kp sort.Sort(sort.Reverse(OverlappingControllers(sorted))) counter := 1 for _, item := range sorted { - if item.Name != latestDeploymentName && deploymentConfig.Name == deployutil.DeploymentConfigNameFor(item) { - header := fmt.Sprintf("Deployment #%d", deployutil.DeploymentVersionFor(item)) + if item.Name != latestDeploymentName && deploymentConfig.Name == appsutil.DeploymentConfigNameFor(item) { + header := fmt.Sprintf("Deployment #%d", appsutil.DeploymentVersionFor(item)) printDeploymentRc(item, d.kubeClient, out, header, item.Name == activeDeploymentName) counter++ } @@ -389,7 +389,7 @@ func printDeploymentRc(deployment *kapi.ReplicationController, kubeClient kclien } timeAt := strings.ToLower(formatRelativeTime(deployment.CreationTimestamp.Time)) fmt.Fprintf(w, "\tCreated:\t%s ago\n", timeAt) - fmt.Fprintf(w, "\tStatus:\t%s\n", deployutil.DeploymentStatusFor(deployment)) + fmt.Fprintf(w, "\tStatus:\t%s\n", appsutil.DeploymentStatusFor(deployment)) fmt.Fprintf(w, "\tReplicas:\t%d current / %d desired\n", deployment.Status.Replicas, deployment.Spec.Replicas) if verbose { @@ -451,13 +451,13 @@ func (d *LatestDeploymentsDescriber) Describe(namespace, name string) (string, e var deployments []kapi.ReplicationController if d.count == -1 || d.count > 1 { - list, err := d.kubeClient.Core().ReplicationControllers(namespace).List(metav1.ListOptions{LabelSelector: deployutil.ConfigSelector(name).String()}) + list, err := d.kubeClient.Core().ReplicationControllers(namespace).List(metav1.ListOptions{LabelSelector: appsutil.ConfigSelector(name).String()}) if err != nil && !kerrors.IsNotFound(err) { return "", err } deployments = list.Items } else { - deploymentName := deployutil.LatestDeploymentNameForConfig(config) + deploymentName := appsutil.LatestDeploymentNameForConfig(config) deployment, err := d.kubeClient.Core().ReplicationControllers(config.Namespace).Get(deploymentName, metav1.GetOptions{}) if err != nil && !kerrors.IsNotFound(err) { return "", err @@ -468,13 +468,13 @@ func (d *LatestDeploymentsDescriber) Describe(namespace, name string) (string, e } g := graph.New() - dcNode := deploygraph.EnsureDeploymentConfigNode(g, config) + dcNode := appsgraph.EnsureDeploymentConfigNode(g, config) for i := range deployments { kubegraph.EnsureReplicationControllerNode(g, &deployments[i]) } - deployedges.AddTriggerEdges(g, dcNode) - deployedges.AddDeploymentEdges(g, dcNode) - activeDeployment, inactiveDeployments := deployedges.RelevantDeployments(g, dcNode) + appsedges.AddTriggerEdges(g, dcNode) + appsedges.AddDeploymentEdges(g, dcNode) + activeDeployment, inactiveDeployments := appsedges.RelevantDeployments(g, dcNode) return tabbedString(func(out *tabwriter.Writer) error { descriptions := describeDeployments(f, dcNode, activeDeployment, inactiveDeployments, nil, d.count) diff --git a/pkg/oc/cli/describe/deployments_test.go b/pkg/oc/cli/describe/deployments_test.go index f33c26a6a843..abdc62a28738 100644 --- a/pkg/oc/cli/describe/deployments_test.go +++ b/pkg/oc/cli/describe/deployments_test.go @@ -11,15 +11,15 @@ import ( kfake "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" kprinters "k8s.io/kubernetes/pkg/printers" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployapitest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapitest "github.com/openshift/origin/pkg/apps/apis/apps/test" appsfake "github.com/openshift/origin/pkg/apps/generated/internalclientset/fake" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" ) func TestDeploymentConfigDescriber(t *testing.T) { - config := deployapitest.OkDeploymentConfig(1) - deployment, _ := deployutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(deployapi.LegacySchemeGroupVersion)) + config := appsapitest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeployment(config, kapi.Codecs.LegacyCodec(appsapi.LegacySchemeGroupVersion)) podList := &kapi.PodList{} fake := &appsfake.Clientset{} @@ -30,7 +30,7 @@ func TestDeploymentConfigDescriber(t *testing.T) { kFake.PrependReactor("list", "horizontalpodautoscalers", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { return true, &autoscaling.HorizontalPodAutoscalerList{ Items: []autoscaling.HorizontalPodAutoscaler{ - *deployapitest.OkHPAForDeploymentConfig(config, 1, 3), + *appsapitest.OkHPAForDeploymentConfig(config, 1, 3), }}, nil }) kFake.PrependReactor("get", "replicationcontrollers", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { @@ -68,20 +68,20 @@ func TestDeploymentConfigDescriber(t *testing.T) { t.Fatalf("expected %q in output:\n%s", substr, out) } - config.Spec.Triggers = append(config.Spec.Triggers, deployapitest.OkConfigChangeTrigger()) + config.Spec.Triggers = append(config.Spec.Triggers, appsapitest.OkConfigChangeTrigger()) describe() - config.Spec.Strategy = deployapitest.OkCustomStrategy() + config.Spec.Strategy = appsapitest.OkCustomStrategy() describe() config.Spec.Triggers[0].ImageChangeParams.From = kapi.ObjectReference{Name: "imagestream"} describe() - config.Spec.Strategy = deployapitest.OkStrategy() - config.Spec.Strategy.RecreateParams = &deployapi.RecreateDeploymentStrategyParams{ - Pre: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyAbort, - ExecNewPod: &deployapi.ExecNewPodHook{ + config.Spec.Strategy = appsapitest.OkStrategy() + config.Spec.Strategy.RecreateParams = &appsapi.RecreateDeploymentStrategyParams{ + Pre: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyAbort, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container", Command: []string{"/command1", "args"}, Env: []kapi.EnvVar{ @@ -92,9 +92,9 @@ func TestDeploymentConfigDescriber(t *testing.T) { }, }, }, - Post: &deployapi.LifecycleHook{ - FailurePolicy: deployapi.LifecycleHookFailurePolicyIgnore, - ExecNewPod: &deployapi.ExecNewPodHook{ + Post: &appsapi.LifecycleHook{ + FailurePolicy: appsapi.LifecycleHookFailurePolicyIgnore, + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: "container", Command: []string{"/command2", "args"}, Env: []kapi.EnvVar{ diff --git a/pkg/oc/cli/describe/describer.go b/pkg/oc/cli/describe/describer.go index 408f0a669460..acd573b475d7 100644 --- a/pkg/oc/cli/describe/describer.go +++ b/pkg/oc/cli/describe/describer.go @@ -26,7 +26,7 @@ import ( kinternalprinters "k8s.io/kubernetes/pkg/printers/internalversion" oapi "github.com/openshift/origin/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" oauthorizationclient "github.com/openshift/origin/pkg/authorization/generated/internalclientset/typed/authorization/internalversion" @@ -107,7 +107,7 @@ func describerMap(clientConfig *rest.Config, kclient kclientset.Interface, host m := map[schema.GroupKind]kprinters.Describer{ buildapi.Kind("Build"): &BuildDescriber{buildClient, kclient}, buildapi.Kind("BuildConfig"): &BuildConfigDescriber{buildClient, kclient, host}, - deployapi.Kind("DeploymentConfig"): &DeploymentConfigDescriber{appsClient, kclient, nil}, + appsapi.Kind("DeploymentConfig"): &DeploymentConfigDescriber{appsClient, kclient, nil}, imageapi.Kind("Image"): &ImageDescriber{imageClient}, imageapi.Kind("ImageStream"): &ImageStreamDescriber{imageClient}, imageapi.Kind("ImageStreamTag"): &ImageStreamTagDescriber{imageClient}, diff --git a/pkg/oc/cli/describe/describer_test.go b/pkg/oc/cli/describe/describer_test.go index 90c8739f6632..c38c388c0519 100644 --- a/pkg/oc/cli/describe/describer_test.go +++ b/pkg/oc/cli/describe/describer_test.go @@ -14,7 +14,7 @@ import ( kfake "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake" api "github.com/openshift/origin/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -45,10 +45,10 @@ var DescriberCoverageExceptions = []reflect.Type{ reflect.TypeOf(&buildapi.BuildLogOptions{}), // normal users don't ever look at these reflect.TypeOf(&buildapi.BinaryBuildRequestOptions{}), // normal users don't ever look at these reflect.TypeOf(&buildapi.BuildRequest{}), // normal users don't ever look at these - reflect.TypeOf(&deployapi.DeploymentConfigRollback{}), // normal users don't ever look at these - reflect.TypeOf(&deployapi.DeploymentLog{}), // normal users don't ever look at these - reflect.TypeOf(&deployapi.DeploymentLogOptions{}), // normal users don't ever look at these - reflect.TypeOf(&deployapi.DeploymentRequest{}), // normal users don't ever look at these + reflect.TypeOf(&appsapi.DeploymentConfigRollback{}), // normal users don't ever look at these + reflect.TypeOf(&appsapi.DeploymentLog{}), // normal users don't ever look at these + reflect.TypeOf(&appsapi.DeploymentLogOptions{}), // normal users don't ever look at these + reflect.TypeOf(&appsapi.DeploymentRequest{}), // normal users don't ever look at these reflect.TypeOf(&imageapi.DockerImage{}), // not a top level resource reflect.TypeOf(&imageapi.ImageStreamImport{}), // normal users don't ever look at these reflect.TypeOf(&oauthapi.OAuthAccessToken{}), // normal users don't ever look at these diff --git a/pkg/oc/cli/describe/printer.go b/pkg/oc/cli/describe/printer.go index f07edc826472..2497ff867a37 100644 --- a/pkg/oc/cli/describe/printer.go +++ b/pkg/oc/cli/describe/printer.go @@ -16,7 +16,7 @@ import ( kprinters "k8s.io/kubernetes/pkg/printers" oapi "github.com/openshift/origin/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -659,7 +659,7 @@ func printRouteList(routeList *routeapi.RouteList, w io.Writer, opts kprinters.P return nil } -func printDeploymentConfig(dc *deployapi.DeploymentConfig, w io.Writer, opts kprinters.PrintOptions) error { +func printDeploymentConfig(dc *appsapi.DeploymentConfig, w io.Writer, opts kprinters.PrintOptions) error { var desired string if dc.Spec.Test { desired = fmt.Sprintf("%d (during test)", dc.Spec.Replicas) @@ -679,9 +679,9 @@ func printDeploymentConfig(dc *deployapi.DeploymentConfig, w io.Writer, opts kpr triggers := sets.String{} for _, trigger := range dc.Spec.Triggers { switch t := trigger.Type; t { - case deployapi.DeploymentTriggerOnConfigChange: + case appsapi.DeploymentTriggerOnConfigChange: triggers.Insert("config") - case deployapi.DeploymentTriggerOnImageChange: + case appsapi.DeploymentTriggerOnImageChange: if p := trigger.ImageChangeParams; p != nil && p.Automatic { var prefix string if len(containers) != 1 && !containers.HasAll(p.ContainerNames...) { @@ -716,7 +716,7 @@ func printDeploymentConfig(dc *deployapi.DeploymentConfig, w io.Writer, opts kpr return err } -func printDeploymentConfigList(list *deployapi.DeploymentConfigList, w io.Writer, opts kprinters.PrintOptions) error { +func printDeploymentConfigList(list *appsapi.DeploymentConfigList, w io.Writer, opts kprinters.PrintOptions) error { for _, dc := range list.Items { if err := printDeploymentConfig(&dc, w, opts); err != nil { return err diff --git a/pkg/oc/cli/describe/printer_test.go b/pkg/oc/cli/describe/printer_test.go index 3061c8af80bc..6d32ba363422 100644 --- a/pkg/oc/cli/describe/printer_test.go +++ b/pkg/oc/cli/describe/printer_test.go @@ -14,7 +14,7 @@ import ( kprinters "k8s.io/kubernetes/pkg/printers" "github.com/openshift/origin/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" buildapi "github.com/openshift/origin/pkg/build/apis/build" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -28,13 +28,13 @@ import ( // If you add something to this list, explain why it doesn't need printing. waaaa is not a valid // reason. var PrinterCoverageExceptions = []reflect.Type{ - reflect.TypeOf(&imageapi.DockerImage{}), // not a top level resource - reflect.TypeOf(&imageapi.ImageStreamImport{}), // normal users don't ever look at these - reflect.TypeOf(&buildapi.BuildLog{}), // just a marker type - reflect.TypeOf(&buildapi.BuildLogOptions{}), // just a marker type - reflect.TypeOf(&deployapi.DeploymentRequest{}), // normal users don't ever look at these - reflect.TypeOf(&deployapi.DeploymentLog{}), // just a marker type - reflect.TypeOf(&deployapi.DeploymentLogOptions{}), // just a marker type + reflect.TypeOf(&imageapi.DockerImage{}), // not a top level resource + reflect.TypeOf(&imageapi.ImageStreamImport{}), // normal users don't ever look at these + reflect.TypeOf(&buildapi.BuildLog{}), // just a marker type + reflect.TypeOf(&buildapi.BuildLogOptions{}), // just a marker type + reflect.TypeOf(&appsapi.DeploymentRequest{}), // normal users don't ever look at these + reflect.TypeOf(&appsapi.DeploymentLog{}), // just a marker type + reflect.TypeOf(&appsapi.DeploymentLogOptions{}), // just a marker type // these resources can't be "GET"ed, so we probably don't need a printer for them reflect.TypeOf(&authorizationapi.SubjectAccessReviewResponse{}), @@ -60,7 +60,7 @@ var PrinterCoverageExceptions = []reflect.Type{ // You should never add to this list // TODO printers should be added for these types var MissingPrinterCoverageExceptions = []reflect.Type{ - reflect.TypeOf(&deployapi.DeploymentConfigRollback{}), + reflect.TypeOf(&appsapi.DeploymentConfigRollback{}), reflect.TypeOf(&imageapi.ImageStreamMapping{}), reflect.TypeOf(&projectapi.ProjectRequest{}), } diff --git a/pkg/oc/cli/describe/projectstatus.go b/pkg/oc/cli/describe/projectstatus.go index be8d59f795a3..99907457b189 100644 --- a/pkg/oc/cli/describe/projectstatus.go +++ b/pkg/oc/cli/describe/projectstatus.go @@ -26,12 +26,12 @@ import ( kubeedges "github.com/openshift/origin/pkg/api/kubegraph" kubeanalysis "github.com/openshift/origin/pkg/api/kubegraph/analysis" kubegraph "github.com/openshift/origin/pkg/api/kubegraph/nodes" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" - deployedges "github.com/openshift/origin/pkg/apps/graph" - deployanalysis "github.com/openshift/origin/pkg/apps/graph/analysis" - deploygraph "github.com/openshift/origin/pkg/apps/graph/nodes" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsedges "github.com/openshift/origin/pkg/apps/graph" + appsanalysis "github.com/openshift/origin/pkg/apps/graph/analysis" + appsgraph "github.com/openshift/origin/pkg/apps/graph/nodes" + appsutil "github.com/openshift/origin/pkg/apps/util" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildclient "github.com/openshift/origin/pkg/build/generated/internalclientset/typed/build/internalversion" buildedges "github.com/openshift/origin/pkg/build/graph" @@ -145,9 +145,9 @@ func (d *ProjectStatusDescriber) MakeGraph(namespace string) (osgraph.Graph, set kubeedges.AddHPAScaleRefEdges(g) buildedges.AddAllInputOutputEdges(g) buildedges.AddAllBuildEdges(g) - deployedges.AddAllTriggerEdges(g) - deployedges.AddAllDeploymentEdges(g) - deployedges.AddAllVolumeClaimEdges(g) + appsedges.AddAllTriggerEdges(g) + appsedges.AddAllDeploymentEdges(g) + appsedges.AddAllVolumeClaimEdges(g) imageedges.AddAllImageStreamRefEdges(g) imageedges.AddAllImageStreamImageRefEdges(g) routeedges.AddAllRouteEdges(g) @@ -237,7 +237,7 @@ func (d *ProjectStatusDescriber) Describe(namespace, name string) (string, error rcNode: for _, rcNode := range service.FulfillingRCs { for _, coveredDC := range service.FulfillingDCs { - if deployedges.BelongsToDeploymentConfig(coveredDC.DeploymentConfig, rcNode.ReplicationController) { + if appsedges.BelongsToDeploymentConfig(coveredDC.DeploymentConfig, rcNode.ReplicationController) { continue rcNode } } @@ -432,11 +432,11 @@ func getMarkerScanners(logsCommandName, securityPolicyCommandFormat, setProbeCom buildanalysis.FindUnpushableBuildConfigs, buildanalysis.FindCircularBuilds, buildanalysis.FindPendingTags, - deployanalysis.FindDeploymentConfigTriggerErrors, - deployanalysis.FindPersistentVolumeClaimWarnings, + appsanalysis.FindDeploymentConfigTriggerErrors, + appsanalysis.FindPersistentVolumeClaimWarnings, buildanalysis.FindMissingInputImageStreams, func(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker { - return deployanalysis.FindDeploymentConfigReadinessWarnings(g, f, setProbeCommandName) + return appsanalysis.FindDeploymentConfigReadinessWarnings(g, f, setProbeCommandName) }, func(g osgraph.Graph, f osgraph.Namer) []osgraph.Marker { return kubeanalysis.FindMissingLivenessProbes(g, f, setProbeCommandName) @@ -521,7 +521,7 @@ func (f namespacedFormatter) ResourceName(obj interface{}) string { case *buildgraph.BuildNode: return namespaceNameWithType("build", t.Build.Name, t.Build.Namespace, f.currentNamespace, f.hideNamespace) - case *deploygraph.DeploymentConfigNode: + case *appsgraph.DeploymentConfigNode: return namespaceNameWithType("dc", t.DeploymentConfig.Name, t.DeploymentConfig.Namespace, f.currentNamespace, f.hideNamespace) case *routegraph.RouteNode: @@ -754,7 +754,7 @@ func describeRouteInServiceGroup(f formatter, routeNode *routegraph.RouteNode) [ return lines } -func describeDeploymentConfigTrigger(dc *deployapi.DeploymentConfig) string { +func describeDeploymentConfigTrigger(dc *appsapi.DeploymentConfig) string { if len(dc.Spec.Triggers) == 0 { return "(manual)" } @@ -1023,7 +1023,7 @@ func describeSourceInPipeline(source *buildapi.BuildSource) (string, bool) { return "", false } -func describeDeployments(f formatter, dcNode *deploygraph.DeploymentConfigNode, activeDeployment *kubegraph.ReplicationControllerNode, inactiveDeployments []*kubegraph.ReplicationControllerNode, restartFn func(*kubegraph.ReplicationControllerNode) int32, count int) []string { +func describeDeployments(f formatter, dcNode *appsgraph.DeploymentConfigNode, activeDeployment *kubegraph.ReplicationControllerNode, inactiveDeployments []*kubegraph.ReplicationControllerNode, restartFn func(*kubegraph.ReplicationControllerNode) int32, count int) []string { if dcNode == nil { return nil } @@ -1050,7 +1050,7 @@ func describeDeployments(f formatter, dcNode *deploygraph.DeploymentConfigNode, out = append(out, describeDeploymentStatus(deployment.ReplicationController, i == 0, dcNode.DeploymentConfig.Spec.Test, restartCount)) switch { case count == -1: - if deployutil.IsCompleteDeployment(deployment.ReplicationController) { + if appsutil.IsCompleteDeployment(deployment.ReplicationController) { return out } default: @@ -1064,28 +1064,28 @@ func describeDeployments(f formatter, dcNode *deploygraph.DeploymentConfigNode, func describeDeploymentStatus(rc *kapi.ReplicationController, first, test bool, restartCount int32) string { timeAt := strings.ToLower(formatRelativeTime(rc.CreationTimestamp.Time)) - status := deployutil.DeploymentStatusFor(rc) - version := deployutil.DeploymentVersionFor(rc) + status := appsutil.DeploymentStatusFor(rc) + version := appsutil.DeploymentVersionFor(rc) maybeCancelling := "" - if deployutil.IsDeploymentCancelled(rc) && !deployutil.IsTerminatedDeployment(rc) { + if appsutil.IsDeploymentCancelled(rc) && !appsutil.IsTerminatedDeployment(rc) { maybeCancelling = " (cancelling)" } switch status { - case deployapi.DeploymentStatusFailed: - reason := deployutil.DeploymentStatusReasonFor(rc) + case appsapi.DeploymentStatusFailed: + reason := appsutil.DeploymentStatusReasonFor(rc) if len(reason) > 0 { reason = fmt.Sprintf(": %s", reason) } // TODO: encode fail time in the rc return fmt.Sprintf("deployment #%d failed %s ago%s%s", version, timeAt, reason, describePodSummaryInline(rc.Status.ReadyReplicas, rc.Status.Replicas, rc.Spec.Replicas, false, restartCount)) - case deployapi.DeploymentStatusComplete: + case appsapi.DeploymentStatusComplete: // TODO: pod status output if test { return fmt.Sprintf("test deployment #%d deployed %s ago", version, timeAt) } return fmt.Sprintf("deployment #%d deployed %s ago%s", version, timeAt, describePodSummaryInline(rc.Status.ReadyReplicas, rc.Status.Replicas, rc.Spec.Replicas, first, restartCount)) - case deployapi.DeploymentStatusRunning: + case appsapi.DeploymentStatusRunning: format := "deployment #%d running%s for %s%s" if test { format = "test deployment #%d running%s for %s%s" @@ -1143,13 +1143,13 @@ func describePodSummary(ready, requested int32, includeEmpty bool, restartCount return fmt.Sprintf("%d/%d pods", ready, requested) + restartWarn } -func describeDeploymentConfigTriggers(config *deployapi.DeploymentConfig) (string, bool) { +func describeDeploymentConfigTriggers(config *appsapi.DeploymentConfig) (string, bool) { hasConfig, hasImage := false, false for _, t := range config.Spec.Triggers { switch t.Type { - case deployapi.DeploymentTriggerOnConfigChange: + case appsapi.DeploymentTriggerOnConfigChange: hasConfig = true - case deployapi.DeploymentTriggerOnImageChange: + case appsapi.DeploymentTriggerOnImageChange: hasImage = true } } @@ -1241,7 +1241,7 @@ func filterBoringPods(pods []graphview.Pod) ([]graphview.Pod, error) { if err != nil { return nil, err } - _, isDeployerPod := meta.GetLabels()[deployapi.DeployerPodForDeploymentLabel] + _, isDeployerPod := meta.GetLabels()[appsapi.DeployerPodForDeploymentLabel] _, isBuilderPod := meta.GetAnnotations()[buildapi.BuildAnnotation] isFinished := actualPod.Status.Phase == kapi.PodSucceeded || actualPod.Status.Phase == kapi.PodFailed if isDeployerPod || isBuilderPod || isFinished { @@ -1481,7 +1481,7 @@ func (l *isLoader) AddToGraph(g osgraph.Graph) error { type dcLoader struct { namespace string lister appsclient.DeploymentConfigsGetter - items []deployapi.DeploymentConfig + items []appsapi.DeploymentConfig } func (l *dcLoader) Load() error { @@ -1496,7 +1496,7 @@ func (l *dcLoader) Load() error { func (l *dcLoader) AddToGraph(g osgraph.Graph) error { for i := range l.items { - deploygraph.EnsureDeploymentConfigNode(g, &l.items[i]) + appsgraph.EnsureDeploymentConfigNode(g, &l.items[i]) } return nil diff --git a/pkg/oc/cli/util/clientcmd/factory.go b/pkg/oc/cli/util/clientcmd/factory.go index a6d6b2283ec8..b1df1409c4d2 100644 --- a/pkg/oc/cli/util/clientcmd/factory.go +++ b/pkg/oc/cli/util/clientcmd/factory.go @@ -28,8 +28,8 @@ import ( "k8s.io/kubernetes/pkg/kubectl/resource" "k8s.io/kubernetes/pkg/printers" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" buildapi "github.com/openshift/origin/pkg/build/apis/build" "github.com/openshift/origin/pkg/cmd/util" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -178,7 +178,7 @@ func (f *Factory) ApproximatePodTemplateForObject(object runtime.Object) (*api.P }, }, }, nil - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: fallback := t.Spec.Template kc, err := f.ClientSet() @@ -186,7 +186,7 @@ func (f *Factory) ApproximatePodTemplateForObject(object runtime.Object) (*api.P return fallback, err } - latestDeploymentName := deployutil.LatestDeploymentNameForConfig(t) + latestDeploymentName := appsutil.LatestDeploymentNameForConfig(t) deployment, err := kc.Core().ReplicationControllers(t.Namespace).Get(latestDeploymentName, metav1.GetOptions{}) if err != nil { return fallback, err @@ -245,7 +245,7 @@ func (f *Factory) PodForResource(resource string, timeout time.Duration) (string return "", err } return pod.Name, nil - case deployapi.Resource("deploymentconfigs"), deployapi.LegacyResource("deploymentconfigs"): + case appsapi.Resource("deploymentconfigs"), appsapi.LegacyResource("deploymentconfigs"): appsClient, err := f.OpenshiftInternalAppsClient() if err != nil { return "", err diff --git a/pkg/oc/cli/util/clientcmd/factory_client_access.go b/pkg/oc/cli/util/clientcmd/factory_client_access.go index edf530053f94..f64d91ae9141 100644 --- a/pkg/oc/cli/util/clientcmd/factory_client_access.go +++ b/pkg/oc/cli/util/clientcmd/factory_client_access.go @@ -34,8 +34,8 @@ import ( "k8s.io/kubernetes/pkg/kubectl/resource" kprinters "k8s.io/kubernetes/pkg/printers" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploycmd "github.com/openshift/origin/pkg/apps/cmd" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appscmd "github.com/openshift/origin/pkg/apps/cmd" imageclient "github.com/openshift/origin/pkg/image/generated/internalclientset" "github.com/openshift/origin/pkg/oc/cli/config" "github.com/openshift/origin/pkg/oc/cli/describe" @@ -193,7 +193,7 @@ func (f *ring0Factory) JSONEncoder() runtime.Encoder { func (f *ring0Factory) UpdatePodSpecForObject(obj runtime.Object, fn func(*kapi.PodSpec) error) (bool, error) { switch t := obj.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: template := t.Spec.Template if template == nil { t.Spec.Template = template @@ -207,7 +207,7 @@ func (f *ring0Factory) UpdatePodSpecForObject(obj runtime.Object, fn func(*kapi. func (f *ring0Factory) MapBasedSelectorForObject(object runtime.Object) (string, error) { switch t := object.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: return kubectl.MakeLabels(t.Spec.Selector), nil default: return f.kubeClientAccessFactory.MapBasedSelectorForObject(object) @@ -216,7 +216,7 @@ func (f *ring0Factory) MapBasedSelectorForObject(object runtime.Object) (string, func (f *ring0Factory) PortsForObject(object runtime.Object) ([]string, error) { switch t := object.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: return getPorts(t.Spec.Template.Spec), nil default: return f.kubeClientAccessFactory.PortsForObject(object) @@ -225,7 +225,7 @@ func (f *ring0Factory) PortsForObject(object runtime.Object) ([]string, error) { func (f *ring0Factory) ProtocolsForObject(object runtime.Object) (map[string]string, error) { switch t := object.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: return getProtocols(t.Spec.Template.Spec), nil default: return f.kubeClientAccessFactory.ProtocolsForObject(object) @@ -270,7 +270,7 @@ func (f *ring0Factory) Printer(mapping *meta.RESTMapping, options kprinters.Prin func (f *ring0Factory) Pauser(info *resource.Info) ([]byte, error) { switch t := info.Object.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: if t.Spec.Paused { return nil, errors.New("is already paused") } @@ -329,7 +329,7 @@ func (f *ring0Factory) ResolveImage(image string) (string, error) { func (f *ring0Factory) Resumer(info *resource.Info) ([]byte, error) { switch t := info.Object.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: if !t.Spec.Paused { return nil, errors.New("is not paused") } @@ -348,7 +348,7 @@ func (f *ring0Factory) DefaultNamespace() (string, bool, error) { func DefaultGenerators(cmdName string) map[string]kubectl.Generator { generators := map[string]map[string]kubectl.Generator{} generators["run"] = map[string]kubectl.Generator{ - "deploymentconfig/v1": deploycmd.BasicDeploymentConfigController{}, + "deploymentconfig/v1": appscmd.BasicDeploymentConfigController{}, "run-controller/v1": kubectl.BasicReplicationController{}, // legacy alias for run/v1 } generators["expose"] = map[string]kubectl.Generator{ @@ -373,14 +373,14 @@ func (f *ring0Factory) Generators(cmdName string) map[string]kubectl.Generator { } func (f *ring0Factory) CanBeExposed(kind schema.GroupKind) error { - if deployapi.IsKindOrLegacy("DeploymentConfig", kind) { + if appsapi.IsKindOrLegacy("DeploymentConfig", kind) { return nil } return f.kubeClientAccessFactory.CanBeExposed(kind) } func (f *ring0Factory) CanBeAutoscaled(kind schema.GroupKind) error { - if deployapi.IsKindOrLegacy("DeploymentConfig", kind) { + if appsapi.IsKindOrLegacy("DeploymentConfig", kind) { return nil } return f.kubeClientAccessFactory.CanBeAutoscaled(kind) diff --git a/pkg/oc/cli/util/clientcmd/factory_object_mapping.go b/pkg/oc/cli/util/clientcmd/factory_object_mapping.go index d371e4ba670f..c02ea623e911 100644 --- a/pkg/oc/cli/util/clientcmd/factory_object_mapping.go +++ b/pkg/oc/cli/util/clientcmd/factory_object_mapping.go @@ -27,11 +27,11 @@ import ( kprinters "k8s.io/kubernetes/pkg/printers" "github.com/openshift/origin/pkg/api/latest" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsmanualclient "github.com/openshift/origin/pkg/apps/client/internalversion" - deploycmd "github.com/openshift/origin/pkg/apps/cmd" + appscmd "github.com/openshift/origin/pkg/apps/cmd" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" authorizationreaper "github.com/openshift/origin/pkg/authorization/reaper" buildapi "github.com/openshift/origin/pkg/build/apis/build" @@ -173,8 +173,8 @@ func (f *ring1Factory) Describer(mapping *meta.RESTMapping) (kprinters.Describer func (f *ring1Factory) LogsForObject(object, options runtime.Object, timeout time.Duration) (*restclient.Request, error) { switch t := object.(type) { - case *deployapi.DeploymentConfig: - dopts, ok := options.(*deployapi.DeploymentLogOptions) + case *appsapi.DeploymentConfig: + dopts, ok := options.(*appsapi.DeploymentLogOptions) if !ok { return nil, errors.New("provided options object is not a DeploymentLogOptions") } @@ -227,7 +227,7 @@ func (f *ring1Factory) LogsForObject(object, options runtime.Object, timeout tim } func (f *ring1Factory) Scaler(mapping *meta.RESTMapping) (kubectl.Scaler, error) { - if deployapi.IsKindOrLegacy("DeploymentConfig", mapping.GroupVersionKind.GroupKind()) { + if appsapi.IsKindOrLegacy("DeploymentConfig", mapping.GroupVersionKind.GroupKind()) { kc, err := f.clientAccessFactory.ClientSet() if err != nil { return nil, err @@ -236,7 +236,7 @@ func (f *ring1Factory) Scaler(mapping *meta.RESTMapping) (kubectl.Scaler, error) if err != nil { return nil, err } - return deploycmd.NewDeploymentConfigScaler(appsclient.NewForConfigOrDie(config), kc), nil + return appscmd.NewDeploymentConfigScaler(appsclient.NewForConfigOrDie(config), kc), nil } return f.kubeObjectMappingFactory.Scaler(mapping) } @@ -244,7 +244,7 @@ func (f *ring1Factory) Scaler(mapping *meta.RESTMapping) (kubectl.Scaler, error) func (f *ring1Factory) Reaper(mapping *meta.RESTMapping) (kubectl.Reaper, error) { gk := mapping.GroupVersionKind.GroupKind() switch { - case deployapi.IsKindOrLegacy("DeploymentConfig", gk): + case appsapi.IsKindOrLegacy("DeploymentConfig", gk): kc, err := f.clientAccessFactory.ClientSet() if err != nil { return nil, err @@ -253,7 +253,7 @@ func (f *ring1Factory) Reaper(mapping *meta.RESTMapping) (kubectl.Reaper, error) if err != nil { return nil, err } - return deploycmd.NewDeploymentConfigReaper(appsclient.NewForConfigOrDie(config), kc), nil + return appscmd.NewDeploymentConfigReaper(appsclient.NewForConfigOrDie(config), kc), nil case authorizationapi.IsKindOrLegacy("Role", gk): authClient, err := f.clientAccessFactory.OpenshiftInternalAuthorizationClient() if err != nil { @@ -321,23 +321,23 @@ func (f *ring1Factory) Reaper(mapping *meta.RESTMapping) (kubectl.Reaper, error) } func (f *ring1Factory) HistoryViewer(mapping *meta.RESTMapping) (kubectl.HistoryViewer, error) { - if deployapi.IsKindOrLegacy("DeploymentConfig", mapping.GroupVersionKind.GroupKind()) { + if appsapi.IsKindOrLegacy("DeploymentConfig", mapping.GroupVersionKind.GroupKind()) { kc, err := f.clientAccessFactory.ClientSet() if err != nil { return nil, err } - return deploycmd.NewDeploymentConfigHistoryViewer(kc), nil + return appscmd.NewDeploymentConfigHistoryViewer(kc), nil } return f.kubeObjectMappingFactory.HistoryViewer(mapping) } func (f *ring1Factory) Rollbacker(mapping *meta.RESTMapping) (kubectl.Rollbacker, error) { - if deployapi.IsKindOrLegacy("DeploymentConfig", mapping.GroupVersionKind.GroupKind()) { + if appsapi.IsKindOrLegacy("DeploymentConfig", mapping.GroupVersionKind.GroupKind()) { config, err := f.clientAccessFactory.OpenShiftClientConfig().ClientConfig() if err != nil { return nil, err } - return deploycmd.NewDeploymentConfigRollbacker(appsclient.NewForConfigOrDie(config)), nil + return appscmd.NewDeploymentConfigRollbacker(appsclient.NewForConfigOrDie(config)), nil } return f.kubeObjectMappingFactory.Rollbacker(mapping) } @@ -347,8 +347,8 @@ func (f *ring1Factory) StatusViewer(mapping *meta.RESTMapping) (kubectl.StatusVi if err != nil { return nil, err } - if deployapi.IsKindOrLegacy("DeploymentConfig", mapping.GroupVersionKind.GroupKind()) { - return deploycmd.NewDeploymentConfigStatusViewer(appsclient.NewForConfigOrDie(config)), nil + if appsapi.IsKindOrLegacy("DeploymentConfig", mapping.GroupVersionKind.GroupKind()) { + return appscmd.NewDeploymentConfigStatusViewer(appsclient.NewForConfigOrDie(config)), nil } return f.kubeObjectMappingFactory.StatusViewer(mapping) } @@ -380,7 +380,7 @@ func (f *ring1Factory) ApproximatePodTemplateForObject(object runtime.Object) (* }, }, }, nil - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: fallback := t.Spec.Template kc, err := f.clientAccessFactory.ClientSet() @@ -388,7 +388,7 @@ func (f *ring1Factory) ApproximatePodTemplateForObject(object runtime.Object) (* return fallback, err } - latestDeploymentName := deployutil.LatestDeploymentNameForConfig(t) + latestDeploymentName := appsutil.LatestDeploymentNameForConfig(t) deployment, err := kc.Core().ReplicationControllers(t.Namespace).Get(latestDeploymentName, metav1.GetOptions{}) if err != nil { return fallback, err @@ -423,7 +423,7 @@ func (f *ring1Factory) ApproximatePodTemplateForObject(object runtime.Object) (* func (f *ring1Factory) AttachablePodForObject(object runtime.Object, timeout time.Duration) (*kapi.Pod, error) { switch t := object.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: kc, err := f.clientAccessFactory.ClientSet() if err != nil { return nil, err diff --git a/pkg/scheduler/admission/podnodeconstraints/admission_test.go b/pkg/scheduler/admission/podnodeconstraints/admission_test.go index 74cbe8f35314..464611b329e0 100644 --- a/pkg/scheduler/admission/podnodeconstraints/admission_test.go +++ b/pkg/scheduler/admission/podnodeconstraints/admission_test.go @@ -17,7 +17,7 @@ import ( "k8s.io/kubernetes/pkg/serviceaccount" _ "github.com/openshift/origin/pkg/api/install" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" oadmission "github.com/openshift/origin/pkg/cmd/server/admission" "github.com/openshift/origin/pkg/scheduler/admission/podnodeconstraints/api" @@ -196,14 +196,14 @@ func TestPodNodeConstraintsResources(t *testing.T) { }, { resource: deploymentConfig, - kind: deployapi.Kind("DeploymentConfig"), - groupresource: deployapi.Resource("deploymentconfigs"), + kind: appsapi.Kind("DeploymentConfig"), + groupresource: appsapi.Resource("deploymentconfigs"), prefix: "DeploymentConfig", }, { resource: podTemplate, - kind: deployapi.LegacyKind("PodTemplate"), - groupresource: deployapi.LegacyResource("podtemplates"), + kind: appsapi.LegacyKind("PodTemplate"), + groupresource: appsapi.LegacyResource("podtemplates"), prefix: "PodTemplate", }, { @@ -376,7 +376,7 @@ func resourceQuota() runtime.Object { } func deploymentConfig(setNodeSelector bool) runtime.Object { - dc := &deployapi.DeploymentConfig{} + dc := &appsapi.DeploymentConfig{} dc.Spec.Template = podTemplateSpec(setNodeSelector) return dc } diff --git a/pkg/template/controller/readiness.go b/pkg/template/controller/readiness.go index 605bea6f2787..b6fe7d8940c2 100644 --- a/pkg/template/controller/readiness.go +++ b/pkg/template/controller/readiness.go @@ -12,7 +12,7 @@ import ( "k8s.io/kubernetes/pkg/apis/extensions" deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildclient "github.com/openshift/origin/pkg/build/generated/internalclientset" buildutil "github.com/openshift/origin/pkg/build/util" @@ -84,15 +84,15 @@ func checkDeploymentReadiness(obj runtime.Object) (bool, bool, error) { // checkDeploymentConfigReadiness determins if a DeploymentConfig is ready, // failed or neither. func checkDeploymentConfigReadiness(obj runtime.Object) (bool, bool, error) { - dc := obj.(*deployapi.DeploymentConfig) + dc := obj.(*appsapi.DeploymentConfig) - var progressing, available *deployapi.DeploymentCondition + var progressing, available *appsapi.DeploymentCondition for i, condition := range dc.Status.Conditions { switch condition.Type { - case deployapi.DeploymentProgressing: + case appsapi.DeploymentProgressing: progressing = &dc.Status.Conditions[i] - case deployapi.DeploymentAvailable: + case appsapi.DeploymentAvailable: available = &dc.Status.Conditions[i] } } @@ -100,7 +100,7 @@ func checkDeploymentConfigReadiness(obj runtime.Object) (bool, bool, error) { ready := dc.Status.ObservedGeneration == dc.Generation && progressing != nil && progressing.Status == kapi.ConditionTrue && - progressing.Reason == deployapi.NewRcAvailableReason && + progressing.Reason == appsapi.NewRcAvailableReason && available != nil && available.Status == kapi.ConditionTrue @@ -146,16 +146,16 @@ func checkRouteReadiness(obj runtime.Object) (bool, bool, error) { // readinessCheckers maps GroupKinds to the appropriate function. Note that in // some cases more than one GK maps to the same function. var readinessCheckers = map[schema.GroupKind]func(runtime.Object) (bool, bool, error){ - buildapi.LegacyKind("Build"): checkBuildReadiness, - buildapi.Kind("Build"): checkBuildReadiness, - apps.Kind("Deployment"): checkDeploymentReadiness, - extensions.Kind("Deployment"): checkDeploymentReadiness, - deployapi.LegacyKind("DeploymentConfig"): checkDeploymentConfigReadiness, - deployapi.Kind("DeploymentConfig"): checkDeploymentConfigReadiness, - batch.Kind("Job"): checkJobReadiness, - apps.Kind("StatefulSet"): checkStatefulSetReadiness, - routeapi.Kind("Route"): checkRouteReadiness, - routeapi.LegacyKind("Route"): checkRouteReadiness, + buildapi.LegacyKind("Build"): checkBuildReadiness, + buildapi.Kind("Build"): checkBuildReadiness, + apps.Kind("Deployment"): checkDeploymentReadiness, + extensions.Kind("Deployment"): checkDeploymentReadiness, + appsapi.LegacyKind("DeploymentConfig"): checkDeploymentConfigReadiness, + appsapi.Kind("DeploymentConfig"): checkDeploymentConfigReadiness, + batch.Kind("Job"): checkJobReadiness, + apps.Kind("StatefulSet"): checkStatefulSetReadiness, + routeapi.Kind("Route"): checkRouteReadiness, + routeapi.LegacyKind("Route"): checkRouteReadiness, } // CanCheckReadiness indicates whether a readiness check exists for a GK. diff --git a/pkg/template/controller/readiness_test.go b/pkg/template/controller/readiness_test.go index 077c0a6da299..d55ba85c8787 100644 --- a/pkg/template/controller/readiness_test.go +++ b/pkg/template/controller/readiness_test.go @@ -13,7 +13,7 @@ import ( "k8s.io/kubernetes/pkg/apis/extensions" deploymentutil "k8s.io/kubernetes/pkg/controller/deployment/util" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" fakebuild "github.com/openshift/origin/pkg/build/generated/internalclientset/fake" routeapi "github.com/openshift/origin/pkg/route/apis/route" @@ -148,21 +148,21 @@ func TestCheckReadiness(t *testing.T) { // DeploymentConfig { - groupKind: deployapi.Kind("DeploymentConfig"), - object: &deployapi.DeploymentConfig{}, + groupKind: appsapi.Kind("DeploymentConfig"), + object: &appsapi.DeploymentConfig{}, }, { - groupKind: deployapi.Kind("DeploymentConfig"), - object: &deployapi.DeploymentConfig{ - Status: deployapi.DeploymentConfigStatus{ - Conditions: []deployapi.DeploymentCondition{ + groupKind: appsapi.Kind("DeploymentConfig"), + object: &appsapi.DeploymentConfig{ + Status: appsapi.DeploymentConfigStatus{ + Conditions: []appsapi.DeploymentCondition{ { - Type: deployapi.DeploymentProgressing, + Type: appsapi.DeploymentProgressing, Status: kapi.ConditionTrue, - Reason: deployapi.NewRcAvailableReason, + Reason: appsapi.NewRcAvailableReason, }, { - Type: deployapi.DeploymentAvailable, + Type: appsapi.DeploymentAvailable, Status: kapi.ConditionTrue, }, }, @@ -171,12 +171,12 @@ func TestCheckReadiness(t *testing.T) { expectedReady: true, }, { - groupKind: deployapi.Kind("DeploymentConfig"), - object: &deployapi.DeploymentConfig{ - Status: deployapi.DeploymentConfigStatus{ - Conditions: []deployapi.DeploymentCondition{ + groupKind: appsapi.Kind("DeploymentConfig"), + object: &appsapi.DeploymentConfig{ + Status: appsapi.DeploymentConfigStatus{ + Conditions: []appsapi.DeploymentCondition{ { - Type: deployapi.DeploymentProgressing, + Type: appsapi.DeploymentProgressing, Status: kapi.ConditionFalse, }, }, diff --git a/pkg/unidling/controller/unidling_controller.go b/pkg/unidling/controller/unidling_controller.go index 0df26151a51d..f55cba7e26f5 100644 --- a/pkg/unidling/controller/unidling_controller.go +++ b/pkg/unidling/controller/unidling_controller.go @@ -9,7 +9,7 @@ import ( unidlingapi "github.com/openshift/origin/pkg/unidling/api" unidlingutil "github.com/openshift/origin/pkg/unidling/util" - deployclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" + appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" kapi "k8s.io/kubernetes/pkg/api" @@ -71,11 +71,11 @@ type UnidlingController struct { lastFiredCache *lastFiredCache // TODO: remove these once we get the scale-source functionality in the scale endpoints - dcNamespacer deployclient.DeploymentConfigsGetter + dcNamespacer appsclient.DeploymentConfigsGetter rcNamespacer kcoreclient.ReplicationControllersGetter } -func NewUnidlingController(scaleNS kextclient.ScalesGetter, endptsNS kcoreclient.EndpointsGetter, evtNS kcoreclient.EventsGetter, dcNamespacer deployclient.DeploymentConfigsGetter, rcNamespacer kcoreclient.ReplicationControllersGetter, resyncPeriod time.Duration) *UnidlingController { +func NewUnidlingController(scaleNS kextclient.ScalesGetter, endptsNS kcoreclient.EndpointsGetter, evtNS kcoreclient.EventsGetter, dcNamespacer appsclient.DeploymentConfigsGetter, rcNamespacer kcoreclient.ReplicationControllersGetter, resyncPeriod time.Duration) *UnidlingController { fieldSet := fields.Set{} fieldSet["reason"] = unidlingapi.NeedPodsReason fieldSelector := fieldSet.AsSelector() diff --git a/pkg/unidling/controller/unidling_controller_test.go b/pkg/unidling/controller/unidling_controller_test.go index a4effe78a157..98d03cf67c83 100644 --- a/pkg/unidling/controller/unidling_controller_test.go +++ b/pkg/unidling/controller/unidling_controller_test.go @@ -8,8 +8,8 @@ import ( unidlingapi "github.com/openshift/origin/pkg/unidling/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployfake "github.com/openshift/origin/pkg/apps/generated/internalclientset/fake" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsfake "github.com/openshift/origin/pkg/apps/generated/internalclientset/fake" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" @@ -29,9 +29,9 @@ type fakeResults struct { resEndpoints *kapi.Endpoints } -func prepFakeClient(t *testing.T, nowTime time.Time, scales ...kextapi.Scale) (*kinternalfake.Clientset, *deployfake.Clientset, *fakeResults) { +func prepFakeClient(t *testing.T, nowTime time.Time, scales ...kextapi.Scale) (*kinternalfake.Clientset, *appsfake.Clientset, *fakeResults) { fakeClient := &kinternalfake.Clientset{} - fakeDeployClient := &deployfake.Clientset{} + fakeDeployClient := &appsfake.Clientset{} nowTimeStr := nowTime.Format(time.RFC3339) @@ -71,11 +71,11 @@ func prepFakeClient(t *testing.T, nowTime time.Time, scales ...kextapi.Scale) (* objName := action.(clientgotesting.GetAction).GetName() for _, scale := range scales { if scale.Kind == "DeploymentConfig" && objName == scale.Name { - return true, &deployapi.DeploymentConfig{ + return true, &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: objName, }, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: scale.Spec.Replicas, }, }, nil @@ -108,13 +108,13 @@ func prepFakeClient(t *testing.T, nowTime time.Time, scales ...kextapi.Scale) (* } fakeDeployClient.PrependReactor("update", "deploymentconfigs", func(action clientgotesting.Action) (bool, runtime.Object, error) { - obj := action.(clientgotesting.UpdateAction).GetObject().(*deployapi.DeploymentConfig) + obj := action.(clientgotesting.UpdateAction).GetObject().(*appsapi.DeploymentConfig) for _, scale := range scales { if scale.Kind == "DeploymentConfig" && obj.Name == scale.Name { newScale := scale newScale.Spec.Replicas = obj.Spec.Replicas - res.resMap[unidlingapi.CrossGroupObjectReference{Name: obj.Name, Kind: "DeploymentConfig", Group: deployapi.GroupName}] = newScale - return true, &deployapi.DeploymentConfig{}, nil + res.resMap[unidlingapi.CrossGroupObjectReference{Name: obj.Name, Kind: "DeploymentConfig", Group: appsapi.GroupName}] = newScale + return true, &appsapi.DeploymentConfig{}, nil } } @@ -137,15 +137,15 @@ func prepFakeClient(t *testing.T, nowTime time.Time, scales ...kextapi.Scale) (* fakeDeployClient.PrependReactor("patch", "deploymentconfigs", func(action clientgotesting.Action) (bool, runtime.Object, error) { patchAction := action.(clientgotesting.PatchActionImpl) - var patch deployapi.DeploymentConfig + var patch appsapi.DeploymentConfig json.Unmarshal(patchAction.GetPatch(), &patch) for _, scale := range scales { if scale.Kind == "DeploymentConfig" && patchAction.GetName() == scale.Name { newScale := scale newScale.Spec.Replicas = patch.Spec.Replicas - res.resMap[unidlingapi.CrossGroupObjectReference{Name: patchAction.GetName(), Kind: "DeploymentConfig", Group: deployapi.GroupName}] = newScale - return true, &deployapi.DeploymentConfig{}, nil + res.resMap[unidlingapi.CrossGroupObjectReference{Name: patchAction.GetName(), Kind: "DeploymentConfig", Group: appsapi.GroupName}] = newScale + return true, &appsapi.DeploymentConfig{}, nil } } @@ -269,7 +269,7 @@ func TestControllerIgnoresAlreadyScaledObjects(t *testing.T) { for _, scale := range baseScales { scaleRef := unidlingapi.CrossGroupObjectReference{Kind: scale.Kind, Name: scale.Name} if scale.Kind == "DeploymentConfig" { - scaleRef.Group = deployapi.GroupName + scaleRef.Group = appsapi.GroupName } resScale, ok := res.resMap[scaleRef] if scale.Spec.Replicas != 0 { @@ -307,7 +307,7 @@ func TestControllerIgnoresAlreadyScaledObjects(t *testing.T) { } for _, target := range resTargets { if target.Kind == "DeploymentConfig" { - target.CrossGroupObjectReference.Group = deployapi.GroupName + target.CrossGroupObjectReference.Group = appsapi.GroupName } if _, ok := stillPresent[target.CrossGroupObjectReference]; !ok { t.Errorf("Expected new target list to contain the unscaled scalables only, but it was %v", resTargets) @@ -380,7 +380,7 @@ func TestControllerUnidlesProperly(t *testing.T) { for _, scale := range baseScales { ref := unidlingapi.CrossGroupObjectReference{Kind: scale.Kind, Name: scale.Name} if scale.Kind == "DeploymentConfig" { - ref.Group = deployapi.GroupName + ref.Group = appsapi.GroupName } resScale, ok := res.resMap[ref] if !ok { @@ -421,9 +421,9 @@ type failureTestInfo struct { annotationsExpected map[string]string } -func prepareFakeClientForFailureTest(test failureTestInfo) (*kinternalfake.Clientset, *deployfake.Clientset) { +func prepareFakeClientForFailureTest(test failureTestInfo) (*kinternalfake.Clientset, *appsfake.Clientset) { fakeClient := &kinternalfake.Clientset{} - fakeDeployClient := &deployfake.Clientset{} + fakeDeployClient := &appsfake.Clientset{} fakeClient.PrependReactor("get", "endpoints", func(action clientgotesting.Action) (bool, runtime.Object, error) { objName := action.(clientgotesting.GetAction).GetName() @@ -438,11 +438,11 @@ func prepareFakeClientForFailureTest(test failureTestInfo) (*kinternalfake.Clien objName := action.(clientgotesting.GetAction).GetName() for _, scale := range test.scaleGets { if scale.Kind == "DeploymentConfig" && objName == scale.Name { - return true, &deployapi.DeploymentConfig{ + return true, &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: objName, }, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Replicas: scale.Spec.Replicas, }, }, nil @@ -471,14 +471,14 @@ func prepareFakeClientForFailureTest(test failureTestInfo) (*kinternalfake.Clien }) fakeDeployClient.PrependReactor("update", "deploymentconfigs", func(action clientgotesting.Action) (bool, runtime.Object, error) { - obj := action.(clientgotesting.UpdateAction).GetObject().(*deployapi.DeploymentConfig) + obj := action.(clientgotesting.UpdateAction).GetObject().(*appsapi.DeploymentConfig) for i, scale := range test.scaleGets { if scale.Kind == "DeploymentConfig" && obj.Name == scale.Name { if test.scaleUpdatesNotFound != nil && test.scaleUpdatesNotFound[i] { return false, nil, nil } - return true, &deployapi.DeploymentConfig{}, nil + return true, &appsapi.DeploymentConfig{}, nil } } @@ -529,7 +529,7 @@ func TestControllerPerformsCorrectlyOnFailures(t *testing.T) { { CrossGroupObjectReference: unidlingapi.CrossGroupObjectReference{ Kind: "DeploymentConfig", - Group: deployapi.GroupName, + Group: appsapi.GroupName, Name: "somedc", }, Replicas: 2, @@ -544,7 +544,7 @@ func TestControllerPerformsCorrectlyOnFailures(t *testing.T) { { CrossGroupObjectReference: unidlingapi.CrossGroupObjectReference{ Kind: "DeploymentConfig", - Group: deployapi.GroupName, + Group: appsapi.GroupName, Name: "somedc", }, Replicas: 2, diff --git a/pkg/unidling/util/scale.go b/pkg/unidling/util/scale.go index de5b7914bd0f..f512e60e1d9c 100644 --- a/pkg/unidling/util/scale.go +++ b/pkg/unidling/util/scale.go @@ -13,9 +13,9 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" - deployapiv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" + appsapiv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" unidlingapi "github.com/openshift/origin/pkg/unidling/api" ) @@ -24,7 +24,7 @@ import ( type AnnotationFunc func(currentReplicas int32, annotations map[string]string) -func NewScaleAnnotater(scales kextensionsclient.ScalesGetter, dcs deployclient.DeploymentConfigsGetter, rcs kcoreclient.ReplicationControllersGetter, changeAnnots AnnotationFunc) *ScaleAnnotater { +func NewScaleAnnotater(scales kextensionsclient.ScalesGetter, dcs appsclient.DeploymentConfigsGetter, rcs kcoreclient.ReplicationControllersGetter, changeAnnots AnnotationFunc) *ScaleAnnotater { return &ScaleAnnotater{ scales: scales, dcs: dcs, @@ -35,7 +35,7 @@ func NewScaleAnnotater(scales kextensionsclient.ScalesGetter, dcs deployclient.D type ScaleAnnotater struct { scales kextensionsclient.ScalesGetter - dcs deployclient.DeploymentConfigsGetter + dcs appsclient.DeploymentConfigsGetter rcs kcoreclient.ReplicationControllersGetter ChangeAnnotations AnnotationFunc } @@ -49,11 +49,11 @@ type ScaleUpdater interface { type scaleUpdater struct { encoder runtime.Encoder namespace string - dcGetter deployclient.DeploymentConfigsGetter + dcGetter appsclient.DeploymentConfigsGetter rcGetter kcoreclient.ReplicationControllersGetter } -func NewScaleUpdater(encoder runtime.Encoder, namespace string, dcGetter deployclient.DeploymentConfigsGetter, rcGetter kcoreclient.ReplicationControllersGetter) ScaleUpdater { +func NewScaleUpdater(encoder runtime.Encoder, namespace string, dcGetter appsclient.DeploymentConfigsGetter, rcGetter kcoreclient.ReplicationControllersGetter) ScaleUpdater { return scaleUpdater{ encoder: encoder, namespace: namespace, @@ -74,7 +74,7 @@ func (s scaleUpdater) Update(annotator *ScaleAnnotater, obj runtime.Object, scal } switch typedObj := obj.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: if typedObj.Annotations == nil { typedObj.Annotations = make(map[string]string) } @@ -87,7 +87,7 @@ func (s scaleUpdater) Update(annotator *ScaleAnnotater, obj runtime.Object, scal return err } - patchBytes, err = strategicpatch.CreateTwoWayMergePatch(originalObj, newObj, &deployapiv1.DeploymentConfig{}) + patchBytes, err = strategicpatch.CreateTwoWayMergePatch(originalObj, newObj, &appsapiv1.DeploymentConfig{}) if err != nil { return err } @@ -124,8 +124,8 @@ func (c *ScaleAnnotater) GetObjectWithScale(namespace string, ref unidlingapi.Cr var scale *kextapi.Scale switch { - case ref.Kind == "DeploymentConfig" && (ref.Group == deployapi.GroupName || ref.Group == deployapi.LegacyGroupName): - var dc *deployapi.DeploymentConfig + case ref.Kind == "DeploymentConfig" && (ref.Group == appsapi.GroupName || ref.Group == appsapi.LegacyGroupName): + var dc *appsapi.DeploymentConfig dc, err = c.dcs.DeploymentConfigs(namespace).Get(ref.Name, metav1.GetOptions{}) if err != nil { return nil, nil, err @@ -166,7 +166,7 @@ func (c *ScaleAnnotater) UpdateObjectScale(updater ScaleUpdater, namespace strin } switch obj.(type) { - case *deployapi.DeploymentConfig, *kapi.ReplicationController: + case *appsapi.DeploymentConfig, *kapi.ReplicationController: return updater.Update(c, obj, scale) default: glog.V(2).Infof("Unidling unknown type %t: using scale interface and not removing annotations", obj) diff --git a/pkg/util/labels.go b/pkg/util/labels.go index 629b724b3e3f..a45d0d5ee432 100644 --- a/pkg/util/labels.go +++ b/pkg/util/labels.go @@ -9,7 +9,7 @@ import ( "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) // MergeInto flags @@ -40,7 +40,7 @@ func AddObjectLabelsWithFlags(obj runtime.Object, labels labels.Set, flags int) } switch objType := obj.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: if err := addDeploymentConfigNestedLabels(objType, labels, flags); err != nil { return fmt.Errorf("unable to add nested labels to %s/%s: %v", obj.GetObjectKind().GroupVersionKind(), accessor.GetName(), err) } @@ -123,7 +123,7 @@ func AddObjectAnnotations(obj runtime.Object, annotations map[string]string) err } switch objType := obj.(type) { - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: if err := addDeploymentConfigNestedAnnotations(objType, annotations); err != nil { return fmt.Errorf("unable to add nested annotations to %s/%s: %v", obj.GetObjectKind().GroupVersionKind(), accessor.GetName(), err) } @@ -177,7 +177,7 @@ func AddObjectAnnotations(obj runtime.Object, annotations map[string]string) err } // addDeploymentConfigNestedLabels adds new label(s) to a nested labels of a single DeploymentConfig object -func addDeploymentConfigNestedLabels(obj *deployapi.DeploymentConfig, labels labels.Set, flags int) error { +func addDeploymentConfigNestedLabels(obj *appsapi.DeploymentConfig, labels labels.Set, flags int) error { if obj.Spec.Template.Labels == nil { obj.Spec.Template.Labels = make(map[string]string) } @@ -187,7 +187,7 @@ func addDeploymentConfigNestedLabels(obj *deployapi.DeploymentConfig, labels lab return nil } -func addDeploymentConfigNestedAnnotations(obj *deployapi.DeploymentConfig, annotations map[string]string) error { +func addDeploymentConfigNestedAnnotations(obj *appsapi.DeploymentConfig, annotations map[string]string) error { if obj.Spec.Template == nil { return nil } diff --git a/pkg/util/labels_test.go b/pkg/util/labels_test.go index aafb35628b10..9ef2aedbe0b2 100644 --- a/pkg/util/labels_test.go +++ b/pkg/util/labels_test.go @@ -9,7 +9,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" testtypes "github.com/openshift/origin/pkg/util/testing" ) @@ -98,11 +98,11 @@ func TestAddConfigLabels(t *testing.T) { expectedLabels: map[string]string{"foo": "same value"}, }, { // [9] Test adding labels to a DeploymentConfig object - obj: &deployapi.DeploymentConfig{ + obj: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{"foo": "first value"}, }, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Template: &kapi.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Labels: map[string]string{"foo": "first value"}, @@ -147,7 +147,7 @@ func TestAddConfigLabels(t *testing.T) { if e, a := map[string]string{}, objType.Spec.Template.Labels; !reflect.DeepEqual(e, a) { t.Errorf("Unexpected labels on testCase[%v]. Expected: %#v, got: %#v.", i, e, a) } - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: if e, a := test.expectedLabels, objType.Spec.Template.Labels; !reflect.DeepEqual(e, a) { t.Errorf("Unexpected labels on testCase[%v]. Expected: %#v, got: %#v.", i, e, a) } diff --git a/test/extended/deployments/deployments.go b/test/extended/deployments/deployments.go index c069b181e721..87e171c84e5e 100644 --- a/test/extended/deployments/deployments.go +++ b/test/extended/deployments/deployments.go @@ -18,8 +18,8 @@ import ( "k8s.io/apimachinery/pkg/watch" e2e "k8s.io/kubernetes/test/e2e/framework" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsutil "github.com/openshift/origin/pkg/apps/util" imageapi "github.com/openshift/origin/pkg/image/apis/image" exutil "github.com/openshift/origin/test/extended/util" ) @@ -167,7 +167,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { secondDeploymentExists := false for _, rc := range rcs { - if rc.Name == deployutil.DeploymentNameForConfigVersion(name, 2) { + if rc.Name == appsutil.DeploymentNameForConfigVersion(name, 2) { secondDeploymentExists = true break } @@ -189,10 +189,10 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { return false, nil } - firstDeploymentName := deployutil.DeploymentNameForConfigVersion(name, 1) + firstDeploymentName := appsutil.DeploymentNameForConfigVersion(name, 1) firstDeployerRemoved := len(deploymentNamesToDeployers[firstDeploymentName]) == 0 - secondDeploymentName := deployutil.DeploymentNameForConfigVersion(name, 2) + secondDeploymentName := appsutil.DeploymentNameForConfigVersion(name, 2) secondDeployerExists := len(deploymentNamesToDeployers[secondDeploymentName]) == 1 return firstDeployerRemoved && secondDeployerExists, nil @@ -531,7 +531,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { o.Expect(err).NotTo(o.HaveOccurred()) g.By("updating the deployment config in order to trigger a new rollout") - _, err = updateConfigWithRetries(oc.AppsClient().Apps(), oc.Namespace(), name, func(update *deployapi.DeploymentConfig) { + _, err = updateConfigWithRetries(oc.AppsClient().Apps(), oc.Namespace(), name, func(update *appsapi.DeploymentConfig) { one := int64(1) update.Spec.Template.Spec.TerminationGracePeriodSeconds = &one }) @@ -702,7 +702,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { o.Expect(fmt.Errorf("expected no deployment, found %#v", rcs[0])).NotTo(o.HaveOccurred()) } - _, err = updateConfigWithRetries(oc.AppsClient().Apps(), oc.Namespace(), name, func(dc *deployapi.DeploymentConfig) { + _, err = updateConfigWithRetries(oc.AppsClient().Apps(), oc.Namespace(), name, func(dc *appsapi.DeploymentConfig) { // TODO: oc rollout pause should patch instead of making a full update dc.Spec.Paused = false }) @@ -868,7 +868,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { // we need to filter out any deployments that we don't care about, // namely the active deployment and any newer deployments - oldDeployments := deployutil.DeploymentsForCleanup(deploymentConfig, deployments) + oldDeployments := appsutil.DeploymentsForCleanup(deploymentConfig, deployments) // we should not have more deployments than acceptable if len(oldDeployments) != revisionHistoryLimit { @@ -878,7 +878,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { // the deployments we continue to keep should be the latest ones for _, deployment := range oldDeployments { - o.Expect(deployutil.DeploymentVersionFor(&deployment)).To(o.BeNumerically(">=", iterations-revisionHistoryLimit)) + o.Expect(appsutil.DeploymentVersionFor(&deployment)).To(o.BeNumerically(">=", iterations-revisionHistoryLimit)) } return true, nil }) @@ -904,7 +904,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { o.Expect(dc.Spec.Triggers).To(o.BeNil()) // FIXME: remove when tests are migrated to the new client // (the old one incorrectly translates nil into an empty array) - dc.Spec.Triggers = append(dc.Spec.Triggers, deployapi.DeploymentTriggerPolicy{Type: deployapi.DeploymentTriggerOnConfigChange}) + dc.Spec.Triggers = append(dc.Spec.Triggers, appsapi.DeploymentTriggerPolicy{Type: appsapi.DeploymentTriggerOnConfigChange}) // This is the last place we can safely say that the time was taken before replicas became ready startTime := time.Now() dc, err = oc.AppsClient().Apps().DeploymentConfigs(namespace).Create(dc) @@ -931,7 +931,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { e2e.Logf("All replicas are ready.") g.By("verifying that the deployment is still running") - if deployutil.IsTerminatedDeployment(rc1) { + if appsutil.IsTerminatedDeployment(rc1) { o.Expect(fmt.Errorf("expected deployment %q not to have terminated", rc1.Name)).NotTo(o.HaveOccurred()) } @@ -943,7 +943,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { return true, nil } - if deployutil.DeploymentStatusFor(rc) == deployapi.DeploymentStatusComplete { + if appsutil.DeploymentStatusFor(rc) == appsapi.DeploymentStatusComplete { e2e.Logf("Failed RC: %#v", rc) return false, errors.New("deployment shouldn't be completed before ReadyReplicas become AvailableReplicas") } @@ -956,11 +956,11 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { "Deployment shall not finish before MinReadySeconds elapse.") o.Expect(rc1.Status.AvailableReplicas).To(o.Equal(dc.Spec.Replicas)) // Deployment status can't be updated yet but should be right after - o.Expect(deployutil.DeploymentStatusFor(rc1)).To(o.Equal(deployapi.DeploymentStatusRunning)) + o.Expect(appsutil.DeploymentStatusFor(rc1)).To(o.Equal(appsapi.DeploymentStatusRunning)) // It should finish right after rc1, err = waitForRCModification(oc, namespace, rc1.Name, deploymentChangeTimeout, rc1.GetResourceVersion(), func(rc *kapiv1.ReplicationController) (bool, error) { - return deployutil.DeploymentStatusFor(rc) == deployapi.DeploymentStatusComplete, nil + return appsutil.DeploymentStatusFor(rc) == appsapi.DeploymentStatusComplete, nil }) o.Expect(err).NotTo(o.HaveOccurred()) @@ -994,15 +994,15 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { o.Expect(err).NotTo(o.HaveOccurred()) g.By("verifying that the deployment config has the desired condition and reason") - var conditions []deployapi.DeploymentCondition + var conditions []appsapi.DeploymentCondition err = wait.PollImmediate(500*time.Millisecond, 30*time.Second, func() (bool, error) { dc, _, _, err := deploymentInfo(oc, name) if err != nil { return false, nil } conditions = dc.Status.Conditions - cond := deployutil.GetDeploymentCondition(dc.Status, deployapi.DeploymentProgressing) - return cond != nil && cond.Reason == deployapi.NewReplicationControllerReason, nil + cond := appsutil.GetDeploymentCondition(dc.Status, appsapi.DeploymentProgressing) + return cond != nil && cond.Reason == appsapi.NewReplicationControllerReason, nil }) if err == wait.ErrWaitTimeout { err = fmt.Errorf("deployment config %q never updated its conditions: %#v", name, conditions) @@ -1022,7 +1022,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { namespace := oc.Namespace() rcName := func(i int) string { return fmt.Sprintf("%s-%d", dcName, i) } - var dc *deployapi.DeploymentConfig + var dc *appsapi.DeploymentConfig var rc1 *kapiv1.ReplicationController var err error @@ -1061,7 +1061,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { o.Expect(controllerRef).To(o.BeNil()) dc, err = waitForDCModification(oc, namespace, dcName, deploymentChangeTimeout, - dc.GetResourceVersion(), func(config *deployapi.DeploymentConfig) (bool, error) { + dc.GetResourceVersion(), func(config *appsapi.DeploymentConfig) (bool, error) { return config.Status.AvailableReplicas == 0, nil }) o.Expect(err).NotTo(o.HaveOccurred()) @@ -1081,7 +1081,7 @@ var _ = g.Describe("[Feature:DeploymentConfig] deploymentconfigs", func() { o.Expect(validRef).To(o.BeTrue()) dc, err = waitForDCModification(oc, namespace, dcName, deploymentChangeTimeout, - dc.GetResourceVersion(), func(config *deployapi.DeploymentConfig) (bool, error) { + dc.GetResourceVersion(), func(config *appsapi.DeploymentConfig) (bool, error) { return config.Status.AvailableReplicas == dc.Spec.Replicas, nil }) o.Expect(err).NotTo(o.HaveOccurred()) diff --git a/test/extended/deployments/util.go b/test/extended/deployments/util.go index b03addcc25b9..a59ec5194c22 100644 --- a/test/extended/deployments/util.go +++ b/test/extended/deployments/util.go @@ -21,21 +21,21 @@ import ( kapiv1 "k8s.io/kubernetes/pkg/api/v1" e2e "k8s.io/kubernetes/test/e2e/framework" - deployapiv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployconversionsv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsapiv1 "github.com/openshift/api/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsconversionsv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" appstypedclientset "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" exutil "github.com/openshift/origin/test/extended/util" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/selection" ) -type updateConfigFunc func(d *deployapi.DeploymentConfig) +type updateConfigFunc func(d *appsapi.DeploymentConfig) // updateConfigWithRetries will try to update a deployment config and ignore any update conflicts. -func updateConfigWithRetries(dn appstypedclientset.DeploymentConfigsGetter, namespace, name string, applyUpdate updateConfigFunc) (*deployapi.DeploymentConfig, error) { - var config *deployapi.DeploymentConfig +func updateConfigWithRetries(dn appstypedclientset.DeploymentConfigsGetter, namespace, name string, applyUpdate updateConfigFunc) (*appsapi.DeploymentConfig, error) { + var config *appsapi.DeploymentConfig resultErr := retry.RetryOnConflict(retry.DefaultBackoff, func() error { var err error config, err = dn.DeploymentConfigs(namespace).Get(name, metav1.GetOptions{}) @@ -53,7 +53,7 @@ func updateConfigWithRetries(dn appstypedclientset.DeploymentConfigsGetter, name func deploymentPods(pods []corev1.Pod) (map[string][]*corev1.Pod, error) { deployers := make(map[string][]*corev1.Pod) for i := range pods { - name, ok := pods[i].Labels[deployapi.DeployerPodForDeploymentLabel] + name, ok := pods[i].Labels[appsapi.DeployerPodForDeploymentLabel] if !ok { continue } @@ -62,7 +62,7 @@ func deploymentPods(pods []corev1.Pod) (map[string][]*corev1.Pod, error) { return deployers, nil } -var completedStatuses = sets.NewString(string(deployapi.DeploymentStatusComplete), string(deployapi.DeploymentStatusFailed)) +var completedStatuses = sets.NewString(string(appsapi.DeploymentStatusComplete), string(appsapi.DeploymentStatusFailed)) func checkDeployerPodInvariants(deploymentName string, pods []*corev1.Pod) (isRunning, isCompleted bool, err error) { running := false @@ -119,7 +119,7 @@ func checkDeployerPodInvariants(deploymentName string, pods []*corev1.Pod) (isRu return running, completed, nil } -func checkDeploymentInvariants(dc *deployapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) error { +func checkDeploymentInvariants(dc *appsapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) error { deployers, err := deploymentPods(pods) if err != nil { return err @@ -163,21 +163,21 @@ func checkDeploymentInvariants(dc *deployapi.DeploymentConfig, rcs []*corev1.Rep sawStatus := sets.NewString() statuses := []string{} for _, rc := range rcs { - status := deployutil.DeploymentStatusFor(rc) + status := appsutil.DeploymentStatusFor(rc) if sawStatus.Len() != 0 { switch status { - case deployapi.DeploymentStatusComplete, deployapi.DeploymentStatusFailed: + case appsapi.DeploymentStatusComplete, appsapi.DeploymentStatusFailed: if sawStatus.Difference(completedStatuses).Len() != 0 { return fmt.Errorf("rc %s was %s, but earlier RCs were not completed: %v", rc.Name, status, statuses) } - case deployapi.DeploymentStatusRunning, deployapi.DeploymentStatusPending: + case appsapi.DeploymentStatusRunning, appsapi.DeploymentStatusPending: if sawStatus.Has(string(status)) { return fmt.Errorf("rc %s was %s, but so was an earlier RC: %v", rc.Name, status, statuses) } if sawStatus.Difference(completedStatuses).Len() != 0 { return fmt.Errorf("rc %s was %s, but earlier RCs were not completed: %v", rc.Name, status, statuses) } - case deployapi.DeploymentStatusNew: + case appsapi.DeploymentStatusNew: default: return fmt.Errorf("rc %s has unexpected status %s: %v", rc.Name, status, statuses) } @@ -188,23 +188,23 @@ func checkDeploymentInvariants(dc *deployapi.DeploymentConfig, rcs []*corev1.Rep return nil } -func deploymentReachedCompletion(dc *deployapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) { +func deploymentReachedCompletion(dc *appsapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) { if len(rcs) == 0 { return false, nil } rcv1 := rcs[len(rcs)-1] rc := &kapi.ReplicationController{} kapiv1.Convert_v1_ReplicationController_To_api_ReplicationController(rcv1, rc, nil) - version := deployutil.DeploymentVersionFor(rc) + version := appsutil.DeploymentVersionFor(rc) if version != dc.Status.LatestVersion { return false, nil } - if !deployutil.IsCompleteDeployment(rc) { + if !appsutil.IsCompleteDeployment(rc) { return false, nil } - cond := deployutil.GetDeploymentCondition(dc.Status, deployapi.DeploymentProgressing) - if cond == nil || cond.Reason != deployapi.NewRcAvailableReason { + cond := appsutil.GetDeploymentCondition(dc.Status, appsapi.DeploymentProgressing) + if cond == nil || cond.Reason != appsapi.NewRcAvailableReason { return false, nil } expectedReplicas := dc.Spec.Replicas @@ -222,56 +222,56 @@ func deploymentReachedCompletion(dc *deployapi.DeploymentConfig, rcs []*corev1.R return true, nil } -func deploymentFailed(dc *deployapi.DeploymentConfig, rcs []*corev1.ReplicationController, _ []corev1.Pod) (bool, error) { +func deploymentFailed(dc *appsapi.DeploymentConfig, rcs []*corev1.ReplicationController, _ []corev1.Pod) (bool, error) { if len(rcs) == 0 { return false, nil } rcv1 := rcs[len(rcs)-1] rc := &kapi.ReplicationController{} kapiv1.Convert_v1_ReplicationController_To_api_ReplicationController(rcv1, rc, nil) - version := deployutil.DeploymentVersionFor(rc) + version := appsutil.DeploymentVersionFor(rc) if version != dc.Status.LatestVersion { return false, nil } - if !deployutil.IsFailedDeployment(rc) { + if !appsutil.IsFailedDeployment(rc) { return false, nil } - cond := deployutil.GetDeploymentCondition(dc.Status, deployapi.DeploymentProgressing) - return cond != nil && cond.Reason == deployapi.TimedOutReason, nil + cond := appsutil.GetDeploymentCondition(dc.Status, appsapi.DeploymentProgressing) + return cond != nil && cond.Reason == appsapi.TimedOutReason, nil } -func deploymentRunning(dc *deployapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) { +func deploymentRunning(dc *appsapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) { if len(rcs) == 0 { return false, nil } rcv1 := rcs[len(rcs)-1] rc := &kapi.ReplicationController{} kapiv1.Convert_v1_ReplicationController_To_api_ReplicationController(rcv1, rc, nil) - version := deployutil.DeploymentVersionFor(rc) + version := appsutil.DeploymentVersionFor(rc) if version != dc.Status.LatestVersion { //e2e.Logf("deployment %s is not the latest version on DC: %d", rc.Name, version) return false, nil } - status := rc.Annotations[deployapi.DeploymentStatusAnnotation] - switch deployapi.DeploymentStatus(status) { - case deployapi.DeploymentStatusFailed: - if deployutil.IsDeploymentCancelled(rc) { + status := rc.Annotations[appsapi.DeploymentStatusAnnotation] + switch appsapi.DeploymentStatus(status) { + case appsapi.DeploymentStatusFailed: + if appsutil.IsDeploymentCancelled(rc) { return true, nil } - reason := deployutil.DeploymentStatusReasonFor(rc) + reason := appsutil.DeploymentStatusReasonFor(rc) if reason == "deployer pod no longer exists" { return true, nil } - return false, fmt.Errorf("deployment failed: %v", deployutil.DeploymentStatusReasonFor(rc)) - case deployapi.DeploymentStatusRunning, deployapi.DeploymentStatusComplete: + return false, fmt.Errorf("deployment failed: %v", appsutil.DeploymentStatusReasonFor(rc)) + case appsapi.DeploymentStatusRunning, appsapi.DeploymentStatusComplete: return true, nil default: return false, nil } } -func deploymentPreHookRetried(dc *deployapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) { +func deploymentPreHookRetried(dc *appsapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) { var preHook *corev1.Pod for i := range pods { pod := pods[i] @@ -289,11 +289,11 @@ func deploymentPreHookRetried(dc *deployapi.DeploymentConfig, rcs []*corev1.Repl return preHook.Status.ContainerStatuses[0].RestartCount > 0, nil } -func deploymentImageTriggersResolved(expectTriggers int) func(dc *deployapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) { - return func(dc *deployapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) { +func deploymentImageTriggersResolved(expectTriggers int) func(dc *appsapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) { + return func(dc *appsapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) { expect := 0 for _, t := range dc.Spec.Triggers { - if t.Type != deployapi.DeploymentTriggerOnImageChange { + if t.Type != appsapi.DeploymentTriggerOnImageChange { continue } if expect >= expectTriggers { @@ -311,7 +311,7 @@ func deploymentImageTriggersResolved(expectTriggers int) func(dc *deployapi.Depl } } -func deploymentInfo(oc *exutil.CLI, name string) (*deployapi.DeploymentConfig, []*corev1.ReplicationController, []corev1.Pod, error) { +func deploymentInfo(oc *exutil.CLI, name string) (*appsapi.DeploymentConfig, []*corev1.ReplicationController, []corev1.Pod, error) { dc, err := oc.AppsClient().Apps().DeploymentConfigs(oc.Namespace()).Get(name, metav1.GetOptions{}) if err != nil { return nil, nil, nil, err @@ -324,7 +324,7 @@ func deploymentInfo(oc *exutil.CLI, name string) (*deployapi.DeploymentConfig, [ } rcs, err := oc.KubeClient().CoreV1().ReplicationControllers(oc.Namespace()).List(metav1.ListOptions{ - LabelSelector: deployutil.ConfigSelector(name).String(), + LabelSelector: appsutil.ConfigSelector(name).String(), }) if err != nil { return nil, nil, nil, err @@ -335,12 +335,12 @@ func deploymentInfo(oc *exutil.CLI, name string) (*deployapi.DeploymentConfig, [ deployments = append(deployments, &rcs.Items[i]) } - sort.Sort(deployutil.ByLatestVersionAscV1(deployments)) + sort.Sort(appsutil.ByLatestVersionAscV1(deployments)) return dc, deployments, pods.Items, nil } -type deploymentConditionFunc func(dc *deployapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) +type deploymentConditionFunc func(dc *appsapi.DeploymentConfig, rcs []*corev1.ReplicationController, pods []corev1.Pod) (bool, error) func waitForLatestCondition(oc *exutil.CLI, name string, timeout time.Duration, fn deploymentConditionFunc) error { return wait.PollImmediate(200*time.Millisecond, timeout, func() (bool, error) { @@ -369,7 +369,7 @@ func waitForSyncedConfig(oc *exutil.CLI, name string, timeout time.Duration) err if err != nil { return false, err } - return deployutil.HasSynced(config, generation), nil + return appsutil.HasSynced(config, generation), nil }) } @@ -397,8 +397,8 @@ func waitForDeployerToComplete(oc *exutil.CLI, name string, timeout time.Duratio }); err != nil { return "", err } - podName := deployutil.DeployerPodNameForDeployment(rc.Name) - if err := deployutil.WaitForRunningDeployerPod(oc.InternalKubeClient().Core(), rc, timeout); err != nil { + podName := appsutil.DeployerPodNameForDeployment(rc.Name) + if err := appsutil.WaitForRunningDeployerPod(oc.InternalKubeClient().Core(), rc, timeout); err != nil { return "", err } output, err := oc.Run("logs").Args("-f", "pods/"+podName).Output() @@ -448,7 +448,7 @@ func waitForRCModification(oc *exutil.CLI, namespace string, name string, timeou return event.Object.(*corev1.ReplicationController), nil } -func waitForDCModification(oc *exutil.CLI, namespace string, name string, timeout time.Duration, resourceVersion string, condition func(rc *deployapi.DeploymentConfig) (bool, error)) (*deployapi.DeploymentConfig, error) { +func waitForDCModification(oc *exutil.CLI, namespace string, name string, timeout time.Duration, resourceVersion string, condition func(rc *appsapi.DeploymentConfig) (bool, error)) (*appsapi.DeploymentConfig, error) { watcher, err := oc.AppsClient().Apps().DeploymentConfigs(namespace).Watch(metav1.SingleObject(metav1.ObjectMeta{Name: name, ResourceVersion: resourceVersion})) if err != nil { return nil, err @@ -458,7 +458,7 @@ func waitForDCModification(oc *exutil.CLI, namespace string, name string, timeou if event.Type != watch.Modified { return false, fmt.Errorf("different kind of event appeared while waiting for modification: event: %#v", event) } - return condition(event.Object.(*deployapi.DeploymentConfig)) + return condition(event.Object.(*appsapi.DeploymentConfig)) }) if err != nil { return nil, err @@ -466,7 +466,7 @@ func waitForDCModification(oc *exutil.CLI, namespace string, name string, timeou if event.Type != watch.Modified { return nil, fmt.Errorf("waiting for DC modification failed: event: %v", event) } - return event.Object.(*deployapi.DeploymentConfig), nil + return event.Object.(*appsapi.DeploymentConfig), nil } // createFixture will create the provided fixture and return the resource and the @@ -484,13 +484,13 @@ func createFixture(oc *exutil.CLI, fixture string) (string, string, error) { return resource, parts[1], nil } -func createDeploymentConfig(oc *exutil.CLI, fixture string) (*deployapi.DeploymentConfig, error) { +func createDeploymentConfig(oc *exutil.CLI, fixture string) (*appsapi.DeploymentConfig, error) { _, name, err := createFixture(oc, fixture) if err != nil { return nil, err } var pollErr error - var dc *deployapi.DeploymentConfig + var dc *appsapi.DeploymentConfig err = wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) { dc, err = oc.AppsClient().Apps().DeploymentConfigs(oc.Namespace()).Get(name, metav1.GetOptions{}) if err != nil { @@ -547,7 +547,7 @@ func failureTrap(oc *exutil.CLI, name string, failed bool) { } for _, pod := range pods { - if _, ok := pod.Labels[deployapi.DeployerPodForDeploymentLabel]; ok { + if _, ok := pod.Labels[appsapi.DeployerPodForDeploymentLabel]; ok { continue } @@ -565,7 +565,7 @@ func failureTrapForDetachedRCs(oc *exutil.CLI, dcName string, failed bool) { return } kclient := oc.KubeClient() - requirement, err := labels.NewRequirement(deployapi.DeploymentConfigAnnotation, selection.NotEquals, []string{dcName}) + requirement, err := labels.NewRequirement(appsapi.DeploymentConfigAnnotation, selection.NotEquals, []string{dcName}) if err != nil { e2e.Logf("failed to create requirement for DC %q", dcName) return @@ -580,7 +580,7 @@ func failureTrapForDetachedRCs(oc *exutil.CLI, dcName string, failed bool) { if len(dc.Items) == 0 { e2e.Logf("No detached RCs found.") } else { - out, err := oc.Run("get").Args("rc", "-o", "yaml", "-l", fmt.Sprintf("%s!=%s", deployapi.DeploymentConfigAnnotation, dcName)).Output() + out, err := oc.Run("get").Args("rc", "-o", "yaml", "-l", fmt.Sprintf("%s!=%s", appsapi.DeploymentConfigAnnotation, dcName)).Output() if err != nil { e2e.Logf("Failed to list detached RCs!") return @@ -595,29 +595,29 @@ func HasValidDCControllerRef(dc metav1.Object, controllee metav1.Object) bool { ref := metav1.GetControllerOf(controllee) return ref != nil && ref.UID == dc.GetUID() && - ref.APIVersion == deployutil.DeploymentConfigControllerRefKind.GroupVersion().String() && - ref.Kind == deployutil.DeploymentConfigControllerRefKind.Kind && + ref.APIVersion == appsutil.DeploymentConfigControllerRefKind.GroupVersion().String() && + ref.Kind == appsutil.DeploymentConfigControllerRefKind.Kind && ref.Name == dc.GetName() } -func readDCFixture(path string) (*deployapi.DeploymentConfig, error) { +func readDCFixture(path string) (*appsapi.DeploymentConfig, error) { data, err := ioutil.ReadFile(path) if err != nil { return nil, err } - dcv1 := new(deployapiv1.DeploymentConfig) + dcv1 := new(appsapiv1.DeploymentConfig) err = yaml.Unmarshal(data, dcv1) if err != nil { return nil, err } dc := new(deployapi.DeploymentConfig) - err = deployconversionsv1.Convert_v1_DeploymentConfig_To_apps_DeploymentConfig(dcv1, dc, nil) + err = appsconversionsv1.Convert_v1_DeploymentConfig_To_apps_DeploymentConfig(dcv1, dc, nil) return dc, err } -func readDCFixtureOrDie(path string) *deployapi.DeploymentConfig { +func readDCFixtureOrDie(path string) *appsapi.DeploymentConfig { data, err := readDCFixture(path) if err != nil { panic(err) diff --git a/test/extended/templates/templateinstance_readiness.go b/test/extended/templates/templateinstance_readiness.go index f4b110d6e9fb..45c30c1784ff 100644 --- a/test/extended/templates/templateinstance_readiness.go +++ b/test/extended/templates/templateinstance_readiness.go @@ -14,7 +14,7 @@ import ( "k8s.io/apimachinery/pkg/util/wait" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" templateapi "github.com/openshift/origin/pkg/template/apis/template" exutil "github.com/openshift/origin/test/extended/util" @@ -62,20 +62,20 @@ var _ = g.Describe("[Conformance][templates] templateinstance readiness test", f return true, nil case buildapi.BuildPhaseComplete: - var progressing, available *deployapi.DeploymentCondition + var progressing, available *appsapi.DeploymentCondition for i, condition := range dc.Status.Conditions { switch condition.Type { - case deployapi.DeploymentProgressing: + case appsapi.DeploymentProgressing: progressing = &dc.Status.Conditions[i] - case deployapi.DeploymentAvailable: + case appsapi.DeploymentAvailable: available = &dc.Status.Conditions[i] } } if (progressing != nil && progressing.Status == kapi.ConditionTrue && - progressing.Reason == deployapi.NewRcAvailableReason && + progressing.Reason == appsapi.NewRcAvailableReason && available != nil && available.Status == kapi.ConditionTrue) || (progressing != nil && diff --git a/test/extended/util/framework.go b/test/extended/util/framework.go index c87c2748b97a..7ff62d304152 100644 --- a/test/extended/util/framework.go +++ b/test/extended/util/framework.go @@ -36,9 +36,9 @@ import ( e2e "k8s.io/kubernetes/test/e2e/framework" "github.com/openshift/origin/pkg/api/apihelpers" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appstypeclientset "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" buildapi "github.com/openshift/origin/pkg/build/apis/build" buildtypedclientset "github.com/openshift/origin/pkg/build/generated/internalclientset/typed/build/internalversion" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -166,7 +166,7 @@ func DumpBuilds(oc *CLI) { } func GetDeploymentConfigPods(oc *CLI, dcName string, version int64) (*kapiv1.PodList, error) { - return oc.KubeClient().CoreV1().Pods(oc.Namespace()).List(metav1.ListOptions{LabelSelector: ParseLabelsOrDie(fmt.Sprintf("%s=%s-%d", deployapi.DeployerPodForDeploymentLabel, dcName, version)).String()}) + return oc.KubeClient().CoreV1().Pods(oc.Namespace()).List(metav1.ListOptions{LabelSelector: ParseLabelsOrDie(fmt.Sprintf("%s=%s-%d", appsapi.DeployerPodForDeploymentLabel, dcName, version)).String()}) } func GetApplicationPods(oc *CLI, dcName string) (*kapiv1.PodList, error) { @@ -778,7 +778,7 @@ var CheckImageStreamTagNotFoundFn = func(i *imageapi.ImageStream) bool { // to a given version and report minimum availability. func WaitForDeploymentConfig(kc kclientset.Interface, dcClient appstypeclientset.DeploymentConfigsGetter, namespace, name string, version int64, cli *CLI) error { e2e.Logf("waiting for deploymentconfig %s/%s to be available with version %d\n", namespace, name, version) - var dc *deployapi.DeploymentConfig + var dc *appsapi.DeploymentConfig start := time.Now() err := wait.Poll(time.Second, 15*time.Minute, func() (done bool, err error) { @@ -798,13 +798,13 @@ func WaitForDeploymentConfig(kc kclientset.Interface, dcClient appstypeclientset return false, nil } - var progressing, available *deployapi.DeploymentCondition + var progressing, available *appsapi.DeploymentCondition for i, condition := range dc.Status.Conditions { switch condition.Type { - case deployapi.DeploymentProgressing: + case appsapi.DeploymentProgressing: progressing = &dc.Status.Conditions[i] - case deployapi.DeploymentAvailable: + case appsapi.DeploymentAvailable: available = &dc.Status.Conditions[i] } } @@ -815,7 +815,7 @@ func WaitForDeploymentConfig(kc kclientset.Interface, dcClient appstypeclientset if progressing != nil && progressing.Status == kapi.ConditionTrue && - progressing.Reason == deployapi.NewRcAvailableReason && + progressing.Reason == appsapi.NewRcAvailableReason && available != nil && available.Status == kapi.ConditionTrue { return true, nil @@ -834,7 +834,7 @@ func WaitForDeploymentConfig(kc kclientset.Interface, dcClient appstypeclientset return err } - requirement, err := labels.NewRequirement(deployapi.DeploymentLabel, selection.Equals, []string{deployutil.LatestDeploymentNameForConfig(dc)}) + requirement, err := labels.NewRequirement(appsapi.DeploymentLabel, selection.Equals, []string{appsutil.LatestDeploymentNameForConfig(dc)}) if err != nil { return err } diff --git a/test/integration/authorization_test.go b/test/integration/authorization_test.go index 0cf515b025ca..6e53f50cb260 100644 --- a/test/integration/authorization_test.go +++ b/test/integration/authorization_test.go @@ -24,7 +24,7 @@ import ( authorizationapiv1 "github.com/openshift/api/authorization/v1" "github.com/openshift/origin/pkg/api/legacy" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + oappsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" authorizationclient "github.com/openshift/origin/pkg/authorization/generated/internalclientset" @@ -175,14 +175,14 @@ func TestClusterReaderCoverage(t *testing.T) { buildapi.LegacyResource("buildconfigs/instantiate"), buildapi.Resource("builds/clone"), buildapi.LegacyResource("builds/clone"), - deployapi.Resource("deploymentconfigrollbacks"), - deployapi.LegacyResource("deploymentconfigrollbacks"), - deployapi.Resource("generatedeploymentconfigs"), - deployapi.LegacyResource("generatedeploymentconfigs"), - deployapi.Resource("deploymentconfigs/rollback"), - deployapi.LegacyResource("deploymentconfigs/rollback"), - deployapi.Resource("deploymentconfigs/instantiate"), - deployapi.LegacyResource("deploymentconfigs/instantiate"), + oappsapi.Resource("deploymentconfigrollbacks"), + oappsapi.LegacyResource("deploymentconfigrollbacks"), + oappsapi.Resource("generatedeploymentconfigs"), + oappsapi.LegacyResource("generatedeploymentconfigs"), + oappsapi.Resource("deploymentconfigs/rollback"), + oappsapi.LegacyResource("deploymentconfigs/rollback"), + oappsapi.Resource("deploymentconfigs/instantiate"), + oappsapi.LegacyResource("deploymentconfigs/instantiate"), imageapi.Resource("imagestreamimports"), imageapi.LegacyResource("imagestreamimports"), imageapi.Resource("imagestreammappings"), diff --git a/test/integration/deploy_defaults_test.go b/test/integration/deploy_defaults_test.go index 332fe1c99266..9652d3dfb2c6 100644 --- a/test/integration/deploy_defaults_test.go +++ b/test/integration/deploy_defaults_test.go @@ -14,7 +14,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" appsapiv1 "github.com/openshift/api/apps/v1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset" appsclientscheme "github.com/openshift/origin/pkg/apps/generated/internalclientset/scheme" testutil "github.com/openshift/origin/test/util" @@ -25,16 +25,16 @@ import ( ) var ( - nonDefaultRevisionHistoryLimit = deployapi.DefaultRevisionHistoryLimit + 42 + nonDefaultRevisionHistoryLimit = appsapi.DefaultRevisionHistoryLimit + 42 ) -func minimalDC(name string, generation int64) *deployapi.DeploymentConfig { - return &deployapi.DeploymentConfig{ +func minimalDC(name string, generation int64) *appsapi.DeploymentConfig { + return &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{ Name: name, Generation: generation, }, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Selector: map[string]string{ "app": name, }, @@ -65,9 +65,9 @@ func int32ptr(v int32) *int32 { return &v } -func setEssentialDefaults(dc *deployapi.DeploymentConfig) *deployapi.DeploymentConfig { - dc.Spec.Strategy.Type = deployapi.DeploymentStrategyTypeRolling - dc.Spec.Strategy.RollingParams = &deployapi.RollingDeploymentStrategyParams{ +func setEssentialDefaults(dc *appsapi.DeploymentConfig) *appsapi.DeploymentConfig { + dc.Spec.Strategy.Type = appsapi.DeploymentStrategyTypeRolling + dc.Spec.Strategy.RollingParams = &appsapi.RollingDeploymentStrategyParams{ IntervalSeconds: int64ptr(1), UpdatePeriodSeconds: int64ptr(1), TimeoutSeconds: int64ptr(600), @@ -75,8 +75,8 @@ func setEssentialDefaults(dc *deployapi.DeploymentConfig) *deployapi.DeploymentC MaxSurge: intstr.FromString("25%"), } dc.Spec.Strategy.ActiveDeadlineSeconds = int64ptr(21600) - dc.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{ - {Type: deployapi.DeploymentTriggerOnConfigChange}, + dc.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{ + {Type: appsapi.DeploymentTriggerOnConfigChange}, } dc.Spec.Template.Spec.Containers[0].TerminationMessagePath = "/dev/termination-log" dc.Spec.Template.Spec.Containers[0].TerminationMessagePolicy = "File" @@ -94,7 +94,7 @@ func setEssentialDefaults(dc *deployapi.DeploymentConfig) *deployapi.DeploymentC return dc } -func clearTransient(dc *deployapi.DeploymentConfig) { +func clearTransient(dc *appsapi.DeploymentConfig) { dc.ObjectMeta.Namespace = "" dc.ObjectMeta.SelfLink = "" dc.ObjectMeta.UID = "" @@ -121,22 +121,22 @@ func TestDeploymentConfigDefaults(t *testing.T) { t.Fatalf("Failed to create appsClient: %v", err) } // install the legacy types into the client for decoding - legacy.InstallLegacy(deployapi.GroupName, deployapi.AddToSchemeInCoreGroup, appsapiv1.AddToSchemeInCoreGroup, + legacy.InstallLegacy(appsapi.GroupName, appsapi.AddToSchemeInCoreGroup, appsapiv1.AddToSchemeInCoreGroup, sets.NewString(), appsclientscheme.Registry, appsclientscheme.Scheme, ) ttLegacy := []struct { - obj *deployapi.DeploymentConfig - legacy *deployapi.DeploymentConfig + obj *appsapi.DeploymentConfig + legacy *appsapi.DeploymentConfig }{ { - obj: func() *deployapi.DeploymentConfig { + obj: func() *appsapi.DeploymentConfig { dc := minimalDC("test-legacy-01", 0) dc.Spec.RevisionHistoryLimit = nil return dc }(), - legacy: func() *deployapi.DeploymentConfig { + legacy: func() *appsapi.DeploymentConfig { dc := minimalDC("test-legacy-01", 1) setEssentialDefaults(dc) // Legacy API shall not default RevisionHistoryLimit to maintain backwards compatibility @@ -145,12 +145,12 @@ func TestDeploymentConfigDefaults(t *testing.T) { }(), }, { - obj: func() *deployapi.DeploymentConfig { + obj: func() *appsapi.DeploymentConfig { dc := minimalDC("test-legacy-02", 0) dc.Spec.RevisionHistoryLimit = &nonDefaultRevisionHistoryLimit return dc }(), - legacy: func() *deployapi.DeploymentConfig { + legacy: func() *appsapi.DeploymentConfig { dc := minimalDC("test-legacy-02", 1) setEssentialDefaults(dc) dc.Spec.RevisionHistoryLimit = &nonDefaultRevisionHistoryLimit @@ -169,7 +169,7 @@ func TestDeploymentConfigDefaults(t *testing.T) { if err != nil { t.Fatalf("Failed to create DC: %v", err) } - legacyDC := legacyObj.(*deployapi.DeploymentConfig) + legacyDC := legacyObj.(*appsapi.DeploymentConfig) clearTransient(legacyDC) if !reflect.DeepEqual(legacyDC, tc.legacy) { @@ -180,16 +180,16 @@ func TestDeploymentConfigDefaults(t *testing.T) { }) ttApps := []struct { - obj *deployapi.DeploymentConfig - apps *deployapi.DeploymentConfig + obj *appsapi.DeploymentConfig + apps *appsapi.DeploymentConfig }{ { - obj: func() *deployapi.DeploymentConfig { + obj: func() *appsapi.DeploymentConfig { dc := minimalDC("test-apps-01", 0) dc.Spec.RevisionHistoryLimit = nil return dc }(), - apps: func() *deployapi.DeploymentConfig { + apps: func() *appsapi.DeploymentConfig { dc := minimalDC("test-apps-01", 1) setEssentialDefaults(dc) // Group API should default RevisionHistoryLimit @@ -198,12 +198,12 @@ func TestDeploymentConfigDefaults(t *testing.T) { }(), }, { - obj: func() *deployapi.DeploymentConfig { + obj: func() *appsapi.DeploymentConfig { dc := minimalDC("test-apps-02", 0) dc.Spec.RevisionHistoryLimit = &nonDefaultRevisionHistoryLimit return dc }(), - apps: func() *deployapi.DeploymentConfig { + apps: func() *appsapi.DeploymentConfig { dc := minimalDC("test-apps-02", 1) setEssentialDefaults(dc) dc.Spec.RevisionHistoryLimit = &nonDefaultRevisionHistoryLimit diff --git a/test/integration/deploy_scale_test.go b/test/integration/deploy_scale_test.go index f9ee5e997b66..f4bccd26a0d1 100644 --- a/test/integration/deploy_scale_test.go +++ b/test/integration/deploy_scale_test.go @@ -9,10 +9,10 @@ import ( "k8s.io/apimachinery/pkg/util/wait" internalextensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" testutil "github.com/openshift/origin/test/util" testserver "github.com/openshift/origin/test/util/server" ) @@ -39,9 +39,9 @@ func TestDeployScale(t *testing.T) { } adminAppsClient := appsclient.NewForConfigOrDie(adminConfig).Apps() - config := deploytest.OkDeploymentConfig(0) + config := appstest.OkDeploymentConfig(0) config.Namespace = namespace - config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{} + config.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{} config.Spec.Replicas = 1 dc, err := adminAppsClient.DeploymentConfigs(namespace).Create(config) @@ -55,7 +55,7 @@ func TestDeployScale(t *testing.T) { if err != nil { return false, nil } - return deployutil.HasSynced(config, generation), nil + return appsutil.HasSynced(config, generation), nil } if err := wait.PollImmediate(500*time.Millisecond, 10*time.Second, condition); err != nil { t.Fatalf("Deployment config never synced: %v", err) @@ -69,7 +69,7 @@ func TestDeployScale(t *testing.T) { t.Fatalf("Expected scale.spec.replicas=1, got %#v", scale) } - scaleUpdate := deployapi.ScaleFromConfig(dc) + scaleUpdate := appsapi.ScaleFromConfig(dc) scaleUpdate.Spec.Replicas = 3 scaleUpdatev1beta1 := &extensionsv1beta1.Scale{} if err := internalextensionsv1beta1.Convert_extensions_Scale_To_v1beta1_Scale(scaleUpdate, scaleUpdatev1beta1, nil); err != nil { diff --git a/test/integration/deploy_trigger_test.go b/test/integration/deploy_trigger_test.go index 9734a08fdf3c..601841b91179 100644 --- a/test/integration/deploy_trigger_test.go +++ b/test/integration/deploy_trigger_test.go @@ -11,10 +11,10 @@ import ( "k8s.io/client-go/util/retry" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" imageapi "github.com/openshift/origin/pkg/image/apis/image" imageclient "github.com/openshift/origin/pkg/image/generated/internalclientset" testutil "github.com/openshift/origin/test/util" @@ -45,9 +45,9 @@ func TestTriggers_manual(t *testing.T) { } adminAppsClient := appsclient.NewForConfigOrDie(adminConfig).Apps() - config := deploytest.OkDeploymentConfig(0) + config := appstest.OkDeploymentConfig(0) config.Namespace = namespace - config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{{Type: deployapi.DeploymentTriggerManual}} + config.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{{Type: appsapi.DeploymentTriggerManual}} dc, err := adminAppsClient.DeploymentConfigs(namespace).Create(config) if err != nil { @@ -60,7 +60,7 @@ func TestTriggers_manual(t *testing.T) { } defer rcWatch.Stop() - request := &deployapi.DeploymentRequest{ + request := &appsapi.DeploymentRequest{ Name: config.Name, Latest: false, Force: true, @@ -81,9 +81,9 @@ func TestTriggers_manual(t *testing.T) { t.Fatal("Instantiated deployment config should have a cause of deployment") } gotType := config.Status.Details.Causes[0].Type - if gotType != deployapi.DeploymentTriggerManual { + if gotType != appsapi.DeploymentTriggerManual { t.Fatalf("Instantiated deployment config should have a %q cause of deployment instead of %q", - deployapi.DeploymentTriggerManual, gotType) + appsapi.DeploymentTriggerManual, gotType) } event := <-rcWatch.ResultChan() @@ -92,10 +92,10 @@ func TestTriggers_manual(t *testing.T) { } deployment := event.Object.(*kapi.ReplicationController) - if e, a := config.Name, deployutil.DeploymentConfigNameFor(deployment); e != a { + if e, a := config.Name, appsutil.DeploymentConfigNameFor(deployment); e != a { t.Fatalf("Expected deployment annotated with deploymentConfig '%s', got '%s'", e, a) } - if e, a := int64(1), deployutil.DeploymentVersionFor(deployment); e != a { + if e, a := int64(1), appsutil.DeploymentVersionFor(deployment); e != a { t.Fatalf("Deployment annotation version does not match: %#v", deployment) } } @@ -119,11 +119,11 @@ func TestTriggers_imageChange(t *testing.T) { projectAdminAppsClient := appsclient.NewForConfigOrDie(projectAdminClientConfig).Apps() projectAdminImageClient := imageclient.NewForConfigOrDie(projectAdminClientConfig).Image() - imageStream := &imageapi.ImageStream{ObjectMeta: metav1.ObjectMeta{Name: deploytest.ImageStreamName}} + imageStream := &imageapi.ImageStream{ObjectMeta: metav1.ObjectMeta{Name: appstest.ImageStreamName}} - config := deploytest.OkDeploymentConfig(0) + config := appstest.OkDeploymentConfig(0) config.Namespace = testutil.Namespace() - config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{deploytest.OkImageChangeTrigger()} + config.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{appstest.OkImageChangeTrigger()} configWatch, err := projectAdminAppsClient.DeploymentConfigs(testutil.Namespace()).Watch(metav1.ListOptions{}) if err != nil { @@ -141,8 +141,8 @@ func TestTriggers_imageChange(t *testing.T) { } defer imageWatch.Stop() - updatedImage := fmt.Sprintf("sha256:%s", deploytest.ImageID) - updatedPullSpec := fmt.Sprintf("registry:8080/%s/%s@%s", testutil.Namespace(), deploytest.ImageStreamName, updatedImage) + updatedImage := fmt.Sprintf("sha256:%s", appstest.ImageID) + updatedPullSpec := fmt.Sprintf("registry:8080/%s/%s@%s", testutil.Namespace(), appstest.ImageStreamName, updatedImage) // Make a function which can create a new tag event for the image stream and // then wait for the stream status to be asynchronously updated. createTagEvent := func() { @@ -181,14 +181,14 @@ func TestTriggers_imageChange(t *testing.T) { createTagEvent() - var newConfig *deployapi.DeploymentConfig + var newConfig *appsapi.DeploymentConfig t.Log("Waiting for a new deployment config in response to imagestream update") waitForNewConfig: for { select { case event := <-configWatch.ResultChan(): if event.Type == watchapi.Modified { - newConfig = event.Object.(*deployapi.DeploymentConfig) + newConfig = event.Object.(*appsapi.DeploymentConfig) // Multiple updates to the config can be expected (e.g. status // updates), so wait for a significant update (e.g. version). if newConfig.Status.LatestVersion > 0 { @@ -222,7 +222,7 @@ func TestTriggers_imageChange_nonAutomatic(t *testing.T) { adminAppsClient := appsclient.NewForConfigOrDie(adminConfig).Apps() adminImageClient := imageclient.NewForConfigOrDie(adminConfig).Image() - imageStream := &imageapi.ImageStream{ObjectMeta: metav1.ObjectMeta{Name: deploytest.ImageStreamName}} + imageStream := &imageapi.ImageStream{ObjectMeta: metav1.ObjectMeta{Name: appstest.ImageStreamName}} if imageStream, err = adminImageClient.ImageStreams(testutil.Namespace()).Create(imageStream); err != nil { t.Fatalf("Couldn't create imagestream: %v", err) @@ -234,8 +234,8 @@ func TestTriggers_imageChange_nonAutomatic(t *testing.T) { } defer imageWatch.Stop() - image := fmt.Sprintf("sha256:%s", deploytest.ImageID) - pullSpec := fmt.Sprintf("registry:5000/%s/%s@%s", testutil.Namespace(), deploytest.ImageStreamName, image) + image := fmt.Sprintf("sha256:%s", appstest.ImageID) + pullSpec := fmt.Sprintf("registry:5000/%s/%s@%s", testutil.Namespace(), appstest.ImageStreamName, image) // Make a function which can create a new tag event for the image stream and // then wait for the stream status to be asynchronously updated. mapping := &imageapi.ImageStreamMapping{ @@ -283,9 +283,9 @@ func TestTriggers_imageChange_nonAutomatic(t *testing.T) { } defer configWatch.Stop() - config := deploytest.OkDeploymentConfig(0) + config := appstest.OkDeploymentConfig(0) config.Namespace = testutil.Namespace() - config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{deploytest.OkImageChangeTrigger()} + config.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{appstest.OkImageChangeTrigger()} config.Spec.Triggers[0].ImageChangeParams.Automatic = false if config, err = adminAppsClient.DeploymentConfigs(testutil.Namespace()).Create(config); err != nil { t.Fatalf("Couldn't create deploymentconfig: %v", err) @@ -293,7 +293,7 @@ func TestTriggers_imageChange_nonAutomatic(t *testing.T) { createTagEvent(mapping) - var newConfig *deployapi.DeploymentConfig + var newConfig *appsapi.DeploymentConfig t.Log("Waiting for the first imagestream update - no deployment should run") timeout := time.After(20 * time.Second) @@ -309,7 +309,7 @@ out: continue } - newConfig = event.Object.(*deployapi.DeploymentConfig) + newConfig = event.Object.(*appsapi.DeploymentConfig) if newConfig.Status.LatestVersion > 0 { t.Fatalf("unexpected latestVersion update - the config has no config change trigger") @@ -324,7 +324,7 @@ out: // Subsequent updates to the image shouldn't update the pod template image mapping.Image.Name = "sha256:0000000000000000000000000000000000000000000000000000000000000321" - mapping.Image.DockerImageReference = fmt.Sprintf("registry:8080/%s/%s@%s", testutil.Namespace(), deploytest.ImageStreamName, mapping.Image.Name) + mapping.Image.DockerImageReference = fmt.Sprintf("registry:8080/%s/%s@%s", testutil.Namespace(), appstest.ImageStreamName, mapping.Image.Name) createTagEvent(mapping) timeout = time.After(20 * time.Second) @@ -337,7 +337,7 @@ loop: continue } - newConfig = event.Object.(*deployapi.DeploymentConfig) + newConfig = event.Object.(*appsapi.DeploymentConfig) if newConfig.Status.LatestVersion > 0 { t.Fatalf("unexpected latestVersion update - the config has no config change trigger") @@ -349,7 +349,7 @@ loop: } t.Log("Instantiate the deployment config - the latest image should be picked up and a new deployment should run") - request := &deployapi.DeploymentRequest{ + request := &appsapi.DeploymentRequest{ Name: config.Name, Latest: true, Force: true, @@ -375,7 +375,7 @@ loop: if config.Status.Details == nil || len(config.Status.Details.Causes) == 0 { t.Fatalf("Expected a cause of deployment for deployment config %q", config.Name) } - if gotType, expectedType := config.Status.Details.Causes[0].Type, deployapi.DeploymentTriggerManual; gotType != expectedType { + if gotType, expectedType := config.Status.Details.Causes[0].Type, appsapi.DeploymentTriggerManual; gotType != expectedType { t.Fatalf("Instantiated deployment config should have a %q cause of deployment instead of %q", expectedType, gotType) } } @@ -399,16 +399,16 @@ func TestTriggers_MultipleICTs(t *testing.T) { adminAppsClient := appsclient.NewForConfigOrDie(adminConfig).Apps() adminImageClient := imageclient.NewForConfigOrDie(adminConfig).Image() - imageStream := &imageapi.ImageStream{ObjectMeta: metav1.ObjectMeta{Name: deploytest.ImageStreamName}} + imageStream := &imageapi.ImageStream{ObjectMeta: metav1.ObjectMeta{Name: appstest.ImageStreamName}} secondImageStream := &imageapi.ImageStream{ObjectMeta: metav1.ObjectMeta{Name: "sample"}} - config := deploytest.OkDeploymentConfig(0) + config := appstest.OkDeploymentConfig(0) config.Namespace = testutil.Namespace() - firstTrigger := deploytest.OkImageChangeTrigger() - secondTrigger := deploytest.OkImageChangeTrigger() + firstTrigger := appstest.OkImageChangeTrigger() + secondTrigger := appstest.OkImageChangeTrigger() secondTrigger.ImageChangeParams.ContainerNames = []string{"container2"} secondTrigger.ImageChangeParams.From.Name = imageapi.JoinImageStreamTag("sample", imageapi.DefaultImageTag) - config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{firstTrigger, secondTrigger} + config.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{firstTrigger, secondTrigger} configWatch, err := adminAppsClient.DeploymentConfigs(testutil.Namespace()).Watch(metav1.ListOptions{}) if err != nil { @@ -429,8 +429,8 @@ func TestTriggers_MultipleICTs(t *testing.T) { } defer imageWatch.Stop() - updatedImage := fmt.Sprintf("sha256:%s", deploytest.ImageID) - updatedPullSpec := fmt.Sprintf("registry:8080/%s/%s@%s", testutil.Namespace(), deploytest.ImageStreamName, updatedImage) + updatedImage := fmt.Sprintf("sha256:%s", appstest.ImageID) + updatedPullSpec := fmt.Sprintf("registry:8080/%s/%s@%s", testutil.Namespace(), appstest.ImageStreamName, updatedImage) // Make a function which can create a new tag event for the image stream and // then wait for the stream status to be asynchronously updated. @@ -483,7 +483,7 @@ out: continue } - newConfig := event.Object.(*deployapi.DeploymentConfig) + newConfig := event.Object.(*appsapi.DeploymentConfig) if newConfig.Status.LatestVersion > 0 { t.Fatalf("unexpected latestVersion update: %#v", newConfig) } @@ -511,7 +511,7 @@ out: continue } - newConfig := event.Object.(*deployapi.DeploymentConfig) + newConfig := event.Object.(*appsapi.DeploymentConfig) switch { case newConfig.Status.LatestVersion == 0: t.Logf("Wating for latestVersion to update to 1") @@ -564,9 +564,9 @@ func TestTriggers_configChange(t *testing.T) { } adminAppsClient := appsclient.NewForConfigOrDie(adminConfig).Apps() - config := deploytest.OkDeploymentConfig(0) + config := appstest.OkDeploymentConfig(0) config.Namespace = namespace - config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{deploytest.OkConfigChangeTrigger()} + config.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{appstest.OkConfigChangeTrigger()} rcWatch, err := kc.Core().ReplicationControllers(namespace).Watch(metav1.ListOptions{}) if err != nil { @@ -588,7 +588,7 @@ func TestTriggers_configChange(t *testing.T) { deployment := event.Object.(*kapi.ReplicationController) - if e, a := config.Name, deployutil.DeploymentConfigNameFor(deployment); e != a { + if e, a := config.Name, appsutil.DeploymentConfigNameFor(deployment); e != a { t.Fatalf("Expected deployment annotated with deploymentConfig '%s', got '%s'", e, a) } @@ -601,7 +601,7 @@ func TestTriggers_configChange(t *testing.T) { return err } - liveDeployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusComplete) + liveDeployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusComplete) // update the deployment _, err = kc.Core().ReplicationControllers(namespace).Update(liveDeployment) diff --git a/test/integration/imagestream_test.go b/test/integration/imagestream_test.go index 09590b47022d..8dd38d715048 100644 --- a/test/integration/imagestream_test.go +++ b/test/integration/imagestream_test.go @@ -11,7 +11,7 @@ import ( "k8s.io/apimachinery/pkg/util/diff" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" stratsupport "github.com/openshift/origin/pkg/apps/strategy/support" imagetest "github.com/openshift/origin/pkg/image/admission/testutil" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -418,8 +418,8 @@ func TestImageStreamTagLifecycleHook(t *testing.T) { // can tag to a stream that exists exec := stratsupport.NewHookExecutor(nil, imageClientset, clusterAdminKubeClientset.Core(), os.Stdout, kapi.Codecs.UniversalDecoder()) err = exec.Execute( - &deployapi.LifecycleHook{ - TagImages: []deployapi.TagImageHook{ + &appsapi.LifecycleHook{ + TagImages: []appsapi.TagImageHook{ { ContainerName: "test", To: kapi.ObjectReference{Kind: "ImageStreamTag", Name: stream.Name + ":test"}, @@ -456,8 +456,8 @@ func TestImageStreamTagLifecycleHook(t *testing.T) { // can execute a second time the same tag and it should work exec = stratsupport.NewHookExecutor(nil, imageClientset, clusterAdminKubeClientset.Core(), os.Stdout, kapi.Codecs.UniversalDecoder()) err = exec.Execute( - &deployapi.LifecycleHook{ - TagImages: []deployapi.TagImageHook{ + &appsapi.LifecycleHook{ + TagImages: []appsapi.TagImageHook{ { ContainerName: "test", To: kapi.ObjectReference{Kind: "ImageStreamTag", Name: stream.Name + ":test"}, @@ -488,8 +488,8 @@ func TestImageStreamTagLifecycleHook(t *testing.T) { // can lifecycle tag a new image stream exec = stratsupport.NewHookExecutor(nil, imageClientset, clusterAdminKubeClientset.Core(), os.Stdout, kapi.Codecs.UniversalDecoder()) err = exec.Execute( - &deployapi.LifecycleHook{ - TagImages: []deployapi.TagImageHook{ + &appsapi.LifecycleHook{ + TagImages: []appsapi.TagImageHook{ { ContainerName: "test", To: kapi.ObjectReference{Kind: "ImageStreamTag", Name: "test2:test"}, diff --git a/test/integration/newapp_test.go b/test/integration/newapp_test.go index 82465f43b688..17dd3ffc4a4c 100644 --- a/test/integration/newapp_test.go +++ b/test/integration/newapp_test.go @@ -33,7 +33,7 @@ import ( clientgotesting "k8s.io/client-go/testing" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" buildapi "github.com/openshift/origin/pkg/build/apis/build" "github.com/openshift/origin/pkg/generate" "github.com/openshift/origin/pkg/generate/app" @@ -895,7 +895,7 @@ func TestNewAppRunAll(t *testing.T) { case *imageapi.ImageStream: got["imageStream"] = append(got["imageStream"], tp.Name) imageStreams = append(imageStreams, tp) - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: got["deploymentConfig"] = append(got["deploymentConfig"], tp.Name) if podTemplate := tp.Spec.Template; podTemplate != nil { for _, volume := range podTemplate.Spec.Volumes { diff --git a/test/integration/pod_node_constraints_test.go b/test/integration/pod_node_constraints_test.go index e4a35fecb288..d3a4782bb79e 100644 --- a/test/integration/pod_node_constraints_test.go +++ b/test/integration/pod_node_constraints_test.go @@ -10,7 +10,7 @@ import ( "k8s.io/kubernetes/pkg/apis/extensions" kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset" authorizationclient "github.com/openshift/origin/pkg/authorization/generated/internalclientset" configapi "github.com/openshift/origin/pkg/cmd/server/api" @@ -208,8 +208,8 @@ func testPodNodeConstraintsJob(nodeName string, nodeSelector map[string]string) return job } -func testPodNodeConstraintsDeploymentConfig(nodeName string, nodeSelector map[string]string) *deployapi.DeploymentConfig { - dc := &deployapi.DeploymentConfig{} +func testPodNodeConstraintsDeploymentConfig(nodeName string, nodeSelector map[string]string) *appsapi.DeploymentConfig { + dc := &appsapi.DeploymentConfig{} dc.Name = "testdc" dc.Spec.Replicas = 1 dc.Spec.Template = &kapi.PodTemplateSpec{}