From 03fe91cc4a9a2a114b6705d528ea8ce706503a8f Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Sun, 3 Aug 2014 00:01:01 -0700 Subject: [PATCH] Add ID to JSONBaseInterface --- pkg/api/jsonbase.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/api/jsonbase.go b/pkg/api/jsonbase.go index 4ce61709439..24b12960f68 100644 --- a/pkg/api/jsonbase.go +++ b/pkg/api/jsonbase.go @@ -44,6 +44,8 @@ func (v JSONBaseVersioning) SetResourceVersion(obj interface{}, version uint64) // JSONBase lets you work with a JSONBase from any of the versioned or // internal APIObjects. type JSONBaseInterface interface { + ID() string + SetID(ID string) APIVersion() string SetAPIVersion(version string) Kind() string @@ -53,11 +55,20 @@ type JSONBaseInterface interface { } type genericJSONBase struct { + id *string apiVersion *string kind *string resourceVersion *uint64 } +func (g genericJSONBase) ID() string { + return *g.id +} + +func (g genericJSONBase) SetID(id string) { + *g.id = id +} + func (g genericJSONBase) APIVersion() string { return *g.apiVersion } @@ -112,7 +123,11 @@ func fieldPtr(v reflect.Value, fieldName string, dest interface{}) error { // Returns an error if this isn't the case. func newGenericJSONBase(v reflect.Value) (genericJSONBase, error) { g := genericJSONBase{} - err := fieldPtr(v, "APIVersion", &g.apiVersion) + err := fieldPtr(v, "ID", &g.id) + if err != nil { + return g, err + } + err = fieldPtr(v, "APIVersion", &g.apiVersion) if err != nil { return g, err }