Documentation ¶
Index ¶
- Variables
- func NewFakes(objects ...runtime.Object) (dynamic.ClientPool, kubernetes.Interface)
- type Consumer
- type ErrMultiLambdaFailure
- type FakeClient
- type FakeClientPool
- type FakeResourceClient
- type Function
- type KubernetesClientLambda
- type Lambda
- func (lambda *Lambda) Add(producer Producer) *Lambda
- func (lambda *Lambda) Any(predicate Predicate) (any bool, err error)
- func (lambda *Lambda) Collect() *Lambda
- func (lambda *Lambda) Create() (created bool, err error)
- func (lambda *Lambda) CreateIfNotExist() (created, existed bool, err error)
- func (lambda *Lambda) Delete() (deleted bool, err error)
- func (lambda *Lambda) DeleteIfExist() (deleted, existed bool, err error)
- func (lambda *Lambda) Dummy() *Lambda
- func (lambda *Lambda) Each(function Function) error
- func (lambda *Lambda) Element() (runtime.Object, error)
- func (lambda *Lambda) Elements() ([]runtime.Object, error)
- func (lambda *Lambda) Every(predicate Predicate) (every bool, err error)
- func (lambda *Lambda) First(predicate Predicate) *Lambda
- func (lambda *Lambda) Grep(predicate Predicate) *Lambda
- func (lambda *Lambda) HasAnnotation(key, value string) *Lambda
- func (lambda *Lambda) HasAnnotationKey(key string) *Lambda
- func (lambda *Lambda) HasLabel(key, value string) *Lambda
- func (lambda *Lambda) HasLabelKey(key string) *Lambda
- func (lambda *Lambda) Iter(function Function) *Lambda
- func (lambda *Lambda) LatestCreated() *Lambda
- func (lambda *Lambda) List() *Lambda
- func (lambda *Lambda) ListWithLabelSelector(selector labels.Selector) *Lambda
- func (lambda *Lambda) Map(consumer Consumer) *Lambda
- func (lambda *Lambda) MustNoError() *Lambda
- func (lambda *Lambda) NameEqual(name string) *Lambda
- func (lambda *Lambda) NamePrefix(prefix string) *Lambda
- func (lambda *Lambda) NameRegex(regex string) *Lambda
- func (lambda *Lambda) NoError() bool
- func (lambda *Lambda) NotEmpty() (noempty bool, err error)
- func (lambda *Lambda) Update() (updated bool, err error)
- func (lambda *Lambda) UpdateIfExist() (updated, existed bool, err error)
- func (lambda *Lambda) UpdateOrCreate() (updated, created bool, err error)
- type Predicate
- type Producer
- type Resource
- type ResourceIndexer
- type SortedGVKs
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( // core Pod = Resource{"Pods", ""} Namespace = Resource{"Namespaces", ""} Node = Resource{"Nodes", ""} Event = Resource{"Events", ""} Service = Resource{"Services", ""} Endpoints = Resource{"Endpoints", ""} LimitRange = Resource{"LimitRanges", ""} Secret = Resource{"Secrets", ""} ConfigMap = Resource{"ConfigMaps", ""} ServiceAccout = Resource{"ServiceAccounts", ""} PodTemplate = Resource{"PodTemplates", ""} ResourceQuota = Resource{"ResourceQuotas", ""} PersistentVolume = Resource{"PersistentVolumes", ""} PersistentVolumeClaim = Resource{"PersistentVolumeClaims", ""} ReplicationController = Resource{"ReplicationControllers", ""} // extensions Ingress = Resource{"Ingresses", ""} ReplicaSet = Resource{"ReplicaSets", "v1beta1"} Deployment = Resource{"Deployments", ""} DaemonSet = Resource{"DaemonSets", ""} PodSecurityPolicy = Resource{"PodSecurityPolicies", ""} // apps StatefulSet = Resource{"StatefulSets", ""} ControllerRevision = Resource{"ControllerRevisions", ""} // rbac ClusterRole = Resource{"ClusterRoles", ""} ClusterRoleBinding = Resource{"ClusterRoleBindings", ""} Role = Resource{"Roles", ""} RoleBinding = Resource{"RoleBindings", ""} // batch Job = Resource{"Jobs", ""} CronJob = Resource{"CronJobs", ""} // storage StorageClass = Resource{"StorageClasses", ""} // autoscaling HorizontalPodAutoscalerV1 = Resource{"HorizontalPodAutoscalers", "v1"} HorizontalPodAutoscalerV2 = Resource{"HorizontalPodAutoscalers", "v2beta1"} )
Functions ¶
func NewFakes ¶ added in v1.1.0
func NewFakes(objects ...runtime.Object) (dynamic.ClientPool, kubernetes.Interface)
Types ¶
type Consumer ¶
type Consumer interface{}
Consumer is a function has one parameter and returns one value. Nil is not allowed to be used as parameter or return value, or panic will occur. Consumer is always used to apply some transformation to elements.
type ErrMultiLambdaFailure ¶
type ErrMultiLambdaFailure struct {
// contains filtered or unexported fields
}
ErrMultiLambdaFailure contains one or more error occured from lambda invocation chain
func (ErrMultiLambdaFailure) Error ¶
func (e ErrMultiLambdaFailure) Error() string
type FakeClient ¶ added in v1.1.0
type FakeClient struct {
*dynamic_fake.FakeClient
}
FakeClient is a fake implementation of dynamic.Interface.
func (*FakeClient) GetRateLimiter ¶ added in v1.1.0
func (c *FakeClient) GetRateLimiter() flowcontrol.RateLimiter
GetRateLimiter returns the rate limiter for this client.
func (*FakeClient) ParameterCodec ¶ added in v1.1.0
func (c *FakeClient) ParameterCodec(parameterCodec runtime.ParameterCodec) dynamic.Interface
ParameterCodec returns a client with the provided parameter codec.
func (*FakeClient) Resource ¶ added in v1.1.0
func (c *FakeClient) Resource(resource *metav1.APIResource, namespace string) dynamic.ResourceInterface
Resource returns an API interface to the specified resource for this client's group and version. If resource is not a namespaced resource, then namespace is ignored. The ResourceClient inherits the parameter codec of this client
type FakeClientPool ¶ added in v1.1.0
FakeClientPool provides a fake implementation of dynamic.ClientPool. It assumes resource GroupVersions are the same as their corresponding kind GroupVersions.
func (*FakeClientPool) ClientForGroupVersionKind ¶ added in v1.1.0
func (p *FakeClientPool) ClientForGroupVersionKind(kind schema.GroupVersionKind) (dynamic.Interface, error)
ClientForGroupVersionKind returns a client configured for the specified groupVersionKind. Kind may be empty.
func (*FakeClientPool) ClientForGroupVersionResource ¶ added in v1.1.0
func (p *FakeClientPool) ClientForGroupVersionResource(resource schema.GroupVersionResource) (dynamic.Interface, error)
ClientForGroupVersionKind returns a client configured for the specified groupVersionResource. Resource may be empty.
type FakeResourceClient ¶ added in v1.1.0
type FakeResourceClient struct {
*dynamic_fake.FakeResourceClient
}
FakeResourceClient is a fake implementation of dynamic.ResourceInterface
func (*FakeResourceClient) Get ¶ added in v1.1.0
func (c *FakeResourceClient) Get(name string, opts metav1.GetOptions) (*unstructured.Unstructured, error)
Get gets the resource with the specified name.
func (*FakeResourceClient) List ¶ added in v1.1.0
func (c *FakeResourceClient) List(opts metav1.ListOptions) (runtime.Object, error)
type Function ¶
type Function interface{}
Function is a function has one parameter and has no return value. The parameter must not be a nil
type KubernetesClientLambda ¶
type KubernetesClientLambda interface {
Type(Resource) *kubernetesExecutable
}
KubernetesClientLambda provides manipulation interface for resources
func Mock ¶
func Mock(objects ...runtime.Object) KubernetesClientLambda
the mock KubernetesClient is statusful and if you want to reset its status then use MockReset
func OutOfClusterDefault ¶
func OutOfClusterDefault() KubernetesClientLambda
OutOfClusterDefault loads configuration from ~/.kube/config
func OutOfClusterInContext ¶
func OutOfClusterInContext(context string) KubernetesClientLambda
OutOfClusterInContext is used to switch context of multi-cluster kubernetes
type Lambda ¶
type Lambda struct { Errors []error // contains filtered or unexported fields }
Lambda is a basic and core type of KCL. It holds a channel for receiving elements from previous lambda or kubernetes resource fetcher. Error is assigned if any error occured during lambda pipelining. The error will be recorded but the lambda pipelining will continue on, and forcing it fail-hard needs call MustNoError method. The error can be also be returned at the end of a pipeline via lambda operation method which is defined in lambda_operation.go
func (*Lambda) Create ¶
Create creates every element remains in lambda collection Returns true if every element is successfully created and lambda error chain Fails if any element already exists
func (*Lambda) CreateIfNotExist ¶
CreateIfNotExist creates element in the lambda collection Will not return false if any element fails to be created
func (*Lambda) DeleteIfExist ¶
DeleteIfExist delete elements in the lambda collection if it exists
func (*Lambda) Element ¶ added in v1.1.0
Element returns a single element. Note that if multiple elements exists in the lambda pipeline, a random object may be returned.
func (*Lambda) HasAnnotation ¶
HasAnnotation filter the elements out if it doesn't have the arugument annotation
func (*Lambda) HasAnnotationKey ¶
HasAnnotationKey filter the elements out if it doesn't have the arugument annotation key
func (*Lambda) HasLabelKey ¶
HasLabelKey filter the elements out if it doesn't have the arugument label key
func (*Lambda) Iter ¶
Iter iterates the elements and apply function to them Note that modifying is not recommened in Iter, use Map to modify elements instead
func (*Lambda) LatestCreated ¶ added in v1.1.0
LatestCreated filters out the latest created object
func (*Lambda) ListWithLabelSelector ¶ added in v1.1.0
List lists all items indexed in the local cache
func (*Lambda) MustNoError ¶
MustNoError panics if any error occured
func (*Lambda) NameEqual ¶
NameEqual filter the elements out if its name mismatches with the argument name
func (*Lambda) NamePrefix ¶
NamePrefix filter the elements out if its name doesn't have the prefix
func (*Lambda) NameRegex ¶
NameRegex filter the elements out if its name fails to matches the regexp
func (*Lambda) NotEmpty ¶
NotEmpty checks if any element remains Returns true if the lambda collection is not empty and error if upstream lambda fails
func (*Lambda) UpdateIfExist ¶
UpdateIfExist checks if the element exists and update it value
func (*Lambda) UpdateOrCreate ¶ added in v1.0.0
type Predicate ¶
type Predicate interface{}
Predicate is a function has only one parameter and return boolean. When return value type is not boolean, panic will occur. The parameter can be of any type but nil and predicates is always used to test an element.
type Producer ¶
type Producer interface{}
Producer is a function takes no parameter and returns a value. Producer is recommeneded to be a closure so that the returning value can be controlled outside lambda.
type Resource ¶
Resource is kubernetes resource enumeration hiding api version
func GetResources ¶ added in v1.0.0
func GetResources() []Resource
func (Resource) GetAPIVersion ¶ added in v1.1.0
func (Resource) GetResource ¶ added in v1.1.0
type ResourceIndexer ¶ added in v1.0.0
type ResourceIndexer interface { IsNamespaced(resource Resource) bool GetAPIResource(resource Resource) *metav1.APIResource GetGroupVersionKind(resource Resource) schema.GroupVersionKind GetGroupVersionResource(resource Resource) schema.GroupVersionResource }
func GetResouceIndexerInstance ¶ added in v1.0.0
func GetResouceIndexerInstance() (indexer ResourceIndexer)
getResouceIndexerInstance blocks until initIndexer is invoked
type SortedGVKs ¶ added in v1.0.0
type SortedGVKs []schema.GroupVersionKind
func (SortedGVKs) Len ¶ added in v1.0.0
func (s SortedGVKs) Len() int
func (SortedGVKs) Less ¶ added in v1.0.0
func (s SortedGVKs) Less(i, j int) bool
func (SortedGVKs) Swap ¶ added in v1.0.0
func (s SortedGVKs) Swap(i, j int)