core

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InstalledByLabel = "app.kubernetes.io/installed-by"
	InstalledByValue = "krateo"
	PackageNameLabel = "krateo.io/package-name"
	DefaultNamespace = "crossplane-system"
)

Variables

View Source
var (
	ErrCannotResolveResourceType = errors.New("cannot resolve resource type")
	ErrCannotListByAPIResource   = errors.New("cannot list objects by API resource")
)
View Source
var (
	ErrWatcherTimeout = errors.New("watcher timed out")
)
View Source
var (
	NoKindMatchError = errors.New("RESTMapper can't find any match for kind")
)

Functions

func Apply

func Apply(ctx context.Context, opts ApplyOpts) error

func Create

func Create(ctx context.Context, opts CreateOpts) error

Create creates a resource if does not exists.

func Delete

func Delete(ctx context.Context, opts DeleteOpts) error

func DynamicForGVR

func DynamicForGVR(restConfig *rest.Config, gvk schema.GroupVersionKind, namespace string) (dynamic.ResourceInterface, error)

func FindGVR

func FindGVR(cfg *rest.Config, gvk schema.GroupVersionKind) (*meta.RESTMapping, error)

FindGVR find the corresponding GVR (available in *meta.RESTMapping) for gvk

func FromUnstructuredViaJSON added in v1.3.0

func FromUnstructuredViaJSON(u map[string]interface{}, obj interface{}) error

func Get

func GetByAPIResource

func GetByAPIResource(ctx context.Context, opts GetByAPIResourceOpts) (*unstructured.Unstructured, error)

GetByAPIResource returns an object that matches the provided name & options on the server.

func InstalledBySelector

func InstalledBySelector() (labels.Selector, error)

func IsNoKindMatchError

func IsNoKindMatchError(err error) bool

func List

func ListByAPIResource

func ListByAPIResource(ctx context.Context, opts ListByAPIResourceOpts) ([]unstructured.Unstructured, error)

listByAPI list all objects of the provided API & namespace. If listing the API at the cluster scope, set the namespace argument as an empty string.

func Patch

func Patch(ctx context.Context, opts PatchOpts) error

func RESTConfigFromBytes

func RESTConfigFromBytes(data []byte, withContext string) (*rest.Config, error)

func Watch

func Watch(ctx context.Context, opts WatchOpts) error

Types

type APIResource

type APIResource struct {
	// name is the plural name of the resource.
	Name string `json:"name"`
	// namespaced indicates if a resource is namespaced or not.
	Namespaced bool `json:"namespaced"`
	// group is the preferred group of the resource.  Empty implies the group of the containing resource list.
	// For subresources, this may have a different value, for example: Scale".
	Group string `json:"group,omitempty"`
	// version is the preferred version of the resource.  Empty implies the version of the containing resource list
	// For subresources, this may have a different value, for example: v1 (while inside a v1beta1 version of the core resource's group)".
	Version string `json:"version,omitempty"`
	// kind is the kind for the resource (e.g. 'Foo' is the kind for a resource 'foo')
	Kind string `json:"kind"`
}

APIResource represents a Kubernetes API resource.

func ResolveAPIResource

func ResolveAPIResource(opts ResolveAPIResourceOpts) (*APIResource, error)

func (*APIResource) GroupKind

func (r *APIResource) GroupKind() schema.GroupKind

func (*APIResource) GroupVersionKind

func (r *APIResource) GroupVersionKind() schema.GroupVersionKind

func (*APIResource) GroupVersionResource

func (r *APIResource) GroupVersionResource() schema.GroupVersionResource

func (*APIResource) String

func (r *APIResource) String() string

func (*APIResource) WithGroupString

func (r *APIResource) WithGroupString() string

type ApplyOpts

type ApplyOpts struct {
	RESTConfig *rest.Config
	Object     *unstructured.Unstructured
	GVK        schema.GroupVersionKind
}

type CreateOpts

type CreateOpts struct {
	RESTConfig *rest.Config
	GVK        schema.GroupVersionKind
	Object     *unstructured.Unstructured
	Namespace  string
}

type DeleteOpts

type DeleteOpts struct {
	RESTConfig *rest.Config
	Object     *unstructured.Unstructured
}

type FilterFunc

type FilterFunc func(unstructured.Unstructured) bool

type GetByAPIResourceOpts

type GetByAPIResourceOpts struct {
	RESTConfig  *rest.Config
	APIResource APIResource
	Name        string
	Namespace   string
}

type GetOpts

type GetOpts struct {
	RESTConfig *rest.Config
	GVK        schema.GroupVersionKind
	Name       string
	Namespace  string
}

type ListByAPIResourceOpts

type ListByAPIResourceOpts struct {
	RESTConfig  *rest.Config
	APIResource APIResource
	Namespace   string
}

type ListOpts

type ListOpts struct {
	RESTConfig    *rest.Config
	GVK           schema.GroupVersionKind
	Namespace     string
	LabelSelector string
}

type PatchOpts

type PatchOpts struct {
	RESTConfig *rest.Config
	PatchData  []byte
	PatchType  types.PatchType
	GVK        schema.GroupVersionKind
	Name       string
	Namespace  string
}

type ResolveAPIResourceOpts

type ResolveAPIResourceOpts struct {
	RESTConfig *rest.Config
	Query      string
}

type StopFunc added in v1.3.0

type StopFunc func(et watch.EventType, obj *unstructured.Unstructured) (bool, error)

type WatchOpts

type WatchOpts struct {
	RESTConfig *rest.Config
	GVR        schema.GroupVersionResource
	Selector   labels.Selector
	Namespace  string
	Timeout    time.Duration
	StopFn     StopFunc
}

Jump to

Keyboard shortcuts

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