var isListCache … // IsListType returns true if the provided Object has a slice called Items. // TODO: Replace the code in this check with an interface comparison by // creating and enforcing that lists implement a list accessor. func IsListType(obj runtime.Object) bool { … } var errExpectFieldItems … var errExpectSliceItems … // GetItemsPtr returns a pointer to the list object's Items member. // If 'list' doesn't have an Items member, it's not really a list type // and an error will be returned. // This function will either return a pointer to a slice, or an error, but not both. // TODO: this will be replaced with an interface in the future func GetItemsPtr(list runtime.Object) (interface{ … } // getItemsPtr returns a pointer to the list object's Items member or an error. func getItemsPtr(list runtime.Object) (interface{ … } // EachListItem invokes fn on each runtime.Object in the list. Any error immediately terminates // the loop. // // If items passed to fn are retained for different durations, and you want to avoid // retaining all items in obj as long as any item is referenced, use EachListItemWithAlloc instead. func EachListItem(obj runtime.Object, fn func(runtime.Object) error) error { … } // EachListItemWithAlloc works like EachListItem, but avoids retaining references to the items slice in obj. // It does this by making a shallow copy of non-pointer items in obj. // // If the items passed to fn are not retained, or are retained for the same duration, use EachListItem instead for memory efficiency. func EachListItemWithAlloc(obj runtime.Object, fn func(runtime.Object) error) error { … } // allocNew: Whether shallow copy is required when the elements in Object.Items are struct func eachListItem(obj runtime.Object, fn func(runtime.Object) error, allocNew bool) error { … } // ExtractList returns obj's Items element as an array of runtime.Objects. // Returns an error if obj is not a List type (does not have an Items member). // // If items in the returned list are retained for different durations, and you want to avoid // retaining all items in obj as long as any item is referenced, use ExtractListWithAlloc instead. func ExtractList(obj runtime.Object) ([]runtime.Object, error) { … } // ExtractListWithAlloc works like ExtractList, but avoids retaining references to the items slice in obj. // It does this by making a shallow copy of non-pointer items in obj. // // If the items in the returned list are not retained, or are retained for the same duration, use ExtractList instead for memory efficiency. func ExtractListWithAlloc(obj runtime.Object) ([]runtime.Object, error) { … } // allocNew: Whether shallow copy is required when the elements in Object.Items are struct func extractList(obj runtime.Object, allocNew bool) ([]runtime.Object, error) { … } var objectSliceType … var objectType … var rawExtensionObjectType … // LenList returns the length of this list or 0 if it is not a list. func LenList(list runtime.Object) int { … } // SetList sets the given list object's Items member have the elements given in // objects. // Returns an error if list is not a List type (does not have an Items member), // or if any of the objects are not of the right type. func SetList(list runtime.Object, objects []runtime.Object) error { … }