Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/examples/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"triggerPolicy": "manual",
"configId": "redisslave-config",
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "127.0.0.1:5000/openshift/kube-deploy"
}
Expand Down
2 changes: 1 addition & 1 deletion api/examples/deploymentConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"triggerPolicy": "manual",
"template": {
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "127.0.0.1:5000/openshift/kube-deploy"
}
Expand Down
2 changes: 1 addition & 1 deletion api/examples/deploymentConfigs.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"triggerPolicy": "manual",
"template": {
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "127.0.0.1:5000/openshift/kube-deploy"
}
Expand Down
2 changes: 1 addition & 1 deletion api/examples/deployments.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"triggerPolicy": "manual",
"configId": "redisslave-config",
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "127.0.0.1:5000/openshift/kube-deploy"
}
Expand Down
14 changes: 7 additions & 7 deletions api/openshift3.html
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@
"triggerPolicy": "manual",
"template": {
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "127.0.0.1:5000/openshift/kube-deploy"
}
Expand Down Expand Up @@ -699,7 +699,7 @@
"triggerPolicy": "manual",
"template": {
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "127.0.0.1:5000/openshift/kube-deploy"
}
Expand Down Expand Up @@ -747,7 +747,7 @@
"triggerPolicy": "manual",
"template": {
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "127.0.0.1:5000/openshift/kube-deploy"
}
Expand Down Expand Up @@ -806,7 +806,7 @@
"triggerPolicy": "manual",
"configId": "redisslave-config",
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "127.0.0.1:5000/openshift/kube-deploy"
}
Expand Down Expand Up @@ -855,7 +855,7 @@
"triggerPolicy": "manual",
"configId": "redisslave-config",
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "127.0.0.1:5000/openshift/kube-deploy"
}
Expand Down Expand Up @@ -902,7 +902,7 @@
"triggerPolicy": "manual",
"configId": "redisslave-config",
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "127.0.0.1:5000/openshift/kube-deploy"
}
Expand Down Expand Up @@ -949,7 +949,7 @@
"triggerPolicy": "manual",
"configId": "redisslave-config",
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "127.0.0.1:5000/openshift/kube-deploy"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-ruby-app/registry-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"triggerPolicy": "manual",
"configId": "registry-config",
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "openshift/kube-deploy"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-ruby-app/template/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"triggerPolicy": "manual",
"configId": "frontend-config",
"strategy": {
"type": "customPod",
"type": "CustomPod",
"customPod": {
"image": "openshift/kube-deploy"
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/api/test/ok.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func OkStrategy() api.DeploymentStrategy {
return api.DeploymentStrategy{
Type: "customPod",
Type: api.DeploymentStrategyTypeCustomPod,
CustomPod: OkCustomPod(),
}
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/deploy/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,17 @@ type CustomPodDeploymentStrategy struct {

// DeploymentStrategy describes how to perform a deployment.
type DeploymentStrategy struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Type DeploymentStrategyType `json:"type,omitempty" yaml:"type,omitempty"`
CustomPod *CustomPodDeploymentStrategy `json:"customPod,omitempty" yaml:"customPod,omitempty"`
}

type DeploymentStrategyType string

const (
DeploymentStrategyTypeCustomPod DeploymentStrategyType = "CustomPod"
DeploymentStrategyTypeBasic DeploymentStrategyType = "Basic"
)

// DeploymentConfig represents a configuration for a single deployment of a replication controller:
// what the template for the deployment, how new deployments are triggered, what the current
// deployed state is.
Expand Down
9 changes: 8 additions & 1 deletion pkg/deploy/api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ type CustomPodDeploymentStrategy struct {

// DeploymentStrategy describes how to perform a deployment.
type DeploymentStrategy struct {
Type string `json:"type,omitempty" yaml:"type,omitempty"`
Type DeploymentStrategyType `json:"type,omitempty" yaml:"type,omitempty"`
CustomPod *CustomPodDeploymentStrategy `json:"customPod,omitempty" yaml:"customPod,omitempty"`
}

type DeploymentStrategyType string

const (
DeploymentStrategyTypeCustomPod DeploymentStrategyType = "CustomPod"
DeploymentStrategyTypeBasic DeploymentStrategyType = "Basic"
)

// DeploymentTemplate contains all the necessary information to create a Deployment from a
// DeploymentStrategy.
type DeploymentTemplate struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/api/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func validateDeploymentStrategy(strategy *deployapi.DeploymentStrategy) errors.E
result = append(result, errors.NewFieldRequired("Type", ""))
}

if strategy.Type == "customPod" {
if strategy.Type == deployapi.DeploymentStrategyTypeCustomPod {
if strategy.CustomPod == nil {
result = append(result, errors.NewFieldRequired("CustomPod", nil))
} else {
Expand Down
10 changes: 5 additions & 5 deletions pkg/deploy/api/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func okDeploymentTemplate() api.DeploymentTemplate {

func okStrategy() api.DeploymentStrategy {
return api.DeploymentStrategy{
Type: "customPod",
Type: api.DeploymentStrategyTypeCustomPod,
CustomPod: okCustomPod(),
}
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func TestValidateDeploymentMissingFields(t *testing.T) {
"missing Strategy.CustomPod": {
api.Deployment{
Strategy: api.DeploymentStrategy{
Type: "customPod",
Type: api.DeploymentStrategyTypeCustomPod,
},
ControllerTemplate: okControllerTemplate(),
},
Expand All @@ -101,7 +101,7 @@ func TestValidateDeploymentMissingFields(t *testing.T) {
"missing Strategy.CustomPod.Image": {
api.Deployment{
Strategy: api.DeploymentStrategy{
Type: "customPod",
Type: api.DeploymentStrategyTypeCustomPod,
CustomPod: &api.CustomPodDeploymentStrategy{},
},
ControllerTemplate: okControllerTemplate(),
Expand Down Expand Up @@ -206,7 +206,7 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) {
Triggers: manualTrigger(),
Template: api.DeploymentTemplate{
Strategy: api.DeploymentStrategy{
Type: "customPod",
Type: api.DeploymentStrategyTypeCustomPod,
},
ControllerTemplate: okControllerTemplate(),
},
Expand All @@ -219,7 +219,7 @@ func TestValidateDeploymentConfigMissingFields(t *testing.T) {
Triggers: manualTrigger(),
Template: api.DeploymentTemplate{
Strategy: api.DeploymentStrategy{
Type: "customPod",
Type: api.DeploymentStrategyTypeCustomPod,
CustomPod: &api.CustomPodDeploymentStrategy{},
},
ControllerTemplate: okControllerTemplate(),
Expand Down
8 changes: 4 additions & 4 deletions pkg/deploy/controller/config_change_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func initialConfig() *deployapi.DeploymentConfig {
LatestVersion: 2,
Template: deployapi.DeploymentTemplate{
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/openshift/kube-deploy",
},
Expand Down Expand Up @@ -174,7 +174,7 @@ func diffedConfig() *deployapi.DeploymentConfig {
LatestVersion: 2,
Template: deployapi.DeploymentTemplate{
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/openshift/kube-deploy",
},
Expand Down Expand Up @@ -216,7 +216,7 @@ func generatedConfig() *deployapi.DeploymentConfig {
LatestVersion: 3,
Template: deployapi.DeploymentTemplate{
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/openshift/kube-deploy",
},
Expand Down Expand Up @@ -252,7 +252,7 @@ func matchingInitialDeployment() *deployapi.Deployment {
JSONBase: kapi.JSONBase{ID: "test-deploy-config-1"},
Status: deployapi.DeploymentStatusNew,
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/repo1:ref1",
Environment: []kapi.EnvVar{},
Expand Down
4 changes: 2 additions & 2 deletions pkg/deploy/controller/deployment_config_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func manualDeploymentConfig() *deployapi.DeploymentConfig {
},
Template: deployapi.DeploymentTemplate{
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/openshift/kube-deploy",
},
Expand Down Expand Up @@ -175,7 +175,7 @@ func matchingDeployment() *deployapi.Deployment {
JSONBase: kapi.JSONBase{ID: "manual-deploy-config-1"},
Status: deployapi.DeploymentStatusNew,
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/repo1:ref1",
Environment: []kapi.EnvVar{},
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/controller/deployment_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func basicDeployment() *deployapi.Deployment {
JSONBase: kapi.JSONBase{ID: "deploy1"},
Status: deployapi.DeploymentStatusNew,
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/repo1:ref1",
Environment: []kapi.EnvVar{},
Expand Down
6 changes: 3 additions & 3 deletions pkg/deploy/controller/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type DeploymentControllerFactory struct {
}

func (factory *DeploymentControllerFactory) Create() *controller.DeploymentController {
field := labels.SelectorFromSet(labels.Set{"Strategy": "customPod"})
field := labels.SelectorFromSet(labels.Set{"Strategy": string(deployapi.DeploymentStrategyTypeCustomPod)})
queue := cache.NewFIFO()
cache.NewReflector(&deploymentLW{client: factory.Client, field: field}, &deployapi.Deployment{}, queue).Run()

Expand All @@ -41,7 +41,7 @@ type BasicDeploymentControllerFactory struct {
}

func (factory *BasicDeploymentControllerFactory) Create() *controller.BasicDeploymentController {
field := labels.SelectorFromSet(labels.Set{"Strategy": "basic"})
field := labels.SelectorFromSet(labels.Set{"Strategy": string(deployapi.DeploymentStrategyTypeBasic)})
queue := cache.NewFIFO()
cache.NewReflector(&deploymentLW{client: factory.Client, field: field}, &deployapi.Deployment{}, queue).Run()

Expand Down Expand Up @@ -128,7 +128,7 @@ func (lw *deploymentLW) List() (runtime.Object, error) {
for _, deployment := range deployments.Items {
fields := labels.Set{
"ID": deployment.ID,
"Strategy": deployment.Strategy.Type,
"Strategy": string(deployment.Strategy.Type),
}
if lw.field.Matches(fields) {
filtered = append(filtered, deployment)
Expand Down
4 changes: 2 additions & 2 deletions pkg/deploy/controller/image_change_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func imageChangeDeploymentConfig() *deployapi.DeploymentConfig {
},
Template: deployapi.DeploymentTemplate{
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/openshift/kube-deploy",
},
Expand Down Expand Up @@ -180,7 +180,7 @@ func regeneratedConfig() *deployapi.DeploymentConfig {
},
Template: deployapi.DeploymentTemplate{
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/openshift/kube-deploy",
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/registry/deploy/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (s *REST) Watch(ctx kubeapi.Context, label, field labels.Selector, resource
return s.registry.WatchDeployments(resourceVersion, func(deployment *deployapi.Deployment) bool {
fields := labels.Set{
"ID": deployment.ID,
"Strategy": deployment.Strategy.Type,
"Strategy": string(deployment.Strategy.Type),
}
return label.Matches(labels.Set(deployment.Labels)) && field.Matches(fields)
})
Expand Down
6 changes: 3 additions & 3 deletions test/integration/deploy_trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func imageChangeDeploymentConfig() *deployapi.DeploymentConfig {
},
Template: deployapi.DeploymentTemplate{
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/openshift/kube-deploy",
},
Expand Down Expand Up @@ -350,7 +350,7 @@ func manualDeploymentConfig() *deployapi.DeploymentConfig {
},
Template: deployapi.DeploymentTemplate{
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/openshift/kube-deploy",
},
Expand Down Expand Up @@ -394,7 +394,7 @@ func changeDeploymentConfig() *deployapi.DeploymentConfig {
},
Template: deployapi.DeploymentTemplate{
Strategy: deployapi.DeploymentStrategy{
Type: "customPod",
Type: deployapi.DeploymentStrategyTypeCustomPod,
CustomPod: &deployapi.CustomPodDeploymentStrategy{
Image: "registry:8080/openshift/kube-deploy",
},
Expand Down