translate

package
v2.11.1-original Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIMAppingsAnnotation = "api-mappings"

	SecretProperySelector = "$.data.#"
)
View Source
const SetFallbackNamespace = "."

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func FromAPI

func FromAPI[S any, T any, P PtrClientObj[T]](t *Translator, target P, source *S) ([]client.Object, error)

FromAPI translaters a source API structure into a Kubernetes object

func ToAPI

func ToAPI[T any](t *Translator, target *T, source client.Object) error

ToAPI translates a source Kubernetes spec into a target API structure

Types

type APIExporter

type APIExporter[T any] interface {
	ToAPI(t *Translator, target *T) error
}

APIExporter can translate itself to an API Object. Use to customize or accelerate translations ad-hoc

type APIImporter

type APIImporter[T any, P PtrClientObj[T]] interface {
	FromAPI(t *Translator, target P) ([]client.Object, error)
}

APIImporter can translate itself into Kubernetes Objects. Use to customize or accelerate translations ad-hoc

type CRDInfo

type CRDInfo struct {
	// contains filtered or unexported fields
}

type Dependencies

type Dependencies struct {
	// contains filtered or unexported fields
}

func NewDependencies

func NewDependencies(mainObj client.Object, objs ...client.Object) *Dependencies

NewDependencies creates a set of Kubernetes client.Objects

func (*Dependencies) Add

func (d *Dependencies) Add(obj client.Object)

Add appends an object to the added list and records it in the general set

func (*Dependencies) Added

func (d *Dependencies) Added() []client.Object

Added dumps an array of all dependencies added to the set after creation

func (*Dependencies) Find

func (d *Dependencies) Find(name, namespace string) client.Object

Find looks for an object within the dependencies by name and namespace

func (*Dependencies) MainObject

func (d *Dependencies) MainObject() client.Object

MainObject retried the main object for this dependecny repository

type DependencyRepo

type DependencyRepo interface {
	MainObject() client.Object
	Find(name, namespace string) client.Object
	Add(obj client.Object)
	Added() []client.Object
}

type EncodeDecodeFunc

type EncodeDecodeFunc func(any) (any, error)

type MajorVersion

type MajorVersion struct {
	// contains filtered or unexported fields
}

MajorVersion holds the SDK version information

type Mapper

type Mapper struct {
	// contains filtered or unexported fields
}

type PtrClientObj

type PtrClientObj[T any] interface {
	*T
	client.Object
}

PtrClientObj is a pointer type implementing client.Object

type Translator

type Translator struct {
	// contains filtered or unexported fields
}

Translator allows to translate back and forth between a CRD schema version and SDK API structures of a certain version

func NewTranslator

func NewTranslator(crd *apiextensionsv1.CustomResourceDefinition, crdVersion string, majorVersion string, deps DependencyRepo) *Translator

NewTranslator creates a translator for a particular CRD and major version pairs, and with a particular set of known Kubernetes object dependencies.

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".

Directories

Path Synopsis
samples
v1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL