Documentation
¶
Index ¶
- func CleanName(generateName string) string
- func FullName(mr metaResource) string
- func FullNameStr(namespace, name string) string
- func TruncateString(s string, maxLength int, truncatedSuffix string) string
- func TruncateStringEllipsis(s string, length int) string
- func WaitForResourceCondition[T runtime.Object, TList runtime.Object, V interface{}](ctx *contexts.Context, timeout time.Duration, client ListerWatcher[TList], ...) (result V, err error)
- type GenerateName
- type LabelableResource
- type ListerWatcher
- type MaxWaitTime
- type MockListerWatcher
- type MockListerWatcher_Expecter
- type MockListerWatcher_List_Call
- func (_c *MockListerWatcher_List_Call[TList]) Return(_a0 TList, _a1 error) *MockListerWatcher_List_Call[TList]
- func (_c *MockListerWatcher_List_Call[TList]) Run(run func(ctx context.Context, opts v1.ListOptions)) *MockListerWatcher_List_Call[TList]
- func (_c *MockListerWatcher_List_Call[TList]) RunAndReturn(run func(context.Context, v1.ListOptions) (TList, error)) *MockListerWatcher_List_Call[TList]
- type MockListerWatcher_Watch_Call
- func (_c *MockListerWatcher_Watch_Call[TList]) Return(_a0 watch.Interface, _a1 error) *MockListerWatcher_Watch_Call[TList]
- func (_c *MockListerWatcher_Watch_Call[TList]) Run(run func(ctx context.Context, opts v1.ListOptions)) *MockListerWatcher_Watch_Call[TList]
- func (_c *MockListerWatcher_Watch_Call[TList]) RunAndReturn(run func(context.Context, v1.ListOptions) (watch.Interface, error)) *MockListerWatcher_Watch_Call[TList]
- type MockmetaResource
- type MockmetaResource_Expecter
- type MockmetaResource_GetName_Call
- type MockmetaResource_GetNamespace_Call
- func (_c *MockmetaResource_GetNamespace_Call) Return(_a0 string) *MockmetaResource_GetNamespace_Call
- func (_c *MockmetaResource_GetNamespace_Call) Run(run func()) *MockmetaResource_GetNamespace_Call
- func (_c *MockmetaResource_GetNamespace_Call) RunAndReturn(run func() string) *MockmetaResource_GetNamespace_Call
- type ResourceLabeler
- type SimpleResourceLabeler
- type WaitEventProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanName ¶
Do a best-effort cleanup of the provided value to make it a valid k8s generated resource name.
func FullNameStr ¶
func TruncateString ¶ added in v0.0.3
func TruncateStringEllipsis ¶ added in v0.0.3
func WaitForResourceCondition ¶
func WaitForResourceCondition[T runtime.Object, TList runtime.Object, V interface{}](ctx *contexts.Context, timeout time.Duration, client ListerWatcher[TList], name string, processEvent WaitEventProcessor[T, V]) (result V, err error)
Wait for a check to pass on a given resource, optionally returning a value when the condition passes. Will not return until the condition is met, or an error occurs.
Types ¶
type GenerateName ¶
type GenerateName bool
func (GenerateName) SetName ¶
func (gn GenerateName) SetName(metadata *metav1.ObjectMeta, name string)
type LabelableResource ¶ added in v0.0.9
type LabelableResource interface {
GetLabels() map[string]string
SetLabels(labels map[string]string)
}
This is a subset of metav1.Object that only includes label functions.
type ListerWatcher ¶
type ListerWatcher[TList runtime.Object] interface { List(ctx context.Context, opts metav1.ListOptions) (TList, error) Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) }
Describes a type that can list and watch k8s resources. `TList` should be a list type (such corev1.PodList), rather than the listed type (such as corev1.Pod). Typically this should be provided via something like `client.CoreV1().Pods(<namespace>)`.
type MaxWaitTime ¶
var ShortWaitTime MaxWaitTime = MaxWaitTime(250 * time.Millisecond)
Very short wait time, mostly used for testing
type MockListerWatcher ¶
MockListerWatcher is an autogenerated mock type for the ListerWatcher type
func NewMockListerWatcher ¶
func NewMockListerWatcher[TList runtime.Object](t interface { mock.TestingT Cleanup(func()) }) *MockListerWatcher[TList]
NewMockListerWatcher creates a new instance of MockListerWatcher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockListerWatcher[TList]) EXPECT ¶
func (_m *MockListerWatcher[TList]) EXPECT() *MockListerWatcher_Expecter[TList]
func (*MockListerWatcher[TList]) List ¶
func (_m *MockListerWatcher[TList]) List(ctx context.Context, opts v1.ListOptions) (TList, error)
List provides a mock function with given fields: ctx, opts
func (*MockListerWatcher[TList]) Watch ¶
func (_m *MockListerWatcher[TList]) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Watch provides a mock function with given fields: ctx, opts
type MockListerWatcher_Expecter ¶
type MockListerWatcher_Expecter[TList runtime.Object] struct { // contains filtered or unexported fields }
func (*MockListerWatcher_Expecter[TList]) List ¶
func (_e *MockListerWatcher_Expecter[TList]) List(ctx interface{}, opts interface{}) *MockListerWatcher_List_Call[TList]
List is a helper method to define mock.On call
- ctx context.Context
- opts v1.ListOptions
func (*MockListerWatcher_Expecter[TList]) Watch ¶
func (_e *MockListerWatcher_Expecter[TList]) Watch(ctx interface{}, opts interface{}) *MockListerWatcher_Watch_Call[TList]
Watch is a helper method to define mock.On call
- ctx context.Context
- opts v1.ListOptions
type MockListerWatcher_List_Call ¶
MockListerWatcher_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List'
func (*MockListerWatcher_List_Call[TList]) Return ¶
func (_c *MockListerWatcher_List_Call[TList]) Return(_a0 TList, _a1 error) *MockListerWatcher_List_Call[TList]
func (*MockListerWatcher_List_Call[TList]) Run ¶
func (_c *MockListerWatcher_List_Call[TList]) Run(run func(ctx context.Context, opts v1.ListOptions)) *MockListerWatcher_List_Call[TList]
func (*MockListerWatcher_List_Call[TList]) RunAndReturn ¶
func (_c *MockListerWatcher_List_Call[TList]) RunAndReturn(run func(context.Context, v1.ListOptions) (TList, error)) *MockListerWatcher_List_Call[TList]
type MockListerWatcher_Watch_Call ¶
MockListerWatcher_Watch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Watch'
func (*MockListerWatcher_Watch_Call[TList]) Return ¶
func (_c *MockListerWatcher_Watch_Call[TList]) Return(_a0 watch.Interface, _a1 error) *MockListerWatcher_Watch_Call[TList]
func (*MockListerWatcher_Watch_Call[TList]) Run ¶
func (_c *MockListerWatcher_Watch_Call[TList]) Run(run func(ctx context.Context, opts v1.ListOptions)) *MockListerWatcher_Watch_Call[TList]
func (*MockListerWatcher_Watch_Call[TList]) RunAndReturn ¶
func (_c *MockListerWatcher_Watch_Call[TList]) RunAndReturn(run func(context.Context, v1.ListOptions) (watch.Interface, error)) *MockListerWatcher_Watch_Call[TList]
type MockmetaResource ¶
MockmetaResource is an autogenerated mock type for the metaResource type
func NewMockmetaResource ¶
func NewMockmetaResource(t interface {
mock.TestingT
Cleanup(func())
}) *MockmetaResource
NewMockmetaResource creates a new instance of MockmetaResource. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.
func (*MockmetaResource) EXPECT ¶
func (_m *MockmetaResource) EXPECT() *MockmetaResource_Expecter
func (*MockmetaResource) GetName ¶
func (_m *MockmetaResource) GetName() string
GetName provides a mock function with no fields
func (*MockmetaResource) GetNamespace ¶
func (_m *MockmetaResource) GetNamespace() string
GetNamespace provides a mock function with no fields
type MockmetaResource_Expecter ¶
type MockmetaResource_Expecter struct {
// contains filtered or unexported fields
}
func (*MockmetaResource_Expecter) GetName ¶
func (_e *MockmetaResource_Expecter) GetName() *MockmetaResource_GetName_Call
GetName is a helper method to define mock.On call
func (*MockmetaResource_Expecter) GetNamespace ¶
func (_e *MockmetaResource_Expecter) GetNamespace() *MockmetaResource_GetNamespace_Call
GetNamespace is a helper method to define mock.On call
type MockmetaResource_GetName_Call ¶
MockmetaResource_GetName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetName'
func (*MockmetaResource_GetName_Call) Return ¶
func (_c *MockmetaResource_GetName_Call) Return(_a0 string) *MockmetaResource_GetName_Call
func (*MockmetaResource_GetName_Call) Run ¶
func (_c *MockmetaResource_GetName_Call) Run(run func()) *MockmetaResource_GetName_Call
func (*MockmetaResource_GetName_Call) RunAndReturn ¶
func (_c *MockmetaResource_GetName_Call) RunAndReturn(run func() string) *MockmetaResource_GetName_Call
type MockmetaResource_GetNamespace_Call ¶
MockmetaResource_GetNamespace_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetNamespace'
func (*MockmetaResource_GetNamespace_Call) Return ¶
func (_c *MockmetaResource_GetNamespace_Call) Return(_a0 string) *MockmetaResource_GetNamespace_Call
func (*MockmetaResource_GetNamespace_Call) Run ¶
func (_c *MockmetaResource_GetNamespace_Call) Run(run func()) *MockmetaResource_GetNamespace_Call
func (*MockmetaResource_GetNamespace_Call) RunAndReturn ¶
func (_c *MockmetaResource_GetNamespace_Call) RunAndReturn(run func() string) *MockmetaResource_GetNamespace_Call
type ResourceLabeler ¶ added in v0.0.9
Describes a type that can label k8s resources. Used to set common labels on resources, which is important for integration with external systems like netpols.
type SimpleResourceLabeler ¶ added in v0.0.9
func (SimpleResourceLabeler) LabelResource ¶ added in v0.0.9
func (srl SimpleResourceLabeler) LabelResource(resource LabelableResource)
Label a resource with the common labels provided to the labeler, if labels with the same keys do not already exist on the resource.
func (*SimpleResourceLabeler) SetCommonLabels ¶ added in v0.0.9
func (srl *SimpleResourceLabeler) SetCommonLabels(labels map[string]string)
type WaitEventProcessor ¶
type WaitEventProcessor[T runtime.Object, V interface{}] func(*contexts.Context, T) (V, bool, error)
Callback for determining if a provided k8s object (`T`, such as corev1.Pod) matches an awaited condition. The function returns result `V` (can be `nil`/`interface{}` type if not needed), whether or not the object matches the condition, and an error if one occurred during processing.