Improve the naming of fields in ContainerImage struct used in NodeStatus.

Signed-off-by: Vishnu kannan <vishnuk@google.com>
This commit is contained in:
Vishnu kannan 2016-02-11 14:15:50 -08:00
parent 0bb59866cd
commit 2623fdde17
14 changed files with 104 additions and 104 deletions

View File

@ -14673,17 +14673,17 @@
"id": "v1.ContainerImage",
"description": "Describe a container image",
"required": [
"repoTags"
"names"
],
"properties": {
"repoTags": {
"names": {
"type": "array",
"items": {
"type": "string"
},
"description": "Names by which this image is known. e.g. [\"gcr.io/google_containers/hyperkube:v1.0.7\", \"dockerhub.io/google_containers/hyperkube:v1.0.7\"]"
},
"size": {
"sizeBytes": {
"type": "integer",
"format": "int64",
"description": "The size of the image in bytes."

View File

@ -6172,14 +6172,14 @@ The resulting set of endpoints can be viewed as:<br>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">repoTags</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">names</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Names by which this image is known. e.g. ["gcr.io/google_containers/hyperkube:v1.0.7", "dockerhub.io/google_containers/hyperkube:v1.0.7"]</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">string array</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">size</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">sizeBytes</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">The size of the image in bytes.</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">integer (int64)</p></td>
@ -7477,7 +7477,7 @@ The resulting set of endpoints can be viewed as:<br>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2016-02-14 21:22:51 UTC
Last updated 2016-02-16 23:43:33 UTC
</div>
</div>
</body>

View File

@ -494,14 +494,14 @@ func DeepCopy_api_Container(in Container, out *Container, c *conversion.Cloner)
}
func DeepCopy_api_ContainerImage(in ContainerImage, out *ContainerImage, c *conversion.Cloner) error {
if in.RepoTags != nil {
in, out := in.RepoTags, &out.RepoTags
if in.Names != nil {
in, out := in.Names, &out.Names
*out = make([]string, len(in))
copy(*out, in)
} else {
out.RepoTags = nil
out.Names = nil
}
out.Size = in.Size
out.SizeBytes = in.SizeBytes
return nil
}

View File

@ -33754,7 +33754,7 @@ func (x *ContainerImage) CodecEncodeSelf(e *codec1978.Encoder) {
var yyq2 [2]bool
_, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false
yyq2[1] = x.Size != 0
yyq2[1] = x.SizeBytes != 0
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(2)
@ -33770,28 +33770,28 @@ func (x *ContainerImage) CodecEncodeSelf(e *codec1978.Encoder) {
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if x.RepoTags == nil {
if x.Names == nil {
r.EncodeNil()
} else {
yym4 := z.EncBinary()
_ = yym4
if false {
} else {
z.F.EncSliceStringV(x.RepoTags, false, e)
z.F.EncSliceStringV(x.Names, false, e)
}
}
} else {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("repoTags"))
r.EncodeString(codecSelferC_UTF81234, string("names"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.RepoTags == nil {
if x.Names == nil {
r.EncodeNil()
} else {
yym5 := z.EncBinary()
_ = yym5
if false {
} else {
z.F.EncSliceStringV(x.RepoTags, false, e)
z.F.EncSliceStringV(x.Names, false, e)
}
}
}
@ -33802,7 +33802,7 @@ func (x *ContainerImage) CodecEncodeSelf(e *codec1978.Encoder) {
_ = yym7
if false {
} else {
r.EncodeInt(int64(x.Size))
r.EncodeInt(int64(x.SizeBytes))
}
} else {
r.EncodeInt(0)
@ -33810,13 +33810,13 @@ func (x *ContainerImage) CodecEncodeSelf(e *codec1978.Encoder) {
} else {
if yyq2[1] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("size"))
r.EncodeString(codecSelferC_UTF81234, string("sizeBytes"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym8 := z.EncBinary()
_ = yym8
if false {
} else {
r.EncodeInt(int64(x.Size))
r.EncodeInt(int64(x.SizeBytes))
}
}
}
@ -33881,11 +33881,11 @@ func (x *ContainerImage) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
yys3 := string(yys3Slc)
z.DecSendContainerState(codecSelfer_containerMapValue1234)
switch yys3 {
case "repoTags":
case "names":
if r.TryDecodeAsNil() {
x.RepoTags = nil
x.Names = nil
} else {
yyv4 := &x.RepoTags
yyv4 := &x.Names
yym5 := z.DecBinary()
_ = yym5
if false {
@ -33893,11 +33893,11 @@ func (x *ContainerImage) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
z.F.DecSliceStringX(yyv4, false, d)
}
}
case "size":
case "sizeBytes":
if r.TryDecodeAsNil() {
x.Size = 0
x.SizeBytes = 0
} else {
x.Size = int64(r.DecodeInt(64))
x.SizeBytes = int64(r.DecodeInt(64))
}
default:
z.DecStructFieldNotFound(-1, yys3)
@ -33925,9 +33925,9 @@ func (x *ContainerImage) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.RepoTags = nil
x.Names = nil
} else {
yyv8 := &x.RepoTags
yyv8 := &x.Names
yym9 := z.DecBinary()
_ = yym9
if false {
@ -33947,9 +33947,9 @@ func (x *ContainerImage) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.Size = 0
x.SizeBytes = 0
} else {
x.Size = int64(r.DecodeInt(64))
x.SizeBytes = int64(r.DecodeInt(64))
}
for {
yyj7++

View File

@ -1719,9 +1719,9 @@ type NodeStatus struct {
// Describe a container image
type ContainerImage struct {
// Names by which this image is known.
RepoTags []string `json:"repoTags"`
Names []string `json:"names"`
// The size of the image in bytes.
Size int64 `json:"size,omitempty"`
SizeBytes int64 `json:"sizeBytes,omitempty"`
}
type NodePhase string

View File

@ -403,15 +403,15 @@ func autoConvert_api_ContainerImage_To_v1_ContainerImage(in *api.ContainerImage,
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.ContainerImage))(in)
}
if in.RepoTags != nil {
out.RepoTags = make([]string, len(in.RepoTags))
for i := range in.RepoTags {
out.RepoTags[i] = in.RepoTags[i]
if in.Names != nil {
out.Names = make([]string, len(in.Names))
for i := range in.Names {
out.Names[i] = in.Names[i]
}
} else {
out.RepoTags = nil
out.Names = nil
}
out.Size = in.Size
out.SizeBytes = in.SizeBytes
return nil
}
@ -3675,15 +3675,15 @@ func autoConvert_v1_ContainerImage_To_api_ContainerImage(in *ContainerImage, out
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*ContainerImage))(in)
}
if in.RepoTags != nil {
out.RepoTags = make([]string, len(in.RepoTags))
for i := range in.RepoTags {
out.RepoTags[i] = in.RepoTags[i]
if in.Names != nil {
out.Names = make([]string, len(in.Names))
for i := range in.Names {
out.Names[i] = in.Names[i]
}
} else {
out.RepoTags = nil
out.Names = nil
}
out.Size = in.Size
out.SizeBytes = in.SizeBytes
return nil
}

View File

@ -349,15 +349,15 @@ func deepCopy_v1_Container(in Container, out *Container, c *conversion.Cloner) e
}
func deepCopy_v1_ContainerImage(in ContainerImage, out *ContainerImage, c *conversion.Cloner) error {
if in.RepoTags != nil {
out.RepoTags = make([]string, len(in.RepoTags))
for i := range in.RepoTags {
out.RepoTags[i] = in.RepoTags[i]
if in.Names != nil {
out.Names = make([]string, len(in.Names))
for i := range in.Names {
out.Names[i] = in.Names[i]
}
} else {
out.RepoTags = nil
out.Names = nil
}
out.Size = in.Size
out.SizeBytes = in.SizeBytes
return nil
}

View File

@ -33636,7 +33636,7 @@ func (x *ContainerImage) CodecEncodeSelf(e *codec1978.Encoder) {
var yyq2 [2]bool
_, _, _ = yysep2, yyq2, yy2arr2
const yyr2 bool = false
yyq2[1] = x.Size != 0
yyq2[1] = x.SizeBytes != 0
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(2)
@ -33652,28 +33652,28 @@ func (x *ContainerImage) CodecEncodeSelf(e *codec1978.Encoder) {
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if x.RepoTags == nil {
if x.Names == nil {
r.EncodeNil()
} else {
yym4 := z.EncBinary()
_ = yym4
if false {
} else {
z.F.EncSliceStringV(x.RepoTags, false, e)
z.F.EncSliceStringV(x.Names, false, e)
}
}
} else {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("repoTags"))
r.EncodeString(codecSelferC_UTF81234, string("names"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.RepoTags == nil {
if x.Names == nil {
r.EncodeNil()
} else {
yym5 := z.EncBinary()
_ = yym5
if false {
} else {
z.F.EncSliceStringV(x.RepoTags, false, e)
z.F.EncSliceStringV(x.Names, false, e)
}
}
}
@ -33684,7 +33684,7 @@ func (x *ContainerImage) CodecEncodeSelf(e *codec1978.Encoder) {
_ = yym7
if false {
} else {
r.EncodeInt(int64(x.Size))
r.EncodeInt(int64(x.SizeBytes))
}
} else {
r.EncodeInt(0)
@ -33692,13 +33692,13 @@ func (x *ContainerImage) CodecEncodeSelf(e *codec1978.Encoder) {
} else {
if yyq2[1] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("size"))
r.EncodeString(codecSelferC_UTF81234, string("sizeBytes"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yym8 := z.EncBinary()
_ = yym8
if false {
} else {
r.EncodeInt(int64(x.Size))
r.EncodeInt(int64(x.SizeBytes))
}
}
}
@ -33763,11 +33763,11 @@ func (x *ContainerImage) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
yys3 := string(yys3Slc)
z.DecSendContainerState(codecSelfer_containerMapValue1234)
switch yys3 {
case "repoTags":
case "names":
if r.TryDecodeAsNil() {
x.RepoTags = nil
x.Names = nil
} else {
yyv4 := &x.RepoTags
yyv4 := &x.Names
yym5 := z.DecBinary()
_ = yym5
if false {
@ -33775,11 +33775,11 @@ func (x *ContainerImage) codecDecodeSelfFromMap(l int, d *codec1978.Decoder) {
z.F.DecSliceStringX(yyv4, false, d)
}
}
case "size":
case "sizeBytes":
if r.TryDecodeAsNil() {
x.Size = 0
x.SizeBytes = 0
} else {
x.Size = int64(r.DecodeInt(64))
x.SizeBytes = int64(r.DecodeInt(64))
}
default:
z.DecStructFieldNotFound(-1, yys3)
@ -33807,9 +33807,9 @@ func (x *ContainerImage) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.RepoTags = nil
x.Names = nil
} else {
yyv8 := &x.RepoTags
yyv8 := &x.Names
yym9 := z.DecBinary()
_ = yym9
if false {
@ -33829,9 +33829,9 @@ func (x *ContainerImage) codecDecodeSelfFromArray(l int, d *codec1978.Decoder) {
}
z.DecSendContainerState(codecSelfer_containerArrayElem1234)
if r.TryDecodeAsNil() {
x.Size = 0
x.SizeBytes = 0
} else {
x.Size = int64(r.DecodeInt(64))
x.SizeBytes = int64(r.DecodeInt(64))
}
for {
yyj7++

View File

@ -2105,9 +2105,9 @@ type NodeStatus struct {
type ContainerImage struct {
// Names by which this image is known.
// e.g. ["gcr.io/google_containers/hyperkube:v1.0.7", "dockerhub.io/google_containers/hyperkube:v1.0.7"]
RepoTags []string `json:"repoTags"`
Names []string `json:"names"`
// The size of the image in bytes.
Size int64 `json:"size,omitempty"`
SizeBytes int64 `json:"sizeBytes,omitempty"`
}
type NodePhase string

View File

@ -201,9 +201,9 @@ func (Container) SwaggerDoc() map[string]string {
}
var map_ContainerImage = map[string]string{
"": "Describe a container image",
"repoTags": "Names by which this image is known. e.g. [\"gcr.io/google_containers/hyperkube:v1.0.7\", \"dockerhub.io/google_containers/hyperkube:v1.0.7\"]",
"size": "The size of the image in bytes.",
"": "Describe a container image",
"names": "Names by which this image is known. e.g. [\"gcr.io/google_containers/hyperkube:v1.0.7\", \"dockerhub.io/google_containers/hyperkube:v1.0.7\"]",
"sizeBytes": "The size of the image in bytes.",
}
func (ContainerImage) SwaggerDoc() map[string]string {

View File

@ -2844,8 +2844,8 @@ func (kl *Kubelet) setNodeStatusImages(node *api.Node) {
} else {
for _, image := range containerImages {
imagesOnNode = append(imagesOnNode, api.ContainerImage{
RepoTags: image.RepoTags,
Size: image.Size,
Names: image.RepoTags,
SizeBytes: image.Size,
})
}
}

View File

@ -2723,12 +2723,12 @@ func TestUpdateNewNodeStatus(t *testing.T) {
},
Images: []api.ContainerImage{
{
RepoTags: []string{"gcr.io/google_containers:v1", "gcr.io/google_containers:v2"},
Size: 123,
Names: []string{"gcr.io/google_containers:v1", "gcr.io/google_containers:v2"},
SizeBytes: 123,
},
{
RepoTags: []string{"gcr.io/google_containers:v3", "gcr.io/google_containers:v4"},
Size: 456,
Names: []string{"gcr.io/google_containers:v3", "gcr.io/google_containers:v4"},
SizeBytes: 456,
},
},
},
@ -2958,12 +2958,12 @@ func TestDockerRuntimeVersion(t *testing.T) {
},
Images: []api.ContainerImage{
{
RepoTags: []string{"gcr.io/google_containers:v1", "gcr.io/google_containers:v2"},
Size: 123,
Names: []string{"gcr.io/google_containers:v1", "gcr.io/google_containers:v2"},
SizeBytes: 123,
},
{
RepoTags: []string{"gcr.io/google_containers:v3", "gcr.io/google_containers:v4"},
Size: 456,
Names: []string{"gcr.io/google_containers:v3", "gcr.io/google_containers:v4"},
SizeBytes: 456,
},
},
},
@ -3142,12 +3142,12 @@ func TestUpdateExistingNodeStatus(t *testing.T) {
},
Images: []api.ContainerImage{
{
RepoTags: []string{"gcr.io/google_containers:v1", "gcr.io/google_containers:v2"},
Size: 123,
Names: []string{"gcr.io/google_containers:v1", "gcr.io/google_containers:v2"},
SizeBytes: 123,
},
{
RepoTags: []string{"gcr.io/google_containers:v3", "gcr.io/google_containers:v4"},
Size: 456,
Names: []string{"gcr.io/google_containers:v3", "gcr.io/google_containers:v4"},
SizeBytes: 456,
},
},
},
@ -3422,12 +3422,12 @@ func TestUpdateNodeStatusWithoutContainerRuntime(t *testing.T) {
},
Images: []api.ContainerImage{
{
RepoTags: []string{"gcr.io/google_containers:v1", "gcr.io/google_containers:v2"},
Size: 123,
Names: []string{"gcr.io/google_containers:v1", "gcr.io/google_containers:v2"},
SizeBytes: 123,
},
{
RepoTags: []string{"gcr.io/google_containers:v3", "gcr.io/google_containers:v4"},
Size: 456,
Names: []string{"gcr.io/google_containers:v3", "gcr.io/google_containers:v4"},
SizeBytes: 456,
},
},
},

View File

@ -183,10 +183,10 @@ func ImageLocalityPriority(pod *api.Pod, nodeNameToInfo map[string]*schedulercac
// checkContainerImageOnNode checks if a container image is present on a node and returns its size.
func checkContainerImageOnNode(node api.Node, container api.Container) int64 {
for _, image := range node.Status.Images {
for _, repoTag := range image.RepoTags {
if container.Image == repoTag {
for _, name := range image.Names {
if container.Image == name {
// Should return immediately.
return image.Size
return image.SizeBytes
}
}
}

View File

@ -767,25 +767,25 @@ func TestImageLocalityPriority(t *testing.T) {
node_40_140_2000 := api.NodeStatus{
Images: []api.ContainerImage{
{
RepoTags: []string{
Names: []string{
"gcr.io/40",
"gcr.io/40:v1",
"gcr.io/40:v1",
},
Size: int64(40 * mb),
SizeBytes: int64(40 * mb),
},
{
RepoTags: []string{
Names: []string{
"gcr.io/140",
"gcr.io/140:v1",
},
Size: int64(140 * mb),
SizeBytes: int64(140 * mb),
},
{
RepoTags: []string{
Names: []string{
"gcr.io/2000",
},
Size: int64(2000 * mb),
SizeBytes: int64(2000 * mb),
},
},
}
@ -793,17 +793,17 @@ func TestImageLocalityPriority(t *testing.T) {
node_250_10 := api.NodeStatus{
Images: []api.ContainerImage{
{
RepoTags: []string{
Names: []string{
"gcr.io/250",
},
Size: int64(250 * mb),
SizeBytes: int64(250 * mb),
},
{
RepoTags: []string{
Names: []string{
"gcr.io/10",
"gcr.io/10:v1",
},
Size: int64(10 * mb),
SizeBytes: int64(10 * mb),
},
},
}