Documentation
¶
Overview ¶
Copyright 2025.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2025.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2025.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNamespaceIfNotExists ¶
CreateNamespaceIfNotExists creates a namespace if it doesn't exist
func GenerateUniqueTestName ¶
GenerateUniqueTestName generates a unique namespace name with prefix
func ProjectRoot ¶
func ProjectRoot() string
ProjectRoot returns the root directory of the project by searching for the go.mod file up from where it is called.
Types ¶
type AddToSchemeFunc ¶
type Cleaner ¶
type Cleaner struct {
// contains filtered or unexported fields
}
Cleaner is a struct to perform deletion of resources, enforcing removal of finalizers. Otherwise, deletion of namespaces wouldn't be possible. See: https://book.kubebuilder.io/reference/envtest.html#namespace-usage-limitation Based on https://github.com/kubernetes-sigs/controller-runtime/issues/880#issuecomment-749742403
func CreateCleaner ¶
type Client ¶
type Client struct { client.Client *envtest.Environment *Cleaner }
Client acts as a facade for setting up k8s envtest. It allows to wire controllers under tests through a simple builder funcs and configure underlying test environment through Option functions. It's composed of k8s client.Client and Cleaner to provide unified way of manipulating resources it the env test cluster.
func (*Client) UsingExistingCluster ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func NewEnvTest ¶
NewEnvTest prepares k8s EnvTest with prereq
func (*Config) Start ¶
Start wires controller-runtime manager with controllers which are subject of the tests and starts Kubernetes EnvTest to verify their behavior.
func (*Config) WithControllers ¶
WithControllers register controllers under tests required for the test suite.
func (*Config) WithWebhooks ¶
WithWebhooks register webhooks under tests required for the test suite.
type Option ¶
type Option func(target *envtest.Environment)
func WithScheme ¶
func WithScheme(addToScheme ...AddToSchemeFunc) Option
WithScheme sets the scheme for the test environment.
func WithWebhookManifests ¶
WithWebhookManifests adds CRDs to the test environment using paths.