Documentation
¶
Index ¶
- func GetNamespacedName(k8sObjYaml string) (types.NamespacedName, error)
- func RemoveFieldRecusive(obj map[string]interface{}, field string) error
- func RemoveFieldRecusiveL(objs []interface{}, field string) error
- func TransformRemoveCreationTimestamp(obj map[string]interface{}) error
- func TransformRemoveCreationTimestampRecursive(obj map[string]interface{}) error
- func TransformRemoveCreationTimestampRecursiveL(objs []interface{}) error
- func TransformRemoveStatus(obj map[string]interface{}) error
- func UnmarshalToRuntimeObject(objYaml string) (runtime.Object, *schema.GroupVersionKind, error)
- func UnmarshalToUnstructured(objYaml string) (*unstructured.Unstructured, error)
- func WithNamespacedName(ns string, name string) types.NamespacedName
- func YAMLMarshal(o interface{}, options ...*TransformYAMLOption) ([]byte, error)
- type TransformYAMLOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNamespacedName ¶
func GetNamespacedName(k8sObjYaml string) (types.NamespacedName, error)
func RemoveFieldRecusive ¶
func RemoveFieldRecusiveL ¶
func TransformRemoveCreationTimestamp ¶
TransformRemoveCreationTimestamp ensures we do not write the metadata.creationTimestamp field.
func TransformRemoveCreationTimestampRecursive ¶
TransformRemoveCreationTimestampRecursive removes all fields "creationTimestamp" recusively.
func TransformRemoveCreationTimestampRecursiveL ¶
func TransformRemoveCreationTimestampRecursiveL(objs []interface{}) error
func TransformRemoveStatus ¶
TransformRemoveStatus remove status field.
func UnmarshalToRuntimeObject ¶
UnmarshalToRuntimeObject unmarshal yaml to runtime.Object.
after you got the returned runObj runtime.Object, you can apply type switch to runObj to get concrete type, eg:
switch obj := runObj.(type) { case *corev1.Service: clusterIP := obj.Spec.ClusterIP port := obj.Spec.Ports[0].Port default: }
or apply type assertion, eg:
if obj, ok := runObj.(*corev1.Service); ok { }
func UnmarshalToUnstructured ¶
func UnmarshalToUnstructured(objYaml string) (*unstructured.Unstructured, error)
func WithNamespacedName ¶
func WithNamespacedName(ns string, name string) types.NamespacedName
apimachinery/pkg defines
type NamespacedName struct { Namespace string Name string }
controller-runtime defines
type ObjectKey = types.NamespacedName
They are the same thing.
func YAMLMarshal ¶
func YAMLMarshal(o interface{}, options ...*TransformYAMLOption) ([]byte, error)
Usage:
b, err := YAMLMarshal(vm, WithTransform(TransformRemoveCreationTimestampRecursive), WithTransform(TransformRemoveStatus)) if err != nil { }
Types ¶
type TransformYAMLOption ¶
type TransformYAMLOption struct {
// contains filtered or unexported fields
}
func WithTransform ¶
func WithTransform(transform func(obj map[string]interface{}) error) *TransformYAMLOption
WithTransform applies a transformation to objects just before writing them.
Click to show internal directories.
Click to hide internal directories.