Documentation
¶
Index ¶
- func DeleteScaledObject(ctx context.Context, name string, namespace string, cl client.Client) error
- func EndpointsForService(ctx context.Context, ns, serviceName, servicePort string, ...) ([]*url.URL, error)
- func FakeEndpointsForURL(u *url.URL, namespace, name string, num int) (*v1.Endpoints, error)
- func FakeEndpointsForURLs(urls []*url.URL, namespace, name string) (*v1.Endpoints, error)
- func GetConfigMap(ctx context.Context, cl client.Client, namespace string, name string) (*corev1.ConfigMap, error)
- func Int32P(i int32) *int32
- func Labels(name string) map[string]string
- func NewClientset() (*kubernetes.Clientset, dynamic.Interface, error)
- func NewScaledObject(namespace, name, deploymentName, scalerAddress, host string, ...) (*unstructured.Unstructured, error)
- func ObjKey(ns, name string) client.ObjectKey
- func PatchConfigMap(ctx context.Context, logger logr.Logger, cl client.Writer, ...) (*corev1.ConfigMap, error)
- type ConfigMapGetter
- type ConfigMapGetterWatcher
- type ConfigMapWatcher
- type DeploymentCache
- type DeploymentLister
- type DeploymentListerWatcher
- type DeploymentWatcher
- type FakeConfigMapGetter
- type FakeDeploymentCache
- func (f *FakeDeploymentCache) Get(name string) (appsv1.Deployment, error)
- func (f *FakeDeploymentCache) MarshalJSON() ([]byte, error)
- func (f *FakeDeploymentCache) Set(name string, deployment appsv1.Deployment)
- func (f *FakeDeploymentCache) SetReplicas(name string, num int32) error
- func (f *FakeDeploymentCache) SetWatcher(name string) *watch.RaceFreeFakeWatcher
- func (f *FakeDeploymentCache) Watch(name string) watch.Interface
- type FakeRuntimeClient
- type FakeRuntimeClientReader
- type FakeRuntimeClientWriter
- func (f *FakeRuntimeClientWriter) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (f *FakeRuntimeClientWriter) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
- func (f *FakeRuntimeClientWriter) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
- func (f *FakeRuntimeClientWriter) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (f *FakeRuntimeClientWriter) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- type FakeRuntimeStatusClient
- type GetCall
- type GetEndpointsFunc
- type K8sDeploymentCache
- func (k *K8sDeploymentCache) Get(name string) (appsv1.Deployment, error)
- func (k *K8sDeploymentCache) MarshalJSON() ([]byte, error)
- func (k *K8sDeploymentCache) StartWatcher(ctx context.Context, lggr logr.Logger, fetchTickDur time.Duration) error
- func (k *K8sDeploymentCache) Watch(name string) watch.Interface
- type MemoryDeploymentCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteScaledObject ¶
DeleteScaledObject deletes a scaled object with the given name
func EndpointsForService ¶ added in v0.2.0
func FakeEndpointsForURL ¶ added in v0.2.0
FakeEndpointsForURL creates and returns a new *v1.Endpoints with a single v1.EndpointSubset in it, which has num v1.EndpointAddresses in it. Each of those EndpointAddresses has a Hostname and IP both equal to u.Hostname()
func FakeEndpointsForURLs ¶ added in v0.2.0
FakeEndpointsForURLs creates and returns a new *v1.Endpoints with a single v1.EndpointSubset in it that has each url in the urls parameter in it.
func GetConfigMap ¶ added in v0.2.0
func Int32P ¶ added in v0.1.0
Int32P converts an int32 into an *int32. It's a convenience function for various values in Kubernetes API types
func NewClientset ¶
func NewClientset() (*kubernetes.Clientset, dynamic.Interface, error)
NewClientset gets a new Kubernetes clientset, or calls log.Fatal if it couldn't
func NewScaledObject ¶
func NewScaledObject( namespace, name, deploymentName, scalerAddress, host string, minReplicas, maxReplicas int32, ) (*unstructured.Unstructured, error)
NewScaledObject creates a new ScaledObject in memory
Types ¶
type ConfigMapGetter ¶ added in v0.2.0
type ConfigMapGetter interface {
Get(ctx context.Context, name string, opts metav1.GetOptions) (*corev1.ConfigMap, error)
}
ConfigMapGetter is a pared down version of a ConfigMapInterface (found here: https://pkg.go.dev/k8s.io/client-go@v0.21.3/kubernetes/typed/core/v1#ConfigMapInterface).
Pass this whenever possible to functions that only need to get individual ConfigMaps from Kubernetes, and nothing else.
type ConfigMapGetterWatcher ¶ added in v0.2.0
type ConfigMapGetterWatcher interface {
ConfigMapGetter
ConfigMapWatcher
}
ConfigMapGetterWatcher is a pared down version of a ConfigMapInterface (found here: https://pkg.go.dev/k8s.io/client-go@v0.21.3/kubernetes/typed/core/v1#ConfigMapInterface).
Pass this whenever possible to functions that only need to watch for ConfigMaps from Kubernetes, and nothing else.
type ConfigMapWatcher ¶ added in v0.2.0
type ConfigMapWatcher interface {
Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error)
}
ConfigMapWatcher is a pared down version of a ConfigMapInterface (found here: https://pkg.go.dev/k8s.io/client-go@v0.21.3/kubernetes/typed/core/v1#ConfigMapInterface).
Pass this whenever possible to functions that only need to watch for ConfigMaps from Kubernetes, and nothing else.
type DeploymentCache ¶ added in v0.1.0
type DeploymentLister ¶ added in v0.2.0
type DeploymentLister interface {
List(ctx context.Context, options metav1.ListOptions) (*appsv1.DeploymentList, error)
}
type DeploymentListerWatcher ¶ added in v0.2.0
type DeploymentListerWatcher interface {
DeploymentLister
DeploymentWatcher
}
DeploymentListerWatcher knows how to list and watch deployments. This interface is implemented by Kubernetes client-go
type DeploymentWatcher ¶ added in v0.2.0
type DeploymentWatcher interface {
Watch(ctx context.Context, options metav1.ListOptions) (watch.Interface, error)
}
DeploymentLister knows how to watch deployments. This interface is implemented by Kubernetes client-go
type FakeConfigMapGetter ¶ added in v0.2.0
type FakeDeploymentCache ¶ added in v0.2.0
type FakeDeploymentCache struct {
json.Marshaler
Mut *sync.RWMutex
Current map[string]appsv1.Deployment
Watchers map[string]*watch.RaceFreeFakeWatcher
}
FakeDeploymentCache is a fake implementation of DeploymentCache, suitable for testing interceptor-level logic, without requiring any real Kubernetes client or API interaction
func NewFakeDeploymentCache ¶ added in v0.2.0
func NewFakeDeploymentCache() *FakeDeploymentCache
func (*FakeDeploymentCache) Get ¶ added in v0.2.0
func (f *FakeDeploymentCache) Get(name string) (appsv1.Deployment, error)
func (*FakeDeploymentCache) MarshalJSON ¶ added in v0.2.0
func (f *FakeDeploymentCache) MarshalJSON() ([]byte, error)
func (*FakeDeploymentCache) Set ¶ added in v0.2.0
func (f *FakeDeploymentCache) Set(name string, deployment appsv1.Deployment)
func (*FakeDeploymentCache) SetReplicas ¶ added in v0.2.0
func (f *FakeDeploymentCache) SetReplicas(name string, num int32) error
func (*FakeDeploymentCache) SetWatcher ¶ added in v0.2.0
func (f *FakeDeploymentCache) SetWatcher(name string) *watch.RaceFreeFakeWatcher
type FakeRuntimeClient ¶ added in v0.2.0
type FakeRuntimeClient struct {
*FakeRuntimeClientReader
*FakeRuntimeClientWriter
*FakeRuntimeStatusClient
}
FakeRuntimeClient is a fake implementation of (k8s.io/controller-runtime/pkg/client).Client
func NewFakeRuntimeClient ¶ added in v0.2.0
func NewFakeRuntimeClient() *FakeRuntimeClient
type FakeRuntimeClientReader ¶ added in v0.2.0
type FakeRuntimeClientReader struct {
GetCalls []GetCall
GetFunc func() client.Object
ListCalls []client.ObjectList
ListFunc func() client.ObjectList
}
FakeRuntimeClientReader is a fake implementation of (k8s.io/controller-runtime/pkg/client).ClientReader
func (*FakeRuntimeClientReader) List ¶ added in v0.2.0
func (f *FakeRuntimeClientReader) List( ctx context.Context, list client.ObjectList, opts ...client.ListOption, ) error
func (*FakeRuntimeClientReader) RESTMapper ¶ added in v0.2.0
func (f *FakeRuntimeClientReader) RESTMapper() meta.RESTMapper
RESTMapper implements the controller-runtime Client interface.
NOTE: this method is not implemented and always returns nil.
type FakeRuntimeClientWriter ¶ added in v0.2.0
type FakeRuntimeClientWriter struct {
Creates []client.Object
Deletes []client.Object
Updates []client.Object
Patches []client.Object
DeleteAllOfs []client.Object
}
FakeRuntimeClientWriter is a fake implementation of (k8s.io/controller-runtime/pkg/client).ClientWriter
It stores all method calls in the respective struct fields. Instances of FakeRuntimeClientWriter are not concurrency-safe
func (*FakeRuntimeClientWriter) Create ¶ added in v0.2.0
func (f *FakeRuntimeClientWriter) Create( ctx context.Context, obj client.Object, opts ...client.CreateOption, ) error
func (*FakeRuntimeClientWriter) Delete ¶ added in v0.2.0
func (f *FakeRuntimeClientWriter) Delete( ctx context.Context, obj client.Object, opts ...client.DeleteOption, ) error
func (*FakeRuntimeClientWriter) DeleteAllOf ¶ added in v0.2.0
func (f *FakeRuntimeClientWriter) DeleteAllOf( ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption, ) error
func (*FakeRuntimeClientWriter) Patch ¶ added in v0.2.0
func (f *FakeRuntimeClientWriter) Patch( ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption, ) error
func (*FakeRuntimeClientWriter) Update ¶ added in v0.2.0
func (f *FakeRuntimeClientWriter) Update( ctx context.Context, obj client.Object, opts ...client.UpdateOption, ) error
type FakeRuntimeStatusClient ¶ added in v0.2.0
type FakeRuntimeStatusClient struct {
}
FakeRuntimeStatusClient is a fake implementation of (k8s.io/controller-runtime/pkg/client).StatusClient
func (*FakeRuntimeStatusClient) Scheme ¶ added in v0.2.0
func (f *FakeRuntimeStatusClient) Scheme() *runtime.Scheme
Scheme implements the controller-runtime Client interface.
NOTE: this method is not implemented and always returns nil.
func (*FakeRuntimeStatusClient) Status ¶ added in v0.2.0
func (f *FakeRuntimeStatusClient) Status() client.StatusWriter
Status implements the controller-runtime StatusClient interface.
NOTE: this function isn't implemented and always returns nil.
type GetEndpointsFunc ¶ added in v0.2.0
type GetEndpointsFunc func( ctx context.Context, namespace, serviceName string, ) (*v1.Endpoints, error)
GetEndpointsFunc is a type that represents a function that can fetch endpoints
func EndpointsFuncForControllerClient ¶ added in v0.2.0
func EndpointsFuncForControllerClient( cl client.Client, ) GetEndpointsFunc
EndpointsFuncForControllerClient returns a new GetEndpointsFunc that uses the controller-runtime client.Client to fetch endpoints
func EndpointsFuncForK8sClientset ¶ added in v0.2.0
func EndpointsFuncForK8sClientset( cl *kubernetes.Clientset, ) GetEndpointsFunc
type K8sDeploymentCache ¶ added in v0.1.0
type K8sDeploymentCache struct {
// contains filtered or unexported fields
}
func NewK8sDeploymentCache ¶ added in v0.1.0
func NewK8sDeploymentCache( ctx context.Context, lggr logr.Logger, cl DeploymentListerWatcher, ) (*K8sDeploymentCache, error)
func (*K8sDeploymentCache) Get ¶ added in v0.1.0
func (k *K8sDeploymentCache) Get(name string) (appsv1.Deployment, error)
func (*K8sDeploymentCache) MarshalJSON ¶ added in v0.2.0
func (k *K8sDeploymentCache) MarshalJSON() ([]byte, error)
func (*K8sDeploymentCache) StartWatcher ¶ added in v0.2.0
type MemoryDeploymentCache ¶ added in v0.1.0
type MemoryDeploymentCache struct {
// RWM protects all accesses to either of Watchers or Deployments
RWM *sync.RWMutex
// Watchers holds watchers to be returned by calls to Watch. If Watch is called with a
// name that has a key in this map, that function will panic. Otherwise, it will
// return the corresponding value
Watchers map[string]*watch.RaceFreeFakeWatcher
// Deployments holds the deployments to be returned in calls to Get. If Get is called
// with a name that exists as a key in this map, the corresponding value will be returned.
// Otherwise, an error will be returned
Deployments map[string]appsv1.Deployment
}
MemoryDeploymentCache is a purely in-memory DeploymentCache implementation.
To ensure this is concurrency-safe, be sure to use RWM properly to protect all accesses to either map in this struct.
func NewMemoryDeploymentCache ¶ added in v0.1.0
func NewMemoryDeploymentCache( initialDeployments map[string]appsv1.Deployment, ) *MemoryDeploymentCache
NewMemoryDeploymentCache creates a new MemoryDeploymentCache with the Deployments map set to initialDeployments, and the Watchers map initialized with a newly created and otherwise untouched FakeWatcher for each key in the initialDeployments map
func (*MemoryDeploymentCache) Get ¶ added in v0.1.0
func (m *MemoryDeploymentCache) Get(name string) (appsv1.Deployment, error)
func (*MemoryDeploymentCache) MarshalJSON ¶ added in v0.2.0
func (m *MemoryDeploymentCache) MarshalJSON() ([]byte, error)