mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-20 01:23:48 +00:00
Add ID to JSONBaseInterface
This commit is contained in:
@@ -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
|
// JSONBase lets you work with a JSONBase from any of the versioned or
|
||||||
// internal APIObjects.
|
// internal APIObjects.
|
||||||
type JSONBaseInterface interface {
|
type JSONBaseInterface interface {
|
||||||
|
ID() string
|
||||||
|
SetID(ID string)
|
||||||
APIVersion() string
|
APIVersion() string
|
||||||
SetAPIVersion(version string)
|
SetAPIVersion(version string)
|
||||||
Kind() string
|
Kind() string
|
||||||
@@ -53,11 +55,20 @@ type JSONBaseInterface interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type genericJSONBase struct {
|
type genericJSONBase struct {
|
||||||
|
id *string
|
||||||
apiVersion *string
|
apiVersion *string
|
||||||
kind *string
|
kind *string
|
||||||
resourceVersion *uint64
|
resourceVersion *uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g genericJSONBase) ID() string {
|
||||||
|
return *g.id
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g genericJSONBase) SetID(id string) {
|
||||||
|
*g.id = id
|
||||||
|
}
|
||||||
|
|
||||||
func (g genericJSONBase) APIVersion() string {
|
func (g genericJSONBase) APIVersion() string {
|
||||||
return *g.apiVersion
|
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.
|
// Returns an error if this isn't the case.
|
||||||
func newGenericJSONBase(v reflect.Value) (genericJSONBase, error) {
|
func newGenericJSONBase(v reflect.Value) (genericJSONBase, error) {
|
||||||
g := genericJSONBase{}
|
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 {
|
if err != nil {
|
||||||
return g, err
|
return g, err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user