kube

package
v0.25.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package kube provides utilities for working with Kubernetes objects, including parsing YAML documents and extracting metadata.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidYAML         = errors.New("invalid yaml")
	ErrInvalidKubeResource = errors.New("invalid kubernetes resource")
)

Functions

func ObjectEqual

func ObjectEqual(a, b *Object) bool

ObjectEqual compares two Object instances for equality based on their apiVersion, kind, namespace, and name.

Types

type Object

type Object map[string]any

func (Object) GetAPIVersion

func (o Object) GetAPIVersion() string

GetAPIVersion returns the apiVersion of the object. If apiVersion is not set, it returns an empty string.

func (Object) GetGroup

func (o Object) GetGroup() string

GetGroup returns the group of the object, which is the first part of the apiVersion. If the group is not set, it assumes "core".

func (Object) GetGroupKind

func (o Object) GetGroupKind() string

GetGroupKind returns the group and kind of the object in the format `group/kind`. If the group is not set, it returns just the kind.

func (Object) GetKind

func (o Object) GetKind() string

GetKind returns the kind of the object. If the kind is not set, it returns "<empty>".

func (Object) GetMetadata added in v0.25.0

func (o Object) GetMetadata() ResourceMetadata

func (Object) GetName

func (o Object) GetName() string

GetName returns the name of the object. If the name is not set, it returns "<empty>".

func (Object) GetNamespace

func (o Object) GetNamespace() string

GetNamespace returns the namespace of the object. If the namespace is not set, it returns an empty string.

func (Object) GetNamespacedName

func (o Object) GetNamespacedName() string

type Resource

type Resource struct {
	Object *Object
	YAML   string
}

func SplitYAML

func SplitYAML(yamlData []byte) ([]*Resource, error)

SplitYAML splits a YAML file into unstructured objects. Returns list of all unstructured objects found in the yaml. If an error occurs, returns objects that have been parsed so far too.

type ResourceMetadata added in v0.25.0

type ResourceMetadata struct {
	APIVersion string `json:"apiVersion"`
	Kind       string `json:"kind"`
	Namespace  string `json:"namespace"`
	Name       string `json:"name"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL