*: update kube vendor to v1.7.4
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
c67859731f
commit
d56bf090ce
1032 changed files with 273965 additions and 40081 deletions
91
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go
generated
vendored
91
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go
generated
vendored
|
@ -27,10 +27,12 @@ import (
|
|||
"github.com/golang/glog"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/conversion/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/json"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
)
|
||||
|
||||
// Unstructured allows objects that do not have Golang structs registered to be manipulated
|
||||
|
@ -126,6 +128,20 @@ func getNestedString(obj map[string]interface{}, fields ...string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func getNestedInt64(obj map[string]interface{}, fields ...string) int64 {
|
||||
if str, ok := getNestedField(obj, fields...).(int64); ok {
|
||||
return str
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func getNestedInt64Pointer(obj map[string]interface{}, fields ...string) *int64 {
|
||||
if str, ok := getNestedField(obj, fields...).(*int64); ok {
|
||||
return str
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getNestedSlice(obj map[string]interface{}, fields ...string) []string {
|
||||
if m, ok := getNestedField(obj, fields...).([]interface{}); ok {
|
||||
strSlice := make([]string, 0, len(m))
|
||||
|
@ -234,22 +250,19 @@ func extractOwnerReference(src interface{}) metav1.OwnerReference {
|
|||
|
||||
func setOwnerReference(src metav1.OwnerReference) map[string]interface{} {
|
||||
ret := make(map[string]interface{})
|
||||
controllerPtr := src.Controller
|
||||
if controllerPtr != nil {
|
||||
controller := *controllerPtr
|
||||
controllerPtr = &controller
|
||||
}
|
||||
blockOwnerDeletionPtr := src.BlockOwnerDeletion
|
||||
if blockOwnerDeletionPtr != nil {
|
||||
blockOwnerDeletion := *blockOwnerDeletionPtr
|
||||
blockOwnerDeletionPtr = &blockOwnerDeletion
|
||||
}
|
||||
setNestedField(ret, src.Kind, "kind")
|
||||
setNestedField(ret, src.Name, "name")
|
||||
setNestedField(ret, src.APIVersion, "apiVersion")
|
||||
setNestedField(ret, string(src.UID), "uid")
|
||||
setNestedField(ret, controllerPtr, "controller")
|
||||
setNestedField(ret, blockOwnerDeletionPtr, "blockOwnerDeletion")
|
||||
// json.Unmarshal() extracts boolean json fields as bool, not as *bool and hence extractOwnerReference()
|
||||
// expects bool or a missing field, not *bool. So if pointer is nil, fields are omitted from the ret object.
|
||||
// If pointer is non-nil, they are set to the referenced value.
|
||||
if src.Controller != nil {
|
||||
setNestedField(ret, *src.Controller, "controller")
|
||||
}
|
||||
if src.BlockOwnerDeletion != nil {
|
||||
setNestedField(ret, *src.BlockOwnerDeletion, "blockOwnerDeletion")
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
|
@ -355,6 +368,14 @@ func (u *Unstructured) SetResourceVersion(version string) {
|
|||
u.setNestedField(version, "metadata", "resourceVersion")
|
||||
}
|
||||
|
||||
func (u *Unstructured) GetGeneration() int64 {
|
||||
return getNestedInt64(u.Object, "metadata", "generation")
|
||||
}
|
||||
|
||||
func (u *Unstructured) SetGeneration(generation int64) {
|
||||
u.setNestedField(generation, "metadata", "generation")
|
||||
}
|
||||
|
||||
func (u *Unstructured) GetSelfLink() string {
|
||||
return getNestedString(u.Object, "metadata", "selfLink")
|
||||
}
|
||||
|
@ -384,10 +405,22 @@ func (u *Unstructured) GetDeletionTimestamp() *metav1.Time {
|
|||
}
|
||||
|
||||
func (u *Unstructured) SetDeletionTimestamp(timestamp *metav1.Time) {
|
||||
if timestamp == nil {
|
||||
u.setNestedField(nil, "metadata", "deletionTimestamp")
|
||||
return
|
||||
}
|
||||
ts, _ := timestamp.MarshalQueryParameter()
|
||||
u.setNestedField(ts, "metadata", "deletionTimestamp")
|
||||
}
|
||||
|
||||
func (u *Unstructured) GetDeletionGracePeriodSeconds() *int64 {
|
||||
return getNestedInt64Pointer(u.Object, "metadata", "deletionGracePeriodSeconds")
|
||||
}
|
||||
|
||||
func (u *Unstructured) SetDeletionGracePeriodSeconds(deletionGracePeriodSeconds *int64) {
|
||||
u.setNestedField(deletionGracePeriodSeconds, "metadata", "deletionGracePeriodSeconds")
|
||||
}
|
||||
|
||||
func (u *Unstructured) GetLabels() map[string]string {
|
||||
return getNestedMap(u.Object, "metadata", "labels")
|
||||
}
|
||||
|
@ -418,6 +451,36 @@ func (u *Unstructured) GroupVersionKind() schema.GroupVersionKind {
|
|||
return gvk
|
||||
}
|
||||
|
||||
var converter = unstructured.NewConverter(false)
|
||||
|
||||
func (u *Unstructured) GetInitializers() *metav1.Initializers {
|
||||
field := getNestedField(u.Object, "metadata", "initializers")
|
||||
if field == nil {
|
||||
return nil
|
||||
}
|
||||
obj, ok := field.(map[string]interface{})
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
out := &metav1.Initializers{}
|
||||
if err := converter.FromUnstructured(obj, out); err != nil {
|
||||
utilruntime.HandleError(fmt.Errorf("unable to retrieve initializers for object: %v", err))
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func (u *Unstructured) SetInitializers(initializers *metav1.Initializers) {
|
||||
if initializers == nil {
|
||||
setNestedField(u.Object, nil, "metadata", "initializers")
|
||||
return
|
||||
}
|
||||
out := make(map[string]interface{})
|
||||
if err := converter.ToUnstructured(initializers, &out); err != nil {
|
||||
utilruntime.HandleError(fmt.Errorf("unable to retrieve initializers for object: %v", err))
|
||||
}
|
||||
setNestedField(u.Object, out, "metadata", "initializers")
|
||||
}
|
||||
|
||||
func (u *Unstructured) GetFinalizers() []string {
|
||||
return getNestedSlice(u.Object, "metadata", "finalizers")
|
||||
}
|
||||
|
@ -441,7 +504,7 @@ type UnstructuredList struct {
|
|||
Object map[string]interface{}
|
||||
|
||||
// Items is a list of unstructured objects.
|
||||
Items []*Unstructured `json:"items"`
|
||||
Items []Unstructured `json:"items"`
|
||||
}
|
||||
|
||||
// MarshalJSON ensures that the unstructured list object produces proper
|
||||
|
@ -642,7 +705,7 @@ func (s unstructuredJSONScheme) decodeToList(data []byte, list *UnstructuredList
|
|||
unstruct.SetKind(itemKind)
|
||||
unstruct.SetAPIVersion(listAPIVersion)
|
||||
}
|
||||
list.Items = append(list.Items, unstruct)
|
||||
list.Items = append(list.Items, *unstruct)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue