Documentation ¶
Index ¶
- func AddFinalizer(o metav1.Object, finalizer string)
- func FinalizerExists(o metav1.Object, finalizer string) bool
- func GetUnstructuredFromGVK(gvk *schema.GroupVersionKind) *unstructured.Unstructured
- func GetUnstructuredListFromGVK(gvk *schema.GroupVersionKind) *unstructured.UnstructuredList
- func Ignore(is ErrorIs, err error) error
- func IgnoreAny(err error, is ...ErrorIs) error
- func IgnoreNotFound(err error) error
- func MarshalData(o *unstructured.Unstructured) (any, error)
- func RemoveFinalizer(o metav1.Object, finalizer string)
- type APIFinalizer
- type APIPatchingApplicator
- type Applicator
- type ApplyFn
- type ApplyOption
- type ClientApplicator
- type ErrorIs
- type Finalizer
- type MockClient
- func (c *MockClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
- func (c *MockClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
- func (c *MockClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
- func (c *MockClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object, ...) error
- func (c *MockClient) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error)
- func (c *MockClient) IsObjectNamespaced(obj runtime.Object) (bool, error)
- func (c *MockClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (c *MockClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (c *MockClient) RESTMapper() meta.RESTMapper
- func (c *MockClient) Scheme() *runtime.Scheme
- func (c *MockClient) Status() client.SubResourceWriter
- func (c *MockClient) SubResource(_ string) client.SubResourceClient
- func (c *MockClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
- type MockCreateFn
- type MockDeleteAllOfFn
- type MockDeleteFn
- type MockGetFn
- type MockListFn
- type MockPatchFn
- type MockSchemeFn
- type MockSubResourceClient
- func (m *MockSubResourceClient) Create(ctx context.Context, obj, subResource client.Object, ...) error
- func (m *MockSubResourceClient) Get(ctx context.Context, obj, subResource client.Object, ...) error
- func (m *MockSubResourceClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, ...) error
- func (m *MockSubResourceClient) Update(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error
- type MockSubResourceCreateFn
- type MockSubResourceGetFn
- type MockSubResourcePatchFn
- type MockSubResourceUpdateFn
- type MockUpdateFn
- type Object
- type ObjectFn
- type ObjectListFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFinalizer ¶
AddFinalizer to the supplied k8s object's metadata.
func FinalizerExists ¶
FinalizerExists checks whether a certain finalizer is already set on the aupplied object
func GetUnstructuredFromGVK ¶
func GetUnstructuredFromGVK(gvk *schema.GroupVersionKind) *unstructured.Unstructured
func GetUnstructuredListFromGVK ¶
func GetUnstructuredListFromGVK(gvk *schema.GroupVersionKind) *unstructured.UnstructuredList
func IgnoreAny ¶
IgnoreAny ignores errors that satisfy any of the supplied ErrorIs functions by returning nil. Errors that do not satisfy any of the supplied functions are returned unmodified.
func IgnoreNotFound ¶
IgnoreNotFound returns the supplied error, or nil if the error indicates a Kubernetes resource was not found.
func MarshalData ¶
func MarshalData(o *unstructured.Unstructured) (any, error)
func RemoveFinalizer ¶
RemoveFinalizer from the supplied k8s object's metadata.
Types ¶
type APIFinalizer ¶
type APIFinalizer struct {
// contains filtered or unexported fields
}
An APIFinalizer manages the lifecycle of a finalizer on a k8s object.
func NewAPIFinalizer ¶
func NewAPIFinalizer(c client.Client, finalizer string) *APIFinalizer
NewAPIFinalizer returns a new APIFinalizer.
func (*APIFinalizer) AddFinalizer ¶
func (a *APIFinalizer) AddFinalizer(ctx context.Context, obj Object) error
AddFinalizer to the supplied Managed resource.
func (*APIFinalizer) RemoveFinalizer ¶
func (a *APIFinalizer) RemoveFinalizer(ctx context.Context, obj Object) error
type APIPatchingApplicator ¶
An APIPatchingApplicator applies changes to an object by either creating or patching it in a Kubernetes API server.
func NewAPIPatchingApplicator ¶
func NewAPIPatchingApplicator(c client.Client) APIPatchingApplicator
NewAPIPatchingApplicator returns an Applicator that applies changes to an object by either creating or patching it in a Kubernetes API server.
func (*APIPatchingApplicator) Apply ¶
func (a *APIPatchingApplicator) Apply(ctx context.Context, o client.Object, ao ...ApplyOption) error
Apply changes to the supplied object. The object will be created if it does not exist, or patched if it does. If the object does exist, it will only be patched if the passed object has the same or an empty resource version.
type Applicator ¶
An Applicator applies changes to an object.
type ApplyOption ¶
An ApplyOption is called before patching the current object to match the desired object. ApplyOptions are not called if no current object exists.
func UpdateFn ¶
func UpdateFn(fn func(current, desired runtime.Object)) ApplyOption
UpdateFn returns an ApplyOption that is used to modify the current object to match fields of the desired.
type ClientApplicator ¶
type ClientApplicator struct { client.Client Applicator }
A ClientApplicator may be used to build a single 'client' that satisfies both client.Client and Applicator.
type Finalizer ¶
type Finalizer interface { AddFinalizer(ctx context.Context, obj Object) error RemoveFinalizer(ctx context.Context, obj Object) error }
Finalizer manages the lifecycle of the finalizer on a k8s object
type MockClient ¶
type MockClient struct { MockGet MockGetFn MockList MockListFn MockCreate MockCreateFn MockDelete MockDeleteFn MockDeleteAllOf MockDeleteAllOfFn MockUpdate MockUpdateFn MockPatch MockPatchFn MockStatusCreate MockSubResourceCreateFn MockStatusUpdate MockSubResourceUpdateFn MockStatusPatch MockSubResourcePatchFn MockSubResourceGet MockSubResourceGetFn MockSubResourceCreate MockSubResourceCreateFn MockSubResourceUpdate MockSubResourceUpdateFn MockSubResourcePatch MockSubResourcePatchFn MockScheme MockSchemeFn }
MockClient implements controller-runtime's Client interface, allowing each method to be overridden for testing. The controller-runtime provides a fake client, but it is has surprising side effects (e.g. silently calling os.Exit(1)) and does not allow us control over the errors it returns.
func NewMockClient ¶
func NewMockClient() *MockClient
NewMockClient returns a MockClient that does nothing when its methods are called.
func (*MockClient) Create ¶
func (c *MockClient) Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
Create calls MockClient's MockCreate function.
func (*MockClient) Delete ¶
func (c *MockClient) Delete(ctx context.Context, obj client.Object, opts ...client.DeleteOption) error
Delete calls MockClient's MockDelete function.
func (*MockClient) DeleteAllOf ¶
func (c *MockClient) DeleteAllOf(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
DeleteAllOf calls MockClient's DeleteAllOf function.
func (*MockClient) Get ¶
func (c *MockClient) Get(ctx context.Context, key client.ObjectKey, obj client.Object, _ ...client.GetOption) error
Get calls MockClient's MockGet function.
func (*MockClient) GroupVersionKindFor ¶
func (c *MockClient) GroupVersionKindFor(obj runtime.Object) (schema.GroupVersionKind, error)
func (*MockClient) IsObjectNamespaced ¶
func (c *MockClient) IsObjectNamespaced(obj runtime.Object) (bool, error)
func (*MockClient) List ¶
func (c *MockClient) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
List calls MockClient's MockList function.
func (*MockClient) Patch ¶
func (c *MockClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
Patch calls MockClient's MockPatch function.
func (*MockClient) RESTMapper ¶
func (c *MockClient) RESTMapper() meta.RESTMapper
RESTMapper returns the REST mapper.
func (*MockClient) Scheme ¶
func (c *MockClient) Scheme() *runtime.Scheme
Scheme calls MockClient's MockScheme function
func (*MockClient) Status ¶
func (c *MockClient) Status() client.SubResourceWriter
Status returns status writer for status sub-resource
func (*MockClient) SubResource ¶
func (c *MockClient) SubResource(_ string) client.SubResourceClient
SubResource is unimplemented. It panics if called.
func (*MockClient) Update ¶
func (c *MockClient) Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
Update calls MockClient's MockUpdate function.
type MockCreateFn ¶
A MockCreateFn is used to mock client.Client's Create implementation.
func NewMockCreateFn ¶
func NewMockCreateFn(err error, ofn ...ObjectFn) MockCreateFn
NewMockCreateFn returns a MockCreateFn that returns the supplied error.
type MockDeleteAllOfFn ¶
type MockDeleteAllOfFn func(ctx context.Context, obj client.Object, opts ...client.DeleteAllOfOption) error
A MockDeleteAllOfFn is used to mock client.Client's Delete implementation.
func NewMockDeleteAllOfFn ¶
func NewMockDeleteAllOfFn(err error, ofn ...ObjectFn) MockDeleteAllOfFn
NewMockDeleteAllOfFn returns a MockDeleteAllOfFn that returns the supplied error.
type MockDeleteFn ¶
A MockDeleteFn is used to mock client.Client's Delete implementation.
func NewMockDeleteFn ¶
func NewMockDeleteFn(err error, ofn ...ObjectFn) MockDeleteFn
NewMockDeleteFn returns a MockDeleteFn that returns the supplied error.
type MockGetFn ¶
A MockGetFn is used to mock client.Client's Get implementation.
func NewMockGetFn ¶
NewMockGetFn returns a MockGetFn that returns the supplied error.
type MockListFn ¶
type MockListFn func(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
A MockListFn is used to mock client.Client's List implementation.
func NewMockListFn ¶
func NewMockListFn(err error, ofn ...ObjectListFn) MockListFn
NewMockListFn returns a MockListFn that returns the supplied error.
type MockPatchFn ¶
type MockPatchFn func(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.PatchOption) error
A MockPatchFn is used to mock client.Client's Patch implementation.
func NewMockPatchFn ¶
func NewMockPatchFn(err error, ofn ...ObjectFn) MockPatchFn
NewMockPatchFn returns a MockPatchFn that returns the supplied error.
type MockSchemeFn ¶
A MockSchemeFn is used to mock client.Client's Scheme implementation.
func NewMockSchemeFn ¶
func NewMockSchemeFn(scheme *runtime.Scheme) MockSchemeFn
NewMockSchemeFn returns a MockSchemeFn that returns the scheme
type MockSubResourceClient ¶
type MockSubResourceClient struct { MockGet MockSubResourceGetFn MockCreate MockSubResourceCreateFn MockUpdate MockSubResourceUpdateFn MockPatch MockSubResourcePatchFn }
MockSubResourceClient provides mock functionality for status sub-resource
func (*MockSubResourceClient) Create ¶
func (m *MockSubResourceClient) Create(ctx context.Context, obj, subResource client.Object, opts ...client.SubResourceCreateOption) error
Create a sub-resource
func (*MockSubResourceClient) Get ¶
func (m *MockSubResourceClient) Get(ctx context.Context, obj, subResource client.Object, opts ...client.SubResourceGetOption) error
Get a sub-resource
func (*MockSubResourceClient) Patch ¶
func (m *MockSubResourceClient) Patch(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.SubResourcePatchOption) error
Patch a sub-resource
func (*MockSubResourceClient) Update ¶
func (m *MockSubResourceClient) Update(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error
Update a sub-resource
type MockSubResourceCreateFn ¶
type MockSubResourceCreateFn func(ctx context.Context, obj, subResource client.Object, opts ...client.SubResourceCreateOption) error
A MockSubResourceCreateFn is used to mock client.SubResourceClient's create implementation.
func NewMockSubResourceCreateFn ¶
func NewMockSubResourceCreateFn(err error, ofn ...ObjectFn) MockSubResourceCreateFn
NewMockSubResourceCreateFn returns a MockSubResourceCreateFn that returns the supplied error.
type MockSubResourceGetFn ¶
type MockSubResourceGetFn func(ctx context.Context, obj, subResource client.Object, opts ...client.SubResourceGetOption) error
A MockSubResourceGetFn is used to mock client.SubResourceClient's get implementation.
type MockSubResourcePatchFn ¶
type MockSubResourcePatchFn func(ctx context.Context, obj client.Object, patch client.Patch, opts ...client.SubResourcePatchOption) error
A MockSubResourcePatchFn is used to mock client.SubResourceClient's patch implementation.
func NewMockSubResourcePatchFn ¶
func NewMockSubResourcePatchFn(err error, ofn ...ObjectFn) MockSubResourcePatchFn
NewMockSubResourcePatchFn returns a MockSubResourcePatchFn that returns the supplied error.
type MockSubResourceUpdateFn ¶
type MockSubResourceUpdateFn func(ctx context.Context, obj client.Object, opts ...client.SubResourceUpdateOption) error
A MockSubResourceUpdateFn is used to mock client.SubResourceClient's update implementation.
func NewMockSubResourceUpdateFn ¶
func NewMockSubResourceUpdateFn(err error, ofn ...ObjectFn) MockSubResourceUpdateFn
NewMockSubResourceUpdateFn returns a MockSubResourceUpdateFn that returns the supplied error.
type MockUpdateFn ¶
A MockUpdateFn is used to mock client.Client's Update implementation.
func NewMockUpdateFn ¶
func NewMockUpdateFn(err error, ofn ...ObjectFn) MockUpdateFn
NewMockUpdateFn returns a MockUpdateFn that returns the supplied error.
type ObjectFn ¶
An ObjectFn operates on the supplied Object. You might use an ObjectFn to test or update the contents of an Object.
type ObjectListFn ¶
type ObjectListFn func(obj client.ObjectList) error
An ObjectListFn operates on the supplied ObjectList. You might use an ObjectListFn to test or update the contents of an ObjectList.