migration

package
v1.2.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 47 Imported by: 23

Documentation

Index

Constants

View Source
const (
	// KeyContextDiagnostics is the executor step context key for
	// storing any extra diagnostics information from
	// the executor.
	KeyContextDiagnostics = "diagnostics"
)

Variables

View Source
var (
	// AllCompositions matches all v1.Composition names.
	AllCompositions = regexp.MustCompile(`.*`)
	// AllConfigurations matches all metav1.Configuration names.
	AllConfigurations = regexp.MustCompile(`.*`)
	// CrossplaneLockName is the Crossplane package lock's `metadata.name`
	CrossplaneLockName = regexp.MustCompile(`^lock$`)
)

Functions

func AddManualExecution

func AddManualExecution(s *Step)

AddManualExecution sets the manual execution hint for the specified step.

func ConvertComposedTemplatePatchesMap

func ConvertComposedTemplatePatchesMap(sourceTemplate xpv1.ComposedTemplate, conversionMap map[string]string) []xpv1.Patch

ConvertComposedTemplatePatchesMap converts the composed templates with given conversionMap Key of the conversionMap points to the source field Value of the conversionMap points to the target field

func CopyInto

func CopyInto(source any, target any, targetGVK schema.GroupVersionKind, skipFieldPaths ...string) (any, error)

CopyInto copies values of fields from the migration `source` object into the migration `target` object and fills in the target object's TypeMeta using the supplied `targetGVK`. While copying fields from migration source to migration target, the fields at the paths specified with `skipFieldPaths` array are skipped. This is a utility that can be used in the migration resource converter implementations. If a certain field with the same name in both the `source` and the `target` objects has different types in `source` and `target`, then it must be included in the `skipFieldPaths` and it must manually be handled in the conversion function.

func FromRawExtension

func FromRawExtension(r runtime.RawExtension) (unstructured.Unstructured, error)

FromRawExtension attempts to convert a runtime.RawExtension into an unstructured.Unstructured.

func InitializeDiscoveryClient

func InitializeDiscoveryClient(kubeconfigPath, cacheDir string) (*disk.CachedDiscoveryClient, error)

func InitializeDynamicClient

func InitializeDynamicClient(kubeconfigPath string) (dynamic.Interface, error)

InitializeDynamicClient returns a dynamic client

func NewUnsupportedStepTypeError

func NewUnsupportedStepTypeError(s Step) error

func ToComposition

func ToComposition(u unstructured.Unstructured) (*xpv1.Composition, error)

ToComposition converts the specified unstructured.Unstructured to a Crossplane Composition. Workaround for: https://github.com/kubernetes-sigs/structured-merge-diff/issues/230

func ToSanitizedUnstructured

func ToSanitizedUnstructured(mg any) unstructured.Unstructured

ToSanitizedUnstructured converts the specified managed resource to an unstructured.Unstructured. Before the converted object is returned, it's sanitized by removing certain fields (like status, metadata.creationTimestamp).

Types

type Action

type Action int

Action represents an action to be taken by the PlanExecutor. An Action is dictated by a ExecutorCallback implementation to the PlanExecutor for each step.

const (
	// ActionContinue tells the PlanExecutor to continue with the execution
	// of a Step.
	ActionContinue Action = iota
	// ActionSkip tells the PlanExecutor to skip the execution
	// of the current Step.
	ActionSkip
	// ActionCancel tells the PlanExecutor to stop executing
	// the Steps of a Plan.
	ActionCancel
	// ActionRepeat tells the PlanExecutor to repeat the execution
	// of the current Step.
	ActionRepeat
)

type ApplyStep

type ApplyStep struct {
	// Files denotes the paths of the manifest files to be applied.
	// The paths can either be relative or absolute.
	Files []string `json:"files,omitempty"`
}

ApplyStep represents an apply step in which an array of manifests is applied from the filesystem.

type CallbackResult

type CallbackResult struct {
	Action Action
}

CallbackResult is the type of a value returned from one of the callback methods of ExecutorCallback implementations.

type CategoricalConverter

type CategoricalConverter interface {
	Convert(u *UnstructuredWithMetadata) error
}

CategoricalConverter is a converter that converts resources of a given Category. Because it receives an unstructured argument, it should be used for implementing generic conversion functions acting on a specific category, such as setting a deletion policy on all the managed resources observed by the migration Source.

type CategoricalConverterFunctionFn

type CategoricalConverterFunctionFn func(u *UnstructuredWithMetadata) error

CategoricalConverterFunctionFn is a function that converts resources of a Category. Because it receives an unstructured argument, it should be used for implementing generic conversion functions acting on a specific category.

type Category

type Category string

Category specifies if a resource is a Claim, Composite or a Managed resource

