Add ID to JSONBaseInterface

This commit is contained in:
Daniel Smith
2014-08-03 00:01:01 -07:00
parent a47b65bf8a
commit 03fe91cc4a

View File

@@ -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
}