| ... | ... |
@@ -117,13 +117,13 @@ func TestBuildConfigValidationFailure(t *testing.T) {
|
| 117 | 117 |
|
| 118 | 118 |
func TestValidateSource(t *testing.T) {
|
| 119 | 119 |
errorCases := map[string]*buildapi.BuildSource{
|
| 120 |
- string(errs.ValidationErrorTypeRequired) + "git.uri": &buildapi.BuildSource{
|
|
| 120 |
+ string(errs.ValidationErrorTypeRequired) + "git.uri": {
|
|
| 121 | 121 |
Type: buildapi.BuildSourceGit, |
| 122 | 122 |
Git: &buildapi.GitBuildSource{
|
| 123 | 123 |
URI: "", |
| 124 | 124 |
}, |
| 125 | 125 |
}, |
| 126 |
- string(errs.ValidationErrorTypeInvalid) + "git.uri": &buildapi.BuildSource{
|
|
| 126 |
+ string(errs.ValidationErrorTypeInvalid) + "git.uri": {
|
|
| 127 | 127 |
Type: buildapi.BuildSourceGit, |
| 128 | 128 |
Git: &buildapi.GitBuildSource{
|
| 129 | 129 |
URI: "::", |
| ... | ... |
@@ -145,7 +145,7 @@ func TestValidateSource(t *testing.T) {
|
| 145 | 145 |
|
| 146 | 146 |
func TestValidateBuildParameters(t *testing.T) {
|
| 147 | 147 |
errorCases := map[string]*buildapi.BuildParameters{
|
| 148 |
- string(errs.ValidationErrorTypeRequired) + "output.imageTag": &buildapi.BuildParameters{
|
|
| 148 |
+ string(errs.ValidationErrorTypeRequired) + "output.imageTag": {
|
|
| 149 | 149 |
Source: buildapi.BuildSource{
|
| 150 | 150 |
Type: buildapi.BuildSourceGit, |
| 151 | 151 |
Git: &buildapi.GitBuildSource{
|
| ... | ... |
@@ -162,7 +162,7 @@ func TestValidateBuildParameters(t *testing.T) {
|
| 162 | 162 |
ImageTag: "", |
| 163 | 163 |
}, |
| 164 | 164 |
}, |
| 165 |
- string(errs.ValidationErrorTypeRequired) + "strategy.stiStrategy.builderImage": &buildapi.BuildParameters{
|
|
| 165 |
+ string(errs.ValidationErrorTypeRequired) + "strategy.stiStrategy.builderImage": {
|
|
| 166 | 166 |
Source: buildapi.BuildSource{
|
| 167 | 167 |
Type: buildapi.BuildSourceGit, |
| 168 | 168 |
Git: &buildapi.GitBuildSource{
|
| ... | ... |
@@ -1,16 +1,16 @@ |
| 1 | 1 |
package test |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "github.com/GoogleCloudPlatform/kubernetes/pkg/util" |
|
| 5 |
- buildapi "github.com/openshift/origin/pkg/build/api" |
|
| 4 |
+ "github.com/GoogleCloudPlatform/kubernetes/pkg/util" |
|
| 5 |
+ buildapi "github.com/openshift/origin/pkg/build/api" |
|
| 6 | 6 |
) |
| 7 | 7 |
|
| 8 | 8 |
type FakeBuildStore struct {
|
| 9 |
- Build *buildapi.Build |
|
| 9 |
+ Build *buildapi.Build |
|
| 10 | 10 |
} |
| 11 | 11 |
|
| 12 | 12 |
func NewFakeBuildStore(build *buildapi.Build) FakeBuildStore {
|
| 13 |
- return FakeBuildStore{build}
|
|
| 13 |
+ return FakeBuildStore{build}
|
|
| 14 | 14 |
} |
| 15 | 15 |
|
| 16 | 16 |
func (s FakeBuildStore) Add(id string, obj interface{}) {
|
| ... | ... |
@@ -23,19 +23,19 @@ func (s FakeBuildStore) Delete(id string) {
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 | 25 |
func (s FakeBuildStore) List() []interface{} {
|
| 26 |
- return []interface{}{s.Build}
|
|
| 26 |
+ return []interface{}{s.Build}
|
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 | 29 |
func (s FakeBuildStore) Contains() util.StringSet {
|
| 30 |
- return util.NewStringSet() |
|
| 30 |
+ return util.NewStringSet() |
|
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 | 33 |
func (s FakeBuildStore) Get(id string) (item interface{}, exists bool) {
|
| 34 |
- if s.Build == nil {
|
|
| 35 |
- return nil, false |
|
| 36 |
- } |
|
| 34 |
+ if s.Build == nil {
|
|
| 35 |
+ return nil, false |
|
| 36 |
+ } |
|
| 37 | 37 |
|
| 38 |
- return s.Build, true |
|
| 38 |
+ return s.Build, true |
|
| 39 | 39 |
} |
| 40 | 40 |
|
| 41 | 41 |
func (s FakeBuildStore) Replace(idToObj map[string]interface{}) {}
|
| ... | ... |
@@ -38,7 +38,7 @@ func printImageRepository(repo *api.ImageRepository, w io.Writer) error {
|
| 38 | 38 |
tags := "" |
| 39 | 39 |
if len(repo.Tags) > 0 {
|
| 40 | 40 |
var t []string |
| 41 |
- for tag, _ := range repo.Tags {
|
|
| 41 |
+ for tag := range repo.Tags {
|
|
| 42 | 42 |
t = append(t, tag) |
| 43 | 43 |
} |
| 44 | 44 |
tags = strings.Join(t, ",") |
| ... | ... |
@@ -289,7 +289,7 @@ func (c *MasterConfig) RunCustomPodDeploymentController() {
|
| 289 | 289 |
Client: c.OSClient, |
| 290 | 290 |
KubeClient: c.KubeClient, |
| 291 | 291 |
Environment: []api.EnvVar{
|
| 292 |
- api.EnvVar{Name: "KUBERNETES_MASTER", Value: c.MasterAddr},
|
|
| 292 |
+ {Name: "KUBERNETES_MASTER", Value: c.MasterAddr},
|
|
| 293 | 293 |
}, |
| 294 | 294 |
} |
| 295 | 295 |
|
| ... | ... |
@@ -90,7 +90,7 @@ func Apply(namespace string, data []byte, storage clientapi.ClientMappings) (res |
| 90 | 90 |
|
| 91 | 91 |
// AddConfigLabels adds new label(s) to all resources defined in the given Config. |
| 92 | 92 |
func AddConfigLabels(c *api.Config, labels labels.Set) error {
|
| 93 |
- for i, _ := range c.Items {
|
|
| 93 |
+ for i := range c.Items {
|
|
| 94 | 94 |
switch t := c.Items[i].Object.(type) {
|
| 95 | 95 |
case *kapi.Pod: |
| 96 | 96 |
if err := mergeMaps(&t.Labels, labels, ErrorOnDifferentDstKeyValue); err != nil {
|
| ... | ... |
@@ -81,7 +81,7 @@ func validateImageChangeParams(params *deployapi.DeploymentTriggerImageChangePar |
| 81 | 81 |
func ValidateDeploymentConfig(config *deployapi.DeploymentConfig) errors.ErrorList {
|
| 82 | 82 |
result := errors.ErrorList{}
|
| 83 | 83 |
|
| 84 |
- for i, _ := range config.Triggers {
|
|
| 84 |
+ for i := range config.Triggers {
|
|
| 85 | 85 |
result = append(result, validateTrigger(&config.Triggers[i]).PrefixIndex(i).Prefix("triggers")...)
|
| 86 | 86 |
} |
| 87 | 87 |
|
| ... | ... |
@@ -1,139 +1,139 @@ |
| 1 | 1 |
package controller |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "github.com/golang/glog" |
|
| 4 |
+ "github.com/golang/glog" |
|
| 5 | 5 |
|
| 6 |
- kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
|
| 7 |
- "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" |
|
| 8 |
- "github.com/GoogleCloudPlatform/kubernetes/pkg/util" |
|
| 6 |
+ kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
|
| 7 |
+ "github.com/GoogleCloudPlatform/kubernetes/pkg/labels" |
|
| 8 |
+ "github.com/GoogleCloudPlatform/kubernetes/pkg/util" |
|
| 9 | 9 |
|
| 10 |
- deployapi "github.com/openshift/origin/pkg/deploy/api" |
|
| 10 |
+ deployapi "github.com/openshift/origin/pkg/deploy/api" |
|
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 | 13 |
// BasicDeploymentController implements the DeploymentStrategyTypeBasic deployment strategy. Its behavior |
| 14 | 14 |
// is to create new replication controllers as defined on a Deployment, and delete any previously existing |
| 15 | 15 |
// replication controllers for the same DeploymentConfig associated with the deployment. |
| 16 | 16 |
type BasicDeploymentController struct {
|
| 17 |
- DeploymentUpdater bdcDeploymentUpdater |
|
| 18 |
- ReplicationControllerClient bdcReplicationControllerClient |
|
| 19 |
- NextDeployment func() *deployapi.Deployment |
|
| 17 |
+ DeploymentUpdater bdcDeploymentUpdater |
|
| 18 |
+ ReplicationControllerClient bdcReplicationControllerClient |
|
| 19 |
+ NextDeployment func() *deployapi.Deployment |
|
| 20 | 20 |
} |
| 21 | 21 |
|
| 22 | 22 |
type bdcDeploymentUpdater interface {
|
| 23 |
- UpdateDeployment(ctx kapi.Context, deployment *deployapi.Deployment) (*deployapi.Deployment, error) |
|
| 23 |
+ UpdateDeployment(ctx kapi.Context, deployment *deployapi.Deployment) (*deployapi.Deployment, error) |
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
type bdcReplicationControllerClient interface {
|
| 27 |
- ListReplicationControllers(ctx kapi.Context, selector labels.Selector) (*kapi.ReplicationControllerList, error) |
|
| 28 |
- GetReplicationController(ctx kapi.Context, id string) (*kapi.ReplicationController, error) |
|
| 29 |
- CreateReplicationController(ctx kapi.Context, ctrl *kapi.ReplicationController) (*kapi.ReplicationController, error) |
|
| 30 |
- UpdateReplicationController(ctx kapi.Context, ctrl *kapi.ReplicationController) (*kapi.ReplicationController, error) |
|
| 31 |
- DeleteReplicationController(ctx kapi.Context, id string) error |
|
| 27 |
+ ListReplicationControllers(ctx kapi.Context, selector labels.Selector) (*kapi.ReplicationControllerList, error) |
|
| 28 |
+ GetReplicationController(ctx kapi.Context, id string) (*kapi.ReplicationController, error) |
|
| 29 |
+ CreateReplicationController(ctx kapi.Context, ctrl *kapi.ReplicationController) (*kapi.ReplicationController, error) |
|
| 30 |
+ UpdateReplicationController(ctx kapi.Context, ctrl *kapi.ReplicationController) (*kapi.ReplicationController, error) |
|
| 31 |
+ DeleteReplicationController(ctx kapi.Context, id string) error |
|
| 32 | 32 |
} |
| 33 | 33 |
|
| 34 | 34 |
func (dc *BasicDeploymentController) Run() {
|
| 35 |
- go util.Forever(func() { dc.HandleDeployment() }, 0)
|
|
| 35 |
+ go util.Forever(func() { dc.HandleDeployment() }, 0)
|
|
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 | 38 |
// HandleDeployment executes a single Deployment. It's assumed that the strategy of the deployment is |
| 39 | 39 |
// DeploymentStrategyTypeBasic. |
| 40 | 40 |
func (dc *BasicDeploymentController) HandleDeployment() error {
|
| 41 |
- deployment := dc.NextDeployment() |
|
| 42 |
- |
|
| 43 |
- if deployment.Strategy.Type != deployapi.DeploymentStrategyTypeBasic {
|
|
| 44 |
- glog.V(4).Infof("Ignoring deployment %s due to incompatible strategy type %s", deployment.ID, deployment.Strategy)
|
|
| 45 |
- return nil |
|
| 46 |
- } |
|
| 47 |
- |
|
| 48 |
- ctx := kapi.WithNamespace(kapi.NewContext(), deployment.Namespace) |
|
| 49 |
- |
|
| 50 |
- nextStatus := deployment.Status |
|
| 51 |
- switch deployment.Status {
|
|
| 52 |
- case deployapi.DeploymentStatusNew: |
|
| 53 |
- nextStatus = dc.handleNew(ctx, deployment) |
|
| 54 |
- } |
|
| 55 |
- |
|
| 56 |
- // persist any status change |
|
| 57 |
- if deployment.Status != nextStatus {
|
|
| 58 |
- deployment.Status = nextStatus |
|
| 59 |
- glog.V(4).Infof("Saving deployment %v status: %v", deployment.ID, deployment.Status)
|
|
| 60 |
- if _, err := dc.DeploymentUpdater.UpdateDeployment(ctx, deployment); err != nil {
|
|
| 61 |
- glog.V(2).Infof("Received error while saving deployment %v: %v", deployment.ID, err)
|
|
| 62 |
- return err |
|
| 63 |
- } |
|
| 64 |
- } |
|
| 65 |
- |
|
| 66 |
- return nil |
|
| 41 |
+ deployment := dc.NextDeployment() |
|
| 42 |
+ |
|
| 43 |
+ if deployment.Strategy.Type != deployapi.DeploymentStrategyTypeBasic {
|
|
| 44 |
+ glog.V(4).Infof("Ignoring deployment %s due to incompatible strategy type %s", deployment.ID, deployment.Strategy)
|
|
| 45 |
+ return nil |
|
| 46 |
+ } |
|
| 47 |
+ |
|
| 48 |
+ ctx := kapi.WithNamespace(kapi.NewContext(), deployment.Namespace) |
|
| 49 |
+ |
|
| 50 |
+ nextStatus := deployment.Status |
|
| 51 |
+ switch deployment.Status {
|
|
| 52 |
+ case deployapi.DeploymentStatusNew: |
|
| 53 |
+ nextStatus = dc.handleNew(ctx, deployment) |
|
| 54 |
+ } |
|
| 55 |
+ |
|
| 56 |
+ // persist any status change |
|
| 57 |
+ if deployment.Status != nextStatus {
|
|
| 58 |
+ deployment.Status = nextStatus |
|
| 59 |
+ glog.V(4).Infof("Saving deployment %v status: %v", deployment.ID, deployment.Status)
|
|
| 60 |
+ if _, err := dc.DeploymentUpdater.UpdateDeployment(ctx, deployment); err != nil {
|
|
| 61 |
+ glog.V(2).Infof("Received error while saving deployment %v: %v", deployment.ID, err)
|
|
| 62 |
+ return err |
|
| 63 |
+ } |
|
| 64 |
+ } |
|
| 65 |
+ |
|
| 66 |
+ return nil |
|
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 | 69 |
func (dc *BasicDeploymentController) handleNew(ctx kapi.Context, deployment *deployapi.Deployment) deployapi.DeploymentStatus {
|
| 70 |
- controllers := &kapi.ReplicationControllerList{}
|
|
| 71 |
- var err error |
|
| 72 |
- |
|
| 73 |
- configID, hasConfigID := deployment.Labels[deployapi.DeploymentConfigLabel] |
|
| 74 |
- if hasConfigID {
|
|
| 75 |
- selector, _ := labels.ParseSelector(deployapi.DeploymentConfigLabel + "=" + configID) |
|
| 76 |
- controllers, err = dc.ReplicationControllerClient.ListReplicationControllers(ctx, selector) |
|
| 77 |
- if err != nil {
|
|
| 78 |
- glog.V(2).Infof("Unable to get list of replication controllers for previous deploymentConfig %s: %v\n", configID, err)
|
|
| 79 |
- return deployapi.DeploymentStatusFailed |
|
| 80 |
- } |
|
| 81 |
- } |
|
| 82 |
- |
|
| 83 |
- controller := &kapi.ReplicationController{
|
|
| 84 |
- DesiredState: deployment.ControllerTemplate, |
|
| 85 |
- Labels: map[string]string{deployapi.DeploymentConfigLabel: configID, "deployment": deployment.ID},
|
|
| 86 |
- } |
|
| 87 |
- |
|
| 88 |
- if controller.DesiredState.PodTemplate.Labels == nil {
|
|
| 89 |
- controller.DesiredState.PodTemplate.Labels = make(map[string]string) |
|
| 90 |
- } |
|
| 91 |
- |
|
| 92 |
- controller.DesiredState.PodTemplate.Labels[deployapi.DeploymentConfigLabel] = configID |
|
| 93 |
- controller.DesiredState.PodTemplate.Labels["deployment"] = deployment.ID |
|
| 94 |
- |
|
| 95 |
- glog.V(2).Infof("Creating replicationController for deployment %s", deployment.ID)
|
|
| 96 |
- if _, err := dc.ReplicationControllerClient.CreateReplicationController(ctx, controller); err != nil {
|
|
| 97 |
- glog.V(2).Infof("An error occurred creating the replication controller for deployment %s: %v", deployment.ID, err)
|
|
| 98 |
- return deployapi.DeploymentStatusFailed |
|
| 99 |
- } |
|
| 100 |
- |
|
| 101 |
- allProcessed := true |
|
| 102 |
- // For this simple deploy, remove previous replication controllers |
|
| 103 |
- for _, rc := range controllers.Items {
|
|
| 104 |
- configID, _ := deployment.Labels[deployapi.DeploymentConfigLabel] |
|
| 105 |
- glog.V(2).Infof("Stopping replication controller for previous deploymentConfig %s: %v", configID, rc.ID)
|
|
| 106 |
- |
|
| 107 |
- controller, err := dc.ReplicationControllerClient.GetReplicationController(ctx, rc.ID) |
|
| 108 |
- if err != nil {
|
|
| 109 |
- glog.V(2).Infof("Unable to get replication controller %s for previous deploymentConfig %s: %#v\n", rc.ID, configID, err)
|
|
| 110 |
- allProcessed = false |
|
| 111 |
- continue |
|
| 112 |
- } |
|
| 113 |
- |
|
| 114 |
- controller.DesiredState.Replicas = 0 |
|
| 115 |
- glog.V(2).Infof("Settings Replicas=0 for replicationController %s for previous deploymentConfig %s", rc.ID, configID)
|
|
| 116 |
- if _, err := dc.ReplicationControllerClient.UpdateReplicationController(ctx, controller); err != nil {
|
|
| 117 |
- glog.V(2).Infof("Unable to stop replication controller %s for previous deploymentConfig %s: %#v\n", rc.ID, configID, err)
|
|
| 118 |
- allProcessed = false |
|
| 119 |
- continue |
|
| 120 |
- } |
|
| 121 |
- } |
|
| 122 |
- |
|
| 123 |
- for _, rc := range controllers.Items {
|
|
| 124 |
- configID, _ := deployment.Labels[deployapi.DeploymentConfigLabel] |
|
| 125 |
- glog.V(2).Infof("Deleting replication controller %s for previous deploymentConfig %s", rc.ID, configID)
|
|
| 126 |
- err := dc.ReplicationControllerClient.DeleteReplicationController(ctx, rc.ID) |
|
| 127 |
- if err != nil {
|
|
| 128 |
- glog.V(2).Infof("Unable to remove replication controller %s for previous deploymentConfig %s:%#v\n", rc.ID, configID, err)
|
|
| 129 |
- allProcessed = false |
|
| 130 |
- continue |
|
| 131 |
- } |
|
| 132 |
- } |
|
| 133 |
- |
|
| 134 |
- if allProcessed {
|
|
| 135 |
- return deployapi.DeploymentStatusComplete |
|
| 136 |
- } |
|
| 137 |
- |
|
| 138 |
- return deployapi.DeploymentStatusFailed |
|
| 70 |
+ controllers := &kapi.ReplicationControllerList{}
|
|
| 71 |
+ var err error |
|
| 72 |
+ |
|
| 73 |
+ configID, hasConfigID := deployment.Labels[deployapi.DeploymentConfigLabel] |
|
| 74 |
+ if hasConfigID {
|
|
| 75 |
+ selector, _ := labels.ParseSelector(deployapi.DeploymentConfigLabel + "=" + configID) |
|
| 76 |
+ controllers, err = dc.ReplicationControllerClient.ListReplicationControllers(ctx, selector) |
|
| 77 |
+ if err != nil {
|
|
| 78 |
+ glog.V(2).Infof("Unable to get list of replication controllers for previous deploymentConfig %s: %v\n", configID, err)
|
|
| 79 |
+ return deployapi.DeploymentStatusFailed |
|
| 80 |
+ } |
|
| 81 |
+ } |
|
| 82 |
+ |
|
| 83 |
+ controller := &kapi.ReplicationController{
|
|
| 84 |
+ DesiredState: deployment.ControllerTemplate, |
|
| 85 |
+ Labels: map[string]string{deployapi.DeploymentConfigLabel: configID, "deployment": deployment.ID},
|
|
| 86 |
+ } |
|
| 87 |
+ |
|
| 88 |
+ if controller.DesiredState.PodTemplate.Labels == nil {
|
|
| 89 |
+ controller.DesiredState.PodTemplate.Labels = make(map[string]string) |
|
| 90 |
+ } |
|
| 91 |
+ |
|
| 92 |
+ controller.DesiredState.PodTemplate.Labels[deployapi.DeploymentConfigLabel] = configID |
|
| 93 |
+ controller.DesiredState.PodTemplate.Labels["deployment"] = deployment.ID |
|
| 94 |
+ |
|
| 95 |
+ glog.V(2).Infof("Creating replicationController for deployment %s", deployment.ID)
|
|
| 96 |
+ if _, err := dc.ReplicationControllerClient.CreateReplicationController(ctx, controller); err != nil {
|
|
| 97 |
+ glog.V(2).Infof("An error occurred creating the replication controller for deployment %s: %v", deployment.ID, err)
|
|
| 98 |
+ return deployapi.DeploymentStatusFailed |
|
| 99 |
+ } |
|
| 100 |
+ |
|
| 101 |
+ allProcessed := true |
|
| 102 |
+ // For this simple deploy, remove previous replication controllers |
|
| 103 |
+ for _, rc := range controllers.Items {
|
|
| 104 |
+ configID, _ := deployment.Labels[deployapi.DeploymentConfigLabel] |
|
| 105 |
+ glog.V(2).Infof("Stopping replication controller for previous deploymentConfig %s: %v", configID, rc.ID)
|
|
| 106 |
+ |
|
| 107 |
+ controller, err := dc.ReplicationControllerClient.GetReplicationController(ctx, rc.ID) |
|
| 108 |
+ if err != nil {
|
|
| 109 |
+ glog.V(2).Infof("Unable to get replication controller %s for previous deploymentConfig %s: %#v\n", rc.ID, configID, err)
|
|
| 110 |
+ allProcessed = false |
|
| 111 |
+ continue |
|
| 112 |
+ } |
|
| 113 |
+ |
|
| 114 |
+ controller.DesiredState.Replicas = 0 |
|
| 115 |
+ glog.V(2).Infof("Settings Replicas=0 for replicationController %s for previous deploymentConfig %s", rc.ID, configID)
|
|
| 116 |
+ if _, err := dc.ReplicationControllerClient.UpdateReplicationController(ctx, controller); err != nil {
|
|
| 117 |
+ glog.V(2).Infof("Unable to stop replication controller %s for previous deploymentConfig %s: %#v\n", rc.ID, configID, err)
|
|
| 118 |
+ allProcessed = false |
|
| 119 |
+ continue |
|
| 120 |
+ } |
|
| 121 |
+ } |
|
| 122 |
+ |
|
| 123 |
+ for _, rc := range controllers.Items {
|
|
| 124 |
+ configID, _ := deployment.Labels[deployapi.DeploymentConfigLabel] |
|
| 125 |
+ glog.V(2).Infof("Deleting replication controller %s for previous deploymentConfig %s", rc.ID, configID)
|
|
| 126 |
+ err := dc.ReplicationControllerClient.DeleteReplicationController(ctx, rc.ID) |
|
| 127 |
+ if err != nil {
|
|
| 128 |
+ glog.V(2).Infof("Unable to remove replication controller %s for previous deploymentConfig %s:%#v\n", rc.ID, configID, err)
|
|
| 129 |
+ allProcessed = false |
|
| 130 |
+ continue |
|
| 131 |
+ } |
|
| 132 |
+ } |
|
| 133 |
+ |
|
| 134 |
+ if allProcessed {
|
|
| 135 |
+ return deployapi.DeploymentStatusComplete |
|
| 136 |
+ } |
|
| 137 |
+ |
|
| 138 |
+ return deployapi.DeploymentStatusFailed |
|
| 139 | 139 |
} |
| ... | ... |
@@ -1,276 +1,276 @@ |
| 1 | 1 |
package controller |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "testing" |
|
| 4 |
+ "testing" |
|
| 5 | 5 |
|
| 6 |
- kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
|
| 7 |
- deployapi "github.com/openshift/origin/pkg/deploy/api" |
|
| 8 |
- deploytest "github.com/openshift/origin/pkg/deploy/controller/test" |
|
| 6 |
+ kapi "github.com/GoogleCloudPlatform/kubernetes/pkg/api" |
|
| 7 |
+ deployapi "github.com/openshift/origin/pkg/deploy/api" |
|
| 8 |
+ deploytest "github.com/openshift/origin/pkg/deploy/controller/test" |
|
| 9 | 9 |
) |
| 10 | 10 |
|
| 11 | 11 |
type testDcDeploymentInterface struct {
|
| 12 |
- UpdateDeploymentFunc func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) |
|
| 12 |
+ UpdateDeploymentFunc func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) |
|
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 | 15 |
func (i *testDcDeploymentInterface) UpdateDeployment(ctx kapi.Context, deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
| 16 |
- return i.UpdateDeploymentFunc(deployment) |
|
| 16 |
+ return i.UpdateDeploymentFunc(deployment) |
|
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 | 19 |
type testDcPodInterface struct {
|
| 20 |
- CreatePodFunc func(pod *kapi.Pod) (*kapi.Pod, error) |
|
| 21 |
- DeletePodFunc func(id string) error |
|
| 20 |
+ CreatePodFunc func(pod *kapi.Pod) (*kapi.Pod, error) |
|
| 21 |
+ DeletePodFunc func(id string) error |
|
| 22 | 22 |
} |
| 23 | 23 |
|
| 24 | 24 |
func (i *testDcPodInterface) CreatePod(ctx kapi.Context, pod *kapi.Pod) (*kapi.Pod, error) {
|
| 25 |
- return i.CreatePodFunc(pod) |
|
| 25 |
+ return i.CreatePodFunc(pod) |
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 | 28 |
func (i *testDcPodInterface) DeletePod(ctx kapi.Context, id string) error {
|
| 29 |
- return i.DeletePodFunc(id) |
|
| 29 |
+ return i.DeletePodFunc(id) |
|
| 30 | 30 |
} |
| 31 | 31 |
|
| 32 | 32 |
func TestHandleNew(t *testing.T) {
|
| 33 |
- var ( |
|
| 34 |
- updatedDeployment *deployapi.Deployment |
|
| 35 |
- createdPod *kapi.Pod |
|
| 36 |
- ) |
|
| 37 |
- |
|
| 38 |
- controller := &CustomPodDeploymentController{
|
|
| 39 |
- DeploymentInterface: &testDcDeploymentInterface{
|
|
| 40 |
- UpdateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 41 |
- updatedDeployment = deployment |
|
| 42 |
- return deployment, nil |
|
| 43 |
- }, |
|
| 44 |
- }, |
|
| 45 |
- PodInterface: &testDcPodInterface{
|
|
| 46 |
- CreatePodFunc: func(pod *kapi.Pod) (*kapi.Pod, error) {
|
|
| 47 |
- createdPod = pod |
|
| 48 |
- return pod, nil |
|
| 49 |
- }, |
|
| 50 |
- }, |
|
| 51 |
- NextDeployment: func() *deployapi.Deployment {
|
|
| 52 |
- deployment := customPodDeployment() |
|
| 53 |
- deployment.Status = deployapi.DeploymentStatusNew |
|
| 54 |
- return deployment |
|
| 55 |
- }, |
|
| 56 |
- } |
|
| 57 |
- |
|
| 58 |
- // Verify pending -> running now that the pod is running |
|
| 59 |
- controller.HandleDeployment() |
|
| 60 |
- |
|
| 61 |
- if updatedDeployment == nil {
|
|
| 62 |
- t.Fatalf("expected an updated deployment")
|
|
| 63 |
- } |
|
| 64 |
- |
|
| 65 |
- if e, a := deployapi.DeploymentStatusPending, updatedDeployment.Status; e != a {
|
|
| 66 |
- t.Fatalf("expected updated deployment status %s, got %s", e, a)
|
|
| 67 |
- } |
|
| 68 |
- |
|
| 69 |
- if createdPod == nil {
|
|
| 70 |
- t.Fatalf("expected a pod to be created")
|
|
| 71 |
- } |
|
| 33 |
+ var ( |
|
| 34 |
+ updatedDeployment *deployapi.Deployment |
|
| 35 |
+ createdPod *kapi.Pod |
|
| 36 |
+ ) |
|
| 37 |
+ |
|
| 38 |
+ controller := &CustomPodDeploymentController{
|
|
| 39 |
+ DeploymentInterface: &testDcDeploymentInterface{
|
|
| 40 |
+ UpdateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 41 |
+ updatedDeployment = deployment |
|
| 42 |
+ return deployment, nil |
|
| 43 |
+ }, |
|
| 44 |
+ }, |
|
| 45 |
+ PodInterface: &testDcPodInterface{
|
|
| 46 |
+ CreatePodFunc: func(pod *kapi.Pod) (*kapi.Pod, error) {
|
|
| 47 |
+ createdPod = pod |
|
| 48 |
+ return pod, nil |
|
| 49 |
+ }, |
|
| 50 |
+ }, |
|
| 51 |
+ NextDeployment: func() *deployapi.Deployment {
|
|
| 52 |
+ deployment := customPodDeployment() |
|
| 53 |
+ deployment.Status = deployapi.DeploymentStatusNew |
|
| 54 |
+ return deployment |
|
| 55 |
+ }, |
|
| 56 |
+ } |
|
| 57 |
+ |
|
| 58 |
+ // Verify pending -> running now that the pod is running |
|
| 59 |
+ controller.HandleDeployment() |
|
| 60 |
+ |
|
| 61 |
+ if updatedDeployment == nil {
|
|
| 62 |
+ t.Fatalf("expected an updated deployment")
|
|
| 63 |
+ } |
|
| 64 |
+ |
|
| 65 |
+ if e, a := deployapi.DeploymentStatusPending, updatedDeployment.Status; e != a {
|
|
| 66 |
+ t.Fatalf("expected updated deployment status %s, got %s", e, a)
|
|
| 67 |
+ } |
|
| 68 |
+ |
|
| 69 |
+ if createdPod == nil {
|
|
| 70 |
+ t.Fatalf("expected a pod to be created")
|
|
| 71 |
+ } |
|
| 72 | 72 |
} |
| 73 | 73 |
|
| 74 | 74 |
func TestHandleNewDeploymentWrongType(t *testing.T) {
|
| 75 |
- controller := &CustomPodDeploymentController{
|
|
| 76 |
- DeploymentInterface: &testDcDeploymentInterface{
|
|
| 77 |
- UpdateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 78 |
- t.Fatalf("Unexpected call to updateDeployment")
|
|
| 79 |
- return nil, nil |
|
| 80 |
- }, |
|
| 81 |
- }, |
|
| 82 |
- PodInterface: &testDcPodInterface{
|
|
| 83 |
- CreatePodFunc: func(pod *kapi.Pod) (*kapi.Pod, error) {
|
|
| 84 |
- t.Fatalf("Unexpected call to createPod")
|
|
| 85 |
- return nil, nil |
|
| 86 |
- }, |
|
| 87 |
- }, |
|
| 88 |
- NextDeployment: func() *deployapi.Deployment {
|
|
| 89 |
- deployment := basicDeployment() |
|
| 90 |
- deployment.Status = deployapi.DeploymentStatusNew |
|
| 91 |
- return deployment |
|
| 92 |
- }, |
|
| 93 |
- } |
|
| 94 |
- |
|
| 95 |
- controller.HandleDeployment() |
|
| 75 |
+ controller := &CustomPodDeploymentController{
|
|
| 76 |
+ DeploymentInterface: &testDcDeploymentInterface{
|
|
| 77 |
+ UpdateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 78 |
+ t.Fatalf("Unexpected call to updateDeployment")
|
|
| 79 |
+ return nil, nil |
|
| 80 |
+ }, |
|
| 81 |
+ }, |
|
| 82 |
+ PodInterface: &testDcPodInterface{
|
|
| 83 |
+ CreatePodFunc: func(pod *kapi.Pod) (*kapi.Pod, error) {
|
|
| 84 |
+ t.Fatalf("Unexpected call to createPod")
|
|
| 85 |
+ return nil, nil |
|
| 86 |
+ }, |
|
| 87 |
+ }, |
|
| 88 |
+ NextDeployment: func() *deployapi.Deployment {
|
|
| 89 |
+ deployment := basicDeployment() |
|
| 90 |
+ deployment.Status = deployapi.DeploymentStatusNew |
|
| 91 |
+ return deployment |
|
| 92 |
+ }, |
|
| 93 |
+ } |
|
| 94 |
+ |
|
| 95 |
+ controller.HandleDeployment() |
|
| 96 | 96 |
} |
| 97 | 97 |
|
| 98 | 98 |
func TestHandlePodRunning(t *testing.T) {
|
| 99 |
- var updatedDeployment *deployapi.Deployment |
|
| 100 |
- |
|
| 101 |
- controller := &CustomPodDeploymentController{
|
|
| 102 |
- DeploymentInterface: &testDcDeploymentInterface{
|
|
| 103 |
- UpdateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 104 |
- updatedDeployment = deployment |
|
| 105 |
- return deployment, nil |
|
| 106 |
- }, |
|
| 107 |
- }, |
|
| 108 |
- PodInterface: &testDcPodInterface{},
|
|
| 109 |
- NextDeployment: func() *deployapi.Deployment {
|
|
| 110 |
- return nil |
|
| 111 |
- }, |
|
| 112 |
- NextPod: func() *kapi.Pod { return runningPod() },
|
|
| 113 |
- DeploymentStore: deploytest.NewFakeDeploymentStore(pendingDeployment()), |
|
| 114 |
- } |
|
| 115 |
- |
|
| 116 |
- controller.HandlePod() |
|
| 117 |
- |
|
| 118 |
- if updatedDeployment == nil {
|
|
| 119 |
- t.Fatalf("Expected a deployment to be updated")
|
|
| 120 |
- } |
|
| 121 |
- |
|
| 122 |
- if e, a := deployapi.DeploymentStatusRunning, updatedDeployment.Status; e != a {
|
|
| 123 |
- t.Fatalf("expected updated deployment status %s, got %s", e, a)
|
|
| 124 |
- } |
|
| 99 |
+ var updatedDeployment *deployapi.Deployment |
|
| 100 |
+ |
|
| 101 |
+ controller := &CustomPodDeploymentController{
|
|
| 102 |
+ DeploymentInterface: &testDcDeploymentInterface{
|
|
| 103 |
+ UpdateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 104 |
+ updatedDeployment = deployment |
|
| 105 |
+ return deployment, nil |
|
| 106 |
+ }, |
|
| 107 |
+ }, |
|
| 108 |
+ PodInterface: &testDcPodInterface{},
|
|
| 109 |
+ NextDeployment: func() *deployapi.Deployment {
|
|
| 110 |
+ return nil |
|
| 111 |
+ }, |
|
| 112 |
+ NextPod: func() *kapi.Pod { return runningPod() },
|
|
| 113 |
+ DeploymentStore: deploytest.NewFakeDeploymentStore(pendingDeployment()), |
|
| 114 |
+ } |
|
| 115 |
+ |
|
| 116 |
+ controller.HandlePod() |
|
| 117 |
+ |
|
| 118 |
+ if updatedDeployment == nil {
|
|
| 119 |
+ t.Fatalf("Expected a deployment to be updated")
|
|
| 120 |
+ } |
|
| 121 |
+ |
|
| 122 |
+ if e, a := deployapi.DeploymentStatusRunning, updatedDeployment.Status; e != a {
|
|
| 123 |
+ t.Fatalf("expected updated deployment status %s, got %s", e, a)
|
|
| 124 |
+ } |
|
| 125 | 125 |
} |
| 126 | 126 |
|
| 127 | 127 |
func TestHandlePodTerminatedOk(t *testing.T) {
|
| 128 |
- var updatedDeployment *deployapi.Deployment |
|
| 129 |
- var deletedPodId string |
|
| 130 |
- |
|
| 131 |
- controller := &CustomPodDeploymentController{
|
|
| 132 |
- DeploymentInterface: &testDcDeploymentInterface{
|
|
| 133 |
- UpdateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 134 |
- updatedDeployment = deployment |
|
| 135 |
- return deployment, nil |
|
| 136 |
- }, |
|
| 137 |
- }, |
|
| 138 |
- PodInterface: &testDcPodInterface{
|
|
| 139 |
- DeletePodFunc: func(id string) error {
|
|
| 140 |
- deletedPodId = id |
|
| 141 |
- return nil |
|
| 142 |
- }, |
|
| 143 |
- }, |
|
| 144 |
- NextDeployment: func() *deployapi.Deployment { return nil },
|
|
| 145 |
- NextPod: func() *kapi.Pod { return terminatedPod(0) },
|
|
| 146 |
- DeploymentStore: deploytest.NewFakeDeploymentStore(runningDeployment()), |
|
| 147 |
- } |
|
| 148 |
- |
|
| 149 |
- controller.HandlePod() |
|
| 150 |
- |
|
| 151 |
- if updatedDeployment == nil {
|
|
| 152 |
- t.Fatalf("Expected a deployment to be updated")
|
|
| 153 |
- } |
|
| 154 |
- |
|
| 155 |
- if e, a := deployapi.DeploymentStatusComplete, updatedDeployment.Status; e != a {
|
|
| 156 |
- t.Fatalf("expected updated deployment status %s, got %s", e, a)
|
|
| 157 |
- } |
|
| 158 |
- |
|
| 159 |
- if len(deletedPodId) == 0 {
|
|
| 160 |
- t.Fatalf("expected pod to be deleted")
|
|
| 161 |
- } |
|
| 128 |
+ var updatedDeployment *deployapi.Deployment |
|
| 129 |
+ var deletedPodId string |
|
| 130 |
+ |
|
| 131 |
+ controller := &CustomPodDeploymentController{
|
|
| 132 |
+ DeploymentInterface: &testDcDeploymentInterface{
|
|
| 133 |
+ UpdateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 134 |
+ updatedDeployment = deployment |
|
| 135 |
+ return deployment, nil |
|
| 136 |
+ }, |
|
| 137 |
+ }, |
|
| 138 |
+ PodInterface: &testDcPodInterface{
|
|
| 139 |
+ DeletePodFunc: func(id string) error {
|
|
| 140 |
+ deletedPodId = id |
|
| 141 |
+ return nil |
|
| 142 |
+ }, |
|
| 143 |
+ }, |
|
| 144 |
+ NextDeployment: func() *deployapi.Deployment { return nil },
|
|
| 145 |
+ NextPod: func() *kapi.Pod { return terminatedPod(0) },
|
|
| 146 |
+ DeploymentStore: deploytest.NewFakeDeploymentStore(runningDeployment()), |
|
| 147 |
+ } |
|
| 148 |
+ |
|
| 149 |
+ controller.HandlePod() |
|
| 150 |
+ |
|
| 151 |
+ if updatedDeployment == nil {
|
|
| 152 |
+ t.Fatalf("Expected a deployment to be updated")
|
|
| 153 |
+ } |
|
| 154 |
+ |
|
| 155 |
+ if e, a := deployapi.DeploymentStatusComplete, updatedDeployment.Status; e != a {
|
|
| 156 |
+ t.Fatalf("expected updated deployment status %s, got %s", e, a)
|
|
| 157 |
+ } |
|
| 158 |
+ |
|
| 159 |
+ if len(deletedPodId) == 0 {
|
|
| 160 |
+ t.Fatalf("expected pod to be deleted")
|
|
| 161 |
+ } |
|
| 162 | 162 |
} |
| 163 | 163 |
|
| 164 | 164 |
func TestHandlePodTerminatedNotOk(t *testing.T) {
|
| 165 |
- var updatedDeployment *deployapi.Deployment |
|
| 166 |
- |
|
| 167 |
- controller := &CustomPodDeploymentController{
|
|
| 168 |
- DeploymentInterface: &testDcDeploymentInterface{
|
|
| 169 |
- UpdateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 170 |
- updatedDeployment = deployment |
|
| 171 |
- return deployment, nil |
|
| 172 |
- }, |
|
| 173 |
- }, |
|
| 174 |
- PodInterface: &testDcPodInterface{
|
|
| 175 |
- DeletePodFunc: func(id string) error {
|
|
| 176 |
- t.Fatalf("unexpected delete of pod %s", id)
|
|
| 177 |
- return nil |
|
| 178 |
- }, |
|
| 179 |
- }, |
|
| 180 |
- NextDeployment: func() *deployapi.Deployment { return nil },
|
|
| 181 |
- NextPod: func() *kapi.Pod { return terminatedPod(1) },
|
|
| 182 |
- DeploymentStore: deploytest.NewFakeDeploymentStore(runningDeployment()), |
|
| 183 |
- } |
|
| 184 |
- |
|
| 185 |
- controller.HandlePod() |
|
| 186 |
- |
|
| 187 |
- if updatedDeployment == nil {
|
|
| 188 |
- t.Fatalf("Expected a deployment to be updated")
|
|
| 189 |
- } |
|
| 190 |
- |
|
| 191 |
- if e, a := deployapi.DeploymentStatusFailed, updatedDeployment.Status; e != a {
|
|
| 192 |
- t.Fatalf("expected updated deployment status %s, got %s", e, a)
|
|
| 193 |
- } |
|
| 165 |
+ var updatedDeployment *deployapi.Deployment |
|
| 166 |
+ |
|
| 167 |
+ controller := &CustomPodDeploymentController{
|
|
| 168 |
+ DeploymentInterface: &testDcDeploymentInterface{
|
|
| 169 |
+ UpdateDeploymentFunc: func(deployment *deployapi.Deployment) (*deployapi.Deployment, error) {
|
|
| 170 |
+ updatedDeployment = deployment |
|
| 171 |
+ return deployment, nil |
|
| 172 |
+ }, |
|
| 173 |
+ }, |
|
| 174 |
+ PodInterface: &testDcPodInterface{
|
|
| 175 |
+ DeletePodFunc: func(id string) error {
|
|
| 176 |
+ t.Fatalf("unexpected delete of pod %s", id)
|
|
| 177 |
+ return nil |
|
| 178 |
+ }, |
|
| 179 |
+ }, |
|
| 180 |
+ NextDeployment: func() *deployapi.Deployment { return nil },
|
|
| 181 |
+ NextPod: func() *kapi.Pod { return terminatedPod(1) },
|
|
| 182 |
+ DeploymentStore: deploytest.NewFakeDeploymentStore(runningDeployment()), |
|
| 183 |
+ } |
|
| 184 |
+ |
|
| 185 |
+ controller.HandlePod() |
|
| 186 |
+ |
|
| 187 |
+ if updatedDeployment == nil {
|
|
| 188 |
+ t.Fatalf("Expected a deployment to be updated")
|
|
| 189 |
+ } |
|
| 190 |
+ |
|
| 191 |
+ if e, a := deployapi.DeploymentStatusFailed, updatedDeployment.Status; e != a {
|
|
| 192 |
+ t.Fatalf("expected updated deployment status %s, got %s", e, a)
|
|
| 193 |
+ } |
|
| 194 | 194 |
} |
| 195 | 195 |
|
| 196 | 196 |
func basicDeployment() *deployapi.Deployment {
|
| 197 |
- return &deployapi.Deployment{
|
|
| 198 |
- TypeMeta: kapi.TypeMeta{ID: "deploy1"},
|
|
| 199 |
- Status: deployapi.DeploymentStatusNew, |
|
| 200 |
- Strategy: deployapi.DeploymentStrategy{
|
|
| 201 |
- Type: deployapi.DeploymentStrategyTypeBasic, |
|
| 202 |
- }, |
|
| 203 |
- ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 204 |
- PodTemplate: kapi.PodTemplate{
|
|
| 205 |
- DesiredState: kapi.PodState{
|
|
| 206 |
- Manifest: kapi.ContainerManifest{
|
|
| 207 |
- Containers: []kapi.Container{
|
|
| 208 |
- {
|
|
| 209 |
- Name: "container1", |
|
| 210 |
- Image: "registry:8080/repo1:ref1", |
|
| 211 |
- }, |
|
| 212 |
- }, |
|
| 213 |
- }, |
|
| 214 |
- }, |
|
| 215 |
- }, |
|
| 216 |
- }, |
|
| 217 |
- } |
|
| 197 |
+ return &deployapi.Deployment{
|
|
| 198 |
+ TypeMeta: kapi.TypeMeta{ID: "deploy1"},
|
|
| 199 |
+ Status: deployapi.DeploymentStatusNew, |
|
| 200 |
+ Strategy: deployapi.DeploymentStrategy{
|
|
| 201 |
+ Type: deployapi.DeploymentStrategyTypeBasic, |
|
| 202 |
+ }, |
|
| 203 |
+ ControllerTemplate: kapi.ReplicationControllerState{
|
|
| 204 |
+ PodTemplate: kapi.PodTemplate{
|
|
| 205 |
+ DesiredState: kapi.PodState{
|
|
| 206 |
+ Manifest: kapi.ContainerManifest{
|
|
| 207 |
+ Containers: []kapi.Container{
|
|
| 208 |
+ {
|
|
| 209 |
+ Name: "container1", |
|
| 210 |
+ Image: "registry:8080/repo1:ref1", |
|
| 211 |
+ }, |
|
| 212 |
+ }, |
|
| 213 |
+ }, |
|
| 214 |
+ }, |
|
| 215 |
+ }, |
|
| 216 |
+ }, |
|
| 217 |
+ } |
|
| 218 | 218 |
} |
| 219 | 219 |
|
| 220 | 220 |
func customPodDeployment() *deployapi.Deployment {
|
| 221 |
- d := basicDeployment() |
|
| 222 |
- d.Strategy = deployapi.DeploymentStrategy{
|
|
| 223 |
- Type: deployapi.DeploymentStrategyTypeCustomPod, |
|
| 224 |
- CustomPod: &deployapi.CustomPodDeploymentStrategy{
|
|
| 225 |
- Image: "registry:8080/repo1:ref1", |
|
| 226 |
- Environment: []kapi.EnvVar{},
|
|
| 227 |
- }, |
|
| 228 |
- } |
|
| 229 |
- |
|
| 230 |
- return d |
|
| 221 |
+ d := basicDeployment() |
|
| 222 |
+ d.Strategy = deployapi.DeploymentStrategy{
|
|
| 223 |
+ Type: deployapi.DeploymentStrategyTypeCustomPod, |
|
| 224 |
+ CustomPod: &deployapi.CustomPodDeploymentStrategy{
|
|
| 225 |
+ Image: "registry:8080/repo1:ref1", |
|
| 226 |
+ Environment: []kapi.EnvVar{},
|
|
| 227 |
+ }, |
|
| 228 |
+ } |
|
| 229 |
+ |
|
| 230 |
+ return d |
|
| 231 | 231 |
} |
| 232 | 232 |
|
| 233 | 233 |
func pendingDeployment() *deployapi.Deployment {
|
| 234 |
- d := customPodDeployment() |
|
| 235 |
- d.Status = deployapi.DeploymentStatusPending |
|
| 236 |
- return d |
|
| 234 |
+ d := customPodDeployment() |
|
| 235 |
+ d.Status = deployapi.DeploymentStatusPending |
|
| 236 |
+ return d |
|
| 237 | 237 |
} |
| 238 | 238 |
|
| 239 | 239 |
func runningDeployment() *deployapi.Deployment {
|
| 240 |
- d := customPodDeployment() |
|
| 241 |
- d.Status = deployapi.DeploymentStatusRunning |
|
| 242 |
- return d |
|
| 240 |
+ d := customPodDeployment() |
|
| 241 |
+ d.Status = deployapi.DeploymentStatusRunning |
|
| 242 |
+ return d |
|
| 243 | 243 |
} |
| 244 | 244 |
|
| 245 | 245 |
func basicPod() *kapi.Pod {
|
| 246 |
- return &kapi.Pod{
|
|
| 247 |
- CurrentState: kapi.PodState{
|
|
| 248 |
- Info: kapi.PodInfo{
|
|
| 249 |
- "container1": kapi.ContainerStatus{},
|
|
| 250 |
- }, |
|
| 251 |
- }, |
|
| 252 |
- Labels: map[string]string{
|
|
| 253 |
- "deployment": "1234", |
|
| 254 |
- }, |
|
| 255 |
- } |
|
| 246 |
+ return &kapi.Pod{
|
|
| 247 |
+ CurrentState: kapi.PodState{
|
|
| 248 |
+ Info: kapi.PodInfo{
|
|
| 249 |
+ "container1": kapi.ContainerStatus{},
|
|
| 250 |
+ }, |
|
| 251 |
+ }, |
|
| 252 |
+ Labels: map[string]string{
|
|
| 253 |
+ "deployment": "1234", |
|
| 254 |
+ }, |
|
| 255 |
+ } |
|
| 256 | 256 |
} |
| 257 | 257 |
|
| 258 | 258 |
func terminatedPod(exitCode int) *kapi.Pod {
|
| 259 |
- p := basicPod() |
|
| 260 |
- p.CurrentState.Status = kapi.PodTerminated |
|
| 261 |
- p.CurrentState.Info["container1"] = kapi.ContainerStatus{
|
|
| 262 |
- State: kapi.ContainerState{
|
|
| 263 |
- Termination: &kapi.ContainerStateTerminated{
|
|
| 264 |
- ExitCode: exitCode, |
|
| 265 |
- }, |
|
| 266 |
- }, |
|
| 267 |
- } |
|
| 268 |
- |
|
| 269 |
- return p |
|
| 259 |
+ p := basicPod() |
|
| 260 |
+ p.CurrentState.Status = kapi.PodTerminated |
|
| 261 |
+ p.CurrentState.Info["container1"] = kapi.ContainerStatus{
|
|
| 262 |
+ State: kapi.ContainerState{
|
|
| 263 |
+ Termination: &kapi.ContainerStateTerminated{
|
|
| 264 |
+ ExitCode: exitCode, |
|
| 265 |
+ }, |
|
| 266 |
+ }, |
|
| 267 |
+ } |
|
| 268 |
+ |
|
| 269 |
+ return p |
|
| 270 | 270 |
} |
| 271 | 271 |
|
| 272 | 272 |
func runningPod() *kapi.Pod {
|
| 273 |
- p := basicPod() |
|
| 274 |
- p.CurrentState.Status = kapi.PodRunning |
|
| 275 |
- return p |
|
| 273 |
+ p := basicPod() |
|
| 274 |
+ p.CurrentState.Status = kapi.PodRunning |
|
| 275 |
+ return p |
|
| 276 | 276 |
} |
| ... | ... |
@@ -8,12 +8,12 @@ import ( |
| 8 | 8 |
// ImageList is a list of Image objects. |
| 9 | 9 |
type ImageList struct {
|
| 10 | 10 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 11 |
- Items []Image `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 11 |
+ Items []Image `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 12 | 12 |
} |
| 13 | 13 |
|
| 14 | 14 |
// Image is an immutable representation of a Docker image and metadata at a point in time. |
| 15 | 15 |
type Image struct {
|
| 16 |
- kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 16 |
+ kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 17 | 17 |
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
| 18 | 18 |
DockerImageReference string `json:"dockerImageReference,omitempty" yaml:"dockerImageReference,omitempty"` |
| 19 | 19 |
Metadata docker.Image `json:"metadata,omitempty" yaml:"metadata,omitempty"` |
| ... | ... |
@@ -22,14 +22,14 @@ type Image struct {
|
| 22 | 22 |
// ImageRepositoryList is a list of ImageRepository objects. |
| 23 | 23 |
type ImageRepositoryList struct {
|
| 24 | 24 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 25 |
- Items []ImageRepository `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 25 |
+ Items []ImageRepository `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 | 28 |
// ImageRepository stores a mapping of tags to images, metadata overrides that are applied |
| 29 | 29 |
// when images are tagged in a repository, and an optional reference to a Docker image |
| 30 | 30 |
// repository on a registry. |
| 31 | 31 |
type ImageRepository struct {
|
| 32 |
- kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 32 |
+ kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 33 | 33 |
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
| 34 | 34 |
DockerImageRepository string `json:"dockerImageRepository,omitempty" yaml:"dockerImageRepository,omitempty"` |
| 35 | 35 |
Tags map[string]string `json:"tags,omitempty" yaml:"tags,omitempty"` |
| ... | ... |
@@ -40,7 +40,7 @@ type ImageRepository struct {
|
| 40 | 40 |
// ImageRepositoryMapping represents a mapping from a single tag to a Docker image as |
| 41 | 41 |
// well as the reference to the Docker image repository the image came from. |
| 42 | 42 |
type ImageRepositoryMapping struct {
|
| 43 |
- kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 43 |
+ kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 44 | 44 |
DockerImageRepository string `json:"dockerImageRepository" yaml:"dockerImageRepository"` |
| 45 | 45 |
Image Image `json:"image" yaml:"image"` |
| 46 | 46 |
Tag string `json:"tag" yaml:"tag"` |
| ... | ... |
@@ -8,12 +8,12 @@ import ( |
| 8 | 8 |
// ImageList is a list of Image objects. |
| 9 | 9 |
type ImageList struct {
|
| 10 | 10 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 11 |
- Items []Image `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 11 |
+ Items []Image `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 12 | 12 |
} |
| 13 | 13 |
|
| 14 | 14 |
// Image is an immutable representation of a Docker image and metadata at a point in time. |
| 15 | 15 |
type Image struct {
|
| 16 |
- kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 16 |
+ kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 17 | 17 |
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
| 18 | 18 |
DockerImageReference string `json:"dockerImageReference,omitempty" yaml:"dockerImageReference,omitempty"` |
| 19 | 19 |
Metadata docker.Image `json:"metadata,omitempty" yaml:"metadata,omitempty"` |
| ... | ... |
@@ -22,14 +22,14 @@ type Image struct {
|
| 22 | 22 |
// ImageRepositoryList is a list of ImageRepository objects. |
| 23 | 23 |
type ImageRepositoryList struct {
|
| 24 | 24 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 25 |
- Items []ImageRepository `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 25 |
+ Items []ImageRepository `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 26 | 26 |
} |
| 27 | 27 |
|
| 28 | 28 |
// ImageRepository stores a mapping of tags to images, metadata overrides that are applied |
| 29 | 29 |
// when images are tagged in a repository, and an optional reference to a Docker image |
| 30 | 30 |
// repository on a registry. |
| 31 | 31 |
type ImageRepository struct {
|
| 32 |
- kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 32 |
+ kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 33 | 33 |
Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
| 34 | 34 |
DockerImageRepository string `json:"dockerImageRepository,omitempty" yaml:"dockerImageRepository,omitempty"` |
| 35 | 35 |
Tags map[string]string `json:"tags,omitempty" yaml:"tags,omitempty"` |
| ... | ... |
@@ -40,7 +40,7 @@ type ImageRepository struct {
|
| 40 | 40 |
// ImageRepositoryMapping represents a mapping from a single tag to a Docker image as |
| 41 | 41 |
// well as the reference to the Docker image repository the image came from. |
| 42 | 42 |
type ImageRepositoryMapping struct {
|
| 43 |
- kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 43 |
+ kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 44 | 44 |
DockerImageRepository string `json:"dockerImageRepository" yaml:"dockerImageRepository"` |
| 45 | 45 |
Image Image `json:"image" yaml:"image"` |
| 46 | 46 |
Tag string `json:"tag" yaml:"tag"` |
| ... | ... |
@@ -7,13 +7,13 @@ import ( |
| 7 | 7 |
// ProjectList is a list of Project objects. |
| 8 | 8 |
type ProjectList struct {
|
| 9 | 9 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 10 |
- Items []Project `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 10 |
+ Items []Project `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 11 | 11 |
} |
| 12 | 12 |
|
| 13 | 13 |
// Project is a logical top-level container for a set of origin resources |
| 14 | 14 |
type Project struct {
|
| 15 | 15 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 16 |
- Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 17 |
- DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"` |
|
| 18 |
- Description string `json:"description,omitempty" yaml:"description,omitempty"` |
|
| 16 |
+ Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 17 |
+ DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"` |
|
| 18 |
+ Description string `json:"description,omitempty" yaml:"description,omitempty"` |
|
| 19 | 19 |
} |
| ... | ... |
@@ -7,13 +7,13 @@ import ( |
| 7 | 7 |
// ProjectList is a list of Project objects. |
| 8 | 8 |
type ProjectList struct {
|
| 9 | 9 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 10 |
- Items []Project `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 10 |
+ Items []Project `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 11 | 11 |
} |
| 12 | 12 |
|
| 13 | 13 |
// Project is a logical top-level container for a set of origin resources |
| 14 | 14 |
type Project struct {
|
| 15 | 15 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 16 |
- Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 17 |
- DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"` |
|
| 18 |
- Description string `json:"description,omitempty" yaml:"description,omitempty"` |
|
| 16 |
+ Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 17 |
+ DisplayName string `json:"displayName,omitempty" yaml:"displayName,omitempty"` |
|
| 18 |
+ Description string `json:"description,omitempty" yaml:"description,omitempty"` |
|
| 19 | 19 |
} |
| ... | ... |
@@ -6,7 +6,7 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
// Route encapsulates the inputs needed to connect a DNS/alias to a service proxy. |
| 8 | 8 |
type Route struct {
|
| 9 |
- kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 9 |
+ kapi.TypeMeta `json:",inline" yaml:",inline"` |
|
| 10 | 10 |
|
| 11 | 11 |
// Required: Alias/DNS that points to the service |
| 12 | 12 |
// Can be host or host:port |
| ... | ... |
@@ -23,5 +23,5 @@ type Route struct {
|
| 23 | 23 |
// RouteList is a collection of Routes. |
| 24 | 24 |
type RouteList struct {
|
| 25 | 25 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 26 |
- Items []Route `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 26 |
+ Items []Route `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 27 | 27 |
} |
| ... | ... |
@@ -6,22 +6,22 @@ import ( |
| 6 | 6 |
|
| 7 | 7 |
// Route encapsulates the inputs needed to connect a DNS/alias to a service proxy. |
| 8 | 8 |
type Route struct {
|
| 9 |
- v1beta1.TypeMeta `json:",inline" yaml:",inline"` |
|
| 9 |
+ v1beta1.TypeMeta `json:",inline" yaml:",inline"` |
|
| 10 | 10 |
|
| 11 | 11 |
// Required: Alias/DNS that points to the service |
| 12 | 12 |
// Can be host or host:port |
| 13 | 13 |
// host and port are combined to follow the net/url URL struct |
| 14 |
- Host string `json:"host" yaml:"host"` |
|
| 14 |
+ Host string `json:"host" yaml:"host"` |
|
| 15 | 15 |
// Optional: Path that the router watches for, to route traffic for to the service |
| 16 |
- Path string `json:"path,omitempty" yaml:"path,omitempty"` |
|
| 16 |
+ Path string `json:"path,omitempty" yaml:"path,omitempty"` |
|
| 17 | 17 |
|
| 18 | 18 |
// the name of the service that this route points to |
| 19 |
- ServiceName string `json:"serviceName" yaml:"serviceName"` |
|
| 20 |
- Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 19 |
+ ServiceName string `json:"serviceName" yaml:"serviceName"` |
|
| 20 |
+ Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 21 | 21 |
} |
| 22 | 22 |
|
| 23 | 23 |
// RouteList is a collection of Routes. |
| 24 | 24 |
type RouteList struct {
|
| 25 | 25 |
v1beta1.TypeMeta `json:",inline" yaml:",inline"` |
| 26 |
- Items []Route `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 26 |
+ Items []Route `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 27 | 27 |
} |
| ... | ... |
@@ -1,22 +1,22 @@ |
| 1 | 1 |
/* |
| 2 |
-Package route provides support for managing and watching routes. |
|
| 2 |
+Package route provides support for managing and watching routes. |
|
| 3 | 3 |
It defines a Route resource type, along with associated storage. |
| 4 | 4 |
|
| 5 | 5 |
A Route object allows the user to specify a DNS / alias for a Kubernetes service. |
| 6 | 6 |
It stores the ID of the Service (ServiceName) and the DNS/alias (Name). |
| 7 |
-The Route can be used to specify just the DNS/alias or it could also include |
|
| 7 |
+The Route can be used to specify just the DNS/alias or it could also include |
|
| 8 | 8 |
port and/or the path. |
| 9 | 9 |
|
| 10 | 10 |
The Route model includes the following attributes to specify the frontend URL: |
| 11 | 11 |
- Host: Alias/DNS that points to the service. Can be host or host:port |
| 12 | 12 |
- Path: Path allows the router to perform fine-grained routing |
| 13 | 13 |
|
| 14 |
-The Route resources can be used by routers and load balancers to route external inbound |
|
| 15 |
-traffic. The proxy is expected to have frontend mappings for the Route.Name in its |
|
| 16 |
-configuration. For its endpoints, a proxy could either forward the traffic to the |
|
| 17 |
-Kubernetes Service port and let it do the load balancing and routing. Alternately, |
|
| 14 |
+The Route resources can be used by routers and load balancers to route external inbound |
|
| 15 |
+traffic. The proxy is expected to have frontend mappings for the Route.Name in its |
|
| 16 |
+configuration. For its endpoints, a proxy could either forward the traffic to the |
|
| 17 |
+Kubernetes Service port and let it do the load balancing and routing. Alternately, |
|
| 18 | 18 |
a more meaningful implementation of a router could take the endpoints for the service |
| 19 |
-and route/load balance the incoming requests to the corresponding service endpoints. |
|
| 19 |
+and route/load balance the incoming requests to the corresponding service endpoints. |
|
| 20 | 20 |
*/ |
| 21 | 21 |
|
| 22 | 22 |
package route |
| ... | ... |
@@ -114,8 +114,8 @@ func (p *TemplateProcessor) SubstituteParameters(t *api.Template) error {
|
| 114 | 114 |
// over the given manifest and substitutes all Parameter expression |
| 115 | 115 |
// occurances with their corresponding values. |
| 116 | 116 |
func (p *TemplateProcessor) substituteParametersInManifest(manifest *kapi.ContainerManifest, paramMap map[string]string) {
|
| 117 |
- for i, _ := range manifest.Containers {
|
|
| 118 |
- for e, _ := range manifest.Containers[i].Env {
|
|
| 117 |
+ for i := range manifest.Containers {
|
|
| 118 |
+ for e := range manifest.Containers[i].Env {
|
|
| 119 | 119 |
envValue := &manifest.Containers[i].Env[e].Value |
| 120 | 120 |
// Match all parameter expressions found in the given env var |
| 121 | 121 |
for _, match := range parameterExp.FindAllStringSubmatch(*envValue, -1) {
|
| ... | ... |
@@ -142,7 +142,7 @@ func (p *TemplateProcessor) substituteParametersInManifest(manifest *kapi.Contai |
| 142 | 142 |
// "0x[A-F0-9]{4}" | "0xB3AF"
|
| 143 | 143 |
// "[a-zA-Z0-9]{8}" | "hW4yQU5i"
|
| 144 | 144 |
func (p *TemplateProcessor) GenerateParameterValues(t *api.Template) error {
|
| 145 |
- for i, _ := range t.Parameters {
|
|
| 145 |
+ for i := range t.Parameters {
|
|
| 146 | 146 |
param := &t.Parameters[i] |
| 147 | 147 |
if param.Generate != "" {
|
| 148 | 148 |
generator, ok := p.Generators[param.Generate] |
| ... | ... |
@@ -9,7 +9,7 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
type User struct {
|
| 11 | 11 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 12 |
- Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 12 |
+ Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 13 | 13 |
|
| 14 | 14 |
// Name is a human readable string uniquely representing this user at any time. |
| 15 | 15 |
Name string `json:"name,omitempty" yaml:"name,omitempty"` |
| ... | ... |
@@ -19,12 +19,12 @@ type User struct {
|
| 19 | 19 |
|
| 20 | 20 |
type UserList struct {
|
| 21 | 21 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 22 |
- Items []User `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 22 |
+ Items []User `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 | 25 |
type Identity struct {
|
| 26 | 26 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 27 |
- Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 27 |
+ Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 28 | 28 |
|
| 29 | 29 |
// Name is the unique identifier of a user within a given provider |
| 30 | 30 |
Name string `json:"name,omitempty" yaml:"name,omitempty"` |
| ... | ... |
@@ -9,7 +9,7 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
type User struct {
|
| 11 | 11 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 12 |
- Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 12 |
+ Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 13 | 13 |
|
| 14 | 14 |
// Name is a human readable string uniquely representing this user at any time. |
| 15 | 15 |
Name string `json:"name,omitempty" yaml:"name,omitempty"` |
| ... | ... |
@@ -19,12 +19,12 @@ type User struct {
|
| 19 | 19 |
|
| 20 | 20 |
type UserList struct {
|
| 21 | 21 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 22 |
- Items []User `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 22 |
+ Items []User `json:"items,omitempty" yaml:"items,omitempty"` |
|
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 | 25 |
type Identity struct {
|
| 26 | 26 |
kapi.TypeMeta `json:",inline" yaml:",inline"` |
| 27 |
- Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 27 |
+ Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` |
|
| 28 | 28 |
|
| 29 | 29 |
// Name is the unique identifier of a user within a given provider |
| 30 | 30 |
Name string `json:"name,omitempty" yaml:"name,omitempty"` |