const (

	// CategoryClaim category for composite claim resources
	CategoryClaim Category = "claim"
	// CategoryComposite category for composite resources
	CategoryComposite Category = "composite"
	// CategoryComposition category for compositions
	CategoryComposition Category = "composition"
	// CategoryManaged category for managed resources
	CategoryManaged Category = "managed"
	// CategoryCrossplanePackage category for provider packages
	CategoryCrossplanePackage Category = "package"
)

Resource categories

func (Category) String

func (c Category) String() string

String returns a string representing the receiver Category.

type ComposedTemplateConversionFn

type ComposedTemplateConversionFn func(sourceTemplate xpv1.ComposedTemplate, convertedTemplates ...*xpv1.ComposedTemplate) error

ComposedTemplateConversionFn is a function that converts from the specified migration source v1.ComposedTemplate to one or more migration target v1.ComposedTemplates.

func DefaultCompositionConverter

func DefaultCompositionConverter(conversionMap map[string]string, fns ...func(sourceTemplate xpv1.ComposedTemplate) ([]xpv1.Patch, error)) ComposedTemplateConversionFn

DefaultCompositionConverter is a generic composition converter conversionMap: is fieldpath map for conversion Key of the conversionMap points to the source field Value of the conversionMap points to the target field Example: "spec.forProvider.assumeRolePolicyDocument": "spec.forProvider.assumeRolePolicy", fns are functions that manipulate the patchsets

type ComposedTemplateConverter

type ComposedTemplateConverter interface {
	// ComposedTemplate receives a migration source v1.ComposedTemplate
	// that has been converted, by a resource converter, to the
	// v1.ComposedTemplates with the new shapes specified in the
	// `convertedTemplates` argument.
	// Conversion of the v1.ComposedTemplate.Bases is handled
	// via ResourceConverter.Resource and ComposedTemplate must only
	// convert the other fields (`Patches`, `ConnectionDetails`,
	// `PatchSet`s, etc.)
	// Returns any errors encountered.
	ComposedTemplate(sourceTemplate xpv1.ComposedTemplate, convertedTemplates ...*xpv1.ComposedTemplate) error
}

ComposedTemplateConverter converts a Composition's ComposedTemplate from the migration source provider's schema to the migration target provider's schema. Conversion of the `Base` must be handled by a ResourceConverter.

type CompositionConverter

type CompositionConverter interface {
	ResourceConverter
	ComposedTemplateConverter
}

CompositionConverter converts a managed resource and a Composition's ComposedTemplate that composes a managed resource of the same kind from the migration source provider's schema to the migration target provider's schema.

type ConfigurationMetadataConverter

type ConfigurationMetadataConverter interface {
	// ConfigurationMetadataV1 takes a Crossplane Configuration v1 metadata,
	// converts it, and stores the converted metadata in its argument.
	// Returns any errors encountered during the conversion.
	ConfigurationMetadataV1(configuration *xpmetav1.Configuration) error
	// ConfigurationMetadataV1Alpha1 takes a Crossplane Configuration v1alpha1
	// metadata, converts it, and stores the converted metadata in its
	// argument. Returns any errors encountered during the conversion.
	ConfigurationMetadataV1Alpha1(configuration *xpmetav1alpha1.Configuration) error
}

ConfigurationMetadataConverter converts a Crossplane Configuration's metadata.

type ConfigurationMetadataV1Alpha1ConversionFn

type ConfigurationMetadataV1Alpha1ConversionFn func(configuration *xpmetav1alpha1.Configuration) error

ConfigurationMetadataV1Alpha1ConversionFn is a function that converts the specified migration source Configuration v1alpha1 metadata to the migration target Configuration metadata.

type ConfigurationMetadataV1ConversionFn

type ConfigurationMetadataV1ConversionFn func(configuration *xpmetav1.Configuration) error

ConfigurationMetadataV1ConversionFn is a function that converts the specified migration source Configuration v1 metadata to the migration target Configuration metadata.

type ConfigurationPackageConverter

type ConfigurationPackageConverter interface {
	// ConfigurationPackageV1 takes a Crossplane Configuration v1 package,
	// converts it possibly to multiple packages and returns
	// the converted configuration package.
	// Returns any errors encountered during the conversion.
	ConfigurationPackageV1(pkg *xppkgv1.Configuration) error
}

ConfigurationPackageConverter converts a Crossplane configuration package.

type ConfigurationPackageV1ConversionFn

type ConfigurationPackageV1ConversionFn func(pkg *xppkgv1.Configuration) error

ConfigurationPackageV1ConversionFn is a function that converts the specified migration source Configuration v1 package to the migration target Configuration package(s).

type DeleteOptions

type DeleteOptions struct {
	// FinalizerPolicy denotes the policy to be used regarding
	// the managed reconciler's finalizer
	FinalizerPolicy *FinalizerPolicy `json:"finalizerPolicy,omitempty"`
}

