// extractFromObjectMeta extracts pointers to metadata fields from a list object func extractFromListMeta(v reflect.Value, a *genericAccessor) error { if err := runtime.FieldPtr(v, "ResourceVersion", &a.resourceVersion); err != nil { return err } if err := runtime.FieldPtr(v, "SelfLink", &a.selfLink); err != nil { return err } return nil }
// extractFromTypeMeta extracts pointers to version and kind fields from an object func extractFromTypeMeta(v reflect.Value, a *genericAccessor) error { if err := runtime.FieldPtr(v, "APIVersion", &a.apiVersion); err != nil { return err } if err := runtime.FieldPtr(v, "Kind", &a.kind); err != nil { return err } return nil }
// extractFromObjectMeta extracts pointers to metadata fields from an object func extractFromObjectMeta(v reflect.Value, a *genericAccessor) error { if err := runtime.FieldPtr(v, "Namespace", &a.namespace); err != nil { return err } if err := runtime.FieldPtr(v, "Name", &a.name); err != nil { return err } if err := runtime.FieldPtr(v, "GenerateName", &a.generateName); err != nil { return err } if err := runtime.FieldPtr(v, "UID", &a.uid); err != nil { return err } if err := runtime.FieldPtr(v, "ResourceVersion", &a.resourceVersion); err != nil { return err } if err := runtime.FieldPtr(v, "SelfLink", &a.selfLink); err != nil { return err } if err := runtime.FieldPtr(v, "Labels", &a.labels); err != nil { return err } if err := runtime.FieldPtr(v, "Annotations", &a.annotations); err != nil { return err } return nil }
// ListMetaFor returns a pointer to a provided object's ListMeta, // or an error if the object does not have that pointer. // TODO: allow runtime.Unknown to extract this object func ListMetaFor(obj runtime.Object) (*ListMeta, error) { v, err := conversion.EnforcePtr(obj) if err != nil { return nil, err } var meta *ListMeta err = runtime.FieldPtr(v, "ListMeta", &meta) return meta, err }
// GetObjectMetaPtr returns a pointer to a provided object's ObjectMeta. // TODO: allow runtime.Unknown to extract this object func ObjectMetaFor(obj runtime.Object) (*ObjectMeta, error) { v, err := conversion.EnforcePtr(obj) if err != nil { return nil, err } var objectMeta *ObjectMeta if err := runtime.FieldPtr(v, "ObjectMeta", &objectMeta); err != nil { return nil, err } return objectMeta, nil }