resources

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

Package resources implement the interface for accessing kubernetes resources

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client holds the state to access kubernetes

func NewFromClient

func NewFromClient(ctx context.Context, dynamic dynamic.Interface) *Client

NewFromClient creates a new client from a dynamic Kubernetes client

func NewFromConfig

func NewFromConfig(ctx context.Context, config *rest.Config) (*Client, error)

NewFromConfig creates a new Client using the provided kubernetes client configuration

func (*Client) Apply

func (c *Client) Apply(manifest string) error

Apply creates a resource in a kubernetes cluster from a YAML manifest

func (*Client) Create

func (c *Client) Create(obj map[string]interface{}) (map[string]interface{}, error)

Create creates a resource in a kubernetes cluster from an object with its specification

func (*Client) Delete

func (c *Client) Delete(kind string, name string, namespace string) error

Delete deletes an object given its kind, name and namespace

func (*Client) Get

func (c *Client) Get(kind string, name string, namespace string) (map[string]interface{}, error)

Get returns an object given its kind, name and namespace

func (*Client) List

func (c *Client) List(kind string, namespace string) ([]map[string]interface{}, error)

List returns a list of objects given its kind and namespace

func (*Client) Structured

func (c *Client) Structured() StructuredOperations

Structured returns a reference to a StructuredOperations interface

func (*Client) Update

func (c *Client) Update(obj map[string]interface{}) (map[string]interface{}, error)

Update updates a resource in a kubernetes cluster from an object with its specification

func (*Client) WithMapper added in v0.3.0

func (c *Client) WithMapper(mapper meta.RESTMapper) *Client

WithMapper specifies the RESTMapper for the client to utilize

type StructuredOperations

type StructuredOperations interface {
	// Create creates a resource described in the runtime object given as input and returns the resource created.
	// The resource must be passed by value (e.g corev1.Pod) and a value (not a reference) will be returned
	Create(obj interface{}) (interface{}, error)
	// Delete deletes a resource given its kind, name and namespace
	Delete(kind string, name string, namespace string) error
	// Get retrieves a resource into the given placeholder given its kind, name and namespace
	Get(kind string, name string, namespace string, obj interface{}) error
	// List retrieves a list of resources in the given slice given their kind and namespace
	List(kind string, namespace string, list interface{}) error
	// Update updates an existing resource and returns the updated version
	// The resource must be passed by value (e.g corev1.Pod) and a value (not a reference) will be returned
	Update(obj interface{}) (interface{}, error)
}

StructuredOperations defines generic operations that handles runtime objects such as corev1.Pod. It facilitates handling objects in the situations where their type is known as opposed to the UnstructuredOperations

type UnstructuredOperations

type UnstructuredOperations interface {
	Apply(manifest string) error
	Create(obj map[string]interface{}) (map[string]interface{}, error)
	Delete(kind string, name string, namespace string) error
	Get(kind string, name string, namespace string) (map[string]interface{}, error)
	List(kind string, namespace string) ([]map[string]interface{}, error)
	Update(obj map[string]interface{}) (map[string]interface{}, error)
}

UnstructuredOperations defines generic functions that operate on any kind of Kubernetes object

Jump to

Keyboard shortcuts

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