-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration.{Converter,Source,Target} interfaces
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |