mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-19 08:54:44 +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
|
||||
// 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
|
||||
}
|
||||
|
Reference in New Issue
Block a user