Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ConfigMapList.Items to not use omitempty #24347

Merged
merged 2 commits into from
Apr 22, 2016
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/swagger-spec/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -15143,6 +15143,9 @@
"v1.ConfigMapList": {
"id": "v1.ConfigMapList",
"description": "ConfigMapList is a resource containing a list of ConfigMap objects.",
"required": [
"items"
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this a breaking change?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think so.

The current behavior was considered broken by our existing client code that had expected the Kubernetes API to follow a consistent behavior and not have a nil items member in a JSON response.

Since clients need to support the non-nil response, and support iteration in that list, I don't see how a client can break from this change, but I know clients can break from our current behavior.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with Derek -- and do not see how clients could break from this change, but can easily understand clients breaking from the state of master (ie, omitempty).

],
"properties": {
"kind": {
"type": "string",
Expand Down
4 changes: 2 additions & 2 deletions docs/api-reference/v1/definitions.html
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ <h3 id="_v1_configmaplist">v1.ConfigMapList</h3>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">items</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Items is the list of ConfigMaps.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_configmap">v1.ConfigMap</a> array</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
Expand Down Expand Up @@ -7742,7 +7742,7 @@ <h3 id="_any">any</h3>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2016-04-15 09:26:34 UTC
Last updated 2016-04-21 02:45:03 UTC
</div>
</div>
</body>
Expand Down
43 changes: 18 additions & 25 deletions pkg/api/types.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -46755,14 +46755,13 @@ func (x *ConfigMapList) CodecEncodeSelf(e *codec1978.Encoder) {
_, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false
yyq2[0] = true
yyq2[1] = len(x.Items) != 0
yyq2[2] = x.Kind != ""
yyq2[3] = x.APIVersion != ""
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(4)
} else {
yynn2 = 0
yynn2 = 1
for _, b := range yyq2 {
if b {
yynn2++
Expand Down Expand Up @@ -46802,34 +46801,28 @@ func (x *ConfigMapList) CodecEncodeSelf(e *codec1978.Encoder) {
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[1] {
if x.Items == nil {
r.EncodeNil()
if x.Items == nil {
r.EncodeNil()
} else {
yym9 := z.EncBinary()
_ = yym9
if false {
} else {
yym9 := z.EncBinary()
_ = yym9
if false {
} else {
h.encSliceConfigMap(([]ConfigMap)(x.Items), e)
}
h.encSliceConfigMap(([]ConfigMap)(x.Items), e)
}
} else {
r.EncodeNil()
}
} else {
if yyq2[1] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("items"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Items == nil {
r.EncodeNil()
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("items"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Items == nil {
r.EncodeNil()
} else {
yym10 := z.EncBinary()
_ = yym10
if false {
} else {
yym10 := z.EncBinary()
_ = yym10
if false {
} else {
h.encSliceConfigMap(([]ConfigMap)(x.Items), e)
}
h.encSliceConfigMap(([]ConfigMap)(x.Items), e)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2407,7 +2407,7 @@ type ConfigMapList struct {
unversioned.ListMeta `json:"metadata,omitempty"`

// Items is the list of ConfigMaps.
Items []ConfigMap `json:"items,omitempty"`
Items []ConfigMap `json:"items"`
}

// These constants are for remote command execution and port forwarding and are
Expand Down
43 changes: 18 additions & 25 deletions pkg/api/v1/types.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -46567,14 +46567,13 @@ func (x *ConfigMapList) CodecEncodeSelf(e *codec1978.Encoder) {
_, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false
yyq2[0] = true
yyq2[1] = len(x.Items) != 0
yyq2[2] = x.Kind != ""
yyq2[3] = x.APIVersion != ""
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(4)
} else {
yynn2 = 0
yynn2 = 1
for _, b := range yyq2 {
if b {
yynn2++
Expand Down Expand Up @@ -46614,34 +46613,28 @@ func (x *ConfigMapList) CodecEncodeSelf(e *codec1978.Encoder) {
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if yyq2[1] {
if x.Items == nil {
r.EncodeNil()
if x.Items == nil {
r.EncodeNil()
} else {
yym9 := z.EncBinary()
_ = yym9
if false {
} else {
yym9 := z.EncBinary()
_ = yym9
if false {
} else {
h.encSliceConfigMap(([]ConfigMap)(x.Items), e)
}
h.encSliceConfigMap(([]ConfigMap)(x.Items), e)
}
} else {
r.EncodeNil()
}
} else {
if yyq2[1] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("items"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Items == nil {
r.EncodeNil()
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("items"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Items == nil {
r.EncodeNil()
} else {
yym10 := z.EncBinary()
_ = yym10
if false {
} else {
yym10 := z.EncBinary()
_ = yym10
if false {
} else {
h.encSliceConfigMap(([]ConfigMap)(x.Items), e)
}
h.encSliceConfigMap(([]ConfigMap)(x.Items), e)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2856,7 +2856,7 @@ type ConfigMapList struct {
unversioned.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`

// Items is the list of ConfigMaps.
Items []ConfigMap `json:"items,omitempty" protobuf:"bytes,2,rep,name=items"`
Items []ConfigMap `json:"items" protobuf:"bytes,2,rep,name=items"`
}

// Type and constants for component health validation.
Expand Down