sdk

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create added in v0.0.6

func Create(object Object) (err error)

Create creates the provided object on the server and updates the arg "object" with the result from the server(UID, resourceVersion, etc). Returns an error if the object’s TypeMeta(Kind, APIVersion) or ObjectMeta(Name/GenerateName, Namespace) is missing or incorrect. Can also return an api error from the server e.g AlreadyExists https://github.com/kubernetes/apimachinery/blob/master/pkg/api/errors/errors.go#L423

func Delete added in v0.0.6

func Delete(object Object, opts ...DeleteOption) (err error)

Delete deletes the specified object Returns an error if the object’s TypeMeta(Kind, APIVersion) or ObjectMeta(Name, Namespace) is missing or incorrect. e.g NotFound https://github.com/kubernetes/apimachinery/blob/master/pkg/api/errors/errors.go#L418 “opts” configures the DeleteOptions When passed WithDeleteOptions(o), the specified metav1.DeleteOptions are set.

func ExposeMetricsPort added in v0.0.6

func ExposeMetricsPort()

ExposeMetricsPort generate a Kubernetes Service to expose metrics port

func Get added in v0.0.6

func Get(into Object, opts ...GetOption) error

Get gets the specified object and unmarshals the retrieved data into the "into" object. "into" is a Object that must have "Kind" and "APIVersion" specified in its "TypeMeta" field and "Name" and "Namespace" specified in its "ObjectMeta" field. "opts" configures the Get operation.

When passed With WithGetOptions(o), the specified metav1.GetOptions is set.

func Handle

func Handle(handler Handler)

Handle registers the handler for all events. In the future, we would have a mux-pattern to dispatch events to matched handlers.

func List added in v0.0.6

func List(namespace string, into Object, opts ...ListOption) error

List retrieves the specified object list and unmarshals the retrieved data into the "into" object. "namespace" indicates which kubernetes namespace to look for the list of kubernetes objects. "into" is a sdkType.Object that must have "Kind" and "APIVersion" specified in its "TypeMeta" field "opts" configures the List operation.

When passed With WithListOptions(o), the specified metav1.ListOptions is set.

func Patch added in v0.0.6

func Patch(object Object, pt types.PatchType, patch []byte) (err error)

Patch patches provided "object" on the server with given "patch" and updates the arg "object" with the result from the server(UID, resourceVersion, etc). Returns an error if the object’s TypeMeta(Kind, APIVersion) or ObjectMeta(Name, Namespace) is missing or incorrect. Returns an error if patch couldn't be json serialized into bytes. Can also return an api error from the server e.g Conflict https://github.com/kubernetes/apimachinery/blob/master/pkg/api/errors/errors.go#L428

func Run

func Run(ctx context.Context)

Run starts the process of Watching resources, handling Events, and processing Actions

func Update added in v0.0.6

func Update(object Object) (err error)

Update updates the provided object on the server and updates the arg "object" with the result from the server(UID, resourceVersion, etc). Returns an error if the object’s TypeMeta(Kind, APIVersion) or ObjectMeta(Name, Namespace) is missing or incorrect. Can also return an api error from the server e.g Conflict https://github.com/kubernetes/apimachinery/blob/master/pkg/api/errors/errors.go#L428

func Watch

func Watch(apiVersion, kind, namespace string, resyncPeriod time.Duration, opts ...watchOption)

Watch watches for changes on the given resource. apiVersion for a resource is of the format "Group/Version" except for the "Core" group whose APIVersion is just "v1". For e.g:

  • Deployments have Group "apps" and Version "v1beta2" giving the APIVersion "apps/v1beta2"
  • Pods have Group "Core" and Version "v1" giving the APIVersion "v1"
  • The custom resource Memcached might have Group "cache.example.com" and Version "v1alpha1" giving the APIVersion "cache.example.com/v1alpha1"

kind is the Kind of the resource, e.g "Pod" for pods resyncPeriod is the time period for how often an event with the latest resource version will be sent to the handler, even if there is no change.

  • 0 means no periodic events will be sent

Consult the API reference for the Group, Version and Kind of a resource: https://kubernetes.io/docs/reference/ namespace is the Namespace to watch for the resource TODO: support opts for specifying label selector

func WithLabelSelector added in v0.0.6

func WithLabelSelector(labelSelector string) watchOption

func WithNumWorkers added in v0.0.6

func WithNumWorkers(numWorkers int) watchOption

WithNumWorkers sets the number of workers for the Watch() operation.

Types

type DeleteOp added in v0.0.6

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

DeleteOp wraps all the options for Delete().

func NewDeleteOp added in v0.0.6

func NewDeleteOp() *DeleteOp

type DeleteOption added in v0.0.6

type DeleteOption func(*DeleteOp)

DeleteOption configures DeleteOp.

func WithDeleteOptions added in v0.0.6

func WithDeleteOptions(metaDeleteOptions *metav1.DeleteOptions) DeleteOption

WithDeleteOptions sets the metav1.DeleteOptions for the Delete() operation.

type Event added in v0.0.6

type Event struct {
	Object  Object
	Deleted bool
}

Event is triggered when some change has happened on the watched resources. If created or updated, Object would be the current state and Deleted=false. If deleted, Object would be the last known state and Deleted=true.

type GetOp added in v0.0.6

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

GetOp wraps all the options for Get().

func NewGetOp added in v0.0.6

func NewGetOp() *GetOp

type GetOption added in v0.0.6

type GetOption func(*GetOp)

GetOption configures GetOp.

func WithGetOptions added in v0.0.6

func WithGetOptions(metaGetOptions *metav1.GetOptions) GetOption

WithGetOptions sets the metav1.GetOptions for the Get() operation.

type Handler added in v0.0.6

type Handler interface {
	Handle(context.Context, Event) error
}

Handler reacts to events and outputs actions. If any intended action failed, the event would be re-triggered. For actions done before the failed action, there is no rollback.

var (
	// RegisteredHandler is the user registered handler set by sdk.Handle()
	RegisteredHandler Handler
)

type Informer added in v0.0.6

type Informer interface {
	Run(ctx context.Context)
}

func NewInformer added in v0.0.6

func NewInformer(resourcePluralName, namespace string, resourceClient dynamic.ResourceInterface, resyncPeriod time.Duration, c *metrics.Collector, n int, labelSelector string) Informer

type ListOp added in v0.0.6

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

ListOp wraps all the options for List.

func NewListOp added in v0.0.6

func NewListOp() *ListOp

type ListOption added in v0.0.6

type ListOption func(*ListOp)

ListOption configures ListOp.

func WithListOptions added in v0.0.6

func WithListOptions(metaListOptions *metav1.ListOptions) ListOption

WithListOptions sets the metav1.ListOptions for the List() operation.

type Object added in v0.0.6

type Object runtime.Object

Object is the Kubernetes runtime.Object interface expected of all resources that the user can watch.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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