DeleteOptions represent options to be used during deletion of a managed resource.

type DeleteStep

type DeleteStep struct {
	// Options represents the options to be used while deleting the resources
	// specified in Resources.
	Options *DeleteOptions `json:"options,omitempty"`
	// Resources is the array of resources to be deleted in this step
	Resources []Resource `json:"resources,omitempty"`
}

DeleteStep represents a deletion step with options

type ExecStep

type ExecStep struct {
	// Command is the command to run
	Command string `json:"command"`
	// Args is the arguments of the command
	Args []string `json:"args"`
}

ExecStep represents an exec command with its arguments

type Executor

type Executor interface {
	// Init initializes an executor using the supplied executor specific
	// configuration data.
	Init(config map[string]any) error
	// Step asks the executor to execute the next step passing any available
	// context from the previous step, and returns any new context to be passed
	// to the next step if there exists one.
	Step(s Step, ctx map[string]any) error
	// Destroy is called when all the steps have been executed,
	// or a step has returned an error, and we would like to stop
	// executing the plan.
	Destroy() error
}

Executor is a migration plan executor.

func NewForkExecutor

func NewForkExecutor(opts ...ForkExecutorOption) Executor

NewForkExecutor returns a new fork executor using a process forker.

type ExecutorCallback

type ExecutorCallback interface {
	// StepToExecute is called just before a migration Plan's Step is executed.
	// Can be used to cancel the execution of the Plan, or to continue/skip
	// the Step's execution.
	StepToExecute(s Step, index int) CallbackResult
	// StepSucceeded is called after a migration Plan's Step is
	// successfully executed.
	// Can be used to cancel the execution of the Plan, or to
	// continue/skip/repeat the Step's execution.
	StepSucceeded(s Step, index int, diagnostics any) CallbackResult
	// StepFailed is called after a migration Plan's Step has
	// failed to execute.
	// Can be used to cancel the execution of the Plan, or to
	// continue/skip/repeat the Step's execution.
	StepFailed(s Step, index int, diagnostics any, err error) CallbackResult
}

ExecutorCallback is the interface for the callback implementations to be notified while executing each Step of a migration Plan.

type FileSystemSource

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

FileSystemSource is a source implementation to read resources from filesystem

func NewFileSystemSource

func NewFileSystemSource(dir string, opts ...FileSystemSourceOption) (*FileSystemSource, error)

NewFileSystemSource returns a FileSystemSource

func (*FileSystemSource) HasNext

func (fs *FileSystemSource) HasNext() (bool, error)

HasNext checks the next item

func (*FileSystemSource) Next

Next returns the next item of slice

func (*FileSystemSource) Reset

func (fs *FileSystemSource) Reset() error

Reset resets the source so that resources can be reread from the beginning.

type FileSystemSourceOption

type FileSystemSourceOption func(*FileSystemSource)

FileSystemSourceOption allows you to configure FileSystemSource

func FsWithFileSystem

func FsWithFileSystem(f afero.Fs) FileSystemSourceOption

FsWithFileSystem configures the filesystem to use. Used mostly for testing.

type FileSystemTarget

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

FileSystemTarget is a target implementation to write/patch/delete resources to file system

func NewFileSystemTarget

func NewFileSystemTarget(opts ...FileSystemTargetOption) *FileSystemTarget

NewFileSystemTarget returns a FileSystemTarget

func (*FileSystemTarget) Delete

Delete deletes a file from filesystem

func (*FileSystemTarget) Put

Put writes input to filesystem

type FileSystemTargetOption

type FileSystemTargetOption func(*FileSystemTarget)

FileSystemTargetOption allows you to configure FileSystemTarget

func FtWithFileSystem

func FtWithFileSystem(f afero.Fs) FileSystemTargetOption

FtWithFileSystem configures the filesystem to use. Used mostly for testing.

func WithParentDirectory

func WithParentDirectory(parent string) FileSystemTargetOption

WithParentDirectory configures the parent directory for the FileSystemTarget

type FinalizerPolicy

type FinalizerPolicy string

FinalizerPolicy denotes the policy regarding the managed reconciler's finalizer while deleting a managed resource.

const (
	// FinalizerPolicyRemove is the FinalizerPolicy for removing
	// the managed reconciler's finalizer from a managed resource.
	FinalizerPolicyRemove FinalizerPolicy = "Remove" // Default
)

type ForkExecutorOption

type ForkExecutorOption func(executor *forkExecutor)

ForkExecutorOption allows you to configure forkExecutor objects.

func WithExecutor

func WithExecutor(e exec.Interface) ForkExecutorOption

WithExecutor sets the executor of ForkExecutor.

func WithLogger

func WithLogger(l logging.Logger) ForkExecutorOption

WithLogger sets the logger of forkExecutor.

