Skip to content

Commit 7790961

Browse files
committed
Rename Object to EmbeddedObject
1 parent e4cd06d commit 7790961

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

pkg/api/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,5 +552,5 @@ type WatchEvent struct {
552552

553553
// For added or modified objects, this is the new object; for deleted objects,
554554
// it's the state of the object immediately prior to its deletion.
555-
Object runtime.Object
555+
Object runtime.EmbeddedObject
556556
}

pkg/api/v1beta1/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,5 +553,5 @@ type WatchEvent struct {
553553

554554
// For added or modified objects, this is the new object; for deleted objects,
555555
// it's the state of the object immediately prior to its deletion.
556-
Object runtime.Object
556+
Object runtime.EmbeddedObject
557557
}

pkg/apiserver/watch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (w *WatchServer) HandleWS(ws *websocket.Conn) {
113113
}
114114
err := websocket.JSON.Send(ws, &api.WatchEvent{
115115
Type: event.Type,
116-
Object: runtime.Object{event.Object},
116+
Object: runtime.EmbeddedObject{event.Object},
117117
})
118118
if err != nil {
119119
// Client disconnect.
@@ -160,7 +160,7 @@ func (self *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
160160
}
161161
err := encoder.Encode(&api.WatchEvent{
162162
Type: event.Type,
163-
Object: runtime.Object{event.Object},
163+
Object: runtime.EmbeddedObject{event.Object},
164164
})
165165
if err != nil {
166166
// Client disconnect.

pkg/client/request_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func TestWatch(t *testing.T) {
401401

402402
encoder := json.NewEncoder(w)
403403
for _, item := range table {
404-
encoder.Encode(&api.WatchEvent{item.t, runtime.Object{item.obj}})
404+
encoder.Encode(&api.WatchEvent{item.t, runtime.EmbeddedObject{item.obj}})
405405
flusher.Flush()
406406
}
407407
}))

pkg/kubelet/config/etcd_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,29 @@ func TestEventToPods(t *testing.T) {
4545
input: watch.Event{
4646
Object: &api.ContainerManifestList{
4747
Items: []api.ContainerManifest{
48-
api.ContainerManifest{ID: "foo"},
49-
api.ContainerManifest{ID: "bar"},
48+
{ID: "foo"},
49+
{ID: "bar"},
5050
},
5151
},
5252
},
5353
pods: []kubelet.Pod{
54-
kubelet.Pod{Name: "foo", Manifest: api.ContainerManifest{ID: "foo"}},
55-
kubelet.Pod{Name: "bar", Manifest: api.ContainerManifest{ID: "bar"}},
54+
{Name: "foo", Manifest: api.ContainerManifest{ID: "foo"}},
55+
{Name: "bar", Manifest: api.ContainerManifest{ID: "bar"}},
5656
},
5757
fail: false,
5858
},
5959
{
6060
input: watch.Event{
6161
Object: &api.ContainerManifestList{
6262
Items: []api.ContainerManifest{
63-
api.ContainerManifest{ID: ""},
64-
api.ContainerManifest{ID: ""},
63+
{ID: ""},
64+
{ID: ""},
6565
},
6666
},
6767
},
6868
pods: []kubelet.Pod{
69-
kubelet.Pod{Name: "1", Manifest: api.ContainerManifest{ID: ""}},
70-
kubelet.Pod{Name: "2", Manifest: api.ContainerManifest{ID: ""}},
69+
{Name: "1", Manifest: api.ContainerManifest{ID: ""}},
70+
{Name: "2", Manifest: api.ContainerManifest{ID: ""}},
7171
},
7272
fail: false,
7373
},

pkg/runtime/object.go renamed to pkg/runtime/embedded.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
// embedded within other API types.
2727

2828
// UnmarshalJSON implements the json.Unmarshaler interface.
29-
func (a *Object) UnmarshalJSON(b []byte) error {
29+
func (a *EmbeddedObject) UnmarshalJSON(b []byte) error {
3030
// Handle JSON's "null": Decode() doesn't expect it.
3131
if len(b) == 4 && string(b) == "null" {
3232
a.Object = nil
@@ -42,7 +42,7 @@ func (a *Object) UnmarshalJSON(b []byte) error {
4242
}
4343

4444
// MarshalJSON implements the json.Marshaler interface.
45-
func (a Object) MarshalJSON() ([]byte, error) {
45+
func (a EmbeddedObject) MarshalJSON() ([]byte, error) {
4646
if a.Object == nil {
4747
// Encode unset/nil objects as JSON's "null".
4848
return []byte("null"), nil
@@ -52,7 +52,7 @@ func (a Object) MarshalJSON() ([]byte, error) {
5252
}
5353

5454
// SetYAML implements the yaml.Setter interface.
55-
func (a *Object) SetYAML(tag string, value interface{}) bool {
55+
func (a *EmbeddedObject) SetYAML(tag string, value interface{}) bool {
5656
if value == nil {
5757
a.Object = nil
5858
return true
@@ -76,7 +76,7 @@ func (a *Object) SetYAML(tag string, value interface{}) bool {
7676
}
7777

7878
// GetYAML implements the yaml.Getter interface.
79-
func (a Object) GetYAML() (tag string, value interface{}) {
79+
func (a EmbeddedObject) GetYAML() (tag string, value interface{}) {
8080
if a.Object == nil {
8181
value = "null"
8282
return

pkg/runtime/object_test.go renamed to pkg/runtime/embedded_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ import (
2222
"testing"
2323
)
2424

25-
func TestObject(t *testing.T) {
25+
func TestEmbeddedObject(t *testing.T) {
2626
type EmbeddedTest struct {
2727
JSONBase `yaml:",inline" json:",inline"`
28-
Object Object `yaml:"object,omitempty" json:"object,omitempty"`
29-
EmptyObject Object `yaml:"emptyObject,omitempty" json:"emptyObject,omitempty"`
28+
Object EmbeddedObject `yaml:"object,omitempty" json:"object,omitempty"`
29+
EmptyObject EmbeddedObject `yaml:"emptyObject,omitempty" json:"emptyObject,omitempty"`
3030
}
3131
AddKnownTypes("", EmbeddedTest{})
3232
AddKnownTypes("v1beta1", EmbeddedTest{})
3333

3434
outer := &EmbeddedTest{
3535
JSONBase: JSONBase{ID: "outer"},
36-
Object: Object{
36+
Object: EmbeddedObject{
3737
&EmbeddedTest{
3838
JSONBase: JSONBase{ID: "inner"},
3939
},

pkg/runtime/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ type JSONBase struct {
4242
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
4343
}
4444

45-
// Object has appropriate encoder and decoder functions, such that on the wire, it's
45+
// EmbeddedObject has appropriate encoder and decoder functions, such that on the wire, it's
4646
// stored as a []byte, but in memory, the contained object is accessable as an interface{}
4747
// via the Get() function. Only objects having a JSONBase may be stored via Object.
4848
// The purpose of this is to allow an API object of type known only at runtime to be
@@ -52,7 +52,7 @@ type JSONBase struct {
5252
//
5353
// Note that objects will be serialized into the api package's default external versioned type;
5454
// this should be fixed in the future to use the version of the current Codec instead.
55-
type Object struct {
55+
type EmbeddedObject struct {
5656
Object interface{}
5757
}
5858

pkg/tools/decoder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestDecoder(t *testing.T) {
3636

3737
expect := &api.Pod{JSONBase: api.JSONBase{ID: "foo"}}
3838
go func() {
39-
err := encoder.Encode(api.WatchEvent{watch.Added, runtime.Object{expect}})
39+
err := encoder.Encode(api.WatchEvent{watch.Added, runtime.EmbeddedObject{expect}})
4040
if err != nil {
4141
t.Errorf("Unexpected error %v", err)
4242
}

0 commit comments

Comments
 (0)