pkg: github.com/knative/pkg/apis/duck Index | Files | Directories

package duck

import "github.com/knative/pkg/apis/duck"

Package duck defines logic for defining and consuming "duck typed" Kubernetes resources. Producers define partial resource definitions that resource authors may choose to implement to interoperate with consumers of these "duck typed" interfaces. For more information see: https://docs.google.com/document/d/16j8C91jML4fQRQPhnHihNJUJDcbvW0RM1YAX2REHgyY/edit#

Index

Package Files

cached.go doc.go enqueue.go interface.go patch.go proxy.go register.go typed.go unstructured.go verify.go

Constants

const (
    GroupName = "duck.knative.dev"
)

func AsStructuredWatcher Uses

func AsStructuredWatcher(wf cache.WatchFunc, obj runtime.Object) cache.WatchFunc

AsStructuredWatcher is public for testing only. TODO(mattmoor): Move tests for this to `package duck` and make private.

func ConformsToType Uses

func ConformsToType(instance interface{}, iface Implementable) (bool, error)

ConformsToType will return true or false depending on whether a concrete resource properly implements the provided Implementable duck type.

It will return an error if marshal/unmarshalling fails

func CreateMergePatch Uses

func CreateMergePatch(before, after interface{}) ([]byte, error)

func FromUnstructured Uses

func FromUnstructured(obj Marshalable, target interface{}) error

FromUnstructured takes unstructured object from (say from client-go/dynamic) and converts it into our duck types.

func NewProxyWatcher Uses

func NewProxyWatcher(ch chan watch.Event) watch.Interface

NewProxyWatcher creates new proxyWatcher by wrapping a channel

func VerifyType Uses

func VerifyType(instance interface{}, iface Implementable) error

VerifyType verifies that a particular concrete resource properly implements the provided Implementable duck type. It is expected that under the resource definition implementing a particular "Fooable" that one would write:

type ConcreteResource struct { ... }

// Check that ConcreteResource properly implement Fooable.
err := duck.VerifyType(&ConcreteResource{}, &something.Fooable{})

This will return an error if the duck typing is not satisfied.

type CachedInformerFactory Uses

type CachedInformerFactory struct {
    Delegate InformerFactory
    // contains filtered or unexported fields
}

CachedInformerFactory implements InformerFactory by delegating to another InformerFactory, but memoizing the results.

func (*CachedInformerFactory) Get Uses

func (cif *CachedInformerFactory) Get(gvr schema.GroupVersionResource) (cache.SharedIndexInformer, cache.GenericLister, error)

Get implements InformerFactory.

type EnqueueInformerFactory Uses

type EnqueueInformerFactory struct {
    Delegate InformerFactory

    EventHandler cache.ResourceEventHandler
}

EnqueueInformerFactory implements InformerFactory by delegating to another InformerFactory, but attaching a ResourceEventHandler to the informer.

func (*EnqueueInformerFactory) Get Uses

func (cif *EnqueueInformerFactory) Get(gvr schema.GroupVersionResource) (cache.SharedIndexInformer, cache.GenericLister, error)

Get implements InformerFactory.

type Implementable Uses

type Implementable interface {
    // GetFullType returns an instance of a full resource wrapping
    // an instance of this Implementable that can populate its fields
    // to verify json roundtripping.
    GetFullType() Populatable
}

Implementable is implemented by the Fooable duck type that consumers are expected to embed as a `.status.fooable` field.

type InformerFactory Uses

type InformerFactory interface {
    // Get returns a synced Informer/Lister pair for the provided schema.GroupVersionResource.
    Get(schema.GroupVersionResource) (cache.SharedIndexInformer, cache.GenericLister, error)
}

InformerFactory is used to create Informer/Lister pairs for a schema.GroupVersionResource

type JSONPatch Uses

type JSONPatch []jsonpatch.JsonPatchOperation

func CreatePatch Uses

func CreatePatch(before, after interface{}) (JSONPatch, error)

func (JSONPatch) MarshalJSON Uses

func (p JSONPatch) MarshalJSON() ([]byte, error)

type Marshalable Uses

type Marshalable interface {
    MarshalJSON() ([]byte, error)
}

Marshallable is implementated by the Unstructured K8s types.

type Populatable Uses

type Populatable interface {
    // Populate fills in all possible fields, so that we can verify that
    // they roundtrip properly through JSON.
    Populate()
}

Populatable is implemented by a skeleton resource wrapping an Implementable duck type. It will generally have TypeMeta, ObjectMeta, and a Status field wrapping a Fooable field.

type TypedInformerFactory Uses

type TypedInformerFactory struct {
    Client       dynamic.Interface
    Type         apis.Listable
    ResyncPeriod time.Duration
    StopChannel  <-chan struct{}
}

TypedInformerFactory implements InformerFactory such that the elements tracked by the informer/lister have the type of the canonical "obj".

func (*TypedInformerFactory) Get Uses

func (dif *TypedInformerFactory) Get(gvr schema.GroupVersionResource) (cache.SharedIndexInformer, cache.GenericLister, error)

Get implements InformerFactory.

Directories

PathSynopsis
v1alpha1
v1beta1

Package duck imports 16 packages (graph) and is imported by 1 packages. Updated 2019-08-14. Refresh now. Tools for package owners.