Documentation ¶
Index ¶
- func AssertDirectoryOnDisk(fakeFS afero.Afero, path string)
- func AssertFileOnDisk(fakeFS afero.Afero, path, expectedContent string, fileMode uint32)
- func AssertNoDirectoryOnDisk(fakeFS afero.Afero, path string)
- func AssertNoFileOnDisk(fakeFS afero.Afero, path string)
- func BrotliCompression(data []byte) ([]byte, error)
- func BrotliCompressionForManifests(manifests ...string) ([]byte, error)
- func BrotliDecompression(data []byte) ([]byte, error)
- func CEventually(ctx context.Context, actual any) AsyncAssertion
- func EXPECTPatch(ctx any, c *mockclient.MockClient, expectedObj, mergeFrom client.Object, ...) *gomock.Call
- func EXPECTPatchWithOptimisticLock(ctx any, c *mockclient.MockClient, expectedObj, mergeFrom client.Object, ...) *gomock.Call
- func EXPECTStatusPatch(ctx any, c *mockclient.MockStatusWriter, expectedObj, mergeFrom client.Object, ...) *gomock.Call
- func EnsureTestResources(ctx context.Context, c client.Client, namespaceName, path string) ([]client.Object, error)
- func ExpectKindWithNameAndNamespace(manifests []string, kind, name, namespace string)
- func ExtractManifestsFromManagedResourceData(data map[string][]byte) ([]string, error)
- func HasObjectKeyOf(expected client.Object) gomock.Matcher
- func ReadTestResources(scheme *runtime.Scheme, namespaceName, path string) ([]client.Object, error)
- func WithEnvVar(key, value string) func()
- func WithFeatureGate(gate featuregate.FeatureGate, f featuregate.Feature, value bool) func()
- func WithTempFile(dir, pattern string, content []byte, fileName *string) func()
- func WithVar(dst, src any) func()
- func WithVars(dstsAndSrcs ...any) func()
- func WithWd(path string) func()
- type Command
- type CommandBuilder
- type FakeManager
- type Flag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertDirectoryOnDisk ¶ added in v1.85.0
AssertDirectoryOnDisk asserts that a given directory exists.
func AssertFileOnDisk ¶ added in v1.85.0
AssertFileOnDisk asserts that a given file exists and has the expected content and mode.
func AssertNoDirectoryOnDisk ¶ added in v1.85.0
AssertNoDirectoryOnDisk asserts that a given directory does not exist.
func AssertNoFileOnDisk ¶ added in v1.85.0
AssertNoFileOnDisk asserts that a given file does not exist.
func BrotliCompression ¶ added in v1.98.0
BrotliCompression compresses the passed data with the Brotli compression algorithm.
func BrotliCompressionForManifests ¶ added in v1.98.0
BrotliCompressionForManifests compresses the passed data with the Brotli compression algorithm.
func BrotliDecompression ¶ added in v1.98.0
BrotliDecompression decompresses the passed data with the Brotli compression algorithm.
func CEventually ¶ added in v1.61.0
CEventually is like gomega.Eventually but with a context.Context. When it has a deadline then the gomega.Eventually call with be configured with the respective timeout.
func EXPECTPatch ¶ added in v1.19.0
func EXPECTPatch(ctx any, c *mockclient.MockClient, expectedObj, mergeFrom client.Object, patchType types.PatchType, rets ...any) *gomock.Call
EXPECTPatch is a helper function for a GoMock call expecting a patch with the mock client.
func EXPECTPatchWithOptimisticLock ¶ added in v1.32.0
func EXPECTPatchWithOptimisticLock(ctx any, c *mockclient.MockClient, expectedObj, mergeFrom client.Object, patchType types.PatchType, rets ...any) *gomock.Call
EXPECTPatchWithOptimisticLock is a helper function for a GoMock call with the mock client expecting a merge patch with optimistic lock.
func EXPECTStatusPatch ¶ added in v1.64.0
func EXPECTStatusPatch(ctx any, c *mockclient.MockStatusWriter, expectedObj, mergeFrom client.Object, patchType types.PatchType, rets ...any) *gomock.Call
EXPECTStatusPatch is a helper function for a GoMock call expecting a status patch with the mock client.
func EnsureTestResources ¶ added in v1.17.0
func EnsureTestResources(ctx context.Context, c client.Client, namespaceName, path string) ([]client.Object, error)
EnsureTestResources reads test resources from path, applies them using the given client and returns the created objects.
func ExpectKindWithNameAndNamespace ¶ added in v1.98.0
ExpectKindWithNameAndNamespace expects that kind, name and namespace is present in the given manifests.
func ExtractManifestsFromManagedResourceData ¶ added in v1.98.0
ExtractManifestsFromManagedResourceData extracts the resources from the given compressed data, usually used for ManagedResources.
func HasObjectKeyOf ¶ added in v1.25.0
HasObjectKeyOf returns a gomock.Matcher that matches if actual is a client.Object that has the same ObjectKey as expected.
func ReadTestResources ¶ added in v1.17.0
ReadTestResources reads test resources from path, decodes them using the given scheme and returns the parsed objects. Objects are values of the proper API types, if registered in the given scheme, and *unstructured.Unstructured otherwise.
func WithEnvVar ¶
func WithEnvVar(key, value string) func()
WithEnvVar sets the env variable to the given environment variable and returns a function to revert. If the value is empty, the environment variable will be unset.
func WithFeatureGate ¶ added in v1.12.0
func WithFeatureGate(gate featuregate.FeatureGate, f featuregate.Feature, value bool) func()
WithFeatureGate sets the specified gate to the specified value, and returns a function that restores the original value. Failures to set or restore cause the test to fail. Example use:
DeferCleanup(WithFeatureGate(features.DefaultFeatureGate, features.<FeatureName>, true))
func WithTempFile ¶ added in v1.18.0
WithTempFile creates a temporary file with the given dir and pattern, writes the given content to it, and returns a function to delete it. Failures to create, open, close, or delete the file case the test to fail.
The filename is generated by taking pattern and adding a random string to the end. If pattern includes a "*", the random string replaces the last "*". If dir is the empty string, WriteTempFile uses the default directory for temporary files (see ioutil.TempFile). The caller can use the value of fileName to find the pathname of the file.
Example usage:
var fileName string DeferCleanup(WithTempFile("", "test", []byte("test file content"), &fileName))
func WithVar ¶
func WithVar(dst, src any) func()
WithVar sets the given var to the src value and returns a function to revert to the original state. The type of `dst` has to be a settable pointer. The value of `src` has to be assignable to the type of `dst`.
Example usage:
v := "foo" DeferCleanup(WithVar(&v, "bar"))
Types ¶
type Command ¶ added in v1.19.0
Command is a command that has a name, a list of flags, and a list of arguments.
type CommandBuilder ¶ added in v1.19.0
type CommandBuilder struct {
// contains filtered or unexported fields
}
CommandBuilder is a builder for Command objects.
func NewCommandBuilder ¶ added in v1.19.0
func NewCommandBuilder(name string) *CommandBuilder
NewCommandBuilder creates and returns a new CommandBuilder with the given name.
func (*CommandBuilder) Args ¶ added in v1.19.0
func (c *CommandBuilder) Args(args ...string) *CommandBuilder
Args appends the given arguments to this CommandBuilder.
func (*CommandBuilder) Command ¶ added in v1.19.0
func (c *CommandBuilder) Command() *Command
Command returns the Command that has been built by this CommandBuilder.
func (*CommandBuilder) Flags ¶ added in v1.19.0
func (c *CommandBuilder) Flags(flags ...Flag) *CommandBuilder
Flags appends the given flags to this CommandBuilder.
type FakeManager ¶ added in v1.52.0
type FakeManager struct { manager.Manager Client client.Client Cache cache.Cache EventRecorder record.EventRecorder APIReader client.Reader Scheme *runtime.Scheme }
FakeManager fakes a manager.Manager.
func (FakeManager) GetAPIReader ¶ added in v1.52.0
func (f FakeManager) GetAPIReader() client.Reader
GetAPIReader returns the apiReader of the FakeManager.
func (FakeManager) GetCache ¶ added in v1.52.0
func (f FakeManager) GetCache() cache.Cache
GetCache returns the cache of the FakeManager.
func (FakeManager) GetClient ¶ added in v1.52.0
func (f FakeManager) GetClient() client.Client
GetClient returns the client of the FakeManager.
func (FakeManager) GetEventRecorderFor ¶ added in v1.52.0
func (f FakeManager) GetEventRecorderFor(_ string) record.EventRecorder
GetEventRecorderFor returns the eventRecorder of the FakeManager.
func (FakeManager) GetScheme ¶ added in v1.85.0
func (f FakeManager) GetScheme() *runtime.Scheme
GetScheme returns the Scheme of the FakeManager.
type Flag ¶ added in v1.19.0
type Flag interface { // Slice returns a representation of this Flag as a slice of strings. Slice() []string }
Flag is a flag that can be represented as a slice of strings.
func StringFlag ¶ added in v1.19.0
StringFlag returns a Flag with the given key and string value.
func StringSliceFlag ¶ added in v1.19.0
StringSliceFlag returns a flag with the given key and string slice value.