Documentation ¶
Index ¶
- Constants
- func ClusterRefsMatch(ref1, ref2 ClusterResourceId) bool
- func CreationTimestampCompare(a, b client.Object) int
- func GetClusterName(id ClusterResourceId) string
- func KeyWithSeparator(id ResourceId, separator string) string
- func MakeClientObjectKey(ref ResourceId) client.ObjectKey
- func MakeClusterObjectRef(resource ClusterResourceId) *v1.ClusterObjectRef
- func MakeObjectRef(resource ResourceId) *v1.ObjectRef
- func NewEnsurer(restClient RestClient) *ensurer
- func NewRestClient(mgr manager.Manager) *restClient
- func ParseGroupVersionKindString(gvk string) (schema.GroupVersionKind, error)
- func RefsMatch(ref1, ref2 ResourceId) bool
- func ResourceIdsCompare(a, b ResourceId) int
- func SetClusterName(obj client.Object, cluster string)
- func UpdateResourceVersion(c RestClient, ctx context.Context, obj Object) error
- type ClusterResourceId
- type Ctl
- type Ensurer
- type List
- type ManagerGetter
- type Object
- type ReconcileFunc
- type ResourceId
- type RestClient
Constants ¶
const ClusterAnnotation = "cluster.solo.io/cluster"
Variables ¶
This section is empty.
Functions ¶
func ClusterRefsMatch ¶ added in v0.7.17
func ClusterRefsMatch(ref1, ref2 ClusterResourceId) bool
func CreationTimestampCompare ¶ added in v0.38.0
CreationTimestampCompare returns an integer comparing two resources lexicographically. The result will be 0 if a == b, -1 if a < b, and +1 if a > b.
func GetClusterName ¶ added in v0.26.0
func GetClusterName(id ClusterResourceId) string
func KeyWithSeparator ¶ added in v0.26.1
func KeyWithSeparator(id ResourceId, separator string) string
KeyWithSeparator constructs a string consisting of the field values of the given resource id, separated by the given separator. It can be used to construct a unique key for a resource.
func MakeClientObjectKey ¶ added in v0.7.17
func MakeClientObjectKey(ref ResourceId) client.ObjectKey
func MakeClusterObjectRef ¶
func MakeClusterObjectRef(resource ClusterResourceId) *v1.ClusterObjectRef
func MakeObjectRef ¶
func MakeObjectRef(resource ResourceId) *v1.ObjectRef
func NewEnsurer ¶
func NewEnsurer(restClient RestClient) *ensurer
Instantiate an Ensurer from a RestClient
func NewRestClient ¶
NewRestClient creates the root REST client used to interact with Kubernetes. Wraps the controller-runtime client.Client. TODO: option to skip cache reads
func ParseGroupVersionKindString ¶ added in v0.7.17
func ParseGroupVersionKindString(gvk string) (schema.GroupVersionKind, error)
parses a string returned by a gvk.String() back into a gvk
func RefsMatch ¶ added in v0.7.17
func RefsMatch(ref1, ref2 ResourceId) bool
func ResourceIdsCompare ¶ added in v0.38.0
func ResourceIdsCompare(a, b ResourceId) int
ResourceIdsCompare compares two ResourceId instances, first by name, then by namespace, and finally by cluster name. If the names or namespaces differ, the comparison returns the result of strings.Compare on those values. If the names and namespaces are the same, it attempts to cast the ResourceId instances to ClusterResourceId and compares the cluster names. If the cast fails, it falls back to using the deprecated cluster name retrieval.
func SetClusterName ¶ added in v0.26.0
func UpdateResourceVersion ¶
func UpdateResourceVersion(c RestClient, ctx context.Context, obj Object) error
Uses the provided client to update the resource of the object by retrieving it from the server
Types ¶
type ClusterResourceId ¶
type ClusterResourceId interface { GetName() string GetNamespace() string GetAnnotations() map[string]string }
ClusterResourceId represents a global identifier for a k8s resource.
func ConvertRefToId ¶ added in v0.26.0
func ConvertRefToId(ref deprecatedClusterResourceId) ClusterResourceId
ConvertRefToId converts a ClusterObjectRef to a struct that implements the ClusterResourceId interface Will not set an empty cluster name over an existing cluster name
type Ctl ¶
type Ctl interface { Ensurer }
Ctl is a Control object for interacting with the Kubernetes API. Its meant as a generic, high-level abstraction over kubernetes client-go, similar to an in-process kubectl
type Ensurer ¶
type Ensurer interface { RestClient // optional reconcile funcs can be passed which determine how // a child object should be reconciled with the existing object // when it already exists in the cluster Ensure(ctx context.Context, parent Object, child Object, reconcileFuncs ...ReconcileFunc) error }
an Ensurer "ensures" that the given object will be created/applied to the cluster the object is applied after a resource version conflict. Warning: this can lead to race conditions if it is called asynchronously for the same resource. The ensured resource will have its controller reference set to the parent resource
type List ¶
type List interface { runtime.Object v1.ListInterface }
the EzKube Object is a wrapper for a kubernetes List object
type ManagerGetter ¶
Our manager returns a manager.Manager
type Object ¶
the EzKube Object is a wrapper for a kubernetes runtime.Object which contains Kubernetes metadata
type ReconcileFunc ¶
ReconcileFuncs are used to dynamically update existing objects on calls to Update and Ensure. ReconcileFuncs perform a comparison of the the existing object with the desired object prior to writing to kube storage.
The returned object will be applied to the cluster If a nil, nil is returned, the write will be skipped
type ResourceId ¶
ResourceId represents a global identifier for a k8s resource.
func ResourceIdFromKeyWithSeparator ¶ added in v0.26.1
func ResourceIdFromKeyWithSeparator(key string, separator string) (ResourceId, error)
ResourceIdFromKeyWithSeparator converts a key back into a ResourceId, using the given separator. Returns an error if it cannot be converted.
type RestClient ¶
type RestClient interface { ManagerGetter // the Object passed will be updated to match the server version. // only key (namespace/name) is required Get(ctx context.Context, obj Object) error // Object passed will be updated to match the server version. // Object should be a List object // example: // // Client.List(ctx, // client.InNamespace("my-namespace", // client.MatchingLabels{"app": "petstore"}) List(ctx context.Context, obj List, options ...client.ListOption) error // create the object passed Create(ctx context.Context, obj Object) error // update the object passed. does not update object subresources such as status. // // optional reconcile funcs can be passed which determine how // a child object should be reconciled with the existing object // when it already exists in the cluster Update(ctx context.Context, obj Object, reconcileFuncs ...ReconcileFunc) error // update the status of the object passed. UpdateStatus(ctx context.Context, obj Object) error // delete the object. only key (namespace/name) is required Delete(ctx context.Context, obj Object) error }
RestClient is a wrapper for the dynamic controller-runtime client.Client