From 7512dcaf036de1ab773f09e32a2dbb5bbe93b89c Mon Sep 17 00:00:00 2001 From: Maciej Szulik Date: Mon, 11 Sep 2017 12:57:02 +0200 Subject: [PATCH] Rename deploy.* imports to apps.* --- examples/examples_test.go | 6 +- pkg/api/graph/graphview/dc_pipeline.go | 18 +- pkg/api/graph/graphview/service_group.go | 6 +- pkg/api/graph/graphview/veneering_test.go | 28 +- .../graph/test/runtimeobject_nodebuilder.go | 6 +- pkg/api/install/install.go | 16 +- pkg/api/kubegraph/analysis/hpa.go | 8 +- pkg/api/kubegraph/analysis/hpa_test.go | 6 +- pkg/api/kubegraph/edge_test.go | 8 +- pkg/api/kubegraph/edges.go | 8 +- pkg/api/meta/pods.go | 16 +- pkg/api/serialization_test.go | 110 ++--- pkg/api/validation/coverage_test.go | 4 +- pkg/api/validation/register.go | 12 +- pkg/apps/apis/apps/install/apigroup.go | 12 +- pkg/apps/apis/apps/install/install.go | 18 +- pkg/apps/apis/apps/test/ok.go | 104 ++--- pkg/apps/apis/apps/v1/defaults.go | 22 +- pkg/apps/apis/apps/v1/defaults_test.go | 438 +++++++++--------- pkg/apps/apis/apps/validation/validation.go | 56 +-- .../apis/apps/validation/validation_test.go | 364 +++++++-------- pkg/apps/cmd/delete.go | 12 +- pkg/apps/cmd/delete_test.go | 24 +- pkg/apps/cmd/generate.go | 6 +- pkg/apps/cmd/history.go | 16 +- pkg/apps/cmd/rollback.go | 8 +- pkg/apps/cmd/scale_test.go | 10 +- pkg/apps/cmd/status.go | 16 +- .../deployer/deployer_controller.go | 132 +++--- .../deployer/deployer_controller_test.go | 258 +++++------ pkg/apps/controller/deployer/factory.go | 10 +- .../deploymentconfig_controller.go | 122 ++--- .../deploymentconfig_controller_test.go | 212 ++++----- .../controller/deploymentconfig/factory.go | 18 +- .../deploy_generictrigger_controller.go | 8 +- .../deploy_generictrigger_controller_test.go | 14 +- pkg/apps/controller/generictrigger/factory.go | 28 +- .../test/fake_deployment_config_store.go | 6 +- pkg/apps/graph/analysis/dc.go | 24 +- pkg/apps/graph/analysis/dc_test.go | 10 +- pkg/apps/graph/edge_test.go | 6 +- pkg/apps/graph/edges.go | 22 +- pkg/apps/graph/helpers.go | 16 +- pkg/apps/graph/nodes/nodes_test.go | 4 +- pkg/apps/graph/nodes/types.go | 8 +- pkg/apps/prune/data.go | 36 +- pkg/apps/prune/data_test.go | 24 +- pkg/apps/prune/prune.go | 16 +- pkg/apps/prune/prune_test.go | 22 +- pkg/apps/prune/resolvers.go | 18 +- pkg/apps/prune/resolvers_test.go | 50 +- pkg/apps/registry/deployconfig/etcd/etcd.go | 16 +- pkg/apps/registry/deployconfig/strategy.go | 26 +- .../registry/deployconfig/strategy_test.go | 50 +- pkg/apps/registry/deploylog/rest.go | 36 +- pkg/apps/registry/deploylog/rest_test.go | 38 +- pkg/apps/registry/instantiate/rest.go | 64 +-- pkg/apps/registry/instantiate/rest_test.go | 418 ++++++++--------- pkg/apps/registry/instantiate/strategy.go | 10 +- pkg/apps/registry/rest.go | 10 +- pkg/apps/registry/rest_test.go | 6 +- pkg/apps/registry/rollback/rest.go | 20 +- pkg/apps/registry/rollback/rest_deprecated.go | 30 +- .../registry/rollback/rest_deprecated_test.go | 96 ++-- pkg/apps/registry/rollback/rest_test.go | 70 +-- .../registry/rollback/rollback_generator.go | 10 +- .../rollback/rollback_generator_test.go | 30 +- pkg/apps/registry/test/deployconfig.go | 14 +- pkg/apps/strategy/recreate/recreate.go | 14 +- pkg/apps/strategy/recreate/recreate_test.go | 108 ++--- pkg/apps/strategy/rolling/rolling.go | 16 +- pkg/apps/strategy/rolling/rolling_test.go | 82 ++-- pkg/apps/strategy/support/lifecycle.go | 32 +- pkg/apps/strategy/support/lifecycle_test.go | 134 +++--- pkg/apps/strategy/util/util.go | 6 +- pkg/apps/util/util.go | 158 +++---- pkg/apps/util/util_test.go | 256 +++++----- pkg/client/cache/deploymentconfig.go | 46 +- pkg/client/cache/index.go | 6 +- pkg/client/deploymentconfigs.go | 56 +-- pkg/client/deploymentlogs.go | 6 +- .../testclient/fake_deploymentconfigs.go | 56 +-- pkg/client/testclient/fake_deploymentlogs.go | 6 +- pkg/client/testclient/testclient_test.go | 6 +- pkg/cmd/infra/deployer/deployer.go | 26 +- pkg/cmd/infra/deployer/deployer_test.go | 54 +-- pkg/cmd/server/bootstrappolicy/policy.go | 6 +- pkg/cmd/server/origin/controller/unidling.go | 4 +- .../origin/reststorage_validation_test.go | 4 +- pkg/cmd/util/clientcmd/factory.go | 10 +- .../util/clientcmd/factory_client_access.go | 22 +- .../util/clientcmd/factory_object_mapping.go | 30 +- .../aggregated_logging/deploymentconfigs.go | 6 +- .../deploymentconfigs_test.go | 10 +- .../cluster/aggregated_logging/diagnostic.go | 4 +- .../cluster/aggregated_logging/interfaces.go | 4 +- pkg/diagnostics/cluster/router.go | 8 +- pkg/generate/app/app.go | 18 +- pkg/generate/app/imageref.go | 10 +- pkg/generate/app/imageref_test.go | 4 +- pkg/generate/app/pipeline.go | 32 +- pkg/generate/app/pipeline_test.go | 12 +- pkg/generate/appjson/appjson.go | 4 +- .../trigger/image_trigger_controller_test.go | 34 +- pkg/image/prune/prune.go | 10 +- pkg/image/prune/prune_test.go | 16 +- .../deploymentconfigs/deploymentconfigs.go | 28 +- .../deploymentconfigs_test.go | 90 ++-- pkg/ipfailover/keepalived/plugin.go | 4 +- pkg/oc/admin/migrate/images/imagerefs_test.go | 10 +- pkg/oc/admin/prune/deployments.go | 4 +- pkg/oc/admin/registry/registry.go | 10 +- pkg/oc/admin/router/router.go | 16 +- pkg/oc/admin/top/images.go | 6 +- pkg/oc/admin/top/images_test.go | 10 +- pkg/oc/cli/cmd/create/deploymentconfig.go | 8 +- pkg/oc/cli/cmd/debug.go | 6 +- pkg/oc/cli/cmd/deploy.go | 72 +-- pkg/oc/cli/cmd/deploy_test.go | 98 ++-- pkg/oc/cli/cmd/exporter.go | 4 +- pkg/oc/cli/cmd/exporter_test.go | 12 +- pkg/oc/cli/cmd/idle.go | 8 +- pkg/oc/cli/cmd/idle_test.go | 4 +- pkg/oc/cli/cmd/logs.go | 8 +- pkg/oc/cli/cmd/logs_test.go | 4 +- pkg/oc/cli/cmd/rollback.go | 26 +- pkg/oc/cli/cmd/rollback_test.go | 40 +- pkg/oc/cli/cmd/rollout/cancel.go | 30 +- pkg/oc/cli/cmd/rollout/latest.go | 14 +- pkg/oc/cli/cmd/rollout/retry.go | 22 +- pkg/oc/cli/cmd/set/deploymenthook.go | 24 +- pkg/oc/cli/cmd/set/triggers.go | 34 +- pkg/oc/cli/describe/deployments.go | 54 +-- pkg/oc/cli/describe/deployments_test.go | 32 +- pkg/oc/cli/describe/describer.go | 4 +- pkg/oc/cli/describe/describer_test.go | 10 +- pkg/oc/cli/describe/printer.go | 10 +- pkg/oc/cli/describe/printer_test.go | 18 +- pkg/oc/cli/describe/projectstatus.go | 58 +-- .../podnodeconstraints/admission_test.go | 12 +- pkg/template/controller/readiness.go | 32 +- pkg/template/controller/readiness_test.go | 30 +- .../controller/unidling_controller.go | 6 +- .../controller/unidling_controller_test.go | 46 +- pkg/unidling/util/scale.go | 24 +- pkg/util/labels.go | 10 +- pkg/util/labels_test.go | 8 +- test/extended/deployments/deployments.go | 40 +- test/extended/deployments/util.go | 116 ++--- .../templates/templateinstance_readiness.go | 10 +- test/extended/util/framework.go | 18 +- test/integration/authorization_test.go | 18 +- test/integration/deploy_defaults_test.go | 50 +- test/integration/deploy_scale_test.go | 14 +- test/integration/deploy_trigger_test.go | 82 ++-- test/integration/imagestream_test.go | 14 +- test/integration/newapp_test.go | 4 +- test/integration/pod_node_constraints_test.go | 6 +- 158 files changed, 3000 insertions(+), 3000 deletions(-) diff --git a/examples/examples_test.go b/examples/examples_test.go index 8b305b2a3c9d..386fd9777904 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{}, @@ -121,7 +121,7 @@ func TestExampleObjectSchemas(t *testing.T) { "../test/integration/testdata": { // TODO fix this test to handle json and yaml "project-request-template-with-quota": nil, // skip a yaml file - "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 ffeccc884c80..160e54eed633 100644 --- a/pkg/api/install/install.go +++ b/pkg/api/install/install.go @@ -37,7 +37,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" @@ -47,7 +47,7 @@ import ( templateapi "github.com/openshift/origin/pkg/template/apis/template" userapi "github.com/openshift/origin/pkg/user/apis/user" - deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" authorizationv1 "github.com/openshift/origin/pkg/authorization/apis/authorization/v1" buildv1 "github.com/openshift/origin/pkg/build/apis/build/v1" imagev1 "github.com/openshift/origin/pkg/image/apis/image/v1" @@ -301,15 +301,15 @@ func init() { return true, templatev1.Convert_template_BrokerTemplateInstanceList_To_v1_BrokerTemplateInstanceList(a, b, s) } - case *deployv1.DeploymentConfig: + case *appsapiv1.DeploymentConfig: switch b := objB.(type) { - case *deployapi.DeploymentConfig: - return true, deployv1.Convert_v1_DeploymentConfig_To_apps_DeploymentConfig(a, b, s) + case *appsapi.DeploymentConfig: + return true, appsapiv1.Convert_v1_DeploymentConfig_To_apps_DeploymentConfig(a, b, s) } - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: switch b := objB.(type) { - case *deployv1.DeploymentConfig: - return true, deployv1.Convert_apps_DeploymentConfig_To_v1_DeploymentConfig(a, b, s) + case *appsapiv1.DeploymentConfig: + return true, appsapiv1.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 9adb36a448c2..aaa91b1b1acf 100644 --- a/pkg/api/meta/pods.go +++ b/pkg/api/meta/pods.go @@ -17,8 +17,8 @@ import ( "k8s.io/kubernetes/pkg/apis/extensions" extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" - 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" securityapi "github.com/openshift/origin/pkg/security/apis/security" securityapiv1 "github.com/openshift/origin/pkg/security/apis/security/v1" ) @@ -63,8 +63,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"), @@ -114,7 +114,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 } @@ -157,7 +157,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 } @@ -197,7 +197,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 } @@ -227,7 +227,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 a0a096ac2487..22eb98682e2c 100644 --- a/pkg/api/serialization_test.go +++ b/pkg/api/serialization_test.go @@ -18,14 +18,14 @@ import ( "k8s.io/kubernetes/pkg/api/validation" _ "github.com/openshift/origin/pkg/api/latest" - deploy "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" - build "github.com/openshift/origin/pkg/build/apis/build" - image "github.com/openshift/origin/pkg/image/apis/image" + buildapi "github.com/openshift/origin/pkg/build/apis/build" + imageapi "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 @@ -168,13 +168,13 @@ 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.Fuzz(&j.ObjectMeta) c.Fuzz(&j.Parameters) // TODO: replace with structured type definition j.Objects = []runtime.Object{} }, - func(j *image.Image, c fuzz.Continue) { + func(j *imageapi.Image, c fuzz.Continue) { c.Fuzz(&j.ObjectMeta) c.Fuzz(&j.DockerImageMetadata) c.Fuzz(&j.Signatures) @@ -183,7 +183,7 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { j.DockerImageMetadataVersion = []string{"pre012", "1.0"}[c.Rand.Intn(2)] j.DockerImageReference = c.RandString() }, - func(j *image.ImageSignature, c fuzz.Continue) { + func(j *imageapi.ImageSignature, c fuzz.Continue) { c.FuzzNoCustom(j) j.Conditions = nil j.ImageIdentity = "" @@ -192,75 +192,75 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { j.IssuedBy = nil j.IssuedTo = nil }, - func(j *image.ImageStream, c fuzz.Continue) { + func(j *imageapi.ImageStream, c fuzz.Continue) { c.FuzzNoCustom(j) for k, v := range j.Spec.Tags { if len(v.ReferencePolicy.Type) == 0 { - v.ReferencePolicy.Type = image.SourceTagReferencePolicy + v.ReferencePolicy.Type = imageapi.SourceTagReferencePolicy j.Spec.Tags[k] = v } } }, - func(j *image.ImageStreamMapping, c fuzz.Continue) { + func(j *imageapi.ImageStreamMapping, c fuzz.Continue) { c.FuzzNoCustom(j) j.DockerImageRepository = "" }, - func(j *image.ImageImportSpec, c fuzz.Continue) { + func(j *imageapi.ImageImportSpec, c fuzz.Continue) { c.FuzzNoCustom(j) if j.To == nil { // To is defaulted to be not nil j.To = &kapi.LocalObjectReference{} } }, - func(j *image.ImageStreamImage, c fuzz.Continue) { + func(j *imageapi.ImageStreamImage, c fuzz.Continue) { c.Fuzz(&j.Image) // because we de-embedded Image from ImageStreamImage, in order to round trip // successfully, the ImageStreamImage's ObjectMeta must match the Image's. j.ObjectMeta = j.Image.ObjectMeta }, - func(j *image.ImageStreamSpec, c fuzz.Continue) { + func(j *imageapi.ImageStreamSpec, c fuzz.Continue) { c.FuzzNoCustom(j) // if the generated fuzz value has a tag or image id, strip it if strings.ContainsAny(j.DockerImageRepository, ":@") { j.DockerImageRepository = "" } if j.Tags == nil { - j.Tags = make(map[string]image.TagReference) + j.Tags = make(map[string]imageapi.TagReference) } for k, v := range j.Tags { v.Name = k j.Tags[k] = v } }, - func(j *image.ImageStreamStatus, c fuzz.Continue) { + func(j *imageapi.ImageStreamStatus, c fuzz.Continue) { c.FuzzNoCustom(j) // if the generated fuzz value has a tag or image id, strip it if strings.ContainsAny(j.DockerImageRepository, ":@") { j.DockerImageRepository = "" } }, - func(j *image.ImageStreamTag, c fuzz.Continue) { + func(j *imageapi.ImageStreamTag, c fuzz.Continue) { c.Fuzz(&j.Image) // because we de-embedded Image from ImageStreamTag, in order to round trip // successfully, the ImageStreamTag's ObjectMeta must match the Image's. j.ObjectMeta = j.Image.ObjectMeta }, - func(j *image.TagReference, c fuzz.Continue) { + func(j *imageapi.TagReference, c fuzz.Continue) { c.FuzzNoCustom(j) if j.From != nil { specs := []string{"", "ImageStreamTag", "ImageStreamImage"} j.From.Kind = specs[c.Intn(len(specs))] } }, - func(j *image.TagReferencePolicy, c fuzz.Continue) { + func(j *imageapi.TagReferencePolicy, c fuzz.Continue) { c.FuzzNoCustom(j) - j.Type = image.SourceTagReferencePolicy + j.Type = imageapi.SourceTagReferencePolicy }, - func(j *build.BuildConfigSpec, c fuzz.Continue) { + func(j *buildapi.BuildConfigSpec, c fuzz.Continue) { c.FuzzNoCustom(j) - j.RunPolicy = build.BuildRunPolicySerial + j.RunPolicy = buildapi.BuildRunPolicySerial }, - func(j *build.SourceBuildStrategy, c fuzz.Continue) { + func(j *buildapi.SourceBuildStrategy, c fuzz.Continue) { c.FuzzNoCustom(j) j.From.Kind = "ImageStreamTag" j.From.Name = "image:tag" @@ -268,7 +268,7 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { j.From.ResourceVersion = "" j.From.FieldPath = "" }, - func(j *build.CustomBuildStrategy, c fuzz.Continue) { + func(j *buildapi.CustomBuildStrategy, c fuzz.Continue) { c.FuzzNoCustom(j) j.From.Kind = "ImageStreamTag" j.From.Name = "image:tag" @@ -276,7 +276,7 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { j.From.ResourceVersion = "" j.From.FieldPath = "" }, - func(j *build.DockerBuildStrategy, c fuzz.Continue) { + func(j *buildapi.DockerBuildStrategy, c fuzz.Continue) { c.FuzzNoCustom(j) if j.From != nil { j.From.Kind = "ImageStreamTag" @@ -286,7 +286,7 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { j.From.FieldPath = "" } }, - func(j *build.BuildOutput, c fuzz.Continue) { + func(j *buildapi.BuildOutput, c fuzz.Continue) { c.FuzzNoCustom(j) if j.To != nil && (len(j.To.Kind) == 0 || j.To.Kind == "ImageStream") { j.To.Kind = "ImageStreamTag" @@ -295,21 +295,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 *appsapi.DeploymentConfig, c fuzz.Continue) { c.FuzzNoCustom(j) - j.Spec.Triggers = []deploy.DeploymentTriggerPolicy{{Type: deploy.DeploymentTriggerOnConfigChange}} + j.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{{Type: appsapi.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 { @@ -323,48 +323,48 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { } } }, - func(j *deploy.DeploymentStrategy, c fuzz.Continue) { + func(j *appsapi.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 := []appsapi.DeploymentStrategyType{appsapi.DeploymentStrategyTypeRecreate, appsapi.DeploymentStrategyTypeRolling, appsapi.DeploymentStrategyTypeCustom} j.Type = strategyTypes[c.Rand.Intn(len(strategyTypes))] j.ActiveDeadlineSeconds = randInt64() switch j.Type { - case deploy.DeploymentStrategyTypeRecreate: - params := &deploy.RecreateDeploymentStrategyParams{} + case appsapi.DeploymentStrategyTypeRecreate: + params := &appsapi.RecreateDeploymentStrategyParams{} c.Fuzz(params) if params.TimeoutSeconds == nil { s := int64(120) params.TimeoutSeconds = &s } j.RecreateParams = params - case deploy.DeploymentStrategyTypeRolling: - params := &deploy.RollingDeploymentStrategyParams{} + case appsapi.DeploymentStrategyTypeRolling: + params := &appsapi.RollingDeploymentStrategyParams{} params.TimeoutSeconds = randInt64() params.IntervalSeconds = randInt64() params.UpdatePeriodSeconds = randInt64() - policyTypes := []deploy.LifecycleHookFailurePolicy{ - deploy.LifecycleHookFailurePolicyRetry, - deploy.LifecycleHookFailurePolicyAbort, - deploy.LifecycleHookFailurePolicyIgnore, + policyTypes := []appsapi.LifecycleHookFailurePolicy{ + appsapi.LifecycleHookFailurePolicyRetry, + appsapi.LifecycleHookFailurePolicyAbort, + appsapi.LifecycleHookFailurePolicyIgnore, } if c.RandBool() { - params.Pre = &deploy.LifecycleHook{ + params.Pre = &appsapi.LifecycleHook{ FailurePolicy: policyTypes[c.Rand.Intn(len(policyTypes))], - ExecNewPod: &deploy.ExecNewPodHook{ + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: c.RandString(), }, } } if c.RandBool() { - params.Post = &deploy.LifecycleHook{ + params.Post = &appsapi.LifecycleHook{ FailurePolicy: policyTypes[c.Rand.Intn(len(policyTypes))], - ExecNewPod: &deploy.ExecNewPodHook{ + ExecNewPod: &appsapi.ExecNewPodHook{ ContainerName: c.RandString(), }, } @@ -379,16 +379,16 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { j.RollingParams = params } }, - func(j *deploy.DeploymentCauseImageTrigger, c fuzz.Continue) { + func(j *appsapi.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"} j.From.Name = specs[c.Intn(len(specs))] if len(j.From.Name) > 0 { - j.From.Name = image.JoinImageStreamTag(j.From.Name, tags[c.Intn(len(tags))]) + j.From.Name = imageapi.JoinImageStreamTag(j.From.Name, tags[c.Intn(len(tags))]) } }, - func(j *deploy.DeploymentTriggerImageChangeParams, c fuzz.Continue) { + func(j *appsapi.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" @@ -426,16 +426,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 } }, @@ -492,7 +492,7 @@ func originFuzzer(t *testing.T, seed int64) *fuzz.Fuzzer { return f } -func defaultHookContainerName(hook *deploy.LifecycleHook, containerName string) { +func defaultHookContainerName(hook *appsapi.LifecycleHook, containerName string) { if hook == nil { return } @@ -527,8 +527,8 @@ func TestSpecificKind(t *testing.T) { } var dockerImageTypes = map[schema.GroupVersionKind]bool{ - image.SchemeGroupVersion.WithKind("DockerImage"): true, - image.LegacySchemeGroupVersion.WithKind("DockerImage"): true, + imageapi.SchemeGroupVersion.WithKind("DockerImage"): true, + imageapi.LegacySchemeGroupVersion.WithKind("DockerImage"): true, } // TestRoundTripTypes applies the round-trip test to all round-trippable Kinds 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/apigroup.go b/pkg/apps/apis/apps/install/apigroup.go index f29b6a97cf7e..10668e3b7336 100644 --- a/pkg/apps/apis/apps/install/apigroup.go +++ b/pkg/apps/apis/apps/install/apigroup.go @@ -6,8 +6,8 @@ import ( "k8s.io/apimachinery/pkg/runtime" kapi "k8s.io/kubernetes/pkg/api" - 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" ) func installApiGroup() { @@ -18,13 +18,13 @@ func installApiGroup() { 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}, + GroupName: appsapi.GroupName, + VersionPreferenceOrder: []string{appsapiv1.SchemeGroupVersion.Version}, ImportPrefix: importPrefix, - AddInternalObjectsToScheme: deployapi.AddToScheme, + 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/install/install.go b/pkg/apps/apis/apps/install/install.go index c30fb14d90f2..5cef257bda4a 100644 --- a/pkg/apps/apis/apps/install/install.go +++ b/pkg/apps/apis/apps/install/install.go @@ -12,8 +12,8 @@ import ( "k8s.io/apimachinery/pkg/util/sets" kapi "k8s.io/kubernetes/pkg/api" - 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" ) const importPrefix = "github.com/openshift/origin/pkg/apps/apis/apps" @@ -21,7 +21,7 @@ const importPrefix = "github.com/openshift/origin/pkg/apps/apis/apps" var accessor = meta.NewAccessor() // availableVersions lists all known external versions for this group from most preferred to least preferred -var availableVersions = []schema.GroupVersion{deployapiv1.LegacySchemeGroupVersion} +var availableVersions = []schema.GroupVersion{appsapiv1.LegacySchemeGroupVersion} func init() { kapi.Registry.RegisterVersions(availableVersions) @@ -32,7 +32,7 @@ func init() { } } if len(externalVersions) == 0 { - glog.Infof("No version is registered for group %v", deployapi.LegacyGroupName) + glog.Infof("No version is registered for group %v", appsapi.LegacyGroupName) return } @@ -70,7 +70,7 @@ func enableVersions(externalVersions []schema.GroupVersion) error { func addVersionsToScheme(externalVersions ...schema.GroupVersion) { // add the internal version to Scheme - deployapi.AddToSchemeInCoreGroup(kapi.Scheme) + appsapi.AddToSchemeInCoreGroup(kapi.Scheme) // add the enabled external versions to Scheme for _, v := range externalVersions { if !kapi.Registry.IsEnabledVersion(v) { @@ -78,8 +78,8 @@ func addVersionsToScheme(externalVersions ...schema.GroupVersion) { continue } switch v { - case deployapiv1.LegacySchemeGroupVersion: - deployapiv1.AddToSchemeInCoreGroup(kapi.Scheme) + case appsapiv1.LegacySchemeGroupVersion: + appsapiv1.AddToSchemeInCoreGroup(kapi.Scheme) default: glog.Errorf("Version %s is not known, so it will not be added to the Scheme.", v) @@ -96,14 +96,14 @@ func newRESTMapper(externalVersions []schema.GroupVersion) meta.RESTMapper { func interfacesFor(version schema.GroupVersion) (*meta.VersionInterfaces, error) { switch version { - case deployapiv1.LegacySchemeGroupVersion: + case appsapiv1.LegacySchemeGroupVersion: return &meta.VersionInterfaces{ ObjectConvertor: kapi.Scheme, MetadataAccessor: accessor, }, nil default: - g, _ := kapi.Registry.Group(deployapi.LegacyGroupName) + g, _ := kapi.Registry.Group(appsapi.LegacyGroupName) return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions) } } diff --git a/pkg/apps/apis/apps/test/ok.go b/pkg/apps/apis/apps/test/ok.go index dbe23f50f916..dd3ba1754b11 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" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployv1 "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" 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), @@ -191,16 +191,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", @@ -213,30 +213,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}, @@ -251,9 +251,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 } @@ -274,13 +274,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 @@ -291,16 +291,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, appsapiv1.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 b3f033237f37..44b699af95a7 100644 --- a/pkg/apps/apis/apps/v1/defaults.go +++ b/pkg/apps/apis/apps/v1/defaults.go @@ -3,16 +3,16 @@ package v1 import ( "k8s.io/apimachinery/pkg/util/intstr" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) // 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 } } @@ -66,9 +66,9 @@ func SetDefaults_DeploymentStrategy(obj *DeploymentStrategy) { if obj.Type == DeploymentStrategyTypeRolling && obj.RollingParams == nil { obj.RollingParams = &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 == DeploymentStrategyTypeRecreate && obj.RecreateParams == nil { @@ -76,27 +76,27 @@ func SetDefaults_DeploymentStrategy(obj *DeploymentStrategy) { } if obj.ActiveDeadlineSeconds == nil { - obj.ActiveDeadlineSeconds = mkintp(deployapi.MaxDeploymentDurationSeconds) + obj.ActiveDeadlineSeconds = mkintp(appsapi.MaxDeploymentDurationSeconds) } } func SetDefaults_RecreateDeploymentStrategyParams(obj *RecreateDeploymentStrategyParams) { if obj.TimeoutSeconds == nil { - obj.TimeoutSeconds = mkintp(deployapi.DefaultRecreateTimeoutSeconds) + obj.TimeoutSeconds = mkintp(appsapi.DefaultRecreateTimeoutSeconds) } } func SetDefaults_RollingDeploymentStrategyParams(obj *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 fc25a1add18b..1383394a331f 100644 --- a/pkg/apps/apis/apps/v1/defaults_test.go +++ b/pkg/apps/apis/apps/v1/defaults_test.go @@ -13,9 +13,9 @@ import ( _ "k8s.io/kubernetes/pkg/api/install" kapiv1 "k8s.io/kubernetes/pkg/api/v1" - 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" - deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" ) func mkintp(i int64) *int64 { @@ -26,55 +26,55 @@ func TestDefaults(t *testing.T) { defaultIntOrString := intstr.FromString("25%") differentIntOrString := intstr.FromInt(5) tests := []struct { - original *deployv1.DeploymentConfig - expected *deployv1.DeploymentConfig + original *appsapiv1.DeploymentConfig + expected *appsapiv1.DeploymentConfig }{ { - original: &deployv1.DeploymentConfig{}, - expected: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ - UpdatePeriodSeconds: newInt64(deployapi.DefaultRollingUpdatePeriodSeconds), - IntervalSeconds: newInt64(deployapi.DefaultRollingIntervalSeconds), - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + original: &appsapiv1.DeploymentConfig{}, + expected: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ + 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: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ { - Type: deployv1.DeploymentTriggerOnConfigChange, + Type: appsapiv1.DeploymentTriggerOnConfigChange, }, }, }, }, }, { - original: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRecreate, - RecreateParams: &deployv1.RecreateDeploymentStrategyParams{ - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), - Pre: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{}, {}}, + original: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapiv1.RecreateDeploymentStrategyParams{ + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), + Pre: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{}, {}}, }, - Mid: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{}, {}}, + Mid: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{}, {}}, }, - Post: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{}, {}}, + Post: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{}, {}}, }, }, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ - Pre: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{}, {}}, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ + Pre: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{}, {}}, }, - Post: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{}, {}}, + Post: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{}, {}}, }, UpdatePeriodSeconds: newInt64(5), IntervalSeconds: newInt64(6), @@ -83,9 +83,9 @@ func TestDefaults(t *testing.T) { MaxUnavailable: &differentIntOrString, }, }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ { - Type: deployv1.DeploymentTriggerOnImageChange, + Type: appsapiv1.DeploymentTriggerOnImageChange, }, }, Template: &kapiv1.PodTemplateSpec{ @@ -99,28 +99,28 @@ func TestDefaults(t *testing.T) { }, }, }, - expected: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRecreate, - RecreateParams: &deployv1.RecreateDeploymentStrategyParams{ - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), - Pre: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{ContainerName: "test"}, {ContainerName: "test"}}, + expected: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapiv1.RecreateDeploymentStrategyParams{ + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), + Pre: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{ContainerName: "test"}, {ContainerName: "test"}}, }, - Mid: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{ContainerName: "test"}, {ContainerName: "test"}}, + Mid: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{ContainerName: "test"}, {ContainerName: "test"}}, }, - Post: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{ContainerName: "test"}, {ContainerName: "test"}}, + Post: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{ContainerName: "test"}, {ContainerName: "test"}}, }, }, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ - Pre: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{ContainerName: "test"}, {ContainerName: "test"}}, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ + Pre: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{ContainerName: "test"}, {ContainerName: "test"}}, }, - Post: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{ContainerName: "test"}, {ContainerName: "test"}}, + Post: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{ContainerName: "test"}, {ContainerName: "test"}}, }, UpdatePeriodSeconds: newInt64(5), IntervalSeconds: newInt64(6), @@ -128,11 +128,11 @@ func TestDefaults(t *testing.T) { MaxSurge: &differentIntOrString, MaxUnavailable: &differentIntOrString, }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ { - Type: deployv1.DeploymentTriggerOnImageChange, + Type: appsapiv1.DeploymentTriggerOnImageChange, }, }, Template: &kapiv1.PodTemplateSpec{ @@ -159,11 +159,11 @@ func TestDefaults(t *testing.T) { }, }, { - original: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ + original: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ UpdatePeriodSeconds: newInt64(5), IntervalSeconds: newInt64(6), TimeoutSeconds: newInt64(7), @@ -171,18 +171,18 @@ func TestDefaults(t *testing.T) { }, ActiveDeadlineSeconds: newInt64(3600), }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ { - Type: deployv1.DeploymentTriggerOnImageChange, + Type: appsapiv1.DeploymentTriggerOnImageChange, }, }, }, }, - expected: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ + expected: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ UpdatePeriodSeconds: newInt64(5), IntervalSeconds: newInt64(6), TimeoutSeconds: newInt64(7), @@ -191,179 +191,179 @@ func TestDefaults(t *testing.T) { }, ActiveDeadlineSeconds: newInt64(3600), }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ { - Type: deployv1.DeploymentTriggerOnImageChange, + Type: appsapiv1.DeploymentTriggerOnImageChange, }, }, }, }, }, { - original: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ + original: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ UpdatePeriodSeconds: newInt64(5), IntervalSeconds: newInt64(6), TimeoutSeconds: newInt64(7), MaxUnavailable: newIntOrString(intstr.FromString("25%")), }, }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ { - Type: deployv1.DeploymentTriggerOnImageChange, + Type: appsapiv1.DeploymentTriggerOnImageChange, }, }, }, }, - expected: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ + expected: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ UpdatePeriodSeconds: newInt64(5), IntervalSeconds: newInt64(6), TimeoutSeconds: newInt64(7), MaxSurge: newIntOrString(intstr.FromInt(0)), MaxUnavailable: newIntOrString(intstr.FromString("25%")), }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ { - Type: deployv1.DeploymentTriggerOnImageChange, + Type: appsapiv1.DeploymentTriggerOnImageChange, }, }, }, }, }, { - original: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ + original: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ UpdatePeriodSeconds: newInt64(5), IntervalSeconds: newInt64(6), TimeoutSeconds: newInt64(7), MaxSurge: newIntOrString(intstr.FromInt(0)), }, }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, - expected: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ + expected: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ UpdatePeriodSeconds: newInt64(5), IntervalSeconds: newInt64(6), TimeoutSeconds: newInt64(7), MaxUnavailable: newIntOrString(intstr.FromString("25%")), MaxSurge: newIntOrString(intstr.FromInt(0)), }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, }, { - original: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{}, + original: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{}, }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, - expected: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ - IntervalSeconds: newInt64(deployapi.DefaultRollingIntervalSeconds), - UpdatePeriodSeconds: newInt64(deployapi.DefaultRollingUpdatePeriodSeconds), - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + expected: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ + 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: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, }, { - original: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRecreate, + original: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRecreate, // test non-nil RecreateParams is filled in - RecreateParams: &deployv1.RecreateDeploymentStrategyParams{}, + RecreateParams: &appsapiv1.RecreateDeploymentStrategyParams{}, }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, - expected: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRecreate, - RecreateParams: &deployv1.RecreateDeploymentStrategyParams{ - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + expected: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapiv1.RecreateDeploymentStrategyParams{ + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, }, { - original: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRecreate, + original: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRecreate, // test nil RecreateParams }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, - expected: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRecreate, - RecreateParams: &deployv1.RecreateDeploymentStrategyParams{ - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + expected: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapiv1.RecreateDeploymentStrategyParams{ + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, }, { - original: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ + original: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ Template: &kapiv1.PodTemplateSpec{ Spec: kapiv1.PodSpec{ Containers: []kapiv1.Container{ @@ -371,30 +371,30 @@ func TestDefaults(t *testing.T) { }, }, }, - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRecreate, - RecreateParams: &deployv1.RecreateDeploymentStrategyParams{ - Pre: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{}}, - ExecNewPod: &deployv1.ExecNewPodHook{}, + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapiv1.RecreateDeploymentStrategyParams{ + Pre: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{}}, + ExecNewPod: &appsapiv1.ExecNewPodHook{}, }, - Mid: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{}}, - ExecNewPod: &deployv1.ExecNewPodHook{}, + Mid: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{}}, + ExecNewPod: &appsapiv1.ExecNewPodHook{}, }, - Post: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{}}, - ExecNewPod: &deployv1.ExecNewPodHook{}, + Post: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{}}, + ExecNewPod: &appsapiv1.ExecNewPodHook{}, }, }, }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, - expected: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ + expected: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ Template: &kapiv1.PodTemplateSpec{ Spec: kapiv1.PodSpec{ Containers: []kapiv1.Container{ @@ -412,34 +412,34 @@ func TestDefaults(t *testing.T) { SchedulerName: kapiv1.DefaultSchedulerName, }, }, - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRecreate, - RecreateParams: &deployv1.RecreateDeploymentStrategyParams{ - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), - Pre: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{ContainerName: "first"}}, - ExecNewPod: &deployv1.ExecNewPodHook{ContainerName: "first"}, + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRecreate, + RecreateParams: &appsapiv1.RecreateDeploymentStrategyParams{ + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), + Pre: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{ContainerName: "first"}}, + ExecNewPod: &appsapiv1.ExecNewPodHook{ContainerName: "first"}, }, - Mid: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{ContainerName: "first"}}, - ExecNewPod: &deployv1.ExecNewPodHook{ContainerName: "first"}, + Mid: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{ContainerName: "first"}}, + ExecNewPod: &appsapiv1.ExecNewPodHook{ContainerName: "first"}, }, - Post: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{ContainerName: "first"}}, - ExecNewPod: &deployv1.ExecNewPodHook{ContainerName: "first"}, + Post: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{ContainerName: "first"}}, + ExecNewPod: &appsapiv1.ExecNewPodHook{ContainerName: "first"}, }, }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, }, { - original: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ + original: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ Template: &kapiv1.PodTemplateSpec{ Spec: kapiv1.PodSpec{ Containers: []kapiv1.Container{ @@ -447,26 +447,26 @@ func TestDefaults(t *testing.T) { }, }, }, - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ - Pre: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{}}, - ExecNewPod: &deployv1.ExecNewPodHook{}, + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ + Pre: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{}}, + ExecNewPod: &appsapiv1.ExecNewPodHook{}, }, - Post: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{}}, - ExecNewPod: &deployv1.ExecNewPodHook{}, + Post: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{}}, + ExecNewPod: &appsapiv1.ExecNewPodHook{}, }, }, }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, - expected: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ + expected: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ Template: &kapiv1.PodTemplateSpec{ Spec: kapiv1.PodSpec{ Containers: []kapiv1.Container{ @@ -484,59 +484,59 @@ func TestDefaults(t *testing.T) { SchedulerName: kapiv1.DefaultSchedulerName, }, }, - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ - UpdatePeriodSeconds: newInt64(deployapi.DefaultRollingUpdatePeriodSeconds), - IntervalSeconds: newInt64(deployapi.DefaultRollingIntervalSeconds), - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ + UpdatePeriodSeconds: newInt64(appsapi.DefaultRollingUpdatePeriodSeconds), + IntervalSeconds: newInt64(appsapi.DefaultRollingIntervalSeconds), + TimeoutSeconds: newInt64(appsapi.DefaultRollingTimeoutSeconds), MaxSurge: &defaultIntOrString, MaxUnavailable: &defaultIntOrString, - Pre: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{ContainerName: "first"}}, - ExecNewPod: &deployv1.ExecNewPodHook{ContainerName: "first"}, + Pre: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{ContainerName: "first"}}, + ExecNewPod: &appsapiv1.ExecNewPodHook{ContainerName: "first"}, }, - Post: &deployv1.LifecycleHook{ - TagImages: []deployv1.TagImageHook{{ContainerName: "first"}}, - ExecNewPod: &deployv1.ExecNewPodHook{ContainerName: "first"}, + Post: &appsapiv1.LifecycleHook{ + TagImages: []appsapiv1.TagImageHook{{ContainerName: "first"}}, + ExecNewPod: &appsapiv1.ExecNewPodHook{ContainerName: "first"}, }, }, - ActiveDeadlineSeconds: newInt64(deployapi.MaxDeploymentDurationSeconds), + ActiveDeadlineSeconds: newInt64(appsapi.MaxDeploymentDurationSeconds), }, - Triggers: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ {}, }, }, }, }, { - original: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Triggers: []deployv1.DeploymentTriggerPolicy{ + original: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ { - Type: deployv1.DeploymentTriggerOnImageChange, - ImageChangeParams: &deployv1.DeploymentTriggerImageChangeParams{}, + Type: appsapiv1.DeploymentTriggerOnImageChange, + ImageChangeParams: &appsapiv1.DeploymentTriggerImageChangeParams{}, }, }, }, }, - expected: &deployv1.DeploymentConfig{ - Spec: deployv1.DeploymentConfigSpec{ - Strategy: deployv1.DeploymentStrategy{ - Type: deployv1.DeploymentStrategyTypeRolling, - RollingParams: &deployv1.RollingDeploymentStrategyParams{ - UpdatePeriodSeconds: newInt64(deployapi.DefaultRollingUpdatePeriodSeconds), - IntervalSeconds: newInt64(deployapi.DefaultRollingIntervalSeconds), - TimeoutSeconds: newInt64(deployapi.DefaultRollingTimeoutSeconds), + expected: &appsapiv1.DeploymentConfig{ + Spec: appsapiv1.DeploymentConfigSpec{ + Strategy: appsapiv1.DeploymentStrategy{ + Type: appsapiv1.DeploymentStrategyTypeRolling, + RollingParams: &appsapiv1.RollingDeploymentStrategyParams{ + 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: []deployv1.DeploymentTriggerPolicy{ + Triggers: []appsapiv1.DeploymentTriggerPolicy{ { - Type: deployv1.DeploymentTriggerOnImageChange, - ImageChangeParams: &deployv1.DeploymentTriggerImageChangeParams{ + Type: appsapiv1.DeploymentTriggerOnImageChange, + ImageChangeParams: &appsapiv1.DeploymentTriggerImageChangeParams{ From: kapiv1.ObjectReference{ Kind: "ImageStreamTag", }, @@ -553,7 +553,7 @@ func TestDefaults(t *testing.T) { original := test.original expected := test.expected obj2 := roundTrip(t, runtime.Object(original)) - got, ok := obj2.(*deployv1.DeploymentConfig) + got, ok := obj2.(*appsapiv1.DeploymentConfig) if !ok { t.Errorf("unexpected object: %v", got) t.FailNow() @@ -566,7 +566,7 @@ func TestDefaults(t *testing.T) { } func roundTrip(t *testing.T, obj runtime.Object) runtime.Object { - data, err := runtime.Encode(kapi.Codecs.LegacyCodec(deployv1.LegacySchemeGroupVersion), obj) + data, err := runtime.Encode(kapi.Codecs.LegacyCodec(appsapiv1.LegacySchemeGroupVersion), obj) if err != nil { t.Errorf("%v\n %#v", err, obj) return nil 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 7497cfbe90be..67cef6b985b9 100644 --- a/pkg/apps/cmd/delete.go +++ b/pkg/apps/cmd/delete.go @@ -13,7 +13,7 @@ import ( "k8s.io/kubernetes/pkg/kubectl" kutil "k8s.io/kubernetes/pkg/util" - 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" "github.com/openshift/origin/pkg/apps/util" @@ -31,11 +31,11 @@ type DeploymentConfigReaper struct { pollInterval, timeout time.Duration } -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 appsinternal.DeploymentConfigsGetter, namespace, name string, applyUpdate updateConfigFunc) (*deployapi.DeploymentConfig, error) { - var config *deployapi.DeploymentConfig +func updateConfigWithRetries(dn appsinternal.DeploymentConfigsGetter, namespace, name string, applyUpdate updateConfigFunc) (*appsapi.DeploymentConfig, error) { + var config *appsapi.DeploymentConfig resultErr := retry.RetryOnConflict(retry.DefaultBackoff, func() error { var err error @@ -53,8 +53,8 @@ func updateConfigWithRetries(dn appsinternal.DeploymentConfigsGetter, namespace, // pause marks the deployment configuration as paused to avoid triggering new // deployments. -func (reaper *DeploymentConfigReaper) pause(namespace, name string) (*deployapi.DeploymentConfig, error) { - return updateConfigWithRetries(reaper.appsClient.Apps(), namespace, name, func(d *deployapi.DeploymentConfig) { +func (reaper *DeploymentConfigReaper) pause(namespace, name string) (*appsapi.DeploymentConfig, error) { + return updateConfigWithRetries(reaper.appsClient.Apps(), namespace, name, func(d *appsapi.DeploymentConfig) { d.Spec.RevisionHistoryLimit = kutil.Int32Ptr(0) d.Spec.Replicas = 0 d.Spec.Paused = true diff --git a/pkg/apps/cmd/delete_test.go b/pkg/apps/cmd/delete_test.go index 8da703fc388a..7c7db8718be1 100644 --- a/pkg/apps/cmd/delete_test.go +++ b/pkg/apps/cmd/delete_test.go @@ -13,15 +13,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 } @@ -40,18 +40,18 @@ func TestStop(t *testing.T) { replicationControllerKind = schema.GroupVersionKind{Kind: "ReplicationController"} ) - pause := func(d *deployapi.DeploymentConfig) *deployapi.DeploymentConfig { + pause := func(d *appsapi.DeploymentConfig) *appsapi.DeploymentConfig { d.Spec.Paused = true return d } - 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), } tests := []struct { diff --git a/pkg/apps/cmd/generate.go b/pkg/apps/cmd/generate.go index 2d18af8846e1..58b857048985 100644 --- a/pkg/apps/cmd/generate.go +++ b/pkg/apps/cmd/generate.go @@ -8,7 +8,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/pkg/kubectl" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/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 d1a4e12f4408..c64c53c90781 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 40769d756d13..6f17be8de2c8 100755 --- a/pkg/apps/controller/deployer/deployer_controller.go +++ b/pkg/apps/controller/deployer/deployer_controller.go @@ -21,8 +21,8 @@ import ( kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/clientset/typed/core/v1" kcorelisters "k8s.io/kubernetes/pkg/client/listers/core/v1" - 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 } @@ -130,14 +130,14 @@ func (c *DeploymentController) handle(deployment *v1.ReplicationController, will 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) @@ -146,11 +146,11 @@ 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 - nextStatus = deployapi.DeploymentStatusPending - glog.V(4).Infof("Created deployer pod %q for %q", deploymentPod.Name, deployutil.LabelForDeploymentV1(deployment)) + updatedAnnotations[appsapi.DeploymentPodAnnotation] = deploymentPod.Name + 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: @@ -158,7 +158,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 @@ -169,39 +169,39 @@ 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 - nextStatus = nextStatusComp(nextStatus, deployapi.DeploymentStatusPending) + updatedAnnotations[appsapi.DeploymentPodAnnotation] = deployer.Name + 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 */ @@ -209,7 +209,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 } @@ -222,10 +222,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 } @@ -237,74 +237,74 @@ func (c *DeploymentController) handle(deployment *v1.ReplicationController, will } } - case deployapi.DeploymentStatusComplete: + case appsapi.DeploymentStatusComplete: if err := c.cleanupDeployerPods(deployment); err != nil { return err } } // Update only if we need to transition to a new phase. - if deployutil.CanTransitionPhase(currentStatus, nextStatus) { - deployment, err := deployutil.DeploymentDeepCopyV1(deployment) + if appsutil.CanTransitionPhase(currentStatus, nextStatus) { + deployment, err := appsutil.DeploymentDeepCopyV1(deployment) if err != nil { return err } - updatedAnnotations[deployapi.DeploymentStatusAnnotation] = string(nextStatus) + updatedAnnotations[appsapi.DeploymentStatusAnnotation] = string(nextStatus) deployment.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 *deployment.Spec.Replicas != 0 && deployutil.IsTerminatedDeployment(deployment) { - if config, err := deployutil.DecodeDeploymentConfig(deployment, c.codec); err == nil && config.Spec.Test { + if *deployment.Spec.Replicas != 0 && appsutil.IsTerminatedDeployment(deployment) { + if config, err := appsutil.DecodeDeploymentConfig(deployment, c.codec); err == nil && config.Spec.Test { zero := int32(0) deployment.Spec.Replicas = &zero } } if _, err := c.rn.ReplicationControllers(deployment.Namespace).Update(deployment); err != nil { - return fmt.Errorf("couldn't update rollout status for %q to %s: %v", deployutil.LabelForDeploymentV1(deployment), nextStatus, err) + return fmt.Errorf("couldn't update rollout status for %q to %s: %v", appsutil.LabelForDeploymentV1(deployment), nextStatus, err) } - glog.V(4).Infof("Updated rollout status for %q from %s to %s (scale: %d)", deployutil.LabelForDeploymentV1(deployment), currentStatus, nextStatus, deployment.Spec.Replicas) + glog.V(4).Infof("Updated rollout status for %q from %s to %s (scale: %d)", appsutil.LabelForDeploymentV1(deployment), currentStatus, nextStatus, deployment.Spec.Replicas) - if deployutil.IsDeploymentCancelled(deployment) && deployutil.IsFailedDeployment(deployment) { - c.emitDeploymentEvent(deployment, v1.EventTypeNormal, "RolloutCancelled", fmt.Sprintf("Rollout for %q cancelled", deployutil.LabelForDeploymentV1(deployment))) + if appsutil.IsDeploymentCancelled(deployment) && appsutil.IsFailedDeployment(deployment) { + c.emitDeploymentEvent(deployment, v1.EventTypeNormal, "RolloutCancelled", fmt.Sprintf("Rollout for %q cancelled", appsutil.LabelForDeploymentV1(deployment))) } } 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. - 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: - return deployapi.DeploymentStatusFailed + return appsapi.DeploymentStatusFailed } - return deployapi.DeploymentStatusNew + return appsapi.DeploymentStatusNew } -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 @@ -313,7 +313,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 } @@ -329,7 +329,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) } @@ -338,12 +338,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 @@ -363,7 +363,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, @@ -397,7 +397,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 @@ -411,7 +411,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) } @@ -433,13 +433,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()...) @@ -492,7 +492,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 @@ -500,19 +500,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 0cbae6c3d022..b5e6bfcc9c91 100644 --- a/pkg/apps/controller/deployer/deployer_controller_test.go +++ b/pkg/apps/controller/deployer/deployer_controller_test.go @@ -19,16 +19,16 @@ import ( "k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake" kinformers "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions" - 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" - deployapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" - deployutil "github.com/openshift/origin/pkg/apps/util" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + 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 } @@ -67,7 +67,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 } @@ -79,16 +79,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 @@ -98,7 +98,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"), @@ -133,10 +133,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"} controller := okDeploymentController(client, nil, nil, true, v1.PodUnknown) @@ -149,7 +149,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) } @@ -157,19 +157,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) } @@ -181,8 +181,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] @@ -224,9 +224,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) controller := okDeploymentController(client, nil, nil, true, v1.PodUnknown) @@ -248,41 +248,41 @@ 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) - deployerPodName := deployutil.DeployerPodNameForDeployment(deployment.Name) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) + deployerPodName := appsutil.DeployerPodNameForDeployment(deployment.Name) client := &fake.Clientset{} client.AddReactor("create", "pods", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) { @@ -302,12 +302,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) } } @@ -319,9 +319,9 @@ 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) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) + config := appstest.OkDeploymentConfig(1) + deployment, _ := appsutil.MakeDeploymentV1(config, codec) + 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) { @@ -340,15 +340,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) } } @@ -359,9 +359,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) one := int32(1) deployment.Spec.Replicas = &one @@ -382,15 +382,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 { @@ -406,33 +406,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) controller := okDeploymentController(client, deployment, nil, true, test.podPhase) @@ -474,11 +474,11 @@ 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) 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) @@ -516,9 +516,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) controller := okDeploymentController(client, deployment, hookPods, true, v1.PodSucceeded) hookPods = append(hookPods, deployment.Name) @@ -560,11 +560,11 @@ 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) 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) @@ -604,13 +604,13 @@ func TestHandle_cleanupPodNoop(t *testing.T) { }) // Verify no-op - 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) 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 { @@ -635,9 +635,9 @@ func TestHandle_cleanupPodFail(t *testing.T) { }) // Verify error - 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) controller := okDeploymentController(client, deployment, nil, true, v1.PodSucceeded) @@ -666,9 +666,9 @@ func TestHandle_cancelNew(t *testing.T) { return true, rc, nil }) - deployment, _ := deployutil.MakeDeploymentV1(deploytest.OkDeploymentConfig(1), codec) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) - deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue + deployment, _ := appsutil.MakeDeploymentV1(appstest.OkDeploymentConfig(1), codec) + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(appsapi.DeploymentStatusNew) + deployment.Annotations[appsapi.DeploymentCancelledAnnotation] = appsapi.DeploymentCancelledAnnotationValue controller := okDeploymentController(client, deployment, nil, true, v1.PodRunning) @@ -676,7 +676,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) } } @@ -687,9 +687,9 @@ func TestHandle_cleanupNewWithDeployers(t *testing.T) { var updatedDeployment *v1.ReplicationController deletedDeployer := false - deployment, _ := deployutil.MakeDeploymentV1(deploytest.OkDeploymentConfig(1), codec) - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(deployapi.DeploymentStatusNew) - deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue + deployment, _ := appsutil.MakeDeploymentV1(appstest.OkDeploymentConfig(1), codec) + 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) { @@ -712,7 +712,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 { @@ -728,7 +728,7 @@ func TestHandle_cleanupPostNew(t *testing.T) { tests := []struct { name string - deploymentPhase deployapi.DeploymentStatus + deploymentPhase appsapi.DeploymentStatus podPhase v1.PodPhase expected int @@ -736,7 +736,7 @@ func TestHandle_cleanupPostNew(t *testing.T) { { name: "pending", - deploymentPhase: deployapi.DeploymentStatusPending, + deploymentPhase: appsapi.DeploymentStatusPending, podPhase: v1.PodPending, expected: len(hookPods) + 1, @@ -744,7 +744,7 @@ func TestHandle_cleanupPostNew(t *testing.T) { { name: "running", - deploymentPhase: deployapi.DeploymentStatusRunning, + deploymentPhase: appsapi.DeploymentStatusRunning, podPhase: v1.PodRunning, expected: len(hookPods) + 1, @@ -752,7 +752,7 @@ func TestHandle_cleanupPostNew(t *testing.T) { { name: "failed", - deploymentPhase: deployapi.DeploymentStatusFailed, + deploymentPhase: appsapi.DeploymentStatusFailed, podPhase: v1.PodFailed, expected: len(hookPods) + 1, @@ -760,7 +760,7 @@ func TestHandle_cleanupPostNew(t *testing.T) { { name: "complete", - deploymentPhase: deployapi.DeploymentStatusComplete, + deploymentPhase: appsapi.DeploymentStatusComplete, podPhase: v1.PodSucceeded, expected: len(hookPods) + 1, @@ -781,9 +781,9 @@ func TestHandle_cleanupPostNew(t *testing.T) { return true, nil, nil }) - deployment, _ := deployutil.MakeDeploymentV1(deploytest.OkDeploymentConfig(1), codec) - deployment.Annotations[deployapi.DeploymentCancelledAnnotation] = deployapi.DeploymentCancelledAnnotationValue - deployment.Annotations[deployapi.DeploymentStatusAnnotation] = string(test.deploymentPhase) + deployment, _ := appsutil.MakeDeploymentV1(appstest.OkDeploymentConfig(1), codec) + deployment.Annotations[appsapi.DeploymentCancelledAnnotation] = appsapi.DeploymentCancelledAnnotationValue + deployment.Annotations[appsapi.DeploymentStatusAnnotation] = string(test.deploymentPhase) controller := okDeploymentController(client, deployment, hookPods, true, test.podPhase) @@ -805,25 +805,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, }, } @@ -839,12 +839,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) updatedDeployment = deployment controller := okDeploymentController(client, nil, nil, true, v1.PodUnknown) @@ -869,14 +869,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 } } @@ -888,81 +888,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, }, } @@ -978,8 +978,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) controller := okDeploymentController(client, deployment, nil, true, test.podPhase) @@ -993,7 +993,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) } } @@ -1016,24 +1016,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) { @@ -1047,11 +1047,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") diff --git a/pkg/apps/controller/deployer/factory.go b/pkg/apps/controller/deployer/factory.go index 0749ce1605de..183489fb729f 100644 --- a/pkg/apps/controller/deployer/factory.go +++ b/pkg/apps/controller/deployer/factory.go @@ -20,7 +20,7 @@ import ( kcoreinformers "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions/core/v1" kcontroller "k8s.io/kubernetes/pkg/controller" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" ) const ( @@ -57,7 +57,7 @@ func NewDeployerController( serviceAccount: sa, deployerImage: image, - environment: deployutil.CopyApiEnvVarToV1EnvVar(env), + environment: appsutil.CopyApiEnvVarToV1EnvVar(env), recorder: recorder, codec: codec, } @@ -101,7 +101,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 } @@ -117,7 +117,7 @@ func (c *DeploymentController) updateReplicationController(old, cur interface{}) } // Filter out all unrelated replication controllers. - if !deployutil.IsOwnedByConfig(curRC) { + if !appsutil.IsOwnedByConfig(curRC) { return } @@ -167,7 +167,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 515eafb2de7d..2b6a46eb04bb 100644 --- a/pkg/apps/controller/deploymentconfig/deploymentconfig_controller.go +++ b/pkg/apps/controller/deploymentconfig/deploymentconfig_controller.go @@ -21,9 +21,9 @@ import ( "k8s.io/kubernetes/pkg/client/retry" 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" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsutil "github.com/openshift/origin/pkg/apps/util" oscache "github.com/openshift/origin/pkg/client/cache" ) @@ -82,7 +82,7 @@ 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 config.Status.LatestVersion == 0 { @@ -95,7 +95,7 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) if err != nil { return fmt.Errorf("error while deploymentConfigController listing replication controllers: %v", err) } - selector := deployutil.ConfigSelector(config.Name) + selector := appsutil.ConfigSelector(config.Name) // If any adoptions are attempted, we should first recheck for deletion with // an uncached quorum read sometime after listing ReplicationControllers (see Kubernetes #42639). canAdoptFunc := kcontroller.RecheckDeletionTimestamp(func() (metav1.Object, error) { @@ -108,7 +108,7 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) } return fresh, nil }) - cm := NewRCControllerRefManager(c.rcControl, config, selector, deployutil.DeploymentConfigControllerRefKind, canAdoptFunc) + cm := NewRCControllerRefManager(c.rcControl, config, selector, 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 the latest deployment doesn't exist yet, cancel any running // deployments to allow them to be superceded by the new config version. awaitingCancellations := false @@ -129,12 +129,12 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) 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 } @@ -157,12 +157,12 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) return nil } - copied, err := deployutil.DeploymentDeepCopyV1(rc) + copied, err := appsutil.DeploymentDeepCopyV1(rc) if err != nil { return err } - 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 }); err != nil { @@ -178,14 +178,14 @@ func (c *DeploymentConfigController) Handle(config *deployapi.DeploymentConfig) // 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)) } // If the latest deployment already exists, reconcile existing deployments // and return early. 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) } @@ -203,9 +203,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 { @@ -232,9 +232,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) @@ -246,7 +246,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) } @@ -256,8 +256,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. @@ -278,7 +278,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 } @@ -303,7 +303,7 @@ func (c *DeploymentConfigController) reconcileDeployments(existingDeployments [] ) } - copied, err = deployutil.DeploymentDeepCopyV1(rc) + copied, err = appsutil.DeploymentDeepCopyV1(rc) if err != nil { return err } @@ -334,7 +334,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 @@ -343,7 +343,7 @@ func (c *DeploymentConfigController) updateStatus(config *deployapi.DeploymentCo return nil } - copied, err := deployutil.DeploymentConfigDeepCopy(config) + copied, err := appsutil.DeploymentConfigDeepCopy(config) if err != nil { return err } @@ -353,7 +353,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) + @@ -362,84 +362,84 @@ func (c *DeploymentConfigController) updateStatus(config *deployapi.DeploymentCo 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) } } } @@ -468,13 +468,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 diff --git a/pkg/apps/controller/deploymentconfig/deploymentconfig_controller_test.go b/pkg/apps/controller/deploymentconfig/deploymentconfig_controller_test.go index 88b4f6f23d08..532f79e78c4a 100644 --- a/pkg/apps/controller/deploymentconfig/deploymentconfig_controller_test.go +++ b/pkg/apps/controller/deploymentconfig/deploymentconfig_controller_test.go @@ -20,12 +20,12 @@ import ( "k8s.io/kubernetes/pkg/client/clientset_generated/clientset/fake" kinformers "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions" - 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" - deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" 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 alwaysReady() bool { return true } @@ -41,26 +41,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(appsapiv1.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 @@ -99,7 +99,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, }, @@ -109,10 +109,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, }, @@ -122,11 +122,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, }, @@ -136,12 +136,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, }, @@ -151,10 +151,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, }, @@ -164,12 +164,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, }, @@ -179,10 +179,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, }, @@ -192,18 +192,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, }, @@ -213,18 +213,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, }, @@ -234,12 +234,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, }, @@ -249,12 +249,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, }, @@ -264,12 +264,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, }, @@ -279,12 +279,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, }, @@ -294,12 +294,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, }, @@ -309,12 +309,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, }, @@ -324,12 +324,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, }, @@ -338,7 +338,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 { @@ -349,7 +349,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 }) @@ -364,7 +364,7 @@ func TestHandleScenarios(t *testing.T) { deployments[rc.Name] = rc return true, rc, nil }) - codec := kapi.Codecs.LegacyCodec(deployv1.SchemeGroupVersion) + codec := kapi.Codecs.LegacyCodec(appsapiv1.SchemeGroupVersion) dcInformer := cache.NewSharedIndexInformer( &cache.ListWatch{ @@ -375,7 +375,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}, ) @@ -390,9 +390,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" @@ -410,8 +410,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 @@ -434,21 +434,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, }, }, @@ -456,12 +456,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, } ) @@ -469,7 +469,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, @@ -486,10 +486,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", @@ -501,13 +501,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, }, }, @@ -521,14 +521,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 ef68d68a182e..586530db585d 100644 --- a/pkg/apps/controller/deploymentconfig/factory.go +++ b/pkg/apps/controller/deploymentconfig/factory.go @@ -19,7 +19,7 @@ import ( kcoreinformers "k8s.io/kubernetes/pkg/client/informers/informers_generated/externalversions/core/v1" 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" ) @@ -99,15 +99,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 } @@ -117,14 +117,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 @@ -175,7 +175,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)) @@ -214,7 +214,7 @@ func (c *DeploymentConfigController) work() bool { return false } -func (c *DeploymentConfigController) getByKey(key string) (*deployapi.DeploymentConfig, error) { +func (c *DeploymentConfigController) getByKey(key string) (*appsapi.DeploymentConfig, error) { obj, exists, err := c.dcStore.Indexer.GetByKey(key) if err != nil { c.queue.AddRateLimited(key) @@ -225,5 +225,5 @@ func (c *DeploymentConfigController) getByKey(key string) (*deployapi.Deployment return nil, nil } - return obj.(*deployapi.DeploymentConfig), nil + return obj.(*appsapi.DeploymentConfig), nil } diff --git a/pkg/apps/controller/generictrigger/deploy_generictrigger_controller.go b/pkg/apps/controller/generictrigger/deploy_generictrigger_controller.go index eca82a6408d6..bae7409d0056 100644 --- a/pkg/apps/controller/generictrigger/deploy_generictrigger_controller.go +++ b/pkg/apps/controller/generictrigger/deploy_generictrigger_controller.go @@ -7,7 +7,7 @@ import ( kcorelister "k8s.io/kubernetes/pkg/client/listers/core/v1" "github.com/golang/glog" - 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" oscache "github.com/openshift/origin/pkg/client/cache" ) @@ -45,18 +45,18 @@ type DeploymentTriggerController struct { } // Handle processes deployment triggers for a deployment config. -func (c *DeploymentTriggerController) Handle(config *deployapi.DeploymentConfig) error { +func (c *DeploymentTriggerController) Handle(config *appsapi.DeploymentConfig) error { if len(config.Spec.Triggers) == 0 || config.Spec.Paused { return nil } - request := &deployapi.DeploymentRequest{ + request := &appsapi.DeploymentRequest{ Name: config.Name, Latest: true, Force: false, } if !c.triggerFromImages { - request.ExcludeTriggers = []deployapi.DeploymentTriggerType{deployapi.DeploymentTriggerOnImageChange} + request.ExcludeTriggers = []appsapi.DeploymentTriggerType{appsapi.DeploymentTriggerOnImageChange} } _, err := c.dn.DeploymentConfigs(config.Namespace).Instantiate(config.Name, request) diff --git a/pkg/apps/controller/generictrigger/deploy_generictrigger_controller_test.go b/pkg/apps/controller/generictrigger/deploy_generictrigger_controller_test.go index 4613f34a2c55..a7a637eb9e51 100644 --- a/pkg/apps/controller/generictrigger/deploy_generictrigger_controller_test.go +++ b/pkg/apps/controller/generictrigger/deploy_generictrigger_controller_test.go @@ -12,17 +12,17 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/client/clientset_generated/clientset/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" testapi "github.com/openshift/origin/pkg/apps/apis/apps/test" - deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" appsfake "github.com/openshift/origin/pkg/apps/generated/internalclientset/fake" 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) + codec = kapi.Codecs.LegacyCodec(appsapiv1.SchemeGroupVersion) dcInformer = cache.NewSharedIndexInformer( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { @@ -32,7 +32,7 @@ var ( return (appsfake.NewSimpleClientset()).Apps().DeploymentConfigs(metav1.NamespaceAll).Watch(options) }, }, - &deployapi.DeploymentConfig{}, + &appsapi.DeploymentConfig{}, 2*time.Minute, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, ) @@ -73,7 +73,7 @@ func TestHandle_noTriggers(t *testing.T) { config := testapi.OkDeploymentConfig(1) config.Namespace = metav1.NamespaceDefault - config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{} + config.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{} if err := controller.Handle(config); err != nil { t.Fatalf("unexpected error: %v", err) } @@ -116,7 +116,7 @@ func TestHandle_configChangeTrigger(t *testing.T) { config := testapi.OkDeploymentConfig(0) config.Namespace = metav1.NamespaceDefault - config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{testapi.OkConfigChangeTrigger()} + config.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{testapi.OkConfigChangeTrigger()} if err := controller.Handle(config); err != nil { t.Fatalf("unexpected error: %v", err) } @@ -142,7 +142,7 @@ func TestHandle_imageChangeTrigger(t *testing.T) { config := testapi.OkDeploymentConfig(0) config.Namespace = metav1.NamespaceDefault - config.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{testapi.OkImageChangeTrigger()} + config.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{testapi.OkImageChangeTrigger()} if err := controller.Handle(config); err != nil { t.Fatalf("unexpected error: %v", err) } diff --git a/pkg/apps/controller/generictrigger/factory.go b/pkg/apps/controller/generictrigger/factory.go index 9700b985bf44..be5e7f470516 100644 --- a/pkg/apps/controller/generictrigger/factory.go +++ b/pkg/apps/controller/generictrigger/factory.go @@ -15,9 +15,9 @@ import ( kcorelisters "k8s.io/kubernetes/pkg/client/listers/core/v1" 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" - 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" ) @@ -93,7 +93,7 @@ func (c *DeploymentTriggerController) waitForSyncedStore(ready chan<- struct{}, } func (c *DeploymentTriggerController) addDeploymentConfig(obj interface{}) { - dc := obj.(*deployapi.DeploymentConfig) + dc := obj.(*appsapi.DeploymentConfig) // No need to enqueue deployment configs that have no triggers or are paused. if len(dc.Spec.Triggers) == 0 || dc.Spec.Paused { @@ -101,7 +101,7 @@ func (c *DeploymentTriggerController) addDeploymentConfig(obj interface{}) { } // We don't want to compete with the main deployment config controller. Let's process this // config once it's synced. - if !deployutil.HasSynced(dc, dc.Generation) { + if !appsutil.HasSynced(dc, dc.Generation) { return } @@ -109,8 +109,8 @@ func (c *DeploymentTriggerController) addDeploymentConfig(obj interface{}) { } func (c *DeploymentTriggerController) updateDeploymentConfig(old, cur interface{}) { - newDc := cur.(*deployapi.DeploymentConfig) - oldDc := old.(*deployapi.DeploymentConfig) + newDc := cur.(*appsapi.DeploymentConfig) + oldDc := old.(*appsapi.DeploymentConfig) // A periodic relist will send update events for all known deployment configs. if newDc.ResourceVersion == oldDc.ResourceVersion { @@ -124,7 +124,7 @@ func (c *DeploymentTriggerController) updateDeploymentConfig(old, cur interface{ // config once it's synced. Note that this does not eliminate conflicts between the two // controllers because the main controller is constantly updating deployment configs as // owning replication controllers and pods are updated. - if !deployutil.HasSynced(newDc, newDc.Generation) { + if !appsutil.HasSynced(newDc, newDc.Generation) { return } // Enqueue the deployment config if it hasn't been deployed yet. @@ -136,15 +136,15 @@ func (c *DeploymentTriggerController) updateDeploymentConfig(old, cur interface{ // we will try to instantiate a deployment config at the expense of duplicating some of the // work that the instantiate endpoint is already doing but I think this is fine. shouldInstantiate := true - latestRc, err := c.rcLister.ReplicationControllers(newDc.Namespace).Get(deployutil.LatestDeploymentNameForConfig(newDc)) + latestRc, err := c.rcLister.ReplicationControllers(newDc.Namespace).Get(appsutil.LatestDeploymentNameForConfig(newDc)) if err != nil { // If we get an error here it may be due to the rc cache lagging behind. In such a case // just defer to the api server (instantiate REST) where we will retry this. - glog.V(4).Infof("Cannot get latest rc for dc %s:%d (%v) - will defer to instantiate", deployutil.LabelForDeploymentConfig(newDc), newDc.Status.LatestVersion, err) + glog.V(4).Infof("Cannot get latest rc for dc %s:%d (%v) - will defer to instantiate", appsutil.LabelForDeploymentConfig(newDc), newDc.Status.LatestVersion, err) } else { - initial, err := deployutil.DecodeDeploymentConfig(latestRc, c.codec) + initial, err := appsutil.DecodeDeploymentConfig(latestRc, c.codec) if err != nil { - glog.V(2).Infof("Cannot decode dc from replication controller %s: %v", deployutil.LabelForDeploymentV1(latestRc), err) + glog.V(2).Infof("Cannot decode dc from replication controller %s: %v", appsutil.LabelForDeploymentV1(latestRc), err) return } shouldInstantiate = !reflect.DeepEqual(newDc.Spec.Template, initial.Spec.Template) @@ -192,7 +192,7 @@ func (c *DeploymentTriggerController) updateImageStream(old, cur interface{}) { } } -func (c *DeploymentTriggerController) enqueueDeploymentConfig(dc *deployapi.DeploymentConfig) { +func (c *DeploymentTriggerController) 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)) @@ -231,7 +231,7 @@ func (c *DeploymentTriggerController) work() bool { return false } -func (c *DeploymentTriggerController) getByKey(key string) (*deployapi.DeploymentConfig, error) { +func (c *DeploymentTriggerController) getByKey(key string) (*appsapi.DeploymentConfig, error) { obj, exists, err := c.dcLister.Indexer.GetByKey(key) if err != nil { c.queue.AddRateLimited(key) @@ -242,5 +242,5 @@ func (c *DeploymentTriggerController) getByKey(key string) (*deployapi.Deploymen return nil, nil } - return obj.(*deployapi.DeploymentConfig), nil + return obj.(*appsapi.DeploymentConfig), nil } 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_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 475e37360c25..01c63dbf5af0 100644 --- a/pkg/apps/graph/nodes/types.go +++ b/pkg/apps/graph/nodes/types.go @@ -4,20 +4,20 @@ import ( "reflect" 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 ( - DeploymentConfigNodeKind = reflect.TypeOf(deployapi.DeploymentConfig{}).Name() + DeploymentConfigNodeKind = reflect.TypeOf(appsapi.DeploymentConfig{}).Name() ) -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 1ba789c284fa..10464b005d5e 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 939353be58d7..6c7e1d79d311 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.Warning("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 614999d0ab87..e42e3a4ca98c 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" ) @@ -32,9 +32,9 @@ var _ rest.StandardStorage = &REST{} 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, @@ -77,7 +77,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. @@ -86,9 +86,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 @@ -120,7 +120,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 d207225a244f..4c58a75a1c4f 100644 --- a/pkg/apps/registry/deployconfig/strategy.go +++ b/pkg/apps/registry/deployconfig/strategy.go @@ -11,8 +11,8 @@ import ( "k8s.io/apiserver/pkg/storage/names" kapi "k8s.io/kubernetes/pkg/api" - 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" "github.com/openshift/origin/pkg/apps/apis/apps/validation" ) @@ -54,9 +54,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 { @@ -67,8 +67,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 @@ -98,12 +98,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. @@ -135,8 +135,8 @@ type groupStrategy struct { func (s groupStrategy) PrepareForCreate(ctx apirequest.Context, obj runtime.Object) { s.strategy.PrepareForCreate(ctx, obj) - dc := obj.(*deployapi.DeploymentConfig) - deployapiv1.AppsV1DeploymentConfigLayeredDefaults(dc) + dc := obj.(*appsapi.DeploymentConfig) + appsapiv1.AppsV1DeploymentConfigLayeredDefaults(dc) } // statusStrategy implements behavior for DeploymentConfig status updates. @@ -148,13 +148,13 @@ 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)) } 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 6efea24e5bf3..470938ae512e 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 9af4e4cb40ff..ad280a52f880 100644 --- a/pkg/apps/registry/instantiate/rest.go +++ b/pkg/apps/registry/instantiate/rest.go @@ -20,9 +20,9 @@ import ( kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" "k8s.io/kubernetes/pkg/client/retry" - 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 da44758fb96f..9b9306e9950c 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" - 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" - deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" - deployutil "github.com/openshift/origin/pkg/apps/util" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + 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(appsapiv1.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 1f3c3710103e..b5d8ca37ce95 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" - 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" - deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" - deployutil "github.com/openshift/origin/pkg/apps/util" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + 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(appsapiv1.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(appsapiv1.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(appsapiv1.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(appsapiv1.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(appsapiv1.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(appsapiv1.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(appsapiv1.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(appsapiv1.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(appsapiv1.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(appsapiv1.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 a5c5fe8b7b73..cb7aebc01cb0 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" - 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" - deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" 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(appsapiv1.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(appsapiv1.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 da2fd7c4222e..df491b7d355f 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" ) @@ -113,12 +113,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 @@ -141,7 +141,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) } } @@ -170,7 +170,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) } } @@ -226,7 +226,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 52a1e1b55468..765a980b5caa 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" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" - deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" 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(appsapiv1.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 1ff8f6ace550..76d581d4deda 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" ) @@ -120,9 +120,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 @@ -136,7 +136,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) } } @@ -149,7 +149,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) } } @@ -165,7 +165,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) } } @@ -250,7 +250,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 93fdc0e62bb3..3d2a4c9f1d35 100644 --- a/pkg/apps/strategy/support/lifecycle.go +++ b/pkg/apps/strategy/support/lifecycle.go @@ -19,9 +19,9 @@ 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" + 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 } @@ -400,11 +400,11 @@ func makeHookPod(hook *deployapi.LifecycleHook, rc *kapi.ReplicationController, ObjectMeta: metav1.ObjectMeta{ Name: namer.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 b62cf25889a0..4e71edce4b6f 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" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" - deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" - 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" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsutil "github.com/openshift/origin/pkg/apps/util" "github.com/openshift/origin/pkg/util/namer" _ "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(appsapiv1.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(appsapiv1.SchemeGroupVersion)) deployment.Spec.Template.Spec.NodeSelector = map[string]string{"labelKey1": "labelValue1", "labelKey2": "labelValue2"} client := newTestClient(config) @@ -142,21 +142,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(appsapiv1.SchemeGroupVersion)) client := newTestClient(config) podCreated := make(chan struct{}) @@ -198,15 +198,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(appsapiv1.SchemeGroupVersion)) _, err := makeHookPod(hook, deployment, &config.Spec.Strategy, "hook", nowFunc().Time) if err == nil { @@ -217,21 +217,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{ @@ -251,11 +251,11 @@ func TestHookExecutor_makeHookPod(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: namer.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{ @@ -320,9 +320,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", }, }, @@ -330,11 +330,11 @@ func TestHookExecutor_makeHookPod(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: namer.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{ @@ -379,9 +379,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", }, }, @@ -389,13 +389,13 @@ func TestHookExecutor_makeHookPod(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: namer.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{ @@ -438,16 +438,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", }, }, @@ -455,11 +455,11 @@ func TestHookExecutor_makeHookPod(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: namer.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{ @@ -520,15 +520,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(appsapiv1.SchemeGroupVersion)) pod, err := makeHookPod(hook, deployment, &config.Spec.Strategy, "hook", nowFunc().Time) if err != nil { @@ -540,20 +540,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"), @@ -618,7 +618,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(appsapiv1.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 5b9cf79cb9a1..a024a79acb94 100644 --- a/pkg/apps/util/util.go +++ b/pkg/apps/util/util.go @@ -20,8 +20,8 @@ import ( kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" kdeplutil "k8s.io/kubernetes/pkg/controller/deployment/util" - 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" "github.com/openshift/origin/pkg/util/namer" ) @@ -29,12 +29,12 @@ 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(), @@ -45,7 +45,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 { @@ -57,7 +57,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 @@ -71,13 +71,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 @@ -88,14 +88,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 } @@ -157,7 +157,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) } @@ -173,28 +173,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 } } @@ -203,21 +203,21 @@ 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 } } return false } -func DeploymentConfigDeepCopy(dc *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) { +func DeploymentConfigDeepCopy(dc *appsapi.DeploymentConfig) (*appsapi.DeploymentConfig, error) { objCopy, err := api.Scheme.DeepCopy(dc) if err != nil { return nil, err } - copied, ok := objCopy.(*deployapi.DeploymentConfig) + copied, ok := objCopy.(*appsapi.DeploymentConfig) if !ok { return nil, fmt.Errorf("expected DeploymentConfig, got %#v", objCopy) } @@ -278,13 +278,13 @@ func CopyApiEnvVarToV1EnvVar(in []api.EnvVar) []v1.EnvVar { // 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") } @@ -292,7 +292,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 @@ -300,7 +300,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{ @@ -316,7 +316,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 @@ -332,7 +332,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 @@ -361,7 +361,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 @@ -370,23 +370,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) @@ -395,13 +395,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}, @@ -421,10 +421,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 @@ -479,39 +479,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 } @@ -519,13 +519,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 } @@ -533,7 +533,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 } @@ -546,36 +546,36 @@ func IsTerminatedDeployment(deployment runtime.Object) bool { // 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 } } @@ -583,13 +583,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 @@ -597,7 +597,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) } @@ -607,7 +607,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) } @@ -642,7 +642,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)) diff --git a/pkg/apps/util/util_test.go b/pkg/apps/util/util_test.go index 34d4fdfc6882..bc664c5cffcd 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" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" - deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" _ "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(appsapiv1.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(appsapiv1.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(appsapiv1.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(), }, diff --git a/pkg/client/cache/deploymentconfig.go b/pkg/client/cache/deploymentconfig.go index d81c25786290..066aa1d3a77a 100644 --- a/pkg/client/cache/deploymentconfig.go +++ b/pkg/client/cache/deploymentconfig.go @@ -7,8 +7,8 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/kubernetes/pkg/api/v1" - 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" ) @@ -18,53 +18,53 @@ type StoreToDeploymentConfigLister struct { } // List all deploymentconfigs in the store. -func (s *StoreToDeploymentConfigLister) List() ([]*deployapi.DeploymentConfig, error) { - configs := []*deployapi.DeploymentConfig{} +func (s *StoreToDeploymentConfigLister) List() ([]*appsapi.DeploymentConfig, error) { + configs := []*appsapi.DeploymentConfig{} for _, c := range s.Indexer.List() { - configs = append(configs, c.(*deployapi.DeploymentConfig)) + configs = append(configs, c.(*appsapi.DeploymentConfig)) } return configs, nil } // GetConfigForController returns the managing deployment config for the provided replication controller. -func (s *StoreToDeploymentConfigLister) GetConfigForController(rc *v1.ReplicationController) (*deployapi.DeploymentConfig, error) { - dcName := deployutil.DeploymentConfigNameFor(rc) +func (s *StoreToDeploymentConfigLister) GetConfigForController(rc *v1.ReplicationController) (*appsapi.DeploymentConfig, error) { + dcName := appsutil.DeploymentConfigNameFor(rc) obj, exists, err := s.Indexer.GetByKey(rc.Namespace + "/" + dcName) if err != nil { return nil, err } if !exists { - return nil, kapierrors.NewNotFound(deployapi.Resource("deploymentconfig"), dcName) + return nil, kapierrors.NewNotFound(appsapi.Resource("deploymentconfig"), dcName) } - return obj.(*deployapi.DeploymentConfig), nil + return obj.(*appsapi.DeploymentConfig), nil } // GetConfigForPod returns the managing deployment config for the provided pod. -func (s *StoreToDeploymentConfigLister) GetConfigForPod(pod *v1.Pod) (*deployapi.DeploymentConfig, error) { - dcName := deployutil.DeploymentConfigNameFor(pod) +func (s *StoreToDeploymentConfigLister) GetConfigForPod(pod *v1.Pod) (*appsapi.DeploymentConfig, error) { + dcName := appsutil.DeploymentConfigNameFor(pod) obj, exists, err := s.Indexer.GetByKey(pod.Namespace + "/" + dcName) if err != nil { return nil, err } if !exists { - return nil, kapierrors.NewNotFound(deployapi.Resource("deploymentconfig"), dcName) + return nil, kapierrors.NewNotFound(appsapi.Resource("deploymentconfig"), dcName) } - return obj.(*deployapi.DeploymentConfig), nil + return obj.(*appsapi.DeploymentConfig), nil } // GetConfigsForImageStream returns all the deployment configs that point to the provided image stream // by searching through using the ImageStreamReferenceIndex (deployment configs are indexed in the cache // by namespace and by image stream references). -func (s *StoreToDeploymentConfigLister) GetConfigsForImageStream(stream *imageapi.ImageStream) ([]*deployapi.DeploymentConfig, error) { +func (s *StoreToDeploymentConfigLister) GetConfigsForImageStream(stream *imageapi.ImageStream) ([]*appsapi.DeploymentConfig, error) { items, err := s.Indexer.ByIndex(ImageStreamReferenceIndex, stream.Namespace+"/"+stream.Name) if err != nil { return nil, err } - var configs []*deployapi.DeploymentConfig + var configs []*appsapi.DeploymentConfig for _, obj := range items { - config := obj.(*deployapi.DeploymentConfig) + config := obj.(*appsapi.DeploymentConfig) configs = append(configs, config) } @@ -82,26 +82,26 @@ type storeDeploymentConfigsNamespacer struct { } // Get the deployment config matching the name from the cache. -func (s storeDeploymentConfigsNamespacer) Get(name string, options metav1.GetOptions) (*deployapi.DeploymentConfig, error) { +func (s storeDeploymentConfigsNamespacer) Get(name string, options metav1.GetOptions) (*appsapi.DeploymentConfig, error) { obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) if err != nil { return nil, err } if !exists { - return nil, kapierrors.NewNotFound(deployapi.Resource("deploymentconfig"), name) + return nil, kapierrors.NewNotFound(appsapi.Resource("deploymentconfig"), name) } - return obj.(*deployapi.DeploymentConfig), nil + return obj.(*appsapi.DeploymentConfig), nil } // List all the deploymentconfigs that match the provided selector using a namespace index. // If the indexed list fails then we will fallback to listing from all namespaces and filter // by the namespace we want. -func (s storeDeploymentConfigsNamespacer) List(selector labels.Selector) ([]*deployapi.DeploymentConfig, error) { - configs := []*deployapi.DeploymentConfig{} +func (s storeDeploymentConfigsNamespacer) List(selector labels.Selector) ([]*appsapi.DeploymentConfig, error) { + configs := []*appsapi.DeploymentConfig{} if s.namespace == metav1.NamespaceAll { for _, obj := range s.indexer.List() { - dc := obj.(*deployapi.DeploymentConfig) + dc := obj.(*appsapi.DeploymentConfig) if selector.Matches(labels.Set(dc.Labels)) { configs = append(configs, dc) } @@ -114,7 +114,7 @@ func (s storeDeploymentConfigsNamespacer) List(selector labels.Selector) ([]*dep return nil, err } for _, obj := range items { - dc := obj.(*deployapi.DeploymentConfig) + dc := obj.(*appsapi.DeploymentConfig) if selector.Matches(labels.Set(dc.Labels)) { configs = append(configs, dc) } diff --git a/pkg/client/cache/index.go b/pkg/client/cache/index.go index 4b41c97ec27c..9cd89a753178 100644 --- a/pkg/client/cache/index.go +++ b/pkg/client/cache/index.go @@ -3,7 +3,7 @@ package cache import ( "fmt" - 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" buildutil "github.com/openshift/origin/pkg/build/util" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -53,10 +53,10 @@ func ImageStreamReferenceIndexFunc(obj interface{}) ([]string, error) { keys = append(keys, "") } return keys, nil - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: var keys []string for _, trigger := range t.Spec.Triggers { - if trigger.Type != deployapi.DeploymentTriggerOnImageChange { + if trigger.Type != appsapi.DeploymentTriggerOnImageChange { continue } params := trigger.ImageChangeParams diff --git a/pkg/client/deploymentconfigs.go b/pkg/client/deploymentconfigs.go index 1845b0a2df59..a216c0704a4b 100644 --- a/pkg/client/deploymentconfigs.go +++ b/pkg/client/deploymentconfigs.go @@ -8,7 +8,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) // DeploymentConfigsNamespacer has methods to work with DeploymentConfig resources in a namespace @@ -18,19 +18,19 @@ type DeploymentConfigsNamespacer interface { // DeploymentConfigInterface contains methods for working with DeploymentConfigs type DeploymentConfigInterface interface { - List(opts metav1.ListOptions) (*deployapi.DeploymentConfigList, error) - Get(name string, options metav1.GetOptions) (*deployapi.DeploymentConfig, error) - Create(config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) - Update(config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *deployapi.DeploymentConfig, err error) + List(opts metav1.ListOptions) (*appsapi.DeploymentConfigList, error) + Get(name string, options metav1.GetOptions) (*appsapi.DeploymentConfig, error) + Create(config *appsapi.DeploymentConfig) (*appsapi.DeploymentConfig, error) + Update(config *appsapi.DeploymentConfig) (*appsapi.DeploymentConfig, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *appsapi.DeploymentConfig, err error) Delete(name string) error Watch(opts metav1.ListOptions) (watch.Interface, error) - Rollback(config *deployapi.DeploymentConfigRollback) (*deployapi.DeploymentConfig, error) - RollbackDeprecated(config *deployapi.DeploymentConfigRollback) (*deployapi.DeploymentConfig, error) + Rollback(config *appsapi.DeploymentConfigRollback) (*appsapi.DeploymentConfig, error) + RollbackDeprecated(config *appsapi.DeploymentConfigRollback) (*appsapi.DeploymentConfig, error) GetScale(name string) (*extensionsv1beta1.Scale, error) UpdateScale(scale *extensionsv1beta1.Scale) (*extensionsv1beta1.Scale, error) - UpdateStatus(config *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) - Instantiate(request *deployapi.DeploymentRequest) (*deployapi.DeploymentConfig, error) + UpdateStatus(config *appsapi.DeploymentConfig) (*appsapi.DeploymentConfig, error) + Instantiate(request *appsapi.DeploymentRequest) (*appsapi.DeploymentConfig, error) } // deploymentConfigs implements DeploymentConfigsNamespacer interface @@ -48,8 +48,8 @@ func newDeploymentConfigs(c *Client, namespace string) *deploymentConfigs { } // List takes a label and field selectors, and returns the list of deploymentConfigs that match that selectors -func (c *deploymentConfigs) List(opts metav1.ListOptions) (result *deployapi.DeploymentConfigList, err error) { - result = &deployapi.DeploymentConfigList{} +func (c *deploymentConfigs) List(opts metav1.ListOptions) (result *appsapi.DeploymentConfigList, err error) { + result = &appsapi.DeploymentConfigList{} err = c.r.Get(). Namespace(c.ns). Resource("deploymentConfigs"). @@ -60,30 +60,30 @@ func (c *deploymentConfigs) List(opts metav1.ListOptions) (result *deployapi.Dep } // Get returns information about a particular deploymentConfig -func (c *deploymentConfigs) Get(name string, options metav1.GetOptions) (result *deployapi.DeploymentConfig, err error) { - result = &deployapi.DeploymentConfig{} +func (c *deploymentConfigs) Get(name string, options metav1.GetOptions) (result *appsapi.DeploymentConfig, err error) { + result = &appsapi.DeploymentConfig{} err = c.r.Get().Namespace(c.ns).Resource("deploymentConfigs").Name(name).VersionedParams(&options, kapi.ParameterCodec).Do().Into(result) return } // Create creates a new deploymentConfig -func (c *deploymentConfigs) Create(deploymentConfig *deployapi.DeploymentConfig) (result *deployapi.DeploymentConfig, err error) { - result = &deployapi.DeploymentConfig{} +func (c *deploymentConfigs) Create(deploymentConfig *appsapi.DeploymentConfig) (result *appsapi.DeploymentConfig, err error) { + result = &appsapi.DeploymentConfig{} err = c.r.Post().Namespace(c.ns).Resource("deploymentConfigs").Body(deploymentConfig).Do().Into(result) return } // Update updates an existing deploymentConfig -func (c *deploymentConfigs) Update(deploymentConfig *deployapi.DeploymentConfig) (result *deployapi.DeploymentConfig, err error) { - result = &deployapi.DeploymentConfig{} +func (c *deploymentConfigs) Update(deploymentConfig *appsapi.DeploymentConfig) (result *appsapi.DeploymentConfig, err error) { + result = &appsapi.DeploymentConfig{} err = c.r.Put().Namespace(c.ns).Resource("deploymentConfigs").Name(deploymentConfig.Name).Body(deploymentConfig).Do().Into(result) return } // Patch takes the partial representation of a deployment config and updates it. // Returns the server's representation of the deployment config, and an error, if there is any. -func (c *deploymentConfigs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *deployapi.DeploymentConfig, err error) { - result = &deployapi.DeploymentConfig{} +func (c *deploymentConfigs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *appsapi.DeploymentConfig, err error) { + result = &appsapi.DeploymentConfig{} err = c.r.Patch(types.StrategicMergePatchType).Namespace(c.ns).Resource("deploymentConfigs").SubResource(subresources...).Name(name).Body(data).Do().Into(result) return } @@ -104,8 +104,8 @@ func (c *deploymentConfigs) Watch(opts metav1.ListOptions) (watch.Interface, err } // Rollback rolls a deploymentConfig back to a previous configuration -func (c *deploymentConfigs) Rollback(config *deployapi.DeploymentConfigRollback) (result *deployapi.DeploymentConfig, err error) { - result = &deployapi.DeploymentConfig{} +func (c *deploymentConfigs) Rollback(config *appsapi.DeploymentConfigRollback) (result *appsapi.DeploymentConfig, err error) { + result = &appsapi.DeploymentConfig{} err = c.r.Post(). Namespace(c.ns). Resource("deploymentConfigs"). @@ -118,8 +118,8 @@ func (c *deploymentConfigs) Rollback(config *deployapi.DeploymentConfigRollback) } // RollbackDeprecated rolls a deploymentConfig back to a previous configuration -func (c *deploymentConfigs) RollbackDeprecated(config *deployapi.DeploymentConfigRollback) (result *deployapi.DeploymentConfig, err error) { - result = &deployapi.DeploymentConfig{} +func (c *deploymentConfigs) RollbackDeprecated(config *appsapi.DeploymentConfigRollback) (result *appsapi.DeploymentConfig, err error) { + result = &appsapi.DeploymentConfig{} err = c.r.Post(). Namespace(c.ns). Resource("deploymentConfigRollbacks"). @@ -151,15 +151,15 @@ func (c *deploymentConfigs) UpdateScale(scale *extensionsv1beta1.Scale) (result } // UpdateStatus updates the status for an existing deploymentConfig. -func (c *deploymentConfigs) UpdateStatus(deploymentConfig *deployapi.DeploymentConfig) (result *deployapi.DeploymentConfig, err error) { - result = &deployapi.DeploymentConfig{} +func (c *deploymentConfigs) UpdateStatus(deploymentConfig *appsapi.DeploymentConfig) (result *appsapi.DeploymentConfig, err error) { + result = &appsapi.DeploymentConfig{} err = c.r.Put().Namespace(c.ns).Resource("deploymentConfigs").Name(deploymentConfig.Name).SubResource("status").Body(deploymentConfig).Do().Into(result) return } // Instantiate instantiates a new build from build config returning new object or an error -func (c *deploymentConfigs) Instantiate(request *deployapi.DeploymentRequest) (*deployapi.DeploymentConfig, error) { - result := &deployapi.DeploymentConfig{} +func (c *deploymentConfigs) Instantiate(request *appsapi.DeploymentRequest) (*appsapi.DeploymentConfig, error) { + result := &appsapi.DeploymentConfig{} resp := c.r.Post().Namespace(c.ns).Resource("deploymentConfigs").Name(request.Name).SubResource("instantiate").Body(request).Do() var statusCode int if resp.StatusCode(&statusCode); statusCode == 204 { diff --git a/pkg/client/deploymentlogs.go b/pkg/client/deploymentlogs.go index 5b18de8a6354..ccad48bece16 100644 --- a/pkg/client/deploymentlogs.go +++ b/pkg/client/deploymentlogs.go @@ -4,7 +4,7 @@ import ( restclient "k8s.io/client-go/rest" kapi "k8s.io/kubernetes/pkg/api" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) // DeploymentLogsNamespacer has methods to work with DeploymentLogs resources in a namespace @@ -14,7 +14,7 @@ type DeploymentLogsNamespacer interface { // DeploymentLogInterface exposes methods on DeploymentLogs resources. type DeploymentLogInterface interface { - Get(name string, opts deployapi.DeploymentLogOptions) *restclient.Request + Get(name string, opts appsapi.DeploymentLogOptions) *restclient.Request } // deploymentLogs implements DeploymentLogsNamespacer interface @@ -32,6 +32,6 @@ func newDeploymentLogs(c *Client, namespace string) *deploymentLogs { } // Get gets the deploymentlogs and return a deploymentLog request -func (c *deploymentLogs) Get(name string, opts deployapi.DeploymentLogOptions) *restclient.Request { +func (c *deploymentLogs) Get(name string, opts appsapi.DeploymentLogOptions) *restclient.Request { return c.r.Get().Namespace(c.ns).Resource("deploymentConfigs").Name(name).SubResource("log").VersionedParams(&opts, kapi.ParameterCodec) } diff --git a/pkg/client/testclient/fake_deploymentconfigs.go b/pkg/client/testclient/fake_deploymentconfigs.go index 975cd404ec16..475c123eaa17 100644 --- a/pkg/client/testclient/fake_deploymentconfigs.go +++ b/pkg/client/testclient/fake_deploymentconfigs.go @@ -8,7 +8,7 @@ import ( clientgotesting "k8s.io/client-go/testing" extensionsv1beta1 "k8s.io/kubernetes/pkg/apis/extensions/v1beta1" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) // FakeDeploymentConfigs implements DeploymentConfigInterface. Meant to be embedded into a struct to get a default @@ -21,48 +21,48 @@ type FakeDeploymentConfigs struct { var deploymentConfigsResource = schema.GroupVersionResource{Group: "", Version: "", Resource: "deploymentconfigs"} var deploymentConfigsKind = schema.GroupVersionKind{Group: "", Version: "", Kind: "DeploymentConfig"} -func (c *FakeDeploymentConfigs) Get(name string, options metav1.GetOptions) (*deployapi.DeploymentConfig, error) { - obj, err := c.Fake.Invokes(clientgotesting.NewGetAction(deploymentConfigsResource, c.Namespace, name), &deployapi.DeploymentConfig{}) +func (c *FakeDeploymentConfigs) Get(name string, options metav1.GetOptions) (*appsapi.DeploymentConfig, error) { + obj, err := c.Fake.Invokes(clientgotesting.NewGetAction(deploymentConfigsResource, c.Namespace, name), &appsapi.DeploymentConfig{}) if obj == nil { return nil, err } - return obj.(*deployapi.DeploymentConfig), err + return obj.(*appsapi.DeploymentConfig), err } -func (c *FakeDeploymentConfigs) List(opts metav1.ListOptions) (*deployapi.DeploymentConfigList, error) { - obj, err := c.Fake.Invokes(clientgotesting.NewListAction(deploymentConfigsResource, deploymentConfigsKind, c.Namespace, opts), &deployapi.DeploymentConfigList{}) +func (c *FakeDeploymentConfigs) List(opts metav1.ListOptions) (*appsapi.DeploymentConfigList, error) { + obj, err := c.Fake.Invokes(clientgotesting.NewListAction(deploymentConfigsResource, deploymentConfigsKind, c.Namespace, opts), &appsapi.DeploymentConfigList{}) if obj == nil { return nil, err } - return obj.(*deployapi.DeploymentConfigList), err + return obj.(*appsapi.DeploymentConfigList), err } -func (c *FakeDeploymentConfigs) Create(inObj *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) { +func (c *FakeDeploymentConfigs) Create(inObj *appsapi.DeploymentConfig) (*appsapi.DeploymentConfig, error) { obj, err := c.Fake.Invokes(clientgotesting.NewCreateAction(deploymentConfigsResource, c.Namespace, inObj), inObj) if obj == nil { return nil, err } - return obj.(*deployapi.DeploymentConfig), err + return obj.(*appsapi.DeploymentConfig), err } -func (c *FakeDeploymentConfigs) Update(inObj *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) { +func (c *FakeDeploymentConfigs) Update(inObj *appsapi.DeploymentConfig) (*appsapi.DeploymentConfig, error) { obj, err := c.Fake.Invokes(clientgotesting.NewUpdateAction(deploymentConfigsResource, c.Namespace, inObj), inObj) if obj == nil { return nil, err } - return obj.(*deployapi.DeploymentConfig), err + return obj.(*appsapi.DeploymentConfig), err } -func (c *FakeDeploymentConfigs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*deployapi.DeploymentConfig, error) { +func (c *FakeDeploymentConfigs) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (*appsapi.DeploymentConfig, error) { return nil, nil } func (c *FakeDeploymentConfigs) Delete(name string) error { - _, err := c.Fake.Invokes(clientgotesting.NewDeleteAction(deploymentConfigsResource, c.Namespace, name), &deployapi.DeploymentConfig{}) + _, err := c.Fake.Invokes(clientgotesting.NewDeleteAction(deploymentConfigsResource, c.Namespace, name), &appsapi.DeploymentConfig{}) return err } @@ -70,26 +70,26 @@ func (c *FakeDeploymentConfigs) Watch(opts metav1.ListOptions) (watch.Interface, return c.Fake.InvokesWatch(clientgotesting.NewWatchAction(deploymentConfigsResource, c.Namespace, opts)) } -func (c *FakeDeploymentConfigs) Rollback(inObj *deployapi.DeploymentConfigRollback) (result *deployapi.DeploymentConfig, err error) { - obj, err := c.Fake.Invokes(clientgotesting.NewCreateAction(deployapi.LegacySchemeGroupVersion.WithResource("deploymentconfigs/rollback"), c.Namespace, inObj), inObj) +func (c *FakeDeploymentConfigs) Rollback(inObj *appsapi.DeploymentConfigRollback) (result *appsapi.DeploymentConfig, err error) { + obj, err := c.Fake.Invokes(clientgotesting.NewCreateAction(appsapi.LegacySchemeGroupVersion.WithResource("deploymentconfigs/rollback"), c.Namespace, inObj), inObj) if obj == nil { return nil, err } - return obj.(*deployapi.DeploymentConfig), err + return obj.(*appsapi.DeploymentConfig), err } -func (c *FakeDeploymentConfigs) RollbackDeprecated(inObj *deployapi.DeploymentConfigRollback) (result *deployapi.DeploymentConfig, err error) { - obj, err := c.Fake.Invokes(clientgotesting.NewCreateAction(deployapi.LegacySchemeGroupVersion.WithResource("deploymentconfigrollbacks"), c.Namespace, inObj), inObj) +func (c *FakeDeploymentConfigs) RollbackDeprecated(inObj *appsapi.DeploymentConfigRollback) (result *appsapi.DeploymentConfig, err error) { + obj, err := c.Fake.Invokes(clientgotesting.NewCreateAction(appsapi.LegacySchemeGroupVersion.WithResource("deploymentconfigrollbacks"), c.Namespace, inObj), inObj) if obj == nil { return nil, err } - return obj.(*deployapi.DeploymentConfig), err + return obj.(*appsapi.DeploymentConfig), err } func (c *FakeDeploymentConfigs) GetScale(name string) (*extensionsv1beta1.Scale, error) { - obj, err := c.Fake.Invokes(clientgotesting.NewGetAction(deployapi.LegacySchemeGroupVersion.WithResource("deploymentconfigs/scale"), c.Namespace, name), &extensionsv1beta1.Scale{}) + obj, err := c.Fake.Invokes(clientgotesting.NewGetAction(appsapi.LegacySchemeGroupVersion.WithResource("deploymentconfigs/scale"), c.Namespace, name), &extensionsv1beta1.Scale{}) if obj == nil { return nil, err } @@ -98,7 +98,7 @@ func (c *FakeDeploymentConfigs) GetScale(name string) (*extensionsv1beta1.Scale, } func (c *FakeDeploymentConfigs) UpdateScale(inObj *extensionsv1beta1.Scale) (*extensionsv1beta1.Scale, error) { - obj, err := c.Fake.Invokes(clientgotesting.NewUpdateAction(deployapi.LegacySchemeGroupVersion.WithResource("deploymentconfigs/scale"), c.Namespace, inObj), inObj) + obj, err := c.Fake.Invokes(clientgotesting.NewUpdateAction(appsapi.LegacySchemeGroupVersion.WithResource("deploymentconfigs/scale"), c.Namespace, inObj), inObj) if obj == nil { return nil, err } @@ -106,21 +106,21 @@ func (c *FakeDeploymentConfigs) UpdateScale(inObj *extensionsv1beta1.Scale) (*ex return obj.(*extensionsv1beta1.Scale), err } -func (c *FakeDeploymentConfigs) UpdateStatus(inObj *deployapi.DeploymentConfig) (*deployapi.DeploymentConfig, error) { - obj, err := c.Fake.Invokes(clientgotesting.NewUpdateAction(deployapi.LegacySchemeGroupVersion.WithResource("deploymentconfigs/status"), c.Namespace, inObj), inObj) +func (c *FakeDeploymentConfigs) UpdateStatus(inObj *appsapi.DeploymentConfig) (*appsapi.DeploymentConfig, error) { + obj, err := c.Fake.Invokes(clientgotesting.NewUpdateAction(appsapi.LegacySchemeGroupVersion.WithResource("deploymentconfigs/status"), c.Namespace, inObj), inObj) if obj == nil { return nil, err } - return obj.(*deployapi.DeploymentConfig), err + return obj.(*appsapi.DeploymentConfig), err } -func (c *FakeDeploymentConfigs) Instantiate(inObj *deployapi.DeploymentRequest) (*deployapi.DeploymentConfig, error) { - deployment := &deployapi.DeploymentConfig{ObjectMeta: metav1.ObjectMeta{Name: inObj.Name}} - obj, err := c.Fake.Invokes(clientgotesting.NewUpdateAction(deployapi.LegacySchemeGroupVersion.WithResource("deploymentconfigs/instantiate"), c.Namespace, deployment), deployment) +func (c *FakeDeploymentConfigs) Instantiate(inObj *appsapi.DeploymentRequest) (*appsapi.DeploymentConfig, error) { + deployment := &appsapi.DeploymentConfig{ObjectMeta: metav1.ObjectMeta{Name: inObj.Name}} + obj, err := c.Fake.Invokes(clientgotesting.NewUpdateAction(appsapi.LegacySchemeGroupVersion.WithResource("deploymentconfigs/instantiate"), c.Namespace, deployment), deployment) if obj == nil { return nil, err } - return obj.(*deployapi.DeploymentConfig), err + return obj.(*appsapi.DeploymentConfig), err } diff --git a/pkg/client/testclient/fake_deploymentlogs.go b/pkg/client/testclient/fake_deploymentlogs.go index 0557ffd6c039..4180892a010e 100644 --- a/pkg/client/testclient/fake_deploymentlogs.go +++ b/pkg/client/testclient/fake_deploymentlogs.go @@ -4,7 +4,7 @@ import ( restclient "k8s.io/client-go/rest" clientgotesting "k8s.io/client-go/testing" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" ) // FakeDeploymentLogs implements DeploymentLogsInterface. Meant to be embedded into a struct to get a default @@ -15,7 +15,7 @@ type FakeDeploymentLogs struct { } // Get builds and returns a buildLog request -func (c *FakeDeploymentLogs) Get(name string, opt deployapi.DeploymentLogOptions) *restclient.Request { +func (c *FakeDeploymentLogs) Get(name string, opt appsapi.DeploymentLogOptions) *restclient.Request { action := clientgotesting.GenericActionImpl{} action.Verb = "get" action.Namespace = c.Namespace @@ -23,6 +23,6 @@ func (c *FakeDeploymentLogs) Get(name string, opt deployapi.DeploymentLogOptions action.Subresource = "log" action.Value = opt - _, _ = c.Fake.Invokes(action, &deployapi.DeploymentConfig{}) + _, _ = c.Fake.Invokes(action, &appsapi.DeploymentConfig{}) return &restclient.Request{} } diff --git a/pkg/client/testclient/testclient_test.go b/pkg/client/testclient/testclient_test.go index fb0e2317d858..db760dba55d8 100644 --- a/pkg/client/testclient/testclient_test.go +++ b/pkg/client/testclient/testclient_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" ) func TestNewClient(t *testing.T) { @@ -36,13 +36,13 @@ func TestNewClient(t *testing.T) { } func TestErrors(t *testing.T) { - oc, _ := NewErrorClients(errors.NewNotFound(deployapi.Resource("DeploymentConfigList"), "")) + oc, _ := NewErrorClients(errors.NewNotFound(appsapi.Resource("DeploymentConfigList"), "")) _, err := oc.DeploymentConfigs("test").List(metav1.ListOptions{}) if !errors.IsNotFound(err) { t.Fatalf("unexpected error: %v", err) } - oc, _ = NewErrorClients(errors.NewForbidden(deployapi.Resource("DeploymentConfigList"), "", nil)) + oc, _ = NewErrorClients(errors.NewForbidden(appsapi.Resource("DeploymentConfigList"), "", nil)) _, err = oc.DeploymentConfigs("test").List(metav1.ListOptions{}) if !errors.IsForbidden(err) { t.Fatalf("unexpected error: %v", err) diff --git a/pkg/cmd/infra/deployer/deployer.go b/pkg/cmd/infra/deployer/deployer.go index 5d8064887b60..c19a7e331206 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" imageclientinternal "github.com/openshift/origin/pkg/image/generated/internalclientset" ocmd "github.com/openshift/origin/pkg/oc/cli/cmd" @@ -127,14 +127,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: @@ -158,7 +158,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. @@ -176,7 +176,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) } @@ -188,7 +188,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) } @@ -204,7 +204,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 @@ -212,13 +212,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) } @@ -238,7 +238,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 1a43c03f6f7b..07104cb0fcd6 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" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deploytest "github.com/openshift/origin/pkg/apps/apis/apps/test" - deployv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appstest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" 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(appsapiv1.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 97b1637c26d9..43866870f5d1 100644 --- a/pkg/cmd/server/bootstrappolicy/policy.go +++ b/pkg/cmd/server/bootstrappolicy/policy.go @@ -20,7 +20,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" @@ -67,8 +67,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 972bc80db9e6..55b86b6c33d8 100644 --- a/pkg/cmd/server/origin/controller/unidling.go +++ b/pkg/cmd/server/origin/controller/unidling.go @@ -3,7 +3,7 @@ package controller import ( "time" - deployclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" + appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" osclient "github.com/openshift/origin/pkg/client" "github.com/openshift/origin/pkg/cmd/server/bootstrappolicy" unidlingcontroller "github.com/openshift/origin/pkg/unidling/controller" @@ -23,7 +23,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 27d278f42c52..b2268a1a699c 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/cmd/util/clientcmd/factory.go b/pkg/cmd/util/clientcmd/factory.go index 09193bdc1018..cf79c494dc58 100644 --- a/pkg/cmd/util/clientcmd/factory.go +++ b/pkg/cmd/util/clientcmd/factory.go @@ -27,8 +27,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" @@ -174,7 +174,7 @@ func (f *Factory) ApproximatePodTemplateForObject(object runtime.Object) (*api.P }, }, }, nil - case *deployapi.DeploymentConfig: + case *appsapi.DeploymentConfig: fallback := t.Spec.Template _, kc, err := f.Clients() @@ -182,7 +182,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 @@ -258,7 +258,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"): oc, kc, err := f.Clients() if err != nil { return "", err diff --git a/pkg/cmd/util/clientcmd/factory_client_access.go b/pkg/cmd/util/clientcmd/factory_client_access.go index bc46e60e5bc2..6bc9b3046bb6 100644 --- a/pkg/cmd/util/clientcmd/factory_client_access.go +++ b/pkg/cmd/util/clientcmd/factory_client_access.go @@ -33,8 +33,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" "github.com/openshift/origin/pkg/client" imageutil "github.com/openshift/origin/pkg/image/util" "github.com/openshift/origin/pkg/oc/cli/config" @@ -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") } @@ -324,7 +324,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") } @@ -343,7 +343,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{ @@ -368,14 +368,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/cmd/util/clientcmd/factory_object_mapping.go b/pkg/cmd/util/clientcmd/factory_object_mapping.go index 86a8bee4b0d6..b16dc13a81eb 100644 --- a/pkg/cmd/util/clientcmd/factory_object_mapping.go +++ b/pkg/cmd/util/clientcmd/factory_object_mapping.go @@ -28,8 +28,8 @@ import ( kprinters "k8s.io/kubernetes/pkg/printers" "github.com/openshift/origin/pkg/api/latest" - 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" appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" authorizationreaper "github.com/openshift/origin/pkg/authorization/reaper" @@ -168,8 +168,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") } @@ -221,7 +221,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.Clients() if err != nil { return nil, err @@ -230,7 +230,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) } @@ -238,7 +238,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.Clients() if err != nil { return nil, err @@ -247,7 +247,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): oc, _, err := f.clientAccessFactory.Clients() if err != nil { @@ -295,23 +295,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.Clients() 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) } @@ -321,15 +321,15 @@ 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) } 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.Clients() if err != nil { return nil, err diff --git a/pkg/diagnostics/cluster/aggregated_logging/deploymentconfigs.go b/pkg/diagnostics/cluster/aggregated_logging/deploymentconfigs.go index b65237fe22d6..0a7a0a3692eb 100644 --- a/pkg/diagnostics/cluster/aggregated_logging/deploymentconfigs.go +++ b/pkg/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/diagnostics/cluster/aggregated_logging/deploymentconfigs_test.go b/pkg/diagnostics/cluster/aggregated_logging/deploymentconfigs_test.go index 8377b8267a6f..93c2aa230c8d 100644 --- a/pkg/diagnostics/cluster/aggregated_logging/deploymentconfigs_test.go +++ b/pkg/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/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/diagnostics/cluster/aggregated_logging/diagnostic.go b/pkg/diagnostics/cluster/aggregated_logging/diagnostic.go index 1d857d386fd8..ae686b80bb8d 100644 --- a/pkg/diagnostics/cluster/aggregated_logging/diagnostic.go +++ b/pkg/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" authapi "github.com/openshift/origin/pkg/authorization/apis/authorization" "github.com/openshift/origin/pkg/client" configapi "github.com/openshift/origin/pkg/cmd/server/api" @@ -87,7 +87,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.OsClient.DeploymentConfigs(project).List(options) } diff --git a/pkg/diagnostics/cluster/aggregated_logging/interfaces.go b/pkg/diagnostics/cluster/aggregated_logging/interfaces.go index 06432dd7ed42..1b1255d2a293 100644 --- a/pkg/diagnostics/cluster/aggregated_logging/interfaces.go +++ b/pkg/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/diagnostics/cluster/router.go b/pkg/diagnostics/cluster/router.go index fb4a9ee36f96..a8e31e471c97 100644 --- a/pkg/diagnostics/cluster/router.go +++ b/pkg/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" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" osclient "github.com/openshift/origin/pkg/client" "github.com/openshift/origin/pkg/diagnostics/types" @@ -98,7 +98,7 @@ func (d *ClusterRouter) CanRun() (bool, error) { can, err := userCan(d.OsClient, authorizationapi.Action{ Namespace: metav1.NamespaceDefault, Verb: "get", - Group: deployapi.GroupName, + Group: appsapi.GroupName, Resource: "deploymentconfigs", ResourceName: 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.OsClient.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/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 45428ea0007a..2951872c0562 100644 --- a/pkg/generate/app/imageref.go +++ b/pkg/generate/app/imageref.go @@ -14,7 +14,7 @@ import ( kvalidation "k8s.io/apimachinery/pkg/util/validation" 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" "github.com/openshift/origin/pkg/util/docker/dockerfile" @@ -326,16 +326,16 @@ func (r *ImageRef) ImageStream() (*imageapi.ImageStream, 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 3bc5ffeb4312..2bc8908e2aac 100644 --- a/pkg/generate/app/pipeline.go +++ b/pkg/generate/app/pipeline.go @@ -15,11 +15,11 @@ 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" - route "github.com/openshift/origin/pkg/route/apis/route" + imageapi "github.com/openshift/origin/pkg/image/apis/image" + routeapi "github.com/openshift/origin/pkg/route/apis/route" "github.com/openshift/origin/pkg/util/docker/dockerfile" ) @@ -37,7 +37,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, @@ -51,7 +51,7 @@ type pipelineBuilder struct { environment Environment outputDocker bool to string - dockerStrategyOptions *build.DockerStrategyOptions + dockerStrategyOptions *buildapi.DockerStrategyOptions } func (pb *pipelineBuilder) To(name string) PipelineBuilder { @@ -73,7 +73,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 } @@ -87,9 +87,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 @@ -100,8 +100,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{}{} @@ -355,7 +355,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) @@ -390,13 +390,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, }, }, @@ -483,7 +483,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 249764c78192..9e9b1e5a6cbf 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" buildutil "github.com/openshift/origin/pkg/build/util" @@ -509,7 +509,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{} @@ -655,18 +655,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"}, @@ -900,19 +900,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)}, @@ -995,7 +995,7 @@ func alterBuildConfigFromTriggers(bcWatch *consistentWatch) imageReactorFunc { func alterDeploymentConfigFromTriggers(dcWatch *consistentWatch) imageReactorFunc { return imageReactorFunc(func(obj interface{}, tagRetriever trigger.TagRetriever) error { obj, _ = kapi.Scheme.DeepCopy(obj) - dc := obj.(*deployapi.DeploymentConfig) + dc := obj.(*appsapi.DeploymentConfig) updated, resolvable, err := deploymentconfigs.UpdateDeploymentConfigImages(dc, tagRetriever) if err != nil { return err @@ -1110,7 +1110,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) @@ -1301,8 +1301,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 2fa4083423f5..ba9c9d0659aa 100644 --- a/pkg/image/prune/prune.go +++ b/pkg/image/prune/prune.go @@ -24,8 +24,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" buildutil "github.com/openshift/origin/pkg/build/util" @@ -134,7 +134,7 @@ type PrunerOptions struct { Builds *buildapi.BuildList // DCs is the entire list of deployment configs across all namespaces in the // cluster. - DCs *deployapi.DeploymentConfigList + DCs *appsapi.DeploymentConfigList // LimitRanges is a map of LimitRanges across namespaces, being keys in this map. LimitRanges map[string][]*kapi.LimitRange // DryRun indicates that no changes will be made to the cluster and nothing @@ -488,11 +488,11 @@ func addReplicationControllersToGraph(g graph.Graph, rcs *kapi.ReplicationContro // 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 addDeploymentConfigsToGraph(g graph.Graph, dcs *deployapi.DeploymentConfigList) { +func addDeploymentConfigsToGraph(g graph.Graph, dcs *appsapi.DeploymentConfigList) { for i := range dcs.Items { dc := &dcs.Items[i] glog.V(4).Infof("Examining DeploymentConfig %s", getName(dc)) - dcNode := deploygraph.EnsureDeploymentConfigNode(g, dc) + dcNode := appsgraph.EnsureDeploymentConfigNode(g, dc) addPodSpecToGraph(g, &dc.Spec.Template.Spec, dcNode) } } diff --git a/pkg/image/prune/prune_test.go b/pkg/image/prune/prune_test.go index 72adf9e13388..857e7c99eb28 100644 --- a/pkg/image/prune/prune_test.go +++ b/pkg/image/prune/prune_test.go @@ -24,7 +24,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" "github.com/openshift/origin/pkg/client/testclient" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -236,19 +236,19 @@ func rc(namespace, name string, containerImages ...string) kapi.ReplicationContr } } -func dcList(dcs ...deployapi.DeploymentConfig) deployapi.DeploymentConfigList { - return deployapi.DeploymentConfigList{ +func dcList(dcs ...appsapi.DeploymentConfig) appsapi.DeploymentConfigList { + return appsapi.DeploymentConfigList{ Items: dcs, } } -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, }, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Template: &kapi.PodTemplateSpec{ Spec: podSpec(containerImages...), }, @@ -428,7 +428,7 @@ func TestImagePruning(t *testing.T) { rcs kapi.ReplicationControllerList bcs buildapi.BuildConfigList builds buildapi.BuildList - dcs deployapi.DeploymentConfigList + dcs appsapi.DeploymentConfigList limits map[string][]*kapi.LimitRange expectedImageDeletions []string expectedStreamUpdates []string @@ -1272,7 +1272,7 @@ func TestRegistryPruning(t *testing.T) { RCs: &kapi.ReplicationControllerList{}, BCs: &buildapi.BuildConfigList{}, Builds: &buildapi.BuildList{}, - DCs: &deployapi.DeploymentConfigList{}, + DCs: &appsapi.DeploymentConfigList{}, RegistryURL: &url.URL{Scheme: "https", Host: "registry1.io"}, } p := NewPruner(options) diff --git a/pkg/image/trigger/deploymentconfigs/deploymentconfigs.go b/pkg/image/trigger/deploymentconfigs/deploymentconfigs.go index e62b6892625a..3ac9c67783c6 100644 --- a/pkg/image/trigger/deploymentconfigs/deploymentconfigs.go +++ b/pkg/image/trigger/deploymentconfigs/deploymentconfigs.go @@ -10,7 +10,7 @@ import ( "k8s.io/client-go/tools/cache" 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/client" triggerapi "github.com/openshift/origin/pkg/image/apis/image/v1/trigger" "github.com/openshift/origin/pkg/image/trigger" @@ -39,7 +39,7 @@ func namesInclude(names []string, name string) bool { // calculateDeploymentConfigTrigger resolves a particular trigger against the deployment config and extracts a list of triggers. // It will silently ignore triggers that do not point to valid container. It returns empty if no triggers can be found. -func calculateDeploymentConfigTrigger(t deployapi.DeploymentTriggerPolicy, dc *deployapi.DeploymentConfig) []triggerapi.ObjectFieldTrigger { +func calculateDeploymentConfigTrigger(t appsapi.DeploymentTriggerPolicy, dc *appsapi.DeploymentConfig) []triggerapi.ObjectFieldTrigger { if t.ImageChangeParams == nil { return nil } @@ -82,7 +82,7 @@ func calculateDeploymentConfigTrigger(t deployapi.DeploymentTriggerPolicy, dc *d // calculateDeploymentConfigTriggers transforms a deployment config into a set of image change triggers. If retrieveChanges // is true an array of the latest state of the triggers will be returned. -func calculateDeploymentConfigTriggers(dc *deployapi.DeploymentConfig) []triggerapi.ObjectFieldTrigger { +func calculateDeploymentConfigTriggers(dc *appsapi.DeploymentConfig) []triggerapi.ObjectFieldTrigger { var triggers []triggerapi.ObjectFieldTrigger for _, t := range dc.Spec.Triggers { addedTriggers := calculateDeploymentConfigTrigger(t, dc) @@ -104,25 +104,25 @@ func NewDeploymentConfigTriggerIndexer(prefix string) trigger.Indexer { func (i deploymentConfigTriggerIndexer) Index(obj, old interface{}) (string, *trigger.CacheEntry, cache.DeltaType, error) { var ( triggers []triggerapi.ObjectFieldTrigger - dc *deployapi.DeploymentConfig + dc *appsapi.DeploymentConfig change cache.DeltaType ) switch { case obj != nil && old == nil: // added - dc = obj.(*deployapi.DeploymentConfig) + dc = obj.(*appsapi.DeploymentConfig) triggers = calculateDeploymentConfigTriggers(dc) change = cache.Added case old != nil && obj == nil: // deleted - dc = old.(*deployapi.DeploymentConfig) + dc = old.(*appsapi.DeploymentConfig) triggers = calculateDeploymentConfigTriggers(dc) change = cache.Deleted default: // updated - dc = obj.(*deployapi.DeploymentConfig) + dc = obj.(*appsapi.DeploymentConfig) triggers = calculateDeploymentConfigTriggers(dc) - oldTriggers := calculateDeploymentConfigTriggers(old.(*deployapi.DeploymentConfig)) + oldTriggers := calculateDeploymentConfigTriggers(old.(*appsapi.DeploymentConfig)) switch { case len(oldTriggers) == 0: change = cache.Added @@ -149,8 +149,8 @@ type DeploymentConfigReactor struct { // UpdateDeploymentConfigImages sets the latest image value from all triggers onto each container, returning false if // one or more triggers could not be resolved yet or an error. The returned dc will be copied if mutated. -func UpdateDeploymentConfigImages(dc *deployapi.DeploymentConfig, tagRetriever trigger.TagRetriever) (*deployapi.DeploymentConfig, bool, error) { - var updated *deployapi.DeploymentConfig +func UpdateDeploymentConfigImages(dc *appsapi.DeploymentConfig, tagRetriever trigger.TagRetriever) (*appsapi.DeploymentConfig, bool, error) { + var updated *appsapi.DeploymentConfig // copy the object and reset dc to the copy copyObject := func() { @@ -161,7 +161,7 @@ func UpdateDeploymentConfigImages(dc *deployapi.DeploymentConfig, tagRetriever t if err != nil { return } - dc = copied.(*deployapi.DeploymentConfig) + dc = copied.(*appsapi.DeploymentConfig) updated = dc } @@ -221,12 +221,12 @@ func UpdateDeploymentConfigImages(dc *deployapi.DeploymentConfig, tagRetriever t // ImageChanged is passed a deployment config and a set of changes. func (r *DeploymentConfigReactor) ImageChanged(obj interface{}, tagRetriever trigger.TagRetriever) error { - dc := obj.(*deployapi.DeploymentConfig) + dc := obj.(*appsapi.DeploymentConfig) copied, err := kapi.Scheme.DeepCopy(dc) if err != nil { return err } - newDC := copied.(*deployapi.DeploymentConfig) + newDC := copied.(*appsapi.DeploymentConfig) updated, resolvable, err := UpdateDeploymentConfigImages(newDC, tagRetriever) if err != nil { @@ -247,7 +247,7 @@ func (r *DeploymentConfigReactor) ImageChanged(obj interface{}, tagRetriever tri return err } -func printDeploymentTriggers(triggers []deployapi.DeploymentTriggerPolicy) string { +func printDeploymentTriggers(triggers []appsapi.DeploymentTriggerPolicy) string { var values []string for _, t := range triggers { if t.ImageChangeParams == nil { diff --git a/pkg/image/trigger/deploymentconfigs/deploymentconfigs_test.go b/pkg/image/trigger/deploymentconfigs/deploymentconfigs_test.go index 7ec8e5c789d5..9fc20587ac92 100644 --- a/pkg/image/trigger/deploymentconfigs/deploymentconfigs_test.go +++ b/pkg/image/trigger/deploymentconfigs/deploymentconfigs_test.go @@ -12,7 +12,7 @@ import ( kapi "k8s.io/kubernetes/pkg/api" kapihelper "k8s.io/kubernetes/pkg/api/helper" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/client/testclient" ) @@ -35,15 +35,15 @@ func (r fakeTagRetriever) ImageStreamTag(namespace, name string) (string, int64, return "", 0, false } -func testDeploymentConfig(params []deployapi.DeploymentTriggerImageChangeParams, containers map[string]string) *deployapi.DeploymentConfig { - obj := &deployapi.DeploymentConfig{ +func testDeploymentConfig(params []appsapi.DeploymentTriggerImageChangeParams, containers map[string]string) *appsapi.DeploymentConfig { + obj := &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "default"}, - Spec: deployapi.DeploymentConfigSpec{ + Spec: appsapi.DeploymentConfigSpec{ Template: &kapi.PodTemplateSpec{}, }, } for i := range params { - obj.Spec.Triggers = append(obj.Spec.Triggers, deployapi.DeploymentTriggerPolicy{ImageChangeParams: ¶ms[i]}) + obj.Spec.Triggers = append(obj.Spec.Triggers, appsapi.DeploymentTriggerPolicy{ImageChangeParams: ¶ms[i]}) } var names []string for k := range containers { @@ -59,13 +59,13 @@ func testDeploymentConfig(params []deployapi.DeploymentTriggerImageChangeParams, func TestDeploymentConfigReactor(t *testing.T) { testCases := []struct { tags []fakeTagResponse - obj *deployapi.DeploymentConfig - response *deployapi.DeploymentConfig - expected *deployapi.DeploymentConfig + obj *appsapi.DeploymentConfig + response *appsapi.DeploymentConfig + expected *appsapi.DeploymentConfig expectedErr bool }{ { - obj: &deployapi.DeploymentConfig{ + obj: &appsapi.DeploymentConfig{ ObjectMeta: metav1.ObjectMeta{Name: "test", Namespace: "default"}, }, }, @@ -73,15 +73,15 @@ func TestDeploymentConfigReactor(t *testing.T) { { // no container, last expected changed tags: []fakeTagResponse{{Namespace: "other", Name: "stream-1:1", Ref: "image-lookup-1", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, ContainerNames: []string{"test"}, }, }, nil), - response: &deployapi.DeploymentConfig{}, - expected: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + response: &appsapi.DeploymentConfig{}, + expected: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -94,7 +94,7 @@ func TestDeploymentConfigReactor(t *testing.T) { { // no container, second run tags: []fakeTagResponse{{Namespace: "other", Name: "stream-1:1", Ref: "image-lookup-2", RV: 3}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -102,8 +102,8 @@ func TestDeploymentConfigReactor(t *testing.T) { LastTriggeredImage: "image-lookup-1", }, }, nil), - response: &deployapi.DeploymentConfig{}, - expected: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + response: &appsapi.DeploymentConfig{}, + expected: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -115,7 +115,7 @@ func TestDeploymentConfigReactor(t *testing.T) { { // no ref, no change - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -127,15 +127,15 @@ func TestDeploymentConfigReactor(t *testing.T) { { // resolved without a change in another namespace tags: []fakeTagResponse{{Namespace: "other", Name: "stream-1:1", Ref: "image-lookup-1", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, ContainerNames: []string{"test"}, }, }, map[string]string{"test": ""}), - response: &deployapi.DeploymentConfig{}, - expected: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + response: &appsapi.DeploymentConfig{}, + expected: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -148,20 +148,20 @@ func TestDeploymentConfigReactor(t *testing.T) { { // will not resolve if not automatic tags: []fakeTagResponse{{Namespace: "other", Name: "stream-1:1", Ref: "image-lookup-1", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: false, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, ContainerNames: []string{"test"}, }, }, map[string]string{"test": ""}), - response: &deployapi.DeploymentConfig{}, + response: &appsapi.DeploymentConfig{}, }, { // will not fire if both triggers aren't resolved tags: []fakeTagResponse{{Namespace: "other", Name: "stream-1:1", Ref: "image-lookup-1", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -173,13 +173,13 @@ func TestDeploymentConfigReactor(t *testing.T) { ContainerNames: []string{"test2"}, }, }, map[string]string{"test": "", "test2": ""}), - response: &deployapi.DeploymentConfig{}, + response: &appsapi.DeploymentConfig{}, }, { // will fire if a trigger has already been resolved before tags: []fakeTagResponse{{Namespace: "other", Name: "stream-1:1", Ref: "image-lookup-1", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -192,8 +192,8 @@ func TestDeploymentConfigReactor(t *testing.T) { LastTriggeredImage: "old-image", }, }, map[string]string{"test": "", "test2": "old-image"}), - response: &deployapi.DeploymentConfig{}, - expected: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + response: &appsapi.DeploymentConfig{}, + expected: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -212,7 +212,7 @@ func TestDeploymentConfigReactor(t *testing.T) { { // will fire if the same trigger has already been resolved before tags: []fakeTagResponse{{Namespace: "other", Name: "stream-2:1", Ref: "image-lookup-2", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -226,8 +226,8 @@ func TestDeploymentConfigReactor(t *testing.T) { LastTriggeredImage: "image-lookup-1", }, }, map[string]string{"test": "old-image", "test2": "image-lookup-1"}), - response: &deployapi.DeploymentConfig{}, - expected: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + response: &appsapi.DeploymentConfig{}, + expected: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -246,21 +246,21 @@ func TestDeploymentConfigReactor(t *testing.T) { { // will not fire the image can't be resolved tags: []fakeTagResponse{{Namespace: "other", Name: "stream-2:1", Ref: "image-lookup-2", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, ContainerNames: []string{"test"}, }, }, map[string]string{"test": "", "test2": "image-lookup-1"}), - response: &deployapi.DeploymentConfig{}, + response: &appsapi.DeploymentConfig{}, expected: nil, }, { // will not fire the one image can't be resolved and the other can tags: []fakeTagResponse{{Namespace: "other", Name: "stream-2:1", Ref: "image-lookup-2", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -273,14 +273,14 @@ func TestDeploymentConfigReactor(t *testing.T) { LastTriggeredImage: "image-lookup-1", }, }, map[string]string{"test": ""}), - response: &deployapi.DeploymentConfig{}, + response: &appsapi.DeploymentConfig{}, expected: nil, }, { // will fire if both triggers are resolved tags: []fakeTagResponse{{Namespace: "other", Name: "stream-1:1", Ref: "image-lookup-1", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -292,8 +292,8 @@ func TestDeploymentConfigReactor(t *testing.T) { ContainerNames: []string{"test2"}, }, }, map[string]string{"test": "", "test2": ""}), - response: &deployapi.DeploymentConfig{}, - expected: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + response: &appsapi.DeploymentConfig{}, + expected: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -312,7 +312,7 @@ func TestDeploymentConfigReactor(t *testing.T) { { // will fire if both triggers are resolved, second run tags: []fakeTagResponse{{Namespace: "other", Name: "stream-1:1", Ref: "image-lookup-2", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -326,8 +326,8 @@ func TestDeploymentConfigReactor(t *testing.T) { LastTriggeredImage: "image-lookup-1", }, }, map[string]string{"test": "image-lookup-1", "test2": "image-lookup-1"}), - response: &deployapi.DeploymentConfig{}, - expected: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + response: &appsapi.DeploymentConfig{}, + expected: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -346,15 +346,15 @@ func TestDeploymentConfigReactor(t *testing.T) { { // will fire from single trigger tags: []fakeTagResponse{{Namespace: "other", Name: "stream-1:1", Ref: "image-lookup-1", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, ContainerNames: []string{"test", "test2"}, }, }, map[string]string{"test": "", "test2": ""}), - response: &deployapi.DeploymentConfig{}, - expected: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + response: &appsapi.DeploymentConfig{}, + expected: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -367,7 +367,7 @@ func TestDeploymentConfigReactor(t *testing.T) { { // will fire from single trigger, second run tags: []fakeTagResponse{{Namespace: "other", Name: "stream-1:1", Ref: "image-lookup-2", RV: 2}}, - obj: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + obj: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, @@ -375,8 +375,8 @@ func TestDeploymentConfigReactor(t *testing.T) { LastTriggeredImage: "image-lookup-1", }, }, map[string]string{"test": "image-lookup-1", "test2": "image-lookup-1"}), - response: &deployapi.DeploymentConfig{}, - expected: testDeploymentConfig([]deployapi.DeploymentTriggerImageChangeParams{ + response: &appsapi.DeploymentConfig{}, + expected: testDeploymentConfig([]appsapi.DeploymentTriggerImageChangeParams{ { Automatic: true, From: kapi.ObjectReference{Name: "stream-1:1", Namespace: "other", Kind: "ImageStreamTag"}, diff --git a/pkg/ipfailover/keepalived/plugin.go b/pkg/ipfailover/keepalived/plugin.go index d628686b2871..72ea42832d23 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/cmd/util/clientcmd" "github.com/openshift/origin/pkg/generate/app" "github.com/openshift/origin/pkg/ipfailover" @@ -84,7 +84,7 @@ 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) { osClient, _, err := p.Factory.Clients() if err != nil { return nil, fmt.Errorf("error getting client: %v", err) diff --git a/pkg/oc/admin/migrate/images/imagerefs_test.go b/pkg/oc/admin/migrate/images/imagerefs_test.go index 2da5b1173609..c6fe12e49df1 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" "github.com/openshift/origin/pkg/cmd/util/clientcmd" imageapi "github.com/openshift/origin/pkg/image/apis/image" @@ -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 f0bccc844fea..067467942a52 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" "github.com/openshift/origin/pkg/apps/prune" "github.com/openshift/origin/pkg/client" "github.com/openshift/origin/pkg/cmd/util/clientcmd" @@ -130,7 +130,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 e102740010b8..31ae35db53cc 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/clientcmd" "github.com/openshift/origin/pkg/cmd/util/variable" - 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" ) @@ -427,16 +427,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 0e30511939da..76b36d3a794d 100644 --- a/pkg/oc/admin/router/router.go +++ b/pkg/oc/admin/router/router.go @@ -30,7 +30,7 @@ import ( cmdutil "github.com/openshift/origin/pkg/cmd/util" "github.com/openshift/origin/pkg/cmd/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" @@ -757,20 +757,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 88dffe7a531d..acbf851a8c0a 100644 --- a/pkg/oc/admin/top/images.go +++ b/pkg/oc/admin/top/images.go @@ -16,7 +16,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" "github.com/openshift/origin/pkg/client" "github.com/openshift/origin/pkg/cmd/util/clientcmd" @@ -255,10 +255,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 c22118378291..087f8cd60a0a 100644 --- a/pkg/oc/admin/top/images_test.go +++ b/pkg/oc/admin/top/images_test.go @@ -8,7 +8,7 @@ import ( "github.com/docker/distribution/digest" - 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" ) @@ -465,7 +465,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}, }, @@ -504,7 +504,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}, }, @@ -543,7 +543,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}, }, @@ -582,7 +582,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 d0dfd1391139..84ce0c5d43d6 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" "github.com/openshift/origin/pkg/client" "github.com/openshift/origin/pkg/cmd/util/clientcmd" ) @@ -32,7 +32,7 @@ var ( ) type CreateDeploymentConfigOptions struct { - DC *deployapi.DeploymentConfig + DC *appsapi.DeploymentConfig Client client.DeploymentConfigsNamespacer 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 ca2bbd0f672e..dffd83439f6c 100644 --- a/pkg/oc/cli/cmd/debug.go +++ b/pkg/oc/cli/cmd/debug.go @@ -25,7 +25,7 @@ import ( "k8s.io/kubernetes/pkg/util/interrupt" "k8s.io/kubernetes/pkg/util/term" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" "github.com/openshift/origin/pkg/client" cmdutil "github.com/openshift/origin/pkg/cmd/util" "github.com/openshift/origin/pkg/cmd/util/clientcmd" @@ -400,7 +400,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 } @@ -411,7 +411,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 52889937f866..89e6e73ef426 100644 --- a/pkg/oc/cli/cmd/deploy.go +++ b/pkg/oc/cli/cmd/deploy.go @@ -21,8 +21,8 @@ import ( kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" "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/client" "github.com/openshift/origin/pkg/cmd/util/clientcmd" "github.com/openshift/origin/pkg/oc/cli/describe" @@ -199,7 +199,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) } @@ -230,7 +230,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") } @@ -239,18 +239,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, @@ -280,7 +280,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") } @@ -292,7 +292,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) { @@ -301,9 +301,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) @@ -313,7 +313,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) } @@ -324,10 +324,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 @@ -342,11 +342,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 } @@ -358,29 +358,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)) } } } @@ -390,13 +390,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) } @@ -404,10 +404,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) } @@ -424,8 +424,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, } readCloser, err := o.osClient.DeploymentLogs(config.Namespace).Get(config.Name, opts).Stream() diff --git a/pkg/oc/cli/cmd/deploy_test.go b/pkg/oc/cli/cmd/deploy_test.go index 05d8e960d82e..f969bbf0aaf3 100644 --- a/pkg/oc/cli/cmd/deploy_test.go +++ b/pkg/oc/cli/cmd/deploy_test.go @@ -14,9 +14,9 @@ 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" tc "github.com/openshift/origin/pkg/client/testclient" // install all APIs @@ -24,24 +24,24 @@ import ( _ "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 := &tc.Fake{} @@ -73,14 +73,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} @@ -100,7 +100,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) @@ -112,19 +112,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, }, }, } @@ -160,11 +160,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") } @@ -174,7 +174,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) } } @@ -182,15 +182,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} @@ -207,7 +207,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 { @@ -217,30 +217,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) } @@ -269,7 +269,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)) @@ -287,22 +287,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 := &tc.Fake{} 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 10eb3c4206d7..a31f46a90d00 100644 --- a/pkg/oc/cli/cmd/idle.go +++ b/pkg/oc/cli/cmd/idle.go @@ -23,8 +23,8 @@ import ( kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" "k8s.io/kubernetes/pkg/kubectl/resource" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" osclient "github.com/openshift/origin/pkg/client" cmdutil "github.com/openshift/origin/pkg/cmd/util" "github.com/openshift/origin/pkg/cmd/util/clientcmd" @@ -306,7 +306,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 } @@ -542,7 +542,7 @@ func (o *IdleOptions) RunIdle(f *clientcmd.Factory) error { externalKubeExtensionClient := kextensionsclient.New(kclient.Core().RESTClient()) delegScaleGetter := osclient.NewDelegatingScaleNamespacer(oclient, externalKubeExtensionClient) - dcGetter := deployclient.New(oclient.RESTClient) + dcGetter := appsclient.New(oclient.RESTClient) scaleAnnotater := utilunidling.NewScaleAnnotater(delegScaleGetter, dcGetter, kclient.Core(), func(currentReplicas int32, annotations map[string]string) { annotations[unidlingapi.IdledAtAnnotation] = nowTime.UTC().Format(time.RFC3339) 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 28052c92f8b8..7e6b6fdfecce 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" buildutil "github.com/openshift/origin/pkg/build/util" osclient "github.com/openshift/origin/pkg/client" @@ -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 64e0bd32a9ae..e4e4a4dce0e7 100644 --- a/pkg/oc/cli/cmd/logs_test.go +++ b/pkg/oc/cli/cmd/logs_test.go @@ -14,7 +14,7 @@ import ( "k8s.io/apimachinery/pkg/watch" 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" buildclient "github.com/openshift/origin/pkg/client" "github.com/openshift/origin/pkg/cmd/util/clientcmd" @@ -212,7 +212,7 @@ func TestIsPipelineBuild(t *testing.T) { isPipeline: false, }, { - o: &deployapi.DeploymentConfig{}, + o: &appsapi.DeploymentConfig{}, isPipeline: false, }, } diff --git a/pkg/oc/cli/cmd/rollback.go b/pkg/oc/cli/cmd/rollback.go index 999dadd286e5..b86f829eaeae 100644 --- a/pkg/oc/cli/cmd/rollback.go +++ b/pkg/oc/cli/cmd/rollback.go @@ -17,8 +17,8 @@ import ( "k8s.io/kubernetes/pkg/kubectl/resource" kprinters "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" "github.com/openshift/origin/pkg/client" "github.com/openshift/origin/pkg/cmd/util/clientcmd" describe "github.com/openshift/origin/pkg/oc/cli/describe" @@ -203,7 +203,7 @@ func (o *RollbackOptions) Run() error { var target *kapi.ReplicationController switch r := obj.(type) { case *kapi.ReplicationController: - dcName := deployutil.DeploymentConfigNameFor(r) + dcName := appsutil.DeploymentConfigNameFor(r) dc, err := o.oc.DeploymentConfigs(r.Namespace).Get(dcName, metav1.GetOptions{}) if err != nil { return err @@ -214,8 +214,8 @@ func (o *RollbackOptions) Run() error { // A specific deployment was used. target = r - configName = deployutil.DeploymentConfigNameFor(obj) - case *deployapi.DeploymentConfig: + configName = appsutil.DeploymentConfigNameFor(obj) + case *appsapi.DeploymentConfig: if r.Spec.Paused { return fmt.Errorf("cannot rollback a paused deployment config") } @@ -234,9 +234,9 @@ func (o *RollbackOptions) Run() error { } // Set up the rollback and generate a new rolled back config. - rollback := &deployapi.DeploymentConfigRollback{ + rollback := &appsapi.DeploymentConfigRollback{ Name: configName, - Spec: deployapi.DeploymentConfigRollbackSpec{ + Spec: appsapi.DeploymentConfigRollbackSpec{ From: kapi.ObjectReference{ Name: target.Name, }, @@ -284,7 +284,7 @@ func (o *RollbackOptions) Run() error { fmt.Fprintf(o.out, "#%d rolled back to %s\n", rolledback.Status.LatestVersion, rollback.Spec.From.Name) for _, trigger := range rolledback.Spec.Triggers { disabled := []string{} - if trigger.Type == deployapi.DeploymentTriggerOnImageChange && !trigger.ImageChangeParams.Automatic { + if trigger.Type == appsapi.DeploymentTriggerOnImageChange && !trigger.ImageChangeParams.Automatic { disabled = append(disabled, trigger.ImageChangeParams.From.Name) } if len(disabled) > 0 { @@ -339,9 +339,9 @@ func (o *RollbackOptions) findResource(targetName string) (runtime.Object, error // the deployment matching desiredVersion will be returned. If desiredVersion // is <=0, the last completed deployment which is older than the config's // version will be returned. -func (o *RollbackOptions) findTargetDeployment(config *deployapi.DeploymentConfig, desiredVersion int64) (*kapi.ReplicationController, error) { +func (o *RollbackOptions) findTargetDeployment(config *appsapi.DeploymentConfig, desiredVersion int64) (*kapi.ReplicationController, error) { // Find deployments for the config sorted by version descending. - deploymentList, err := o.kc.Core().ReplicationControllers(config.Namespace).List(metav1.ListOptions{LabelSelector: deployutil.ConfigSelector(config.Name).String()}) + deploymentList, err := o.kc.Core().ReplicationControllers(config.Namespace).List(metav1.ListOptions{LabelSelector: appsutil.ConfigSelector(config.Name).String()}) if err != nil { return nil, err } @@ -349,21 +349,21 @@ func (o *RollbackOptions) findTargetDeployment(config *deployapi.DeploymentConfi for i := range deploymentList.Items { deployments = append(deployments, &deploymentList.Items[i]) } - sort.Sort(deployutil.ByLatestVersionDesc(deployments)) + sort.Sort(appsutil.ByLatestVersionDesc(deployments)) // Find the target deployment for rollback. If a version was specified, // use the version for a search. Otherwise, use the last completed // deployment. var target *kapi.ReplicationController for _, deployment := range deployments { - version := deployutil.DeploymentVersionFor(deployment) + version := appsutil.DeploymentVersionFor(deployment) if desiredVersion > 0 { if version == desiredVersion { target = deployment break } } else { - if version < config.Status.LatestVersion && deployutil.IsCompleteDeployment(deployment) { + if version < config.Status.LatestVersion && appsutil.IsCompleteDeployment(deployment) { target = deployment break } 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 d1c46663aa80..598814bb01b9 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/cmd/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 %T", info.Object))) } @@ -123,14 +123,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) }) @@ -157,13 +157,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) } @@ -173,7 +173,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 } @@ -184,16 +184,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 3497ce7bb3be..44e46e427743 100644 --- a/pkg/oc/cli/cmd/rollout/latest.go +++ b/pkg/oc/cli/cmd/rollout/latest.go @@ -15,8 +15,8 @@ import ( kcmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util" "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/client" "github.com/openshift/origin/pkg/cmd/util/clientcmd" ) @@ -128,7 +128,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) } @@ -139,13 +139,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): @@ -154,7 +154,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 22fbd2671dde..c7f1bf3ff7c7 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/cmd/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 4b64cc0b221a..f431bb43b259 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/cmd/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.UsageError(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 ed780780dc7d..5158e981c6cd 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" buildutil "github.com/openshift/origin/pkg/build/util" cmdutil "github.com/openshift/origin/pkg/cmd/util" @@ -565,13 +565,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, @@ -629,7 +629,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") } @@ -643,10 +643,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 { @@ -666,9 +666,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", @@ -870,8 +870,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 { @@ -898,9 +898,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) @@ -916,7 +916,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 @@ -967,7 +967,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 2cb7aacc4810..cdf2ede33eef 100644 --- a/pkg/oc/cli/describe/deployments.go +++ b/pkg/oc/cli/describe/deployments.go @@ -20,10 +20,10 @@ 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" - 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" + 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" + appsutil "github.com/openshift/origin/pkg/apps/util" "github.com/openshift/origin/pkg/client" imageapi "github.com/openshift/origin/pkg/image/apis/image" ) @@ -45,11 +45,11 @@ type DeploymentConfigDescriber struct { osClient client.Interface kubeClient kclientset.Interface - config *deployapi.DeploymentConfig + config *appsapi.DeploymentConfig } // NewDeploymentConfigDescriber returns a new DeploymentConfigDescriber -func NewDeploymentConfigDescriber(client client.Interface, kclient kclientset.Interface, config *deployapi.DeploymentConfig) *DeploymentConfigDescriber { +func NewDeploymentConfigDescriber(client client.Interface, kclient kclientset.Interface, config *appsapi.DeploymentConfig) *DeploymentConfigDescriber { return &DeploymentConfigDescriber{ osClient: client, kubeClient: kclient, @@ -59,7 +59,7 @@ func NewDeploymentConfigDescriber(client client.Interface, kclient kclientset.In // Describe returns the description of a DeploymentConfig func (d *DeploymentConfigDescriber) Describe(namespace, name string, settings kprinters.DescriberSettings) (string, error) { - var deploymentConfig *deployapi.DeploymentConfig + var deploymentConfig *appsapi.DeploymentConfig if d.config != nil { // If a deployment config is already provided use that. // This is used by `oc rollback --dry-run`. @@ -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++ } @@ -189,7 +189,7 @@ func multilineStringArray(sep, indent string, args ...string) string { return strings.Join(args, " ") } -func printStrategy(strategy deployapi.DeploymentStrategy, indent string, w *tabwriter.Writer) { +func printStrategy(strategy appsapi.DeploymentStrategy, indent string, w *tabwriter.Writer) { if strategy.CustomParams != nil { if len(strategy.CustomParams.Image) == 0 { fmt.Fprintf(w, "%sImage:\t%s\n", indent, "") @@ -233,7 +233,7 @@ func printStrategy(strategy deployapi.DeploymentStrategy, indent string, w *tabw } } -func printHook(prefix string, hook *deployapi.LifecycleHook, indent string, w io.Writer) { +func printHook(prefix string, hook *appsapi.LifecycleHook, indent string, w io.Writer) { if hook.ExecNewPod != nil { fmt.Fprintf(w, "%s%s hook (pod type, failure policy: %s):\n", indent, prefix, hook.FailurePolicy) fmt.Fprintf(w, "%s Container:\t%s\n", indent, hook.ExecNewPod.ContainerName) @@ -250,7 +250,7 @@ func printHook(prefix string, hook *deployapi.LifecycleHook, indent string, w io } } -func printTriggers(triggers []deployapi.DeploymentTriggerPolicy, w *tabwriter.Writer) { +func printTriggers(triggers []appsapi.DeploymentTriggerPolicy, w *tabwriter.Writer) { if len(triggers) == 0 { formatString(w, "Triggers", "") return @@ -260,9 +260,9 @@ func printTriggers(triggers []deployapi.DeploymentTriggerPolicy, w *tabwriter.Wr for _, t := range triggers { switch t.Type { - case deployapi.DeploymentTriggerOnConfigChange: + case appsapi.DeploymentTriggerOnConfigChange: labels = append(labels, "Config") - case deployapi.DeploymentTriggerOnImageChange: + case appsapi.DeploymentTriggerOnImageChange: if len(t.ImageChangeParams.From.Name) > 0 { name, tag, _ := imageapi.SplitImageStreamTag(t.ImageChangeParams.From.Name) labels = append(labels, fmt.Sprintf("Image(%s@%s, auto=%v)", name, tag, t.ImageChangeParams.Automatic)) @@ -274,7 +274,7 @@ func printTriggers(triggers []deployapi.DeploymentTriggerPolicy, w *tabwriter.Wr formatString(w, "Triggers", desc) } -func printDeploymentConfigSpec(kc kclientset.Interface, dc deployapi.DeploymentConfig, w *tabwriter.Writer) error { +func printDeploymentConfigSpec(kc kclientset.Interface, dc appsapi.DeploymentConfig, w *tabwriter.Writer) error { spec := dc.Spec // Selector formatString(w, "Selector", formatLabels(spec.Selector)) @@ -292,7 +292,7 @@ func printDeploymentConfigSpec(kc kclientset.Interface, dc deployapi.DeploymentC // Autoscaling info // FIXME: The CrossVersionObjectReference should specify the Group - printAutoscalingInfo([]schema.GroupResource{deployapi.Resource("DeploymentConfig"), deployapi.LegacyResource("DeploymentConfig")}, dc.Namespace, dc.Name, kc, w) + printAutoscalingInfo([]schema.GroupResource{appsapi.Resource("DeploymentConfig"), appsapi.LegacyResource("DeploymentConfig")}, dc.Namespace, dc.Name, kc, w) // Triggers printTriggers(spec.Triggers, w) @@ -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 bf99085a69af..b11f944e8d6e 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" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapitest "github.com/openshift/origin/pkg/apps/apis/apps/test" + appsutil "github.com/openshift/origin/pkg/apps/util" "github.com/openshift/origin/pkg/client/testclient" ) 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 := &testclient.Fake{} @@ -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 3635fb82e06f..0a51b5bee471 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" authorizationapi "github.com/openshift/origin/pkg/authorization/apis/authorization" oauthorizationclient "github.com/openshift/origin/pkg/authorization/generated/internalclientset/typed/authorization/internalversion" buildapi "github.com/openshift/origin/pkg/build/apis/build" @@ -73,7 +73,7 @@ func describerMap(clientConfig *rest.Config, c *client.Client, kclient kclientse m := map[schema.GroupKind]kprinters.Describer{ buildapi.Kind("Build"): &BuildDescriber{c, kclient}, buildapi.Kind("BuildConfig"): &BuildConfigDescriber{c, kclient, host}, - deployapi.Kind("DeploymentConfig"): &DeploymentConfigDescriber{c, kclient, nil}, + appsapi.Kind("DeploymentConfig"): &DeploymentConfigDescriber{c, 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 b223d84ab5f5..5a6f0dd72b15 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" "github.com/openshift/origin/pkg/client" @@ -48,10 +48,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 febdd1c722da..b105e7987996 100644 --- a/pkg/oc/cli/describe/printer.go +++ b/pkg/oc/cli/describe/printer.go @@ -17,7 +17,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" 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" @@ -658,7 +658,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) @@ -678,9 +678,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...) { @@ -715,7 +715,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 d9add8a43973..bae507ff33bd 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 0616cb87b957..01d0ee4d58ae 100644 --- a/pkg/oc/cli/describe/projectstatus.go +++ b/pkg/oc/cli/describe/projectstatus.go @@ -26,11 +26,11 @@ 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" - 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" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + 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" buildedges "github.com/openshift/origin/pkg/build/graph" buildanalysis "github.com/openshift/origin/pkg/build/graph/analysis" @@ -135,9 +135,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) @@ -227,7 +227,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 } } @@ -422,11 +422,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) @@ -511,7 +511,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: @@ -744,7 +744,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)" } @@ -1012,7 +1012,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 } @@ -1039,7 +1039,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: @@ -1053,28 +1053,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" @@ -1132,13 +1132,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 } } @@ -1230,7 +1230,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 { @@ -1470,7 +1470,7 @@ func (l *isLoader) AddToGraph(g osgraph.Graph) error { type dcLoader struct { namespace string lister client.DeploymentConfigsNamespacer - items []deployapi.DeploymentConfig + items []appsapi.DeploymentConfig } func (l *dcLoader) Load() error { @@ -1485,7 +1485,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/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 c38bea9590ca..ad5edb0b8b30 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" buildutil "github.com/openshift/origin/pkg/build/util" "github.com/openshift/origin/pkg/client" @@ -83,15 +83,15 @@ func checkDeploymentReadiness(oc client.Interface, obj runtime.Object) (bool, bo // checkDeploymentConfigReadiness determins if a DeploymentConfig is ready, // failed or neither. func checkDeploymentConfigReadiness(oc client.Interface, 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] } } @@ -99,7 +99,7 @@ func checkDeploymentConfigReadiness(oc client.Interface, obj runtime.Object) (bo 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 @@ -136,16 +136,16 @@ func checkStatefulSetReadiness(oc client.Interface, obj runtime.Object) (bool, b // 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(client.Interface, runtime.Object) (bool, bool, error){ - buildapi.LegacyKind("Build"): checkBuildReadiness, - buildapi.Kind("Build"): checkBuildReadiness, - buildapi.LegacyKind("BuildConfig"): checkBuildConfigReadiness, - buildapi.Kind("BuildConfig"): checkBuildConfigReadiness, - apps.Kind("Deployment"): checkDeploymentReadiness, - extensions.Kind("Deployment"): checkDeploymentReadiness, - deployapi.LegacyKind("DeploymentConfig"): checkDeploymentConfigReadiness, - deployapi.Kind("DeploymentConfig"): checkDeploymentConfigReadiness, - batch.Kind("Job"): checkJobReadiness, - apps.Kind("StatefulSet"): checkStatefulSetReadiness, + buildapi.LegacyKind("Build"): checkBuildReadiness, + buildapi.Kind("Build"): checkBuildReadiness, + buildapi.LegacyKind("BuildConfig"): checkBuildConfigReadiness, + buildapi.Kind("BuildConfig"): checkBuildConfigReadiness, + apps.Kind("Deployment"): checkDeploymentReadiness, + extensions.Kind("Deployment"): checkDeploymentReadiness, + appsapi.LegacyKind("DeploymentConfig"): checkDeploymentConfigReadiness, + appsapi.Kind("DeploymentConfig"): checkDeploymentConfigReadiness, + batch.Kind("Job"): checkJobReadiness, + apps.Kind("StatefulSet"): checkStatefulSetReadiness, } // 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 4ee8f7ce5472..8701a56b42f6 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" "github.com/openshift/origin/pkg/client/testclient" ) @@ -141,21 +141,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, }, }, @@ -164,12 +164,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 7d27c34038ab..28976c83809e 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 071f63a5ccf6..6fa77b3eeea2 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 3c58636805e9..68924294cbc1 100644 --- a/pkg/unidling/util/scale.go +++ b/pkg/unidling/util/scale.go @@ -13,9 +13,9 @@ import ( kextensionsclient "k8s.io/kubernetes/pkg/client/clientset_generated/clientset/typed/extensions/v1beta1" kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" - deployclient "github.com/openshift/origin/pkg/apps/generated/internalclientset/typed/apps/internalversion" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + 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") 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 108b701482b3..d4b4a05df490 100644 --- a/pkg/util/labels_test.go +++ b/pkg/util/labels_test.go @@ -10,7 +10,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" ) type FakeLabelsResource struct { @@ -105,11 +105,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"}, @@ -154,7 +154,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 5a4a0a63181c..1e289e015629 100644 --- a/test/extended/deployments/deployments.go +++ b/test/extended/deployments/deployments.go @@ -19,8 +19,8 @@ import ( kcontroller "k8s.io/kubernetes/pkg/controller" 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" ) @@ -168,7 +168,7 @@ var _ = g.Describe("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 } @@ -190,10 +190,10 @@ var _ = g.Describe("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 @@ -532,7 +532,7 @@ var _ = g.Describe("deploymentconfigs", func() { o.Expect(err).NotTo(o.HaveOccurred()) g.By("updating the deployment config in order to trigger a new rollout") - _, err = updateConfigWithRetries(oc.Client(), oc.Namespace(), name, func(update *deployapi.DeploymentConfig) { + _, err = updateConfigWithRetries(oc.Client(), oc.Namespace(), name, func(update *appsapi.DeploymentConfig) { one := int64(1) update.Spec.Template.Spec.TerminationGracePeriodSeconds = &one }) @@ -703,7 +703,7 @@ var _ = g.Describe("deploymentconfigs", func() { o.Expect(fmt.Errorf("expected no deployment, found %#v", rcs[0])).NotTo(o.HaveOccurred()) } - _, err = updateConfigWithRetries(oc.Client(), oc.Namespace(), name, func(dc *deployapi.DeploymentConfig) { + _, err = updateConfigWithRetries(oc.Client(), oc.Namespace(), name, func(dc *appsapi.DeploymentConfig) { // TODO: oc rollout pause should patch instead of making a full update dc.Spec.Paused = false }) @@ -869,7 +869,7 @@ var _ = g.Describe("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 { @@ -879,7 +879,7 @@ var _ = g.Describe("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 }) @@ -905,7 +905,7 @@ var _ = g.Describe("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.Client().DeploymentConfigs(namespace).Create(dc) @@ -932,7 +932,7 @@ var _ = g.Describe("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()) } @@ -944,7 +944,7 @@ var _ = g.Describe("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") } @@ -957,11 +957,11 @@ var _ = g.Describe("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()) @@ -995,15 +995,15 @@ var _ = g.Describe("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) @@ -1023,7 +1023,7 @@ var _ = g.Describe("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 @@ -1060,7 +1060,7 @@ var _ = g.Describe("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 != dc.Status.AvailableReplicas, nil }) o.Expect(err).NotTo(o.HaveOccurred()) @@ -1080,7 +1080,7 @@ var _ = g.Describe("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.Status.AvailableReplicas, nil }) o.Expect(err).NotTo(o.HaveOccurred()) diff --git a/test/extended/deployments/util.go b/test/extended/deployments/util.go index fea76939ca0a..13fab87ab355 100644 --- a/test/extended/deployments/util.go +++ b/test/extended/deployments/util.go @@ -21,20 +21,20 @@ import ( kcontroller "k8s.io/kubernetes/pkg/controller" e2e "k8s.io/kubernetes/test/e2e/framework" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" - deployapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" - deployutil "github.com/openshift/origin/pkg/apps/util" + appsapi "github.com/openshift/origin/pkg/apps/apis/apps" + appsapiv1 "github.com/openshift/origin/pkg/apps/apis/apps/v1" + appsutil "github.com/openshift/origin/pkg/apps/util" "github.com/openshift/origin/pkg/client" 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 client.DeploymentConfigsNamespacer, namespace, name string, applyUpdate updateConfigFunc) (*deployapi.DeploymentConfig, error) { - var config *deployapi.DeploymentConfig +func updateConfigWithRetries(dn client.DeploymentConfigsNamespacer, 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{}) @@ -52,7 +52,7 @@ func updateConfigWithRetries(dn client.DeploymentConfigsNamespacer, namespace, n func deploymentPods(pods []kapiv1.Pod) (map[string][]*kapiv1.Pod, error) { deployers := make(map[string][]*kapiv1.Pod) for i := range pods { - name, ok := pods[i].Labels[deployapi.DeployerPodForDeploymentLabel] + name, ok := pods[i].Labels[appsapi.DeployerPodForDeploymentLabel] if !ok { continue } @@ -61,7 +61,7 @@ func deploymentPods(pods []kapiv1.Pod) (map[string][]*kapiv1.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 []*kapiv1.Pod) (isRunning, isCompleted bool, err error) { running := false @@ -118,7 +118,7 @@ func checkDeployerPodInvariants(deploymentName string, pods []*kapiv1.Pod) (isRu return running, completed, nil } -func checkDeploymentInvariants(dc *deployapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, pods []kapiv1.Pod) error { +func checkDeploymentInvariants(dc *appsapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, pods []kapiv1.Pod) error { deployers, err := deploymentPods(pods) if err != nil { return err @@ -161,21 +161,21 @@ func checkDeploymentInvariants(dc *deployapi.DeploymentConfig, rcs []*kapiv1.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) } @@ -186,23 +186,23 @@ func checkDeploymentInvariants(dc *deployapi.DeploymentConfig, rcs []*kapiv1.Rep return nil } -func deploymentReachedCompletion(dc *deployapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, pods []kapiv1.Pod) (bool, error) { +func deploymentReachedCompletion(dc *appsapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, pods []kapiv1.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 @@ -220,56 +220,56 @@ func deploymentReachedCompletion(dc *deployapi.DeploymentConfig, rcs []*kapiv1.R return true, nil } -func deploymentFailed(dc *deployapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, _ []kapiv1.Pod) (bool, error) { +func deploymentFailed(dc *appsapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, _ []kapiv1.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 []*kapiv1.ReplicationController, pods []kapiv1.Pod) (bool, error) { +func deploymentRunning(dc *appsapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, pods []kapiv1.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 []*kapiv1.ReplicationController, pods []kapiv1.Pod) (bool, error) { +func deploymentPreHookRetried(dc *appsapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, pods []kapiv1.Pod) (bool, error) { var preHook *kapiv1.Pod for i := range pods { pod := pods[i] @@ -287,11 +287,11 @@ func deploymentPreHookRetried(dc *deployapi.DeploymentConfig, rcs []*kapiv1.Repl return preHook.Status.ContainerStatuses[0].RestartCount > 0, nil } -func deploymentImageTriggersResolved(expectTriggers int) func(dc *deployapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, pods []kapiv1.Pod) (bool, error) { - return func(dc *deployapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, pods []kapiv1.Pod) (bool, error) { +func deploymentImageTriggersResolved(expectTriggers int) func(dc *appsapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, pods []kapiv1.Pod) (bool, error) { + return func(dc *appsapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, pods []kapiv1.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 { @@ -309,7 +309,7 @@ func deploymentImageTriggersResolved(expectTriggers int) func(dc *deployapi.Depl } } -func deploymentInfo(oc *exutil.CLI, name string) (*deployapi.DeploymentConfig, []*kapiv1.ReplicationController, []kapiv1.Pod, error) { +func deploymentInfo(oc *exutil.CLI, name string) (*appsapi.DeploymentConfig, []*kapiv1.ReplicationController, []kapiv1.Pod, error) { dc, err := oc.Client().DeploymentConfigs(oc.Namespace()).Get(name, metav1.GetOptions{}) if err != nil { return nil, nil, nil, err @@ -322,7 +322,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 @@ -333,12 +333,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 []*kapiv1.ReplicationController, pods []kapiv1.Pod) (bool, error) +type deploymentConditionFunc func(dc *appsapi.DeploymentConfig, rcs []*kapiv1.ReplicationController, pods []kapiv1.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) { @@ -367,7 +367,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 }) } @@ -395,8 +395,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() @@ -446,7 +446,7 @@ func waitForRCModification(oc *exutil.CLI, namespace string, name string, timeou return event.Object.(*kapiv1.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.Client().DeploymentConfigs(namespace).Watch(metav1.SingleObject(metav1.ObjectMeta{Name: name, ResourceVersion: resourceVersion})) if err != nil { return nil, err @@ -456,7 +456,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 @@ -464,7 +464,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 @@ -482,13 +482,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.Client().DeploymentConfigs(oc.Namespace()).Get(name, metav1.GetOptions{}) if err != nil { @@ -545,7 +545,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 } @@ -563,7 +563,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 @@ -578,7 +578,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 @@ -593,29 +593,29 @@ func HasValidDCControllerRef(dc metav1.Object, controllee metav1.Object) bool { ref := kcontroller.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 = deployapiv1.Convert_v1_DeploymentConfig_To_apps_DeploymentConfig(dcv1, dc, nil) + dc := new(appsapi.DeploymentConfig) + err = appsapiv1.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 dbe87dca6d8b..96de704f81b0 100644 --- a/test/extended/templates/templateinstance_readiness.go +++ b/test/extended/templates/templateinstance_readiness.go @@ -14,7 +14,7 @@ import ( "k8s.io/kubernetes/pkg/api/v1" "k8s.io/kubernetes/test/e2e/framework" - 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 b3ca592ade93..47f5318abd7c 100644 --- a/test/extended/util/framework.go +++ b/test/extended/util/framework.go @@ -35,8 +35,8 @@ import ( "k8s.io/kubernetes/pkg/quota" "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" authapi "github.com/openshift/origin/pkg/authorization/apis/authorization" buildapi "github.com/openshift/origin/pkg/build/apis/build" "github.com/openshift/origin/pkg/client" @@ -154,7 +154,7 @@ func DumpBuildLogs(bc string, 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) { @@ -730,7 +730,7 @@ var CheckImageStreamTagNotFoundFn = func(i *imageapi.ImageStream) bool { // to a given version and report minimum availability. func WaitForDeploymentConfig(kc kclientset.Interface, oc client.Interface, namespace, name string, version int64, cli *CLI) error { fmt.Fprintf(g.GinkgoWriter, "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) { @@ -750,13 +750,13 @@ func WaitForDeploymentConfig(kc kclientset.Interface, oc client.Interface, names 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] } } @@ -767,7 +767,7 @@ func WaitForDeploymentConfig(kc kclientset.Interface, oc client.Interface, names if progressing != nil && progressing.Status == kapi.ConditionTrue && - progressing.Reason == deployapi.NewRcAvailableReason && + progressing.Reason == appsapi.NewRcAvailableReason && available != nil && available.Status == kapi.ConditionTrue { return true, nil @@ -786,7 +786,7 @@ func WaitForDeploymentConfig(kc kclientset.Interface, oc client.Interface, names 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 37c2952db08d..a06dc158d18f 100644 --- a/test/integration/authorization_test.go +++ b/test/integration/authorization_test.go @@ -20,7 +20,7 @@ import ( kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset" "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/authorization/internalversion" - deployapi "github.com/openshift/origin/pkg/apps/apis/apps" + oappsapi "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" "github.com/openshift/origin/pkg/client" @@ -168,14 +168,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 32645af16d3a..e40a4517e531 100644 --- a/test/integration/deploy_defaults_test.go +++ b/test/integration/deploy_defaults_test.go @@ -10,8 +10,8 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" kapi "k8s.io/kubernetes/pkg/api" - 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" "github.com/openshift/origin/pkg/apps/generated/clientset" "github.com/openshift/origin/pkg/client" testutil "github.com/openshift/origin/test/util" @@ -19,16 +19,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, }, @@ -59,9 +59,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), @@ -69,7 +69,7 @@ func setEssentialDefaults(dc *deployapi.DeploymentConfig) *deployapi.DeploymentC MaxSurge: intstr.FromString("25%"), } dc.Spec.Strategy.ActiveDeadlineSeconds = int64ptr(21600) - dc.Spec.Triggers = []deployapi.DeploymentTriggerPolicy{} + dc.Spec.Triggers = []appsapi.DeploymentTriggerPolicy{} dc.Spec.Template.Spec.Containers[0].TerminationMessagePath = "/dev/termination-log" dc.Spec.Template.Spec.Containers[0].TerminationMessagePolicy = "File" dc.Spec.Template.Spec.Containers[0].ImagePullPolicy = "IfNotPresent" @@ -86,7 +86,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 = "" @@ -119,16 +119,16 @@ func TestDeploymentConfigDefaults(t *testing.T) { } 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 @@ -137,12 +137,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 @@ -167,16 +167,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 @@ -185,12 +185,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 @@ -201,7 +201,7 @@ func TestDeploymentConfigDefaults(t *testing.T) { t.Run("apps.openshift.io", func(t *testing.T) { for _, tc := range ttApps { t.Run("", func(t *testing.T) { - var objV1 deployapiv1.DeploymentConfig + var objV1 appsapiv1.DeploymentConfig err := kapi.Scheme.Convert(tc.obj, &objV1, nil) if err != nil { t.Fatalf("Failed to convert internal DC to v1: %v", err) @@ -211,7 +211,7 @@ func TestDeploymentConfigDefaults(t *testing.T) { t.Fatalf("Failed to create DC: %v", err) } - var appsDC deployapi.DeploymentConfig + var appsDC appsapi.DeploymentConfig err = kapi.Scheme.Convert(appsDCV1, &appsDC, nil) if err != nil { t.Fatalf("Failed to convert v1 to internal DC: %v", err) diff --git a/test/integration/deploy_scale_test.go b/test/integration/deploy_scale_test.go index 784ac7dd2cc6..7e155030b58a 100644 --- a/test/integration/deploy_scale_test.go +++ b/test/integration/deploy_scale_test.go @@ -8,9 +8,9 @@ import ( "k8s.io/apimachinery/pkg/util/wait" extensionsv1beta1 "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" - 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" testutil "github.com/openshift/origin/test/util" testserver "github.com/openshift/origin/test/util/server" ) @@ -40,9 +40,9 @@ func TestDeployScale(t *testing.T) { t.Fatal(err) } - 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 := osClient.DeploymentConfigs(namespace).Create(config) @@ -56,7 +56,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) @@ -70,7 +70,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 := extensionsv1beta1.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 8f84c4a76e41..56a42d8c152d 100644 --- a/test/integration/deploy_trigger_test.go +++ b/test/integration/deploy_trigger_test.go @@ -11,9 +11,9 @@ import ( kapi "k8s.io/kubernetes/pkg/api" "k8s.io/kubernetes/pkg/client/retry" - 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" imageapi "github.com/openshift/origin/pkg/image/apis/image" testutil "github.com/openshift/origin/test/util" testserver "github.com/openshift/origin/test/util/server" @@ -46,9 +46,9 @@ func TestTriggers_manual(t *testing.T) { t.Fatal(err) } - 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 := oc.DeploymentConfigs(namespace).Create(config) if err != nil { @@ -61,7 +61,7 @@ func TestTriggers_manual(t *testing.T) { } defer rcWatch.Stop() - request := &deployapi.DeploymentRequest{ + request := &appsapi.DeploymentRequest{ Name: config.Name, Latest: false, Force: true, @@ -82,9 +82,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() @@ -93,10 +93,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) } } @@ -122,11 +122,11 @@ func TestTriggers_imageChange(t *testing.T) { t.Fatalf("error creating project: %v", err) } - 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 := openshiftProjectAdminClient.DeploymentConfigs(testutil.Namespace()).Watch(metav1.ListOptions{}) if err != nil { @@ -144,8 +144,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() { @@ -184,14 +184,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 { @@ -227,7 +227,7 @@ func TestTriggers_imageChange_nonAutomatic(t *testing.T) { t.Fatalf("error creating project: %v", err) } - imageStream := &imageapi.ImageStream{ObjectMeta: metav1.ObjectMeta{Name: deploytest.ImageStreamName}} + imageStream := &imageapi.ImageStream{ObjectMeta: metav1.ObjectMeta{Name: appstest.ImageStreamName}} if imageStream, err = oc.ImageStreams(testutil.Namespace()).Create(imageStream); err != nil { t.Fatalf("Couldn't create imagestream: %v", err) @@ -239,8 +239,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{ @@ -288,9 +288,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 = oc.DeploymentConfigs(testutil.Namespace()).Create(config); err != nil { t.Fatalf("Couldn't create deploymentconfig: %v", err) @@ -298,7 +298,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) @@ -314,7 +314,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") @@ -329,7 +329,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) @@ -342,7 +342,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") @@ -354,7 +354,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, @@ -380,7 +380,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) } } @@ -406,16 +406,16 @@ func TestTriggers_MultipleICTs(t *testing.T) { t.Fatalf("error creating project: %v", err) } - 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 := openshiftProjectAdminClient.DeploymentConfigs(testutil.Namespace()).Watch(metav1.ListOptions{}) if err != nil { @@ -436,8 +436,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. @@ -490,7 +490,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) } @@ -518,7 +518,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") @@ -574,9 +574,9 @@ func TestTriggers_configChange(t *testing.T) { t.Fatal(err) } - 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 { @@ -598,7 +598,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) } @@ -611,7 +611,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 f389f9c11a7b..a796a1937066 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" @@ -411,8 +411,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"}, @@ -449,8 +449,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"}, @@ -481,8 +481,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 98f50c6a470c..92c9d9bfba0d 100644 --- a/test/integration/newapp_test.go +++ b/test/integration/newapp_test.go @@ -30,7 +30,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" client "github.com/openshift/origin/pkg/client/testclient" "github.com/openshift/origin/pkg/generate" @@ -872,7 +872,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 a9e0d44cdb08..e7d12e17f957 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" "github.com/openshift/origin/pkg/client" configapi "github.com/openshift/origin/pkg/cmd/server/api" "github.com/openshift/origin/pkg/cmd/server/bootstrappolicy" @@ -213,8 +213,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{}