You can check the Kubebuilder/v4/test/e2e/utils package, which offers TestContext
with rich methods:
kubebuilder
, operator-sdk
, or your extended CLI).Once defined, you can use TestContext
to:
Setup the testing environment, e.g.:
Validate the plugin behavior, e.g.:
Ensure the scaffolded output works, e.g.:
Makefile
. See Make.Cleanup temporary resources after testing:
References:
Generate Test SamplesIt’s straightforward to view the content of sample projects generated by your plugin.
For example, Kubebuilder generates sample projects based on different plugins to validate the layouts.
You can also use TestContext
to generate folders of scaffolded projects from your plugin. The commands are similar to those mentioned in Extending CLI Features and Plugins.
Here’s a general workflow to create a sample project using the go/v4
plugin (kbc
is an instance of TestContext
):
To initialize a project:
By("initializing a project")
err = kbc.Init(
"--plugins", "go/v4",
"--project-version", "3",
"--domain", kbc.Domain,
"--fetch-deps=false",
)
Expect(err).NotTo(HaveOccurred(), "Failed to initialize a project")
To define API:
By("creating API definition")
err = kbc.CreateAPI(
"--group", kbc.Group,
"--version", kbc.Version,
"--kind", kbc.Kind,
"--namespaced",
"--resource",
"--controller",
"--make=false",
)
Expect(err).NotTo(HaveOccurred(), "Failed to create an API")
To scaffold webhook configurations:
By("scaffolding mutating and validating webhooks")
err = kbc.CreateWebhook(
"--group", kbc.Group,
"--version", kbc.Version,
"--kind", kbc.Kind,
"--defaulting",
"--programmatic-validation",
)
Expect(err).NotTo(HaveOccurred(), "Failed to create an webhook")
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4