Documentation ¶
Overview ¶
Package kube provides utilities for working with Kubernetes configurations.
Index ¶
- func CopyAndRemoveMetadataAndStatus(object *unstructured.Unstructured) *unstructured.Unstructured
- func GetKubeConfigPath() string
- func HasDrifted(existing, current *unstructured.Unstructured) bool
- func JsonByteToRawExtension(jsonByte []byte) (runtime.RawExtension, error)
- func JsonByteToUnstructured(jsonByte []byte) (*unstructured.Unstructured, error)
- func NormalizeMap(input interface{}) (interface{}, error)
- func NormalizeServerSideFields(ur *unstructured.Unstructured) *unstructured.Unstructured
- func ObjToRawExtension(obj interface{}) (runtime.RawExtension, error)
- func UnstructuredID(obj *unstructured.Unstructured) string
- func UnstructuredToRawExtension(obj *unstructured.Unstructured) (runtime.RawExtension, error)
- func YamlByteToUnstructured(yamlByte []byte) (*unstructured.Unstructured, error)
- func YamlStreamByteToUnstructuredList(yamlByte []byte) (result []*unstructured.Unstructured, err error)
- type KubeObject
- func (o *KubeObject) As(ptr interface{}) error
- func (o *KubeObject) GetAPIVersion() string
- func (o *KubeObject) GetKind() string
- func (o *KubeObject) GetName() string
- func (o *KubeObject) GetNamespace() string
- func (o *KubeObject) GetNestedMap(field string) (*KubeObject, error)
- func (o *KubeObject) GetNestedSlice(field string) (KubeObjects, error)
- func (o *KubeObject) IsNilOrEmpty() bool
- func (o *KubeObject) MustString() string
- func (o *KubeObject) Node() *yaml.RNode
- type KubeObjects
- type ObjMetadata
- type ResourceList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CopyAndRemoveMetadataAndStatus ¶ added in v0.9.2
func CopyAndRemoveMetadataAndStatus(object *unstructured.Unstructured) *unstructured.Unstructured
RemoveMetadataAndStatus removes the metadata and status fields from the object to prepare for semantic equality check.
func GetKubeConfigPath ¶ added in v0.9.2
func GetKubeConfigPath() string
GetKubeConfigPath returns the path to the Kubernetes configuration file. If the KUBECONFIG environment variable is set, it returns the first path in the list that matches the current context.
func HasDrifted ¶ added in v0.9.2
func HasDrifted(existing, current *unstructured.Unstructured) bool
HasDrifted checks if the current object has drifted from the existing object.
func JsonByteToRawExtension ¶ added in v0.9.2
func JsonByteToRawExtension(jsonByte []byte) (runtime.RawExtension, error)
JsonByteToRawExtension converts a JSON byte array to a runtime.RawExtension object.
func JsonByteToUnstructured ¶ added in v0.9.2
func JsonByteToUnstructured(jsonByte []byte) (*unstructured.Unstructured, error)
JsonByteToUnstructured converts a JSON byte array to an unstructured.Unstructured object.
func NormalizeMap ¶ added in v0.9.2
func NormalizeMap(input interface{}) (interface{}, error)
NormalizeMap converts map[interface{}]interface{} to map[string]interface{}
func NormalizeServerSideFields ¶ added in v0.9.2
func NormalizeServerSideFields(ur *unstructured.Unstructured) *unstructured.Unstructured
NormalizeServerSideFields removes the metadata and status fields from the object to prepare for semantic equality check.
func ObjToRawExtension ¶ added in v0.9.2
func ObjToRawExtension(obj interface{}) (runtime.RawExtension, error)
ObjToRawExtension converts an arbitrary object to a runtime.RawExtension object using JSON encoding.
func UnstructuredID ¶ added in v0.9.2
func UnstructuredID(obj *unstructured.Unstructured) string
UnstructuredID returns the object ID in the format <kind>/<namespace>/<name>.
func UnstructuredToRawExtension ¶ added in v0.9.2
func UnstructuredToRawExtension(obj *unstructured.Unstructured) (runtime.RawExtension, error)
UnstructuredToRawExtension converts an unstructured.Unstructured object to a runtime.RawExtension object.
func YamlByteToUnstructured ¶ added in v0.9.2
func YamlByteToUnstructured(yamlByte []byte) (*unstructured.Unstructured, error)
YamlByteToUnstructured converts a Yaml byte array to an unstructured.Unstructured object.
func YamlStreamByteToUnstructuredList ¶ added in v0.9.2
func YamlStreamByteToUnstructuredList(yamlByte []byte) (result []*unstructured.Unstructured, err error)
YamlByteToUnstructured returns the manifests list from the YAML stream data.
Types ¶
type KubeObject ¶
type KubeObject struct {
// contains filtered or unexported fields
}
KubeObject represents a Kubernetes object with associated functions.
func ParseKubeObject ¶
func ParseKubeObject(in []byte) (*KubeObject, error)
ParseKubeObject parses a single YAML object from a byte slice into a KubeObject.
func ParseKubeObjects ¶
func ParseKubeObjects(in []byte) ([]*KubeObject, error)
ParseKubeObjects parses a YAML byte slice into a slice of KubeObjects.
func (*KubeObject) As ¶
func (o *KubeObject) As(ptr interface{}) error
As unmarshals the Kubernetes object into a Go struct pointed by ptr.
func (*KubeObject) GetAPIVersion ¶
func (o *KubeObject) GetAPIVersion() string
GetAPIVersion retrieves the APIVersion of the Kubernetes object.
func (*KubeObject) GetKind ¶
func (o *KubeObject) GetKind() string
GetKind retrieves the kind of the Kubernetes object.
func (*KubeObject) GetName ¶
func (o *KubeObject) GetName() string
GetName retrieves the name of the Kubernetes object.
func (*KubeObject) GetNamespace ¶
func (o *KubeObject) GetNamespace() string
GetNamespace retrieves the namespace of the Kubernetes object.
func (*KubeObject) GetNestedMap ¶
func (o *KubeObject) GetNestedMap(field string) (*KubeObject, error)
GetNestedMap retrieves a nested field from a Kubernetes object as a KubeObject. The field must be a map type.
func (*KubeObject) GetNestedSlice ¶
func (o *KubeObject) GetNestedSlice(field string) (KubeObjects, error)
GetNestedSlice retrieves a nested field from Kubernetes object as a slice of KubeObjects. The field must be a slice type.
func (*KubeObject) IsNilOrEmpty ¶
func (o *KubeObject) IsNilOrEmpty() bool
IsNilOrEmpty checks if the Kubernetes object is either nil or empty.
func (*KubeObject) MustString ¶
func (o *KubeObject) MustString() string
MustString returns the YAML string representation of the Kubernetes object. It panics if any error occurs while encoding to YAML.
func (*KubeObject) Node ¶
func (o *KubeObject) Node() *yaml.RNode
Node returns the underlying RNode of the Kubernetes object.
type KubeObjects ¶
type KubeObjects []*KubeObject
KubeObjects defines a slice of KubeObject types with convenience methods.
func (KubeObjects) MustString ¶
func (o KubeObjects) MustString() string
MustString concatenates all KubeObjects into a single YAML string, separated by '---' (YAML document separator).
func (KubeObjects) Swap ¶
func (o KubeObjects) Swap(i, j int)
Swap switches the positions of two KubeObjects in the slice.
type ObjMetadata ¶ added in v0.9.2
type ObjMetadata struct { // Namespace of the object Namespace string // Name of the object Name string // GroupKind of the object GroupKind schema.GroupKind }
ObjMetadata contains metadata information for a Kubernetes object.
func UnstructuredToObjMetadata ¶ added in v0.9.2
func UnstructuredToObjMetadata(obj *unstructured.Unstructured) ObjMetadata
UnstructuredToObjMetadata extracts the identifying information from an Unstructured object and returns it as ObjMetadata object.
func (*ObjMetadata) ID ¶ added in v0.9.2
func (obj *ObjMetadata) ID() string
ID returns the object ID in the format <kind>/<namespace>/<name>.
type ResourceList ¶
type ResourceList struct { yaml.ResourceMeta `json:",inline" yaml:",inline"` Items KubeObjects `yaml:"items" json:"items"` // Items is a slice of Kubernetes objects. FunctionConfig *KubeObject `yaml:"functionConfig,omitempty" json:"functionConfig,omitempty"` // FunctionConfig is an optional KubeObject that describes the function configuration. }
ResourceList represents a list of Kubernetes objects typically used for configuration purposes.
func ParseResourceList ¶
func ParseResourceList(in []byte) (*ResourceList, error)
ParseResourceList takes a byte slice of a YAML ResourceList and parses it into a ResourceList structure.