Documentation
¶
Index ¶
- Variables
- func CompareObjectMeta(t *testing.T, got, want metav1.ObjectMeta)
- func FetchConfigMapContentByKey(ctx context.Context, rclient client.Client, cm *corev1.ConfigMap, key string) (string, error)
- func GetCredFromConfigMap(ctx context.Context, rclient client.Client, ns string, ...) (string, error)
- func GetCredFromSecret(ctx context.Context, rclient client.Client, ns string, ...) (string, error)
- func GetTestClientWithObjects(predefinedObjects []runtime.Object) client.Client
- func IsFSGroupChangePolicySupported() bool
- func ListObjectsByNamespace[T any, PT interface{ ... }](ctx context.Context, rclient client.Client, nss []string, collect func(PT), ...) error
- func MergePatchContainers(base, patches []corev1.Container) ([]corev1.Container, error)
- func MustConvertObjectVersionsJSON[A, B any](src *A, objectName string) *B
- func NewObjectWatcherForNamespaces[T any, PT interface{ ... }](ctx context.Context, rclient client.WithWatch, crdTypeName string, ...) (watch.Interface, error)
- func NewReadyDeployment(name, namespace string) *appsv1.Deployment
- func RenderPlaceholders[T any](resource *T, placeholders map[string]string) (*T, error)
- func SanitizeVolumeName(name string) string
- func SelectNamespaces(ctx context.Context, rclient client.Client, selector labels.Selector) ([]string, error)
- func SetKubernetesVersionWithDefaults(vi *version.Info, defaultMinor, defaultMajor uint64) error
- func SetSpaceTrim(disabled bool)
- func UpdatePodAnnotations(ctx context.Context, rclient client.Client, selector map[string]string, ...) error
- func VisitObjectsForSelectorsAtNs[T any, PT interface{ ... }](ctx context.Context, rclient client.Client, ...) error
- type BasicAuthCredentials
- type KeyNotFoundError
- type OAuthCreds
- type ObjectWatcherForNamespaces
- type TestClientWithStatsTrack
- func (tcs *TestClientWithStatsTrack) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (tcs *TestClientWithStatsTrack) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
- func (tcs *TestClientWithStatsTrack) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
- func (tcs *TestClientWithStatsTrack) Get(ctx context.Context, key client.ObjectKey, obj client.Object, ...) error
- func (tcs *TestClientWithStatsTrack) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error)
- func (tcs *TestClientWithStatsTrack) IsObjectNamespaced(obj runtime.Object) (bool, error)
- func (tcs *TestClientWithStatsTrack) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (tcs *TestClientWithStatsTrack) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (tcs *TestClientWithStatsTrack) RESTMapper() meta.RESTMapper
- func (tcs *TestClientWithStatsTrack) Scheme() *runtime.Scheme
- func (tcs *TestClientWithStatsTrack) Status() client.SubResourceWriter
- func (tcs *TestClientWithStatsTrack) SubResource(subResource string) client.SubResourceClient
- func (tcs *TestClientWithStatsTrack) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
Constants ¶
This section is empty.
Variables ¶
var ( // ServerMajorVersion defines major number for current kubernetes API server version ServerMajorVersion uint64 // ServerMinorVersion defines minor number for current kubernetes API server version ServerMinorVersion uint64 )
Functions ¶
func CompareObjectMeta ¶
func CompareObjectMeta(t *testing.T, got, want metav1.ObjectMeta)
CompareObjectMeta compares metadata objects
func FetchConfigMapContentByKey ¶ added in v0.47.0
func FetchConfigMapContentByKey(ctx context.Context, rclient client.Client, cm *corev1.ConfigMap, key string) (string, error)
FetchConfigMapContentByKey returns configmap content by key
func GetCredFromConfigMap ¶
func GetCredFromConfigMap( ctx context.Context, rclient client.Client, ns string, sel corev1.ConfigMapKeySelector, cacheKey string, cache map[string]*corev1.ConfigMap, ) (string, error)
GetCredFromConfigMap fetches content of configmap by given key
func GetCredFromSecret ¶
func GetCredFromSecret( ctx context.Context, rclient client.Client, ns string, sel *corev1.SecretKeySelector, cacheKey string, cache map[string]*corev1.Secret, ) (string, error)
GetCredFromSecret fetch content of secret by given key
func GetTestClientWithObjects ¶
GetTestClientWithObjects returns testing client with optional predefined objects
func IsFSGroupChangePolicySupported ¶
func IsFSGroupChangePolicySupported() bool
IsFSGroupChangePolicySupported checks if `fsGroupChangePolicy` is supported, Supported since 1.20 https://kubernetes.io/blog/2020/12/14/kubernetes-release-1.20-fsgroupchangepolicy-fsgrouppolicy/#allow-users-to-skip-recursive-permission-changes-on-mount
func ListObjectsByNamespace ¶
func ListObjectsByNamespace[T any, PT interface { *T client.ObjectList }](ctx context.Context, rclient client.Client, nss []string, collect func(PT), opts ...client.ListOption) error
ListObjectsByNamespace performs object list for given namespaces
func MergePatchContainers ¶
MergePatchContainers adds patches to base using a strategic merge patch and iterating by container name, failing on the first error
func MustConvertObjectVersionsJSON ¶
MustConvertObjectVersionsJSON objects with json serialize and deserialize it could be used only for converting BETA apis to Stable version
func NewObjectWatcherForNamespaces ¶
func NewObjectWatcherForNamespaces[T any, PT interface { *T client.ObjectList }](ctx context.Context, rclient client.WithWatch, crdTypeName string, namespaces []string) (watch.Interface, error)
NewObjectWatcherForNamespaces returns a watcher for events at multiple namespaces for given object in case of empty namespaces, performs cluster wide watch
func NewReadyDeployment ¶
func NewReadyDeployment(name, namespace string) *appsv1.Deployment
NewReadyDeployment returns a new deployment with ready status condition
func RenderPlaceholders ¶
RenderPlaceholders replaces placeholders at resource with given values placeholder must be in %NAME% format resource must be reference to json serializable struct
func SanitizeVolumeName ¶
SanitizeVolumeName replaces all incompatible with k8s characters with -
func SelectNamespaces ¶
func SelectNamespaces(ctx context.Context, rclient client.Client, selector labels.Selector) ([]string, error)
SelectNamespaces select namespaces by given label selector
func SetKubernetesVersionWithDefaults ¶
SetKubernetesVersionWithDefaults parses kubernetes version response with given default versions
func SetSpaceTrim ¶ added in v0.48.0
func SetSpaceTrim(disabled bool)
SetSpaceTrim configures option to trim space at Secret/Configmap keys
func UpdatePodAnnotations ¶
func UpdatePodAnnotations(ctx context.Context, rclient client.Client, selector map[string]string, ns string) error
UpdatePodAnnotations - updates configmap-sync-time annotation it triggers config rules reload for vmalert
func VisitObjectsForSelectorsAtNs ¶
func VisitObjectsForSelectorsAtNs[T any, PT interface { *T client.ObjectList }](ctx context.Context, rclient client.Client, nsSelector, objectSelector *metav1.LabelSelector, objNamespace string, selectAllByDefault bool, cb func(PT), ) error
VisitObjectsForSelectorsAtNs applies given function to any object matched given selectors
Types ¶
type BasicAuthCredentials ¶
BasicAuthCredentials represents a username password pair to be used with basic http authentication, see https://tools.ietf.org/html/rfc7617.
type KeyNotFoundError ¶ added in v0.47.0
type KeyNotFoundError struct {
// contains filtered or unexported fields
}
KeyNotFoundError represents an error if expected key was not found at secret or configmap data
func NewKeyNotFoundError ¶ added in v0.47.0
func NewKeyNotFoundError(key, cacheKey, object string) *KeyNotFoundError
NewKeyNotFoundError returns NewKeyNotFoundError
func (*KeyNotFoundError) Error ¶ added in v0.47.0
func (ke *KeyNotFoundError) Error() string
Error implements interface
type OAuthCreds ¶
OAuthCreds represents OAuth2 secret values within plain text
type ObjectWatcherForNamespaces ¶
type ObjectWatcherForNamespaces struct {
// contains filtered or unexported fields
}
ObjectWatcherForNamespaces performs a watch operation for multiple namespaces without using cluster wide permissions with empty namaspaces uses cluster wide mode
func (*ObjectWatcherForNamespaces) ResultChan ¶
func (ow *ObjectWatcherForNamespaces) ResultChan() <-chan watch.Event
ResultChan returns a channel with events
func (*ObjectWatcherForNamespaces) Stop ¶
func (ow *ObjectWatcherForNamespaces) Stop()
Stop performs a stop on all watchers and waits for it's finish
type TestClientWithStatsTrack ¶ added in v0.48.0
type TestClientWithStatsTrack struct { GetCalls atomic.Int64 DeleteCalls atomic.Int64 CreateCalls atomic.Int64 UpdateCalls atomic.Int64 ListCalls atomic.Int64 PatchCalls atomic.Int64 DeleteAllCalls atomic.Int64 // contains filtered or unexported fields }
TestClientWithStatsTrack helps to track actual requests to the api server
func (*TestClientWithStatsTrack) Create ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
func (*TestClientWithStatsTrack) Delete ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
func (*TestClientWithStatsTrack) DeleteAllOf ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
DeleteAllOf deletes all objects of the given type matching the given options.
func (*TestClientWithStatsTrack) GroupVersionKindFor ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error)
func (*TestClientWithStatsTrack) IsObjectNamespaced ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) IsObjectNamespaced(obj runtime.Object) (bool, error)
func (*TestClientWithStatsTrack) List ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
func (*TestClientWithStatsTrack) Patch ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
func (*TestClientWithStatsTrack) RESTMapper ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) RESTMapper() meta.RESTMapper
func (*TestClientWithStatsTrack) Scheme ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) Scheme() *runtime.Scheme
func (*TestClientWithStatsTrack) Status ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) Status() client.SubResourceWriter
func (*TestClientWithStatsTrack) SubResource ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) SubResource(subResource string) client.SubResourceClient
func (*TestClientWithStatsTrack) Update ¶ added in v0.48.0
func (tcs *TestClientWithStatsTrack) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error