kubeutil

package
v1.0.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DeploymentGVK = schema.GroupVersionKind{
		Group:   appsv1.GroupName,
		Version: "v1",
		Kind:    "Deployment",
	}
	ServiceGVK = schema.GroupVersionKind{
		Group:   corev1.GroupName,
		Version: "v1",
		Kind:    "Service",
	}
)

Functions

func Apply

func Apply(ctx context.Context, c client.Client, obj *unstructured.Unstructured, fieldManager string, dryrun, force bool) (patched *unstructured.Unstructured, err error)

func GetAnnotation

func GetAnnotation(obj AnnotationHolder, key string) string

func GetLabel

func GetLabel(obj LabelHolder, key string) string

func GetUnstructured

func GetUnstructured(ctx context.Context, c client.Client, gvk schema.GroupVersionKind, name, namespace string) (*unstructured.Unstructured, error)

func IsGVKEqual

func IsGVKEqual(a, b schema.GroupVersionKind) bool

func ListClusterTemplatesByType added in v0.6.0

func ListClusterTemplatesByType(ctx context.Context, c client.Client, tmplTypes []string) ([]cosmov1alpha1.ClusterTemplate, error)

func ListTemplateObjects added in v0.6.0

func ListTemplateObjects(ctx context.Context, c client.Client) ([]cosmov1alpha1.TemplateObject, error)

func ListTemplateObjectsByType added in v0.6.0

func ListTemplateObjectsByType(ctx context.Context, c client.Client, tmplTypes []string) ([]cosmov1alpha1.TemplateObject, error)

func ListTemplatesByType

func ListTemplatesByType(ctx context.Context, c client.Client, tmplTypes []string) ([]cosmov1alpha1.Template, error)

func LooseDeepEqual

func LooseDeepEqual(xObj, yObj Comparable, opts ...DeepEqualOption) bool

LooseDeepEqual deep equal objects without dynamic values

func PodStatusReason

func PodStatusReason(pod corev1.Pod) string

func RemoveDynamicFields

func RemoveDynamicFields(obj Comparable)

func SetAnnotation

func SetAnnotation(obj AnnotationHolder, key, value string)

Types

type AnnotationHolder

type AnnotationHolder interface {
	GetAnnotations() map[string]string
	SetAnnotations(map[string]string)
}

type ClientMock added in v0.6.0

type ClientMock struct {
	client.Client

	GetMock         func(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) (mocked bool, err error)
	ListMock        func(ctx context.Context, list client.ObjectList, opts ...client.ListOption) (mocked bool, err error)
	CreateMock      func(ctx context.Context, obj client.Object, opts ...client.CreateOption) (mocked bool, err error)
	DeleteMock      func(ctx context.Context, obj client.Object, opts ...client.DeleteOption) (mocked bool, err error)
	UpdateMock      func(ctx context.Context, obj client.Object, opts ...client.UpdateOption) (mocked bool, err error)
	PatchMock       func(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) (mocked bool, err error)
	DeleteAllOfMock func(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) (mocked bool, err error)
}

func NewClientMock added in v0.6.0

func NewClientMock(c client.Client) ClientMock

func (*ClientMock) Clear added in v0.6.0

func (c *ClientMock) Clear()

func (*ClientMock) Create added in v0.6.0

func (c *ClientMock) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error

func (*ClientMock) Delete added in v0.6.0

func (c *ClientMock) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error

func (*ClientMock) DeleteAllOf added in v0.6.0

func (c *ClientMock) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error

func (*ClientMock) Get added in v0.6.0

func (c *ClientMock) Get(ctx context.Context, key client.ObjectKey, obj client.Object, opts ...client.GetOption) error

func (*ClientMock) IsCallingFrom added in v0.6.0

func (c *ClientMock) IsCallingFrom(f interface{}) bool

func (*ClientMock) List added in v0.6.0

func (c *ClientMock) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error

func (*ClientMock) Patch added in v0.6.0

func (c *ClientMock) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error

func (*ClientMock) SetCreateError added in v0.6.0

func (c *ClientMock) SetCreateError(caller interface{}, retErr error)

func (*ClientMock) SetDeleteAllOfError added in v0.6.0

func (c *ClientMock) SetDeleteAllOfError(caller interface{}, retErr error)

func (*ClientMock) SetDeleteError added in v0.6.0

func (c *ClientMock) SetDeleteError(caller interface{}, retErr error)

func (*ClientMock) SetGetError added in v0.6.0

func (c *ClientMock) SetGetError(caller interface{}, retErr error)

func (*ClientMock) SetListError added in v0.6.0

func (c *ClientMock) SetListError(caller interface{}, retErr error)

func (*ClientMock) SetPatchError added in v0.6.0

func (c *ClientMock) SetPatchError(caller interface{}, retErr error)

func (*ClientMock) SetUpdateError added in v0.6.0

func (c *ClientMock) SetUpdateError(caller interface{}, retErr error)

func (*ClientMock) Update added in v0.6.0

func (c *ClientMock) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error

type Comparable

type Comparable interface {
	runtime.Object
	SetGroupVersionKind(gvk schema.GroupVersionKind)
	GetManagedFields() []metav1.ManagedFieldsEntry
	SetManagedFields(managedFields []metav1.ManagedFieldsEntry)
	SetResourceVersion(resourceVersion string)
}

type DeepEqualOption

type DeepEqualOption interface {
	Apply(x, y Comparable)
}

func WithFixGVK

func WithFixGVK(scheme *runtime.Scheme) DeepEqualOption

func WithPrintDiff

func WithPrintDiff(w io.Writer) DeepEqualOption

type LabelHolder

type LabelHolder interface {
	GetLabels() map[string]string
	SetLabels(map[string]string)
}

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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