func WithWorkingDir

func WithWorkingDir(dir string) ForkExecutorOption

WithWorkingDir sets the current working directory for the executor.

type GroupVersionKind

type GroupVersionKind struct {
	// Group is the API group for the resource
	Group string `json:"group"`
	// Version is the API version for the resource
	Version string `json:"version"`
	// Kind is the kind name for the resource
	Kind string `json:"kind"`
}

GroupVersionKind represents the GVK for an object's kind. schema.GroupVersionKind does not contain json the serialization tags for its fields, but we would like to serialize these as part of the migration plan.

func FromGroupVersionKind

func FromGroupVersionKind(gvk schema.GroupVersionKind) GroupVersionKind

FromGroupVersionKind converts a schema.GroupVersionKind into a migration.GroupVersionKind.

type KubernetesSource

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

KubernetesSource is a source implementation to read resources from Kubernetes cluster.

func NewKubernetesSource

func NewKubernetesSource(dynamicClient dynamic.Interface, discoveryClient discovery.CachedDiscoveryInterface, opts ...KubernetesSourceOption) (*KubernetesSource, error)

NewKubernetesSource returns a KubernetesSource DynamicClient is used here to query resources. Elements of gvks (slice of GroupVersionKind) are passed to the Dynamic Client in a loop to get list of resources. An example element of gvks slice: Group: "ec2.aws.upbound.io", Version: "v1beta1", Kind: "VPC",

func NewKubernetesSourceFromKubeConfig

func NewKubernetesSourceFromKubeConfig(kubeconfigPath string, opts ...KubernetesSourceOption) (*KubernetesSource, error)

NewKubernetesSourceFromKubeConfig initializes a new KubernetesSource using the specified kube config file and KubernetesSourceOptions.

func (*KubernetesSource) HasNext

func (ks *KubernetesSource) HasNext() (bool, error)

HasNext checks the next item

func (*KubernetesSource) Next

Next returns the next item of slice

func (*KubernetesSource) Reset

func (ks *KubernetesSource) Reset() error

Reset resets the source so that resources can be reread from the beginning.

type KubernetesSourceOption

type KubernetesSourceOption func(source *KubernetesSource)

KubernetesSourceOption sets an option for a KubernetesSource.

func WithCacheDir

func WithCacheDir(cacheDir string) KubernetesSourceOption

WithCacheDir sets the cache directory for the disk cached discovery client used by a KubernetesSource.

func WithCategories

func WithCategories(c []Category) KubernetesSourceOption

WithCategories configures a KubernetesSource so that it will fetch all resources belonging to the specified categories.

func WithRegistry

func WithRegistry(r *Registry) KubernetesSourceOption

WithRegistry configures a KubernetesSource to use the specified registry for determining the GVKs of resources which will be read from the Kubernetes API server.

type ManagedPreProcessor

type ManagedPreProcessor interface {
	// ResourcePreProcessor is called for a manifest read by the Source
	// before any converters are run.
	ResourcePreProcessor(mg resource.Managed) error
}

ManagedPreProcessor allows manifests read by the Source to be pre-processed before the converters are run. These pre-processors will work for GVKs that have ResourceConverter registered.

type Metadata

type Metadata struct {
	// Path uniquely identifies the path for this object on its Source
	Path string
	// colon separated list of parent `Path`s for fan-ins and fan-outs
	// Example: resources/a.yaml:resources/b.yaml
	Parents string
	// Category specifies if the associated resource is a Claim, Composite or a
	// Managed resource
	Category Category
}

Metadata holds metadata for an object read from a Source

type PackageLockConverter

type PackageLockConverter interface {
	// PackageLockV1Beta1 takes a Crossplane v1beta1 package lock,
	// converts it, and stores the converted lock in its argument.
	// Returns any errors encountered during the conversion.
	PackageLockV1Beta1(lock *xppkgv1beta1.Lock) error
}

PackageLockConverter converts a Crossplane package lock.

type PackageLockV1Beta1ConversionFn

type PackageLockV1Beta1ConversionFn func(pkg *xppkgv1beta1.Lock) error

PackageLockV1Beta1ConversionFn is a function that converts the specified migration source package v1beta1 lock to the migration target package lock.

type PatchSetConverter

type PatchSetConverter interface {
	// PatchSets converts the `spec.patchSets` of a Composition
	// from the migration source provider's schema to the migration target
	// provider's schema.
	PatchSets(psMap map[string]*xpv1.PatchSet) error
}

PatchSetConverter converts patch sets of Compositions. Any registered PatchSetConverters will be called before any resource or ComposedTemplate conversion is done. The rationale is to convert the Composition-wide patch sets before any resource-specific conversions so that migration targets can automatically inherit converted patch sets if their schemas match them. Registered PatchSetConverters will be called in the order they are registered.

type PatchSetsConversionFn

type PatchSetsConversionFn func(psMap map[string]*xpv1.PatchSet) error

PatchSetsConversionFn is a function that converts the `spec.patchSets` of a Composition from the migration source provider's schema to the migration target provider's schema.

type PatchStep

type PatchStep struct {
	// Files denotes the paths of the manifest files
	// to be used as patch documents.
	// The paths can either be relative or absolute.
	Files []string `json:"files,omitempty"`
	// Type is the PatchType to be used in this step
	Type PatchType `json:"type,omitempty"`
}

PatchStep represents a patch step in which an array of manifests is used to patch resources.

type PatchType

type PatchType string

PatchType represents the patch type used in a patch operation

const (
	// PatchTypeStrategic represents the strategic merge patch
	PatchTypeStrategic PatchType = "strategic"
	// PatchTypeMerge represents the RFC 7386 JSON merge patch
	PatchTypeMerge PatchType = "merge"
	// PatchTypeJSON represents the RFC 6902 JSON patch
	PatchTypeJSON PatchType = "json"
)

type Plan

type Plan struct {
	Version string `json:"version"`
	Spec    Spec   `json:"spec,omitempty"`
}

Plan represents a migration plan for migrating managed resources, and associated composites and claims from a migration source provider to a migration target provider.

type PlanExecutor

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

PlanExecutor drives the execution of a plan's steps and uses the configured `executors` to execute those steps.

func NewPlanExecutor

func NewPlanExecutor(plan Plan, executors []Executor, opts ...PlanExecutorOption) *PlanExecutor

NewPlanExecutor returns a new plan executor for executing the steps of a migration plan.

func (*PlanExecutor) Execute

func (pe *PlanExecutor) Execute() error

type PlanExecutorOption

type PlanExecutorOption func(executor *PlanExecutor)

PlanExecutorOption is a mutator function for setting an option of a PlanExecutor.

func WithExecutorCallback

func WithExecutorCallback(cb ExecutorCallback) PlanExecutorOption

WithExecutorCallback configures an ExecutorCallback for a PlanExecutor to be notified as the Plan's Step's are executed.

type PlanGenerator

type PlanGenerator struct {

	// Plan is the migration.Plan whose steps are expected
	// to complete a migration when they're executed in order.
	Plan Plan
	// ErrorOnInvalidPatchSchema errors and stops plan generation in case
	// an error is encountered while checking the conformance of a patch
	// statement against the migration source or the migration target.
	ErrorOnInvalidPatchSchema bool
	// GVKs of managed resources that
	// should be skipped for conversion during the migration, if no
	// converters are registered for them. If any of the GVK components
	// is left empty, it will be a wildcard component.
	// Exact matching with an empty group name is not possible.
	SkipGVKs []schema.GroupVersionKind
	// contains filtered or unexported fields
}

PlanGenerator generates a migration.Plan reading the manifests available from `source`, converting managed resources and compositions using the available `migration.Converter`s registered in the `registry` and writing the output manifests to the specified `target`.

func NewPlanGenerator

func NewPlanGenerator(registry *Registry, source Source, target Target, opts ...PlanGeneratorOption) PlanGenerator

NewPlanGenerator constructs a new PlanGenerator using the specified Source and Target and the default converter Registry.

func (*PlanGenerator) GeneratePlan

func (pg *PlanGenerator) GeneratePlan() error

GeneratePlan generates a migration plan for the manifests available from the configured Source and writing them to the configured Target using the configured converter Registry. The generated Plan is available in the PlanGenerator.Plan variable if the generation is successful (i.e., no errors are reported).

type PlanGeneratorOption

type PlanGeneratorOption func(generator *PlanGenerator)

PlanGeneratorOption configures a PlanGenerator

func WithEnableConfigurationMigrationSteps

func WithEnableConfigurationMigrationSteps() PlanGeneratorOption

WithEnableConfigurationMigrationSteps enables only the configuration migration steps. TODO: to be replaced with a higher abstraction encapsulating migration scenarios.

func WithEnableOnlyFileSystemAPISteps

func WithEnableOnlyFileSystemAPISteps() PlanGeneratorOption

func WithErrorOnInvalidPatchSchema

func WithErrorOnInvalidPatchSchema(e bool) PlanGeneratorOption

WithErrorOnInvalidPatchSchema returns a PlanGeneratorOption for configuring whether the PlanGenerator should error and stop the migration plan generation in case an error is encountered while checking a patch statement's conformance to the migration source or target.

func WithMultipleSources

func WithMultipleSources(source ...Source) PlanGeneratorOption

WithMultipleSources can be used to configure multiple sources for a PlanGenerator.

func WithSkipGVKs

func WithSkipGVKs(gvk ...schema.GroupVersionKind) PlanGeneratorOption

WithSkipGVKs configures the set of GVKs to skip for conversion during a migration.

type PreProcessor

type PreProcessor func(u UnstructuredWithMetadata) error

PreProcessor is a function type to convert pre-processor functions to UnstructuredPreProcessor.

func (PreProcessor) PreProcess

func (pp PreProcessor) PreProcess(u UnstructuredWithMetadata) error

type ProviderPackageConverter

type ProviderPackageConverter interface {
	// ProviderPackageV1 takes a Crossplane Provider v1 package,
	// converts it possibly to multiple packages and returns the
	// converted provider packages.
	// Returns any errors encountered during the conversion.
	ProviderPackageV1(pkg xppkgv1.Provider) ([]xppkgv1.Provider, error)
}

ProviderPackageConverter converts a Crossplane provider package.

type ProviderPackageV1ConversionFn

type ProviderPackageV1ConversionFn func(pkg xppkgv1.Provider) ([]xppkgv1.Provider, error)

ProviderPackageV1ConversionFn is a function that converts the specified migration source provider v1 package to the migration target Provider package(s).

type Registry

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

Registry is a registry of `migration.Converter`s keyed with the associated `schema.GroupVersionKind`s and an associated runtime.Scheme with which the corresponding types are registered.

func NewRegistry

func NewRegistry(scheme *runtime.Scheme) *Registry

NewRegistry returns a new Registry initialized with the specified runtime.Scheme.

func (*Registry) AddClaimType

func (r *Registry) AddClaimType(gvk schema.GroupVersionKind)

AddClaimType registers a new composite resource claim type with the given GVK

func (*Registry) AddCompositeType

func (r *Registry) AddCompositeType(gvk schema.GroupVersionKind)

AddCompositeType registers a new composite resource type with the given GVK

func (*Registry) AddCompositionTypes

func (r *Registry) AddCompositionTypes() error

AddCompositionTypes registers the Composition types with the registry's scheme. Only the v1 API of Compositions is currently supported.

func (*Registry) AddCrossplanePackageTypes

func (r *Registry) AddCrossplanePackageTypes() error

AddCrossplanePackageTypes registers the {Provider,Configuration,Lock, etc.}.pkg types with the registry's scheme.

func (*Registry) AddToScheme

func (r *Registry) AddToScheme(sb func(scheme *runtime.Scheme) error) error

AddToScheme registers types with this Registry's runtime.Scheme

func (*Registry) GetAllRegisteredGVKs

func (r *Registry) GetAllRegisteredGVKs() []schema.GroupVersionKind

GetAllRegisteredGVKs returns a list of registered GVKs including v1.CompositionGroupVersionKind, metav1.ConfigurationGroupVersionKind, metav1alpha1.ConfigurationGroupVersionKind pkg.ConfigurationGroupVersionKind, pkg.ProviderGroupVersionKind, pkg.LockGroupVersionKind.

func (*Registry) GetCompositionGVKs

func (r *Registry) GetCompositionGVKs() []schema.GroupVersionKind

GetCompositionGVKs returns the registered Composition GVKs.

func (*Registry) GetCrossplanePackageGVKs

func (r *Registry) GetCrossplanePackageGVKs() []schema.GroupVersionKind

GetCrossplanePackageGVKs returns the registered Crossplane package GVKs.

func (*Registry) GetManagedResourceGVKs

func (r *Registry) GetManagedResourceGVKs() []schema.GroupVersionKind

GetManagedResourceGVKs returns a list of all registered managed resource GVKs

func (*Registry) RegisterAPIConversionFunctions

func (r *Registry) RegisterAPIConversionFunctions(gvk schema.GroupVersionKind, rFn ResourceConversionFn, cmpFn ComposedTemplateConversionFn, psFn PatchSetsConversionFn)

RegisterAPIConversionFunctions registers the supplied ResourceConversionFn and ComposedTemplateConversionFn for the specified GVK, and the supplied PatchSetsConversionFn for all the discovered Compositions. The specified GVK must belong to a Crossplane managed resource type and the type must already have been registered with this registry's scheme by calling Registry.AddToScheme.

func (*Registry) RegisterCategoricalConverter

func (r *Registry) RegisterCategoricalConverter(c Category, converter CategoricalConverter)

RegisterCategoricalConverter registers the specified CategoricalConverter for the specified Category of resources.

func (*Registry) RegisterCategoricalConverterFunction

func (r *Registry) RegisterCategoricalConverterFunction(c Category, converterFn CategoricalConverterFunctionFn)

RegisterCategoricalConverterFunction registers the specified CategoricalConverterFunctionFn for the specified Category.

func (*Registry) RegisterCompositionConverter

func (r *Registry) RegisterCompositionConverter(gvk schema.GroupVersionKind, conv CompositionConverter)

RegisterCompositionConverter is a convenience method for registering both a ResourceConverter and a ComposedTemplateConverter that act on the same managed resource kind and are implemented by the same type.

func (*Registry) RegisterConfigurationMetadataConverter

func (r *Registry) RegisterConfigurationMetadataConverter(re *regexp.Regexp, confConv ConfigurationMetadataConverter)

RegisterConfigurationMetadataConverter registers the given ConfigurationMetadataConverter for the configurations whose name match the given regular expression.

func (*Registry) RegisterConfigurationMetadataV1Alpha1ConversionFunction

func (r *Registry) RegisterConfigurationMetadataV1Alpha1ConversionFunction(re *regexp.Regexp, confConversionFn ConfigurationMetadataV1Alpha1ConversionFn)

RegisterConfigurationMetadataV1Alpha1ConversionFunction registers the specified ConfigurationMetadataV1Alpha1ConversionFn for the v1alpha1 configurations whose name match the given regular expression.

func (*Registry) RegisterConfigurationMetadataV1ConversionFunction

func (r *Registry) RegisterConfigurationMetadataV1ConversionFunction(re *regexp.Regexp, confConversionFn ConfigurationMetadataV1ConversionFn)

RegisterConfigurationMetadataV1ConversionFunction registers the specified ConfigurationMetadataV1ConversionFn for the v1 configurations whose name match the given regular expression.

func (*Registry) RegisterConfigurationPackageConverter

func (r *Registry) RegisterConfigurationPackageConverter(re *regexp.Regexp, pkgConv ConfigurationPackageConverter)

RegisterConfigurationPackageConverter registers the specified ConfigurationPackageConverter for the Configuration v1 packages whose reference match the given regular expression.

func (*Registry) RegisterConfigurationPackageV1ConversionFunction

func (r *Registry) RegisterConfigurationPackageV1ConversionFunction(re *regexp.Regexp, confConversionFn ConfigurationPackageV1ConversionFn)

RegisterConfigurationPackageV1ConversionFunction registers the specified ConfigurationPackageV1ConversionFn for the Configuration v1 packages whose reference match the given regular expression.

func (*Registry) RegisterConversionFunctions

func (r *Registry) RegisterConversionFunctions(gvk schema.GroupVersionKind, rFn ResourceConversionFn, cmpFn ComposedTemplateConversionFn, psFn PatchSetsConversionFn)

RegisterConversionFunctions registers the supplied ResourceConversionFn and ComposedTemplateConversionFn for the specified GVK, and the supplied PatchSetsConversionFn for all the discovered Compositions. The specified GVK must belong to a Crossplane managed resource type and the type must already have been registered with this registry's scheme by calling Registry.AddToScheme. Deprecated: Use RegisterAPIConversionFunctions instead.

func (*Registry) RegisterPackageLockConverter

func (r *Registry) RegisterPackageLockConverter(re *regexp.Regexp, lockConv PackageLockConverter)

RegisterPackageLockConverter registers the given PackageLockConverter.

func (*Registry) RegisterPackageLockV1Beta1ConversionFunction

func (r *Registry) RegisterPackageLockV1Beta1ConversionFunction(re *regexp.Regexp, lockConversionFn PackageLockV1Beta1ConversionFn)

RegisterPackageLockV1Beta1ConversionFunction registers the specified RegisterPackageLockV1Beta1ConversionFunction for the package v1beta1 locks.

func (*Registry) RegisterPatchSetConverter

func (r *Registry) RegisterPatchSetConverter(re *regexp.Regexp, psConv PatchSetConverter)

RegisterPatchSetConverter registers the given PatchSetConverter for the compositions whose name match the given regular expression.

func (*Registry) RegisterPreProcessor

func (r *Registry) RegisterPreProcessor(category Category, pp UnstructuredPreProcessor)

func (*Registry) RegisterProviderPackageConverter

func (r *Registry) RegisterProviderPackageConverter(re *regexp.Regexp, pkgConv ProviderPackageConverter)

RegisterProviderPackageConverter registers the given ProviderPackageConverter for the provider packages whose references match the given regular expression.

func (*Registry) RegisterProviderPackageV1ConversionFunction

func (r *Registry) RegisterProviderPackageV1ConversionFunction(re *regexp.Regexp, pkgConversionFn ProviderPackageV1ConversionFn)

RegisterProviderPackageV1ConversionFunction registers the specified ProviderPackageV1ConversionFn for the provider v1 packages whose reference match the given regular expression.

func (*Registry) RegisterResourceConverter

func (r *Registry) RegisterResourceConverter(gvk schema.GroupVersionKind, conv ResourceConverter)

RegisterResourceConverter registers the specified ResourceConverter for the specified GVK with this Registry.

func (*Registry) RegisterResourcePreProcessor

func (r *Registry) RegisterResourcePreProcessor(pp ManagedPreProcessor)

func (*Registry) RegisterTemplateConverter

func (r *Registry) RegisterTemplateConverter(gvk schema.GroupVersionKind, conv ComposedTemplateConverter)

RegisterTemplateConverter registers the specified ComposedTemplateConverter for the specified GVK with this Registry.

type Resource

type Resource struct {
	// GroupVersionKind holds the GVK for the resource's type
	// schema.GroupVersionKind is not embedded for consistent serialized names
	GroupVersionKind `json:",inline"`
	// Name is the name of the resource
	Name string `json:"name"`
}

type ResourceConversionFn

type ResourceConversionFn func(mg resource.Managed) ([]resource.Managed, error)

ResourceConversionFn is a function that converts the specified migration source managed resource to one or more migration target managed resources.

type ResourceConverter

type ResourceConverter interface {
	// Resource takes a managed resource and returns zero or more managed
	// resources to be created.
	Resource(mg resource.Managed) ([]resource.Managed, error)
}

ResourceConverter converts a managed resource from the migration source provider's schema to the migration target provider's schema.

type ResourcePreProcessor

type ResourcePreProcessor func(mg resource.Managed) error

func (ResourcePreProcessor) ResourcePreProcessor

func (pp ResourcePreProcessor) ResourcePreProcessor(mg resource.Managed) error

type Source

type Source interface {
	// HasNext returns `true` if the Source implementation has a next manifest
	// available to return with a call to Next. Any errors encountered while
	// determining whether a next manifest exists will also be reported.
	HasNext() (bool, error)
	// Next returns the next resource manifest available or
	// any errors encountered while reading the next resource manifest.
	Next() (UnstructuredWithMetadata, error)
	// Reset resets the Source so that it can read the manifests
	// from the beginning. There is no guarantee that the Source
	// will return the same set of manifests or it will return
	// them in the same order after a reset.
	Reset() error
}

Source is a source for reading resource manifests

type Spec

type Spec struct {
	// Steps are the migration plan's steps that are expected
	// to complete a migration when executed in order.
	Steps []Step `json:"steps,omitempty"`
	// contains filtered or unexported fields
}

Spec represents the specification of a migration plan

type Step

type Step struct {
	// Name is the name of this Step
	Name string `json:"name"`
	// Type is the type of this Step.
	// Can be one of Apply, Delete, etc.
	Type StepType `json:"type"`
	// Apply contains the information needed to run an StepTypeApply step.
	// Must be set when the Step.Type is StepTypeApply.
	Apply *ApplyStep `json:"apply,omitempty" yaml:"apply,omitempty"`
	// Patch contains the information needed to run a StepTypePatch step.
	Patch *PatchStep `json:"patch,omitempty" yaml:"patch,omitempty"`
	// Delete contains the information needed to run an StepTypeDelete step.
	// Must be set when the Step.Type is StepTypeDelete.
	Delete *DeleteStep `json:"delete,omitempty" yaml:"delete,omitempty"`
	// Exec contains the information needed to run a StepTypeExec step.
	Exec *ExecStep `json:"exec,omitempty" yaml:"exec,omitempty"`
	// ManualExecution string is to make copy/pasting easier for folks.
	ManualExecution []string `json:"manualExecution,omitempty" yaml:"manualExecution,omitempty"`
}

Step represents a step in the generated migration plan

type StepType

type StepType string

StepType is the type used to name a migration step

const (
	// StepTypeApply denotes an apply step
	StepTypeApply StepType = "Apply"
	// StepTypePatch denotes a patch step, where a resource is patched
	// using the given JSON patch document.
	StepTypePatch StepType = "Patch"
	// StepTypeDelete denotes a delete step
	StepTypeDelete StepType = "Delete"
	// StepTypeExec executes the command with provided args
	StepTypeExec StepType = "Exec"
)

type Target

type Target interface {
	// Put writes a resource manifest to this Target
	Put(o UnstructuredWithMetadata) error
	// Delete deletes a resource manifest from this Target
	Delete(o UnstructuredWithMetadata) error
}

Target is a target where resource manifests can be manipulated (e.g., added, deleted, patched, etc.)

type UnstructuredPreProcessor

type UnstructuredPreProcessor interface {
	// PreProcess is called for a manifest read by the Source
	// before any converters are run.
	PreProcess(u UnstructuredWithMetadata) error
}

UnstructuredPreProcessor allows manifests read by the Source to be pre-processed before the converters are run It's not possible to do any conversions via the pre-processors, and they only allow migrators to extract information from the manifests read by the Source before any converters are run.

type UnstructuredWithMetadata

type UnstructuredWithMetadata struct {
	Object   unstructured.Unstructured
	Metadata Metadata
}

UnstructuredWithMetadata represents an unstructured.Unstructured together with the associated Metadata.

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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