Skip to content

Commit

Permalink
Add migration.{Converter,Source,Target} interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
  • Loading branch information
ulucinar committed Oct 24, 2022
1 parent f2c9c80 commit 99d5791
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/migration/interfaces.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Copyright 2022 Upbound Inc.
*/

package migration

import (
"github.com/crossplane/crossplane-runtime/pkg/resource"
v1 "github.com/crossplane/crossplane/apis/apiextensions/v1"
)

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

// ComposedTemplates takes a ComposedTemplate entry and returns zero or more
// ComposedTemplate with the new shape, including the necessary changes in
// its patches. Conversion of the v1.ComposedTemplate.Bases is handled
// via Converter.Resources and Converter.ComposedTemplates must only
// convert the other fields (`Patches`, `ConnectionDetails`, etc.)
ComposedTemplates(cmp v1.ComposedTemplate, convertedBase ...*v1.ComposedTemplate) error
}

type Source interface {
HasNext() (bool, error)
Next() (UnstructuredWithMetadata, error)
}

type Target interface {
Put(o UnstructuredWithMetadata) error
Patch(o UnstructuredWithMetadata) error
Delete(o UnstructuredWithMetadata) error
}

0 comments on commit 99d5791

Please sign in to comment.