Skip to content

Commit

Permalink
Merge pull request #22758 from madhusudancs/replicaset-nonpointer-tem…
Browse files Browse the repository at this point in the history
…plate

ReplicaSetSpec.Template shouldn't be a pointer.
  • Loading branch information
ncdc committed Mar 10, 2016
2 parents d5d3f92 + 6fc1837 commit cdd3395
Show file tree
Hide file tree
Showing 26 changed files with 105 additions and 167 deletions.
38 changes: 12 additions & 26 deletions pkg/apis/extensions/types.generated.go
Expand Up @@ -14609,7 +14609,7 @@ func (x *ReplicaSetSpec) CodecEncodeSelf(e *codec1978.Encoder) {
_, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false
yyq2[1] = x.Selector != nil
yyq2[2] = x.Template != nil
yyq2[2] = true
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(3)
Expand Down Expand Up @@ -14680,11 +14680,8 @@ func (x *ReplicaSetSpec) CodecEncodeSelf(e *codec1978.Encoder) {
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[2] {
if x.Template == nil {
r.EncodeNil()
} else {
x.Template.CodecEncodeSelf(e)
}
yy10 := &x.Template
yy10.CodecEncodeSelf(e)
} else {
r.EncodeNil()
}
Expand All @@ -14693,11 +14690,8 @@ func (x *ReplicaSetSpec) CodecEncodeSelf(e *codec1978.Encoder) {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("template"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Template == nil {
r.EncodeNil()
} else {
x.Template.CodecEncodeSelf(e)
}
yy12 := &x.Template
yy12.CodecEncodeSelf(e)
}
}
if yyr2 || yy2arr2 {
Expand Down Expand Up @@ -14786,14 +14780,10 @@ func (x *ReplicaSetSpec) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
}
case "template":
if r.TryDecodeAsNil() {
if x.Template != nil {
x.Template = nil
}
x.Template = pkg2_api.PodTemplateSpec{}
} else {
if x.Template == nil {
x.Template = new(pkg2_api.PodTemplateSpec)
}
x.Template.CodecDecodeSelf(d)
yyv7 := &x.Template
yyv7.CodecDecodeSelf(d)
}
default:
z.DecStructFieldNotFound(-1, yys3)
Expand Down Expand Up @@ -14864,14 +14854,10 @@ func (x *ReplicaSetSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
if x.Template != nil {
x.Template = nil
}
x.Template = pkg2_api.PodTemplateSpec{}
} else {
if x.Template == nil {
x.Template = new(pkg2_api.PodTemplateSpec)
}
x.Template.CodecDecodeSelf(d)
yyv12 := &x.Template
yyv12.CodecDecodeSelf(d)
}
for {
yyj8++
Expand Down Expand Up @@ -18962,7 +18948,7 @@ func (x codecSelfer1234) decSliceReplicaSet(v *[]ReplicaSet, d *codec1978.Decode

yyrg1 := len(yyv1) > 0
yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 232)
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 552)
if yyrt1 {
if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1]
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/extensions/types.go
Expand Up @@ -807,7 +807,7 @@ type ReplicaSetSpec struct {

// Template is the object that describes the pod that will be created if
// insufficient replicas are detected.
Template *api.PodTemplateSpec `json:"template,omitempty"`
Template api.PodTemplateSpec `json:"template,omitempty"`
}

// ReplicaSetStatus represents the current status of a ReplicaSet.
Expand Down
19 changes: 5 additions & 14 deletions pkg/apis/extensions/v1beta1/conversion.go
Expand Up @@ -297,13 +297,9 @@ func Convert_extensions_ReplicaSetSpec_To_v1beta1_ReplicaSetSpec(in *extensions.
} else {
out.Selector = nil
}
if in.Template != nil {
out.Template = new(v1.PodTemplateSpec)
if err := v1.Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in.Template, out.Template, s); err != nil {
return err
}
} else {
out.Template = nil

if err := v1.Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
return err
}
return nil
}
Expand All @@ -323,13 +319,8 @@ func Convert_v1beta1_ReplicaSetSpec_To_extensions_ReplicaSetSpec(in *ReplicaSetS
} else {
out.Selector = nil
}
if in.Template != nil {
out.Template = new(api.PodTemplateSpec)
if err := v1.Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in.Template, out.Template, s); err != nil {
return err
}
} else {
out.Template = nil
if err := v1.Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
return err
}
return nil
}
Expand Down
20 changes: 4 additions & 16 deletions pkg/apis/extensions/v1beta1/conversion_generated.go
Expand Up @@ -3599,14 +3599,8 @@ func autoConvert_extensions_ReplicaSetSpec_To_v1beta1_ReplicaSetSpec(in *extensi
} else {
out.Selector = nil
}
// unable to generate simple pointer conversion for api.PodTemplateSpec -> v1.PodTemplateSpec
if in.Template != nil {
out.Template = new(v1.PodTemplateSpec)
if err := Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in.Template, out.Template, s); err != nil {
return err
}
} else {
out.Template = nil
if err := Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
return err
}
return nil
}
Expand Down Expand Up @@ -4848,14 +4842,8 @@ func autoConvert_v1beta1_ReplicaSetSpec_To_extensions_ReplicaSetSpec(in *Replica
} else {
out.Selector = nil
}
// unable to generate simple pointer conversion for v1.PodTemplateSpec -> api.PodTemplateSpec
if in.Template != nil {
out.Template = new(api.PodTemplateSpec)
if err := Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in.Template, out.Template, s); err != nil {
return err
}
} else {
out.Template = nil
if err := Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
return err
}
return nil
}
Expand Down
9 changes: 2 additions & 7 deletions pkg/apis/extensions/v1beta1/deep_copy_generated.go
Expand Up @@ -1738,13 +1738,8 @@ func deepCopy_v1beta1_ReplicaSetSpec(in ReplicaSetSpec, out *ReplicaSetSpec, c *
} else {
out.Selector = nil
}
if in.Template != nil {
out.Template = new(v1.PodTemplateSpec)
if err := deepCopy_v1_PodTemplateSpec(*in.Template, out.Template, c); err != nil {
return err
}
} else {
out.Template = nil
if err := deepCopy_v1_PodTemplateSpec(in.Template, &out.Template, c); err != nil {
return err
}
return nil
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/apis/extensions/v1beta1/defaults.go
Expand Up @@ -118,10 +118,8 @@ func addDefaultingFuncs(scheme *runtime.Scheme) {
}
},
func(obj *ReplicaSet) {
var labels map[string]string
if obj.Spec.Template != nil {
labels = obj.Spec.Template.Labels
}
labels := obj.Spec.Template.Labels

// TODO: support templates defined elsewhere when we support them in the API
if labels != nil {
if obj.Spec.Selector == nil {
Expand Down
16 changes: 8 additions & 8 deletions pkg/apis/extensions/v1beta1/defaults_test.go
Expand Up @@ -426,7 +426,7 @@ func TestSetDefaultReplicaSet(t *testing.T) {
{
rs: &ReplicaSet{
Spec: ReplicaSetSpec{
Template: &v1.PodTemplateSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{
"foo": "bar",
Expand All @@ -446,7 +446,7 @@ func TestSetDefaultReplicaSet(t *testing.T) {
},
},
Spec: ReplicaSetSpec{
Template: &v1.PodTemplateSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{
"foo": "bar",
Expand All @@ -471,7 +471,7 @@ func TestSetDefaultReplicaSet(t *testing.T) {
"some": "other",
},
},
Template: &v1.PodTemplateSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{
"foo": "bar",
Expand All @@ -491,7 +491,7 @@ func TestSetDefaultReplicaSet(t *testing.T) {
"some": "other",
},
},
Template: &v1.PodTemplateSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{
"foo": "bar",
Expand Down Expand Up @@ -538,7 +538,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
{
rs: ReplicaSet{
Spec: ReplicaSetSpec{
Template: &v1.PodTemplateSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{
"foo": "bar",
Expand All @@ -553,7 +553,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
rs: ReplicaSet{
Spec: ReplicaSetSpec{
Replicas: newInt32(0),
Template: &v1.PodTemplateSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{
"foo": "bar",
Expand All @@ -568,7 +568,7 @@ func TestSetDefaultReplicaSetReplicas(t *testing.T) {
rs: ReplicaSet{
Spec: ReplicaSetSpec{
Replicas: newInt32(3),
Template: &v1.PodTemplateSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{
"foo": "bar",
Expand Down Expand Up @@ -611,7 +611,7 @@ func TestDefaultRequestIsNotSetForReplicaSet(t *testing.T) {
rs := &ReplicaSet{
Spec: ReplicaSetSpec{
Replicas: newInt32(3),
Template: &v1.PodTemplateSpec{
Template: v1.PodTemplateSpec{
ObjectMeta: v1.ObjectMeta{
Labels: map[string]string{
"foo": "bar",
Expand Down
38 changes: 12 additions & 26 deletions pkg/apis/extensions/v1beta1/types.generated.go
Expand Up @@ -15962,7 +15962,7 @@ func (x *ReplicaSetSpec) CodecEncodeSelf(e *codec1978.Encoder) {
const yyr2 bool = false
yyq2[0] = x.Replicas != nil
yyq2[1] = x.Selector != nil
yyq2[2] = x.Template != nil
yyq2[2] = true
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(3)
Expand Down Expand Up @@ -16037,11 +16037,8 @@ func (x *ReplicaSetSpec) CodecEncodeSelf(e *codec1978.Encoder) {
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[2] {
if x.Template == nil {
r.EncodeNil()
} else {
x.Template.CodecEncodeSelf(e)
}
yy12 := &x.Template
yy12.CodecEncodeSelf(e)
} else {
r.EncodeNil()
}
Expand All @@ -16050,11 +16047,8 @@ func (x *ReplicaSetSpec) CodecEncodeSelf(e *codec1978.Encoder) {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("template"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Template == nil {
r.EncodeNil()
} else {
x.Template.CodecEncodeSelf(e)
}
yy14 := &x.Template
yy14.CodecEncodeSelf(e)
}
}
if yyr2 || yy2arr2 {
Expand Down Expand Up @@ -16147,14 +16141,10 @@ func (x *ReplicaSetSpec) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
}
case "template":
if r.TryDecodeAsNil() {
if x.Template != nil {
x.Template = nil
}
x.Template = pkg2_v1.PodTemplateSpec{}
} else {
if x.Template == nil {
x.Template = new(pkg2_v1.PodTemplateSpec)
}
x.Template.CodecDecodeSelf(d)
yyv7 := &x.Template
yyv7.CodecDecodeSelf(d)
}
default:
z.DecStructFieldNotFound(-1, yys3)
Expand Down Expand Up @@ -16229,14 +16219,10 @@ func (x *ReplicaSetSpec) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
if x.Template != nil {
x.Template = nil
}
x.Template = pkg2_v1.PodTemplateSpec{}
} else {
if x.Template == nil {
x.Template = new(pkg2_v1.PodTemplateSpec)
}
x.Template.CodecDecodeSelf(d)
yyv12 := &x.Template
yyv12.CodecDecodeSelf(d)
}
for {
yyj8++
Expand Down Expand Up @@ -20446,7 +20432,7 @@ func (x codecSelfer1234) decSliceReplicaSet(v *[]ReplicaSet, d *codec1978.Decode

yyrg1 := len(yyv1) > 0
yyv21 := yyv1
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 232)
yyrl1, yyrt1 = z.DecInferLen(yyl1, z.DecBasicHandle().MaxInitLen, 576)
if yyrt1 {
if yyrl1 <= cap(yyv1) {
yyv1 = yyv1[:yyrl1]
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/extensions/v1beta1/types.go
Expand Up @@ -898,7 +898,7 @@ type ReplicaSetSpec struct {
// Template is the object that describes the pod that will be created if
// insufficient replicas are detected.
// More info: http://releases.k8s.io/HEAD/docs/user-guide/replication-controller.md#pod-template
Template *v1.PodTemplateSpec `json:"template,omitempty"`
Template v1.PodTemplateSpec `json:"template,omitempty"`
}

// ReplicaSetStatus represents the current status of a ReplicaSet.
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/extensions/validation/validation.go
Expand Up @@ -710,7 +710,7 @@ func ValidateReplicaSetSpec(spec *extensions.ReplicaSetSpec, fldPath *field.Path
if err != nil {
allErrs = append(allErrs, field.Invalid(fldPath.Child("selector"), spec.Selector, "invalid label selector."))
} else {
allErrs = append(allErrs, ValidatePodTemplateSpecForReplicaSet(spec.Template, selector, spec.Replicas, fldPath.Child("template"))...)
allErrs = append(allErrs, ValidatePodTemplateSpecForReplicaSet(&spec.Template, selector, spec.Replicas, fldPath.Child("template"))...)
}
return allErrs
}
Expand Down

2 comments on commit cdd3395

@k8s-teamcity-mesosphere

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity OSS :: Kubernetes Mesos :: 4 - Smoke Tests Build 18822 outcome was SUCCESS
Summary: Tests passed: 1, ignored: 254 Build time: 00:05:11

@k8s-teamcity-mesosphere

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity OSS :: Kubernetes Mesos :: 4 - Smoke Tests Build 18823 outcome was FAILURE
Summary: Tests failed: 1 (1 new), passed: 0, ignored: 254 Build time: 00:13:33

Failed tests

null: Kubernetes e2e suite.Kubectl client Guestbook application should create and stop a working application [Conformance]: <no details avaliable>

Please sign in to comment.