Documentation
¶
Overview ¶
Copyright 2024 Red Hat, Inc.
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 2024 Red Hat, Inc.
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 2024 Red Hat, Inc.
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 Red Hat, Inc.
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 2026 Red Hat, Inc.
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 ¶
- func AddNamespaceFinalizerCleanup(mgr ctrl.Manager) error
- func BeK8SNotFound() types.GomegaMatcher
- func CRDToYAML(crd *apiextensionsv1.CustomResourceDefinition) string
- func CleanupAndWait(ctx context.Context, cl client.Client, objs ...client.Object) error
- func ClusterRoleYAML(name string) string
- func ConfigMapWithAnnotationsYAML(name string, annotations map[string]string, data map[string]string) string
- func ConfigMapYAML(name string, data ...map[string]string) string
- func DeploymentYAML(name string) string
- func GenerateCRD(gvk schema.GroupVersionKind, additionalVersions ...string) *apiextensionsv1.CustomResourceDefinition
- func GenerateSchemalessSpecStatusCRD(gvk schema.GroupVersionKind, additionalVersions ...string) *apiextensionsv1.CustomResourceDefinition
- func GenerateTestCRD() *apiextensionsv1.CustomResourceDefinition
- func GenerateTestCompatibilityRequirement(testCRD *apiextensionsv1.CustomResourceDefinition) *apiextensionsv1alpha1.CompatibilityRequirement
- func IgnoreFields(fields []string, matcher types.GomegaMatcher) types.GomegaMatcher
- func InvalidObjectMissingRequiredField(crd *apiextensionsv1.CustomResourceDefinition, missingField string) *unstructured.Unstructured
- func MatchViaDiff(expected any) types.GomegaMatcher
- func MultiDoc(docs ...string) string
- func NamespaceYAML(name string) string
- func NewTestObject(gvk schema.GroupVersionKind) *unstructuredBuilder
- func NewVerboseGinkgoLogger(verbosity int) logr.Logger
- func ObjectWithExtraField(crd *apiextensionsv1.CustomResourceDefinition, extraField string, ...) *unstructured.Unstructured
- func SHA256Pad(name string) string
- func StartEnvTest(testEnv *envtest.Environment) (*rest.Config, client.WithWatch, error)
- func StopEnvTest(testEnv *envtest.Environment) error
- func ValidObjectForCRD(crd *apiextensionsv1.CustomResourceDefinition) *unstructured.Unstructured
- type CRDSchemaBuilder
- func (b *CRDSchemaBuilder) Build() *apiextensionsv1.CustomResourceDefinition
- func (b *CRDSchemaBuilder) RemoveProperty(name string) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) RemoveRequiredField(fieldName string) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithAdditionalProperties(allowed bool) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithArrayProperty(name string, itemSchema apiextensionsv1.JSONSchemaProps) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithIntegerProperty(name string) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithObjectProperty(name string, properties map[string]apiextensionsv1.JSONSchemaProps) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithPattern(propertyName, pattern string) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithProperty(name string, propSchema apiextensionsv1.JSONSchemaProps) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithRequiredField(fieldName string) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithRequiredStringProperty(name string) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithScaleSubresource(specReplicasPath, statusReplicasPath, labelSelectorPath *string) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithSchema(schema *apiextensionsv1.JSONSchemaProps) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithSchemaBuilder(schemaBuilder *JSONSchemaPropsBuilder) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithStatusSubresource(statusProperties map[string]apiextensionsv1.JSONSchemaProps) *CRDSchemaBuilder
- func (b *CRDSchemaBuilder) WithStringProperty(name string) *CRDSchemaBuilder
- type ConditionMatcher
- func (m *ConditionMatcher) FailureMessage(actual interface{}) string
- func (m *ConditionMatcher) Match(actual interface{}) (bool, error)
- func (m *ConditionMatcher) NegatedFailureMessage(actual interface{}) string
- func (m *ConditionMatcher) WithLastTransitionTime(expected interface{}) *ConditionMatcher
- func (m *ConditionMatcher) WithMessage(expected interface{}) *ConditionMatcher
- func (m *ConditionMatcher) WithObservedGeneration(expected interface{}) *ConditionMatcher
- func (m *ConditionMatcher) WithReason(expected interface{}) *ConditionMatcher
- func (m *ConditionMatcher) WithStatus(expected interface{}) *ConditionMatcher
- type JSONSchemaPropsBuilder
- func NewArraySchema() *JSONSchemaPropsBuilder
- func NewBooleanSchema() *JSONSchemaPropsBuilder
- func NewIntegerSchema() *JSONSchemaPropsBuilder
- func NewJSONSchemaPropsBuilder() *JSONSchemaPropsBuilder
- func NewNumberSchema() *JSONSchemaPropsBuilder
- func NewObjectSchema() *JSONSchemaPropsBuilder
- func NewStringSchema() *JSONSchemaPropsBuilder
- func SimpleArraySchema(itemBuilder *JSONSchemaPropsBuilder, minItems, maxItems *int64, ...) *JSONSchemaPropsBuilder
- func SimpleIntegerSchema(minimum, maximum *float64) *JSONSchemaPropsBuilder
- func SimpleStringSchema(pattern string, minLength, maxLength *int64) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) Build() *apiextensionsv1.JSONSchemaProps
- func (b *JSONSchemaPropsBuilder) WithAdditionalProperties(allowed bool) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithAdditionalPropertiesSchema(schemaBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithArrayProperty(name string, arrayBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithBooleanProperty(name string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithDefault(defaultValue interface{}) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithDescription(description string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithEnum(values ...interface{}) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithExclusiveMaximum(exclusive bool) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithExclusiveMinimum(exclusive bool) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithFormat(format string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithIntegerItems() *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithIntegerProperty(name string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithItems(itemsSchema *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithMaxItems(maxItems int64) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithMaxLength(maxLength int64) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithMaximum(maximum float64) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithMinItems(minItems int64) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithMinLength(minLength int64) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithMinimum(minimum float64) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithNumberItems() *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithNumberProperty(name string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithObjectItems(objectBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithObjectProperty(name string, objectBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithPattern(pattern string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithProperty(name string, propSchema apiextensionsv1.JSONSchemaProps) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithRequiredArrayProperty(name string, arrayBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithRequiredBooleanProperty(name string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithRequiredField(fieldName string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithRequiredFields(fieldNames ...string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithRequiredIntegerProperty(name string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithRequiredNumberProperty(name string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithRequiredObjectProperty(name string, objectBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithRequiredProperty(name string, propSchema apiextensionsv1.JSONSchemaProps) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithRequiredStringProperty(name string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithStringEnum(values ...string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithStringItems() *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithStringProperty(name string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithTitle(title string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithType(schemaType string) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithUniqueItems(unique bool) *JSONSchemaPropsBuilder
- func (b *JSONSchemaPropsBuilder) WithXPreserveUnknownFields(preserveUnknownFields bool) *JSONSchemaPropsBuilder
- type ProviderImageManifestsBuilder
- func (b *ProviderImageManifestsBuilder) Build() providerimages.ProviderImageManifests
- func (b *ProviderImageManifestsBuilder) WithAttributes(attrs map[string]string) *ProviderImageManifestsBuilder
- func (b *ProviderImageManifestsBuilder) WithContentID(id string) *ProviderImageManifestsBuilder
- func (b *ProviderImageManifestsBuilder) WithImageRef(ref string) *ProviderImageManifestsBuilder
- func (b *ProviderImageManifestsBuilder) WithInstallOrder(order int) *ProviderImageManifestsBuilder
- func (b *ProviderImageManifestsBuilder) WithManifests(docs ...string) *ProviderImageManifestsBuilder
- func (b *ProviderImageManifestsBuilder) WithPlatform(platform configv1.PlatformType) *ProviderImageManifestsBuilder
- func (b *ProviderImageManifestsBuilder) WithProfile(profile string) *ProviderImageManifestsBuilder
- func (b *ProviderImageManifestsBuilder) WithSelfImageRef(ref string) *ProviderImageManifestsBuilder
- type WarningHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddNamespaceFinalizerCleanup ¶
AddNamespaceFinalizerCleanup registers a controller on mgr that clears spec finalizers from terminating Namespace objects via the /finalize subresource.
In envtest the namespace controller doesn't run, so namespaces get stuck in Terminating state. This controller watches for namespaces with a non-zero deletion timestamp and removes their spec finalizers so deletion completes.
func BeK8SNotFound ¶
func BeK8SNotFound() types.GomegaMatcher
BeK8SNotFound is a gomega matcher that checks if an error is a NotFound error returned by the Kubernetes API.
func CRDToYAML ¶
func CRDToYAML(crd *apiextensionsv1.CustomResourceDefinition) string
CRDToYAML marshals a CRD object to YAML. Use with GenerateCRD or GenerateSchemalessSpecStatusCRD from crdbuilder.go to create CRD fixtures for use with WithManifests.
func CleanupAndWait ¶
CleanupAndWait deletes all the given objects and waits for the cache to be updated accordingly.
func ClusterRoleYAML ¶
ClusterRoleYAML returns a minimal ClusterRole YAML document.
func ConfigMapWithAnnotationsYAML ¶
func ConfigMapWithAnnotationsYAML(name string, annotations map[string]string, data map[string]string) string
ConfigMapWithAnnotationsYAML returns a ConfigMap YAML document with the given annotations and data.
func ConfigMapYAML ¶
ConfigMapYAML returns a ConfigMap YAML document. If no data map is provided, a default of {"key": "value"} is used.
func DeploymentYAML ¶
DeploymentYAML returns a minimal Deployment YAML document with a single replica.
func GenerateCRD ¶
func GenerateCRD(gvk schema.GroupVersionKind, additionalVersions ...string) *apiextensionsv1.CustomResourceDefinition
GenerateCRD generates a fake CustomResourceDefinition for a given GroupVersionKind for use in tests. It may optionally be given a set of additional versions to include in the CRD. The additional versions will be added before the primary version. Only the primary version will be marked as a storage version.
func GenerateSchemalessSpecStatusCRD ¶
func GenerateSchemalessSpecStatusCRD(gvk schema.GroupVersionKind, additionalVersions ...string) *apiextensionsv1.CustomResourceDefinition
GenerateSchemalessSpecStatusCRD generates a simple CRD with a spec and status schema that accepts all values in spec and status using XPreserveUnknownFields.
func GenerateTestCRD ¶
func GenerateTestCRD() *apiextensionsv1.CustomResourceDefinition
GenerateTestCRD generates a simple CRD with a randomly generated Kind. Version is always v1. Group is always example.com.
func GenerateTestCompatibilityRequirement ¶
func GenerateTestCompatibilityRequirement(testCRD *apiextensionsv1.CustomResourceDefinition) *apiextensionsv1alpha1.CompatibilityRequirement
GenerateTestCompatibilityRequirement generates a simple CompatibilityRequirement using the given CRD as the CompatibilityCRD. The generated requirement uses GenerateName, so it will not have a valid Name until it is created.
func IgnoreFields ¶
func IgnoreFields(fields []string, matcher types.GomegaMatcher) types.GomegaMatcher
IgnoreFields is a gomega matcher that ignores the specified fields in the object.
func InvalidObjectMissingRequiredField ¶
func InvalidObjectMissingRequiredField(crd *apiextensionsv1.CustomResourceDefinition, missingField string) *unstructured.Unstructured
InvalidObjectMissingRequiredField creates an object missing a required field.
func MatchViaDiff ¶
func MatchViaDiff(expected any) types.GomegaMatcher
MatchViaDiff is a gomega matcher that checks if the actual object is equal to the expected object by using cmp.Diff. This is useful for complex objects where you want to focus on a small subset of the object when there is a difference.
func NamespaceYAML ¶
NamespaceYAML returns a Namespace YAML document.
func NewTestObject ¶
func NewTestObject(gvk schema.GroupVersionKind) *unstructuredBuilder
NewTestObject creates a builder for unstructured objects with the given GVK.
func NewVerboseGinkgoLogger ¶
NewVerboseGinkgoLogger sets up a new logr.Logger that writes to GinkoWriter, and uses the passed verbosity Useful for debugging.
func ObjectWithExtraField ¶
func ObjectWithExtraField(crd *apiextensionsv1.CustomResourceDefinition, extraField string, value interface{}) *unstructured.Unstructured
ObjectWithExtraField creates an object with an additional field not in the schema.
func SHA256Pad ¶
SHA256Pad creates a deterministic 64-char hex string from a name (for fake digests).
func StartEnvTest ¶
StartEnvTest starts a new test environment and returns a client and config. The returned client implements client.WithWatch for use with interceptor clients.
func StopEnvTest ¶
func StopEnvTest(testEnv *envtest.Environment) error
StopEnvTest stops the test environment.
func ValidObjectForCRD ¶
func ValidObjectForCRD(crd *apiextensionsv1.CustomResourceDefinition) *unstructured.Unstructured
ValidObjectForCRD creates an object that should pass validation for the given CRD.
Types ¶
type CRDSchemaBuilder ¶
type CRDSchemaBuilder struct {
// contains filtered or unexported fields
}
CRDSchemaBuilder provides utilities for manipulating CRD schemas for testing.
func FromCRD ¶
func FromCRD(crd *apiextensionsv1.CustomResourceDefinition) *CRDSchemaBuilder
FromCRD creates a builder from an existing CRD.
func NewCRDSchemaBuilder ¶
func NewCRDSchemaBuilder() *CRDSchemaBuilder
NewCRDSchemaBuilder creates a builder for CRD schema manipulation.
func (*CRDSchemaBuilder) Build ¶
func (b *CRDSchemaBuilder) Build() *apiextensionsv1.CustomResourceDefinition
Build returns a deep copy of the constructed CRD.
func (*CRDSchemaBuilder) RemoveProperty ¶
func (b *CRDSchemaBuilder) RemoveProperty(name string) *CRDSchemaBuilder
RemoveProperty removes a property from the CRD's schema.
func (*CRDSchemaBuilder) RemoveRequiredField ¶
func (b *CRDSchemaBuilder) RemoveRequiredField(fieldName string) *CRDSchemaBuilder
RemoveRequiredField removes a field from the required fields list.
func (*CRDSchemaBuilder) WithAdditionalProperties ¶
func (b *CRDSchemaBuilder) WithAdditionalProperties(allowed bool) *CRDSchemaBuilder
WithAdditionalProperties sets whether additional properties are allowed.
func (*CRDSchemaBuilder) WithArrayProperty ¶
func (b *CRDSchemaBuilder) WithArrayProperty(name string, itemSchema apiextensionsv1.JSONSchemaProps) *CRDSchemaBuilder
WithArrayProperty adds an array property to the CRD's schema.
func (*CRDSchemaBuilder) WithIntegerProperty ¶
func (b *CRDSchemaBuilder) WithIntegerProperty(name string) *CRDSchemaBuilder
WithIntegerProperty adds an integer property to the CRD's schema.
func (*CRDSchemaBuilder) WithObjectProperty ¶
func (b *CRDSchemaBuilder) WithObjectProperty(name string, properties map[string]apiextensionsv1.JSONSchemaProps) *CRDSchemaBuilder
WithObjectProperty adds an object property with nested properties.
func (*CRDSchemaBuilder) WithPattern ¶
func (b *CRDSchemaBuilder) WithPattern(propertyName, pattern string) *CRDSchemaBuilder
WithPattern adds a pattern validation to a string property.
func (*CRDSchemaBuilder) WithProperty ¶
func (b *CRDSchemaBuilder) WithProperty(name string, propSchema apiextensionsv1.JSONSchemaProps) *CRDSchemaBuilder
WithProperty adds a property to the CRD's schema.
func (*CRDSchemaBuilder) WithRequiredField ¶
func (b *CRDSchemaBuilder) WithRequiredField(fieldName string) *CRDSchemaBuilder
WithRequiredField adds a field to the required fields list.
func (*CRDSchemaBuilder) WithRequiredStringProperty ¶
func (b *CRDSchemaBuilder) WithRequiredStringProperty(name string) *CRDSchemaBuilder
WithRequiredStringProperty adds a required string property to the CRD's schema.
func (*CRDSchemaBuilder) WithScaleSubresource ¶
func (b *CRDSchemaBuilder) WithScaleSubresource(specReplicasPath, statusReplicasPath, labelSelectorPath *string) *CRDSchemaBuilder
WithScaleSubresource adds a scale subresource with the given configuration.
func (*CRDSchemaBuilder) WithSchema ¶
func (b *CRDSchemaBuilder) WithSchema(schema *apiextensionsv1.JSONSchemaProps) *CRDSchemaBuilder
WithSchema replaces the entire OpenAPIV3Schema with the provided schema.
func (*CRDSchemaBuilder) WithSchemaBuilder ¶
func (b *CRDSchemaBuilder) WithSchemaBuilder(schemaBuilder *JSONSchemaPropsBuilder) *CRDSchemaBuilder
WithSchemaBuilder replaces the entire OpenAPIV3Schema with a schema built from JSONSchemaPropsBuilder.
func (*CRDSchemaBuilder) WithStatusSubresource ¶
func (b *CRDSchemaBuilder) WithStatusSubresource(statusProperties map[string]apiextensionsv1.JSONSchemaProps) *CRDSchemaBuilder
WithStatusSubresource adds a status subresource with optional custom status schema properties.
func (*CRDSchemaBuilder) WithStringProperty ¶
func (b *CRDSchemaBuilder) WithStringProperty(name string) *CRDSchemaBuilder
WithStringProperty adds a string property to the CRD's schema.
type ConditionMatcher ¶
type ConditionMatcher struct {
// contains filtered or unexported fields
}
ConditionMatcher is a Gomega matcher for condition structs. It uses reflection to work with any condition-like struct. Use HaveCondition to match within a slice, or BeCondition to match a single element.
func BeCondition ¶
func BeCondition[T ~string](conditionType T) *ConditionMatcher
BeCondition returns a matcher that checks if a single condition struct has the specified type. It shares all WithX methods with HaveCondition but operates on a single condition rather than a slice.
Supported condition types include:
- configv1.ClusterOperatorStatusCondition
- configv1apply.ClusterOperatorStatusConditionApplyConfiguration (or pointer)
- metav1.Condition
- Any struct with Type, Status, Reason, Message fields
Usage:
Expect(cond).To(BeCondition("Progressing").
WithStatus(configv1.ConditionTrue).
WithReason("EphemeralError"))
func HaveCondition ¶
func HaveCondition[T ~string](conditionType T) *ConditionMatcher
HaveCondition returns a matcher that checks if a slice of condition structs contains a condition with the specified type. It uses reflection to work with any condition-like struct that has Type, Status, Reason, Message, and optionally LastTransitionTime and ObservedGeneration fields. It can operate on both Condition objects, and generated apply configurations of those objects.
Supported condition types include:
- configv1.ClusterOperatorStatusCondition
- metav1.Condition
- clusterv1.Condition (v1beta1 and v1beta2)
- Any struct with Type, Status, Reason, Message fields
Usage:
Expect(co.Status.Conditions).To(HaveCondition("Progressing"))
Expect(co.Status.Conditions).To(HaveCondition("Progressing").
WithStatus(configv1.ConditionTrue).
WithReason("EphemeralError"))
// With custom matchers:
Expect(co.Status.Conditions).To(HaveCondition("Progressing").
WithStatus(configv1.ConditionTrue).
WithLastTransitionTime(Equal(expectedTime)))
func (*ConditionMatcher) FailureMessage ¶
func (m *ConditionMatcher) FailureMessage(actual interface{}) string
FailureMessage implements types.GomegaMatcher.
func (*ConditionMatcher) Match ¶
func (m *ConditionMatcher) Match(actual interface{}) (bool, error)
Match implements types.GomegaMatcher.
func (*ConditionMatcher) NegatedFailureMessage ¶
func (m *ConditionMatcher) NegatedFailureMessage(actual interface{}) string
NegatedFailureMessage implements types.GomegaMatcher.
func (*ConditionMatcher) WithLastTransitionTime ¶
func (m *ConditionMatcher) WithLastTransitionTime(expected interface{}) *ConditionMatcher
WithLastTransitionTime adds a LastTransitionTime check to the matcher. Accepts either a time value or a types.GomegaMatcher (e.g., Equal, BeTemporally with WithTransform).
func (*ConditionMatcher) WithMessage ¶
func (m *ConditionMatcher) WithMessage(expected interface{}) *ConditionMatcher
WithMessage adds a message check to the matcher. Accepts either a string value or a types.GomegaMatcher.
func (*ConditionMatcher) WithObservedGeneration ¶
func (m *ConditionMatcher) WithObservedGeneration(expected interface{}) *ConditionMatcher
WithObservedGeneration adds an ObservedGeneration check to the matcher. Accepts either an int64 value or a types.GomegaMatcher. Only usable with condition types that have an ObservedGeneration field (e.g., metav1.Condition).
func (*ConditionMatcher) WithReason ¶
func (m *ConditionMatcher) WithReason(expected interface{}) *ConditionMatcher
WithReason adds a reason check to the matcher. Accepts either a string value or a types.GomegaMatcher.
func (*ConditionMatcher) WithStatus ¶
func (m *ConditionMatcher) WithStatus(expected interface{}) *ConditionMatcher
WithStatus adds a status check to the matcher. Accepts either a status value (string or typed) or a types.GomegaMatcher.
type JSONSchemaPropsBuilder ¶
type JSONSchemaPropsBuilder struct {
// contains filtered or unexported fields
}
JSONSchemaPropsBuilder provides a fluent interface for building JSONSchemaProps for use in CRD schema construction and testing.
func NewArraySchema ¶
func NewArraySchema() *JSONSchemaPropsBuilder
NewArraySchema creates a builder for an array schema.
func NewBooleanSchema ¶
func NewBooleanSchema() *JSONSchemaPropsBuilder
NewBooleanSchema creates a builder for a boolean schema.
func NewIntegerSchema ¶
func NewIntegerSchema() *JSONSchemaPropsBuilder
NewIntegerSchema creates a builder for an integer schema.
func NewJSONSchemaPropsBuilder ¶
func NewJSONSchemaPropsBuilder() *JSONSchemaPropsBuilder
NewJSONSchemaPropsBuilder creates a new builder for JSONSchemaProps.
func NewNumberSchema ¶
func NewNumberSchema() *JSONSchemaPropsBuilder
NewNumberSchema creates a builder for a number schema.
func NewObjectSchema ¶
func NewObjectSchema() *JSONSchemaPropsBuilder
NewObjectSchema creates a builder for an object schema.
func NewStringSchema ¶
func NewStringSchema() *JSONSchemaPropsBuilder
NewStringSchema creates a builder for a string schema.
func SimpleArraySchema ¶
func SimpleArraySchema(itemBuilder *JSONSchemaPropsBuilder, minItems, maxItems *int64, uniqueItems bool) *JSONSchemaPropsBuilder
SimpleArraySchema creates a simple array schema with the given item type.
func SimpleIntegerSchema ¶
func SimpleIntegerSchema(minimum, maximum *float64) *JSONSchemaPropsBuilder
SimpleIntegerSchema creates a simple integer schema with optional constraints.
func SimpleStringSchema ¶
func SimpleStringSchema(pattern string, minLength, maxLength *int64) *JSONSchemaPropsBuilder
SimpleStringSchema creates a simple string schema with optional constraints.
func (*JSONSchemaPropsBuilder) Build ¶
func (b *JSONSchemaPropsBuilder) Build() *apiextensionsv1.JSONSchemaProps
Build returns a deep copy of the constructed JSONSchemaProps.
func (*JSONSchemaPropsBuilder) WithAdditionalProperties ¶
func (b *JSONSchemaPropsBuilder) WithAdditionalProperties(allowed bool) *JSONSchemaPropsBuilder
WithAdditionalProperties sets whether additional properties are allowed.
func (*JSONSchemaPropsBuilder) WithAdditionalPropertiesSchema ¶
func (b *JSONSchemaPropsBuilder) WithAdditionalPropertiesSchema(schemaBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
WithAdditionalPropertiesSchema sets a schema for additional properties.
func (*JSONSchemaPropsBuilder) WithArrayProperty ¶
func (b *JSONSchemaPropsBuilder) WithArrayProperty(name string, arrayBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
WithArrayProperty adds an array property to an object schema.
func (*JSONSchemaPropsBuilder) WithBooleanProperty ¶
func (b *JSONSchemaPropsBuilder) WithBooleanProperty(name string) *JSONSchemaPropsBuilder
WithBooleanProperty adds a boolean property to an object schema.
func (*JSONSchemaPropsBuilder) WithDefault ¶
func (b *JSONSchemaPropsBuilder) WithDefault(defaultValue interface{}) *JSONSchemaPropsBuilder
WithDefault sets a default value.
func (*JSONSchemaPropsBuilder) WithDescription ¶
func (b *JSONSchemaPropsBuilder) WithDescription(description string) *JSONSchemaPropsBuilder
WithDescription sets the description field.
func (*JSONSchemaPropsBuilder) WithEnum ¶
func (b *JSONSchemaPropsBuilder) WithEnum(values ...interface{}) *JSONSchemaPropsBuilder
WithEnum adds enum values for validation.
func (*JSONSchemaPropsBuilder) WithExclusiveMaximum ¶
func (b *JSONSchemaPropsBuilder) WithExclusiveMaximum(exclusive bool) *JSONSchemaPropsBuilder
WithExclusiveMaximum sets whether the maximum is exclusive.
func (*JSONSchemaPropsBuilder) WithExclusiveMinimum ¶
func (b *JSONSchemaPropsBuilder) WithExclusiveMinimum(exclusive bool) *JSONSchemaPropsBuilder
WithExclusiveMinimum sets whether the minimum is exclusive.
func (*JSONSchemaPropsBuilder) WithFormat ¶
func (b *JSONSchemaPropsBuilder) WithFormat(format string) *JSONSchemaPropsBuilder
WithFormat sets the format field (e.g., "date-time", "email").
func (*JSONSchemaPropsBuilder) WithIntegerItems ¶
func (b *JSONSchemaPropsBuilder) WithIntegerItems() *JSONSchemaPropsBuilder
WithIntegerItems creates an array schema with integer items.
func (*JSONSchemaPropsBuilder) WithIntegerProperty ¶
func (b *JSONSchemaPropsBuilder) WithIntegerProperty(name string) *JSONSchemaPropsBuilder
WithIntegerProperty adds an integer property to an object schema.
func (*JSONSchemaPropsBuilder) WithItems ¶
func (b *JSONSchemaPropsBuilder) WithItems(itemsSchema *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
WithItems sets the items schema for arrays.
func (*JSONSchemaPropsBuilder) WithMaxItems ¶
func (b *JSONSchemaPropsBuilder) WithMaxItems(maxItems int64) *JSONSchemaPropsBuilder
WithMaxItems sets the maximum number of items for arrays.
func (*JSONSchemaPropsBuilder) WithMaxLength ¶
func (b *JSONSchemaPropsBuilder) WithMaxLength(maxLength int64) *JSONSchemaPropsBuilder
WithMaxLength sets the maximum length for strings.
func (*JSONSchemaPropsBuilder) WithMaximum ¶
func (b *JSONSchemaPropsBuilder) WithMaximum(maximum float64) *JSONSchemaPropsBuilder
WithMaximum sets the maximum value for numbers.
func (*JSONSchemaPropsBuilder) WithMinItems ¶
func (b *JSONSchemaPropsBuilder) WithMinItems(minItems int64) *JSONSchemaPropsBuilder
WithMinItems sets the minimum number of items for arrays.
func (*JSONSchemaPropsBuilder) WithMinLength ¶
func (b *JSONSchemaPropsBuilder) WithMinLength(minLength int64) *JSONSchemaPropsBuilder
WithMinLength sets the minimum length for strings.
func (*JSONSchemaPropsBuilder) WithMinimum ¶
func (b *JSONSchemaPropsBuilder) WithMinimum(minimum float64) *JSONSchemaPropsBuilder
WithMinimum sets the minimum value for numbers.
func (*JSONSchemaPropsBuilder) WithNumberItems ¶
func (b *JSONSchemaPropsBuilder) WithNumberItems() *JSONSchemaPropsBuilder
WithNumberItems creates an array schema with number items.
func (*JSONSchemaPropsBuilder) WithNumberProperty ¶
func (b *JSONSchemaPropsBuilder) WithNumberProperty(name string) *JSONSchemaPropsBuilder
WithNumberProperty adds a number property to an object schema.
func (*JSONSchemaPropsBuilder) WithObjectItems ¶
func (b *JSONSchemaPropsBuilder) WithObjectItems(objectBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
WithObjectItems creates an array schema with object items.
func (*JSONSchemaPropsBuilder) WithObjectProperty ¶
func (b *JSONSchemaPropsBuilder) WithObjectProperty(name string, objectBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
WithObjectProperty adds an object property to an object schema.
func (*JSONSchemaPropsBuilder) WithPattern ¶
func (b *JSONSchemaPropsBuilder) WithPattern(pattern string) *JSONSchemaPropsBuilder
WithPattern sets a regex pattern for string validation.
func (*JSONSchemaPropsBuilder) WithProperty ¶
func (b *JSONSchemaPropsBuilder) WithProperty(name string, propSchema apiextensionsv1.JSONSchemaProps) *JSONSchemaPropsBuilder
WithProperty adds a property to an object schema.
func (*JSONSchemaPropsBuilder) WithRequiredArrayProperty ¶
func (b *JSONSchemaPropsBuilder) WithRequiredArrayProperty(name string, arrayBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
WithRequiredArrayProperty adds a required array property.
func (*JSONSchemaPropsBuilder) WithRequiredBooleanProperty ¶
func (b *JSONSchemaPropsBuilder) WithRequiredBooleanProperty(name string) *JSONSchemaPropsBuilder
WithRequiredBooleanProperty adds a required boolean property.
func (*JSONSchemaPropsBuilder) WithRequiredField ¶
func (b *JSONSchemaPropsBuilder) WithRequiredField(fieldName string) *JSONSchemaPropsBuilder
WithRequiredField adds a field to the required fields list.
func (*JSONSchemaPropsBuilder) WithRequiredFields ¶
func (b *JSONSchemaPropsBuilder) WithRequiredFields(fieldNames ...string) *JSONSchemaPropsBuilder
WithRequiredFields adds multiple fields to the required fields list.
func (*JSONSchemaPropsBuilder) WithRequiredIntegerProperty ¶
func (b *JSONSchemaPropsBuilder) WithRequiredIntegerProperty(name string) *JSONSchemaPropsBuilder
WithRequiredIntegerProperty adds a required integer property.
func (*JSONSchemaPropsBuilder) WithRequiredNumberProperty ¶
func (b *JSONSchemaPropsBuilder) WithRequiredNumberProperty(name string) *JSONSchemaPropsBuilder
WithRequiredNumberProperty adds a required number property.
func (*JSONSchemaPropsBuilder) WithRequiredObjectProperty ¶
func (b *JSONSchemaPropsBuilder) WithRequiredObjectProperty(name string, objectBuilder *JSONSchemaPropsBuilder) *JSONSchemaPropsBuilder
WithRequiredObjectProperty adds a required object property.
func (*JSONSchemaPropsBuilder) WithRequiredProperty ¶
func (b *JSONSchemaPropsBuilder) WithRequiredProperty(name string, propSchema apiextensionsv1.JSONSchemaProps) *JSONSchemaPropsBuilder
WithRequiredProperty adds a property and marks it as required.
func (*JSONSchemaPropsBuilder) WithRequiredStringProperty ¶
func (b *JSONSchemaPropsBuilder) WithRequiredStringProperty(name string) *JSONSchemaPropsBuilder
WithRequiredStringProperty adds a required string property.
func (*JSONSchemaPropsBuilder) WithStringEnum ¶
func (b *JSONSchemaPropsBuilder) WithStringEnum(values ...string) *JSONSchemaPropsBuilder
WithStringEnum adds string enum values.
func (*JSONSchemaPropsBuilder) WithStringItems ¶
func (b *JSONSchemaPropsBuilder) WithStringItems() *JSONSchemaPropsBuilder
WithStringItems creates an array schema with string items.
func (*JSONSchemaPropsBuilder) WithStringProperty ¶
func (b *JSONSchemaPropsBuilder) WithStringProperty(name string) *JSONSchemaPropsBuilder
WithStringProperty adds a string property to an object schema.
func (*JSONSchemaPropsBuilder) WithTitle ¶
func (b *JSONSchemaPropsBuilder) WithTitle(title string) *JSONSchemaPropsBuilder
WithTitle sets the title field.
func (*JSONSchemaPropsBuilder) WithType ¶
func (b *JSONSchemaPropsBuilder) WithType(schemaType string) *JSONSchemaPropsBuilder
WithType sets the type field.
func (*JSONSchemaPropsBuilder) WithUniqueItems ¶
func (b *JSONSchemaPropsBuilder) WithUniqueItems(unique bool) *JSONSchemaPropsBuilder
WithUniqueItems sets whether array items must be unique.
func (*JSONSchemaPropsBuilder) WithXPreserveUnknownFields ¶
func (b *JSONSchemaPropsBuilder) WithXPreserveUnknownFields(preserveUnknownFields bool) *JSONSchemaPropsBuilder
WithXPreserveUnknownFields sets the x-preserve-unknown-fields field.
type ProviderImageManifestsBuilder ¶
type ProviderImageManifestsBuilder struct {
// contains filtered or unexported fields
}
ProviderImageManifestsBuilder constructs a ProviderImageManifests for testing with sensible defaults. Manifest files are written to tb.TempDir() and cleaned up automatically.
func NewProviderImageManifests ¶
func NewProviderImageManifests(tb testing.TB, name string) *ProviderImageManifestsBuilder
NewProviderImageManifests returns a builder with sensible defaults for a test provider.
func (*ProviderImageManifestsBuilder) Build ¶
func (b *ProviderImageManifestsBuilder) Build() providerimages.ProviderImageManifests
Build constructs the ProviderImageManifests, writing any manifests to a temp file.
func (*ProviderImageManifestsBuilder) WithAttributes ¶
func (b *ProviderImageManifestsBuilder) WithAttributes(attrs map[string]string) *ProviderImageManifestsBuilder
WithAttributes merges the given attributes into the provider attributes map.
func (*ProviderImageManifestsBuilder) WithContentID ¶
func (b *ProviderImageManifestsBuilder) WithContentID(id string) *ProviderImageManifestsBuilder
WithContentID sets a custom content ID.
func (*ProviderImageManifestsBuilder) WithImageRef ¶
func (b *ProviderImageManifestsBuilder) WithImageRef(ref string) *ProviderImageManifestsBuilder
WithImageRef sets a custom image reference.
func (*ProviderImageManifestsBuilder) WithInstallOrder ¶
func (b *ProviderImageManifestsBuilder) WithInstallOrder(order int) *ProviderImageManifestsBuilder
WithInstallOrder sets a custom install order.
func (*ProviderImageManifestsBuilder) WithManifests ¶
func (b *ProviderImageManifestsBuilder) WithManifests(docs ...string) *ProviderImageManifestsBuilder
WithManifests appends the given YAML documents to the manifest list.
func (*ProviderImageManifestsBuilder) WithPlatform ¶
func (b *ProviderImageManifestsBuilder) WithPlatform(platform configv1.PlatformType) *ProviderImageManifestsBuilder
WithPlatform sets the OCP platform type.
func (*ProviderImageManifestsBuilder) WithProfile ¶
func (b *ProviderImageManifestsBuilder) WithProfile(profile string) *ProviderImageManifestsBuilder
WithProfile sets a custom profile name.
func (*ProviderImageManifestsBuilder) WithSelfImageRef ¶
func (b *ProviderImageManifestsBuilder) WithSelfImageRef(ref string) *ProviderImageManifestsBuilder
WithSelfImageRef sets the self image reference.
type WarningHandler ¶
type WarningHandler struct {
// contains filtered or unexported fields
}
WarningHandler is a test implementation of the rest.WarningHandler interface.
func NewTestWarningHandler ¶
func NewTestWarningHandler() *WarningHandler
NewTestWarningHandler creates a new WarningHandler.
func (*WarningHandler) HandleWarningHeader ¶
func (w *WarningHandler) HandleWarningHeader(code int, agent string, text string)
HandleWarningHeader is a test implementation of the rest.WarningHandler.HandleWarningHeader method.
func (*WarningHandler) HandleWarningHeaderWithContext ¶
func (w *WarningHandler) HandleWarningHeaderWithContext(_ context.Context, code int, agent string, text string)
HandleWarningHeaderWithContext is a test implementation of the rest.WarningHandler.HandleWarningHeaderWithContext method.
func (*WarningHandler) Messages ¶
func (w *WarningHandler) Messages() []string
Messages returns the messages from the warning handler.