Skip to content

Commit

Permalink
DeploymentConfig replicas should be optional, other fields too
Browse files Browse the repository at this point in the history
Make a set of fields truly optional in openapi, and also make replicas a
pointer so we can default it.
  • Loading branch information
smarterclayton committed Oct 27, 2017
1 parent 951a379 commit f5624be
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 30 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions api/swagger-spec/oapi-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -23170,8 +23170,7 @@
"id": "v1.DeploymentConfig",
"description": "Deployment Configs define the template for a pod and manages deploying new images or configuration changes. A single deployment configuration is usually analogous to a single micro-service. Can support many different deployment patterns, including full restart, customizable rolling updates, and fully custom behaviors, as well as pre- and post- deployment hooks. Each individual deployment is represented as a replication controller.\n\nA deployment is \"triggered\" when its configuration is changed or a tag in an Image Stream is changed. Triggers can be disabled to allow manual control over a deployment. The \"strategy\" determines how the deployment is carried out and may be changed at any time. The `latestVersion` field is updated when a new deployment is triggered by any means.",
"required": [
"spec",
"status"
"spec"
],
"properties": {
"kind": {
Expand Down
13 changes: 2 additions & 11 deletions api/swagger-spec/openshift-openapi-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -87032,8 +87032,7 @@
"com.github.openshift.origin.pkg.apps.apis.apps.v1.DeploymentConfig": {
"description": "Deployment Configs define the template for a pod and manages deploying new images or configuration changes. A single deployment configuration is usually analogous to a single micro-service. Can support many different deployment patterns, including full restart, customizable rolling updates, and fully custom behaviors, as well as pre- and post- deployment hooks. Each individual deployment is represented as a replication controller.\n\nA deployment is \"triggered\" when its configuration is changed or a tag in an Image Stream is changed. Triggers can be disabled to allow manual control over a deployment. The \"strategy\" determines how the deployment is carried out and may be changed at any time. The `latestVersion` field is updated when a new deployment is triggered by any means.",
"required": [
"spec",
"status"
"spec"
],
"properties": {
"apiVersion": {
Expand Down Expand Up @@ -87192,12 +87191,6 @@
},
"com.github.openshift.origin.pkg.apps.apis.apps.v1.DeploymentConfigSpec": {
"description": "DeploymentConfigSpec represents the desired state of the deployment.",
"required": [
"strategy",
"triggers",
"replicas",
"test"
],
"properties": {
"minReadySeconds": {
"description": "MinReadySeconds is the minimum number of seconds for which a newly created pod should be ready without any of its container crashing, for it to be considered available. Defaults to 0 (pod will be considered available as soon as it is ready)",
Expand Down Expand Up @@ -90677,9 +90670,7 @@
"com.github.openshift.origin.pkg.image.apis.image.v1.TagReference": {
"description": "TagReference specifies optional annotations for images using this tag and an optional reference to an ImageStreamTag, ImageStreamImage, or DockerImage this tag should track.",
"required": [
"name",
"annotations",
"generation"
"name"
],
"properties": {
"annotations": {
Expand Down
28 changes: 15 additions & 13 deletions pkg/apps/apis/apps/v1/defaults_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1

import (
"fmt"
"reflect"
"testing"

Expand Down Expand Up @@ -540,19 +541,20 @@ func TestDefaults(t *testing.T) {
}

for i, test := range tests {
t.Logf("test %d", i)
original := test.original
expected := test.expected
obj2 := roundTrip(t, runtime.Object(original))
got, ok := obj2.(*DeploymentConfig)
if !ok {
t.Errorf("unexpected object: %v", got)
t.FailNow()
}
// TODO(rebase): check that there are no fields which have different semantics for nil and []
if !equality.Semantic.DeepEqual(got.Spec, expected.Spec) {
t.Errorf("got different than expected:\nA:\t%#v\nB:\t%#v\n\nDiff:\n%s\n\n%s", got, expected, diff.ObjectDiff(expected, got), diff.ObjectGoPrintSideBySide(expected, got))
}
t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
t.Logf("test %d", i)
original := test.original
expected := test.expected
obj2 := roundTrip(t, runtime.Object(original))
got, ok := obj2.(*DeploymentConfig)
if !ok {
t.Fatalf("unexpected object: %v", got)
}
// TODO(rebase): check that there are no fields which have different semantics for nil and []
if !equality.Semantic.DeepEqual(got.Spec, expected.Spec) {
t.Errorf("got different than expected:\nA:\t%#v\nB:\t%#v\n\nDiff:\n%s\n\n%s", got, expected, diff.ObjectDiff(expected, got), diff.ObjectGoPrintSideBySide(expected, got))
}
})
}
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/apps/apis/apps/v1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion pkg/apps/apis/apps/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ type DeploymentConfig struct {
Spec DeploymentConfigSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`

// Status represents the current deployment state.
Status DeploymentConfigStatus `json:"status" protobuf:"bytes,3,opt,name=status"`
Status DeploymentConfigStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}

// DeploymentConfigSpec represents the desired state of the deployment.
type DeploymentConfigSpec struct {
// Strategy describes how a deployment is executed.
// +optional
Strategy DeploymentStrategy `json:"strategy" protobuf:"bytes,1,opt,name=strategy"`

// MinReadySeconds is the minimum number of seconds for which a newly created pod should
Expand All @@ -49,9 +50,11 @@ type DeploymentConfigSpec struct {
// Triggers determine how updates to a DeploymentConfig result in new deployments. If no triggers
// are defined, a new deployment can only occur as a result of an explicit client update to the
// DeploymentConfig with a new LatestVersion. If null, defaults to having a config change trigger.
// +optional
Triggers DeploymentTriggerPolicies `json:"triggers" protobuf:"bytes,2,rep,name=triggers"`

// Replicas is the number of desired replicas.
// +optional
Replicas int32 `json:"replicas" protobuf:"varint,3,opt,name=replicas"`

// RevisionHistoryLimit is the number of old ReplicationControllers to retain to allow for rollbacks.
Expand All @@ -62,6 +65,7 @@ type DeploymentConfigSpec struct {
// Test ensures that this deployment config will have zero replicas except while a deployment is running. This allows the
// deployment config to be used as a continuous deployment test - triggering on images, running the deployment, and then succeeding
// or failing. Post strategy hooks and After actions can be used to integrate successful deployment with an action.
// +optional
Test bool `json:"test" protobuf:"varint,5,opt,name=test"`

// Paused indicates that the deployment config is paused resulting in no new deployments on template
Expand Down
2 changes: 2 additions & 0 deletions pkg/image/apis/image/v1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/image/apis/image/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ type TagReference struct {
// Name of the tag
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
// Optional; if specified, annotations that are applied to images retrieved via ImageStreamTags.
// +optional
Annotations map[string]string `json:"annotations" protobuf:"bytes,2,rep,name=annotations"`
// Optional; if specified, a reference to another image that this tag should point to. Valid values
// are ImageStreamTag, ImageStreamImage, and DockerImage.
Expand All @@ -217,6 +218,7 @@ type TagReference struct {
// to import the newest remote tag. To trigger a new import, clients may set this value to zero which
// will reset the generation to the latest stream generation. Legacy clients will send this value as
// nil which will be merged with the current tag generation.
// +optional
Generation *int64 `json:"generation" protobuf:"varint,5,opt,name=generation"`
// ImportPolicy is information that controls how images may be imported by the server.
ImportPolicy TagImportPolicy `json:"importPolicy,omitempty" protobuf:"bytes,6,opt,name=importPolicy"`
Expand Down
5 changes: 2 additions & 3 deletions pkg/openapi/zz_generated.openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope
},
},
},
Required: []string{"spec", "status"},
Required: []string{"spec"},
},
},
Dependencies: []string{
Expand Down Expand Up @@ -429,7 +429,6 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope
},
},
},
Required: []string{"strategy", "triggers", "replicas", "test"},
},
},
Dependencies: []string{
Expand Down Expand Up @@ -6741,7 +6740,7 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope
},
},
},
Required: []string{"name", "annotations", "generation"},
Required: []string{"name"},
},
},
Dependencies: []string{
Expand Down

0 comments on commit f5624be

Please sign in to comment.