Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPerVersionTranslators ¶
func NewPerVersionTranslators(crd *apiextensionsv1.CustomResourceDefinition, crdVersion string, versions ...string) (map[string]Translator, error)
NewPerVersionTranslators creates a set of translators indexed by SDK versions
Given the following example resource:
apiVersion: atlas.generated.mongodb.com/v1
kind: SearchIndex
metadata:
name: search-index
spec:
v20250312:
...
v20250810:
In the above case crdVersion is "v1" and versions can be "v20250312" and/or "v20250810".
Types ¶
type Request
deprecated
type Request struct {
Translator Translator
Dependencies []client.Object
}
Request is deprecated do not use
Deprecated: request is no longer used in the ToAPI and FromAPI calls
type Translator ¶
type Translator interface {
// MajorVersion returns the pinned SDK major version
MajorVersion() string
// Mappings returns all the OpenAPi custom reference extensions, or an error
Mappings() ([]*refs.Mapping, error)
// ToAPI translates a source Kubernetes object into a target API structure.
// It uses the spec only to populate ethe API request, nothing from the status.
// The target is set to a API request struct to be filled.
// The source is set to the Kubernetes CR value. Only the spec data is used here.
// The request includes the translator and the dependencies associated with the
// source CR, usually Kubernetes secrets.
ToAPI(target any, source client.Object, objs ...client.Object) error
// FromAPI translates a source API structure into a Kubernetes object.
// The API source is used to populate the Kubernetes spec, including the
// spec.entry and status as well.
// The target is set to CR value to be filled. Both spec and status are filled.
// The source is set to API response.
// The request includes the translator and any dependencies associated with the
// source CR.
// Returns any extra objects extracted from the response as separate Kubernetes
// objects, such as Kubernetes secrets, for instance. This list does not include
// the mutated target, and will be empty if nothing else was extracted off the ç
// response.
FromAPI(target client.Object, source any, objs ...client.Object) ([]client.Object, error)
}
Translator allows to translate back and forth between a CRD schema and SDK API structures of a certain version. A translator is an immutable configuration object, it can be safely shared across goroutines
func NewTranslator ¶
func NewTranslator(crd *apiextensionsv1.CustomResourceDefinition, crdVersion string, majorVersion string) (Translator, error)
NewTranslator creates a translator for a particular CRD version. It is also locked into a particular API majorVersion.
Given the following example resource:
apiVersion: atlas.generated.mongodb.com/v1 kind: SearchIndex metadata: name: search-index spec: v20250312:
In the above case crdVersion is "v1" and majorVersion is "v20250312".