helper methods, types, and unit tests for transformer annotations

This commit is contained in:
natasha41575
2021-12-29 15:13:04 -08:00
parent 77b1af2d91
commit 4f21d60045
10 changed files with 428 additions and 15 deletions

View File

@@ -21,6 +21,13 @@ type Transformer interface {
Transform(m ResMap) error
}
// A TransformerWithProperties contains a Transformer and stores
// some of its properties
type TransformerWithProperties struct {
Transformer
Origin *resource.Origin
}
// A Generator creates an instance of ResMap.
type Generator interface {
Generate() (ResMap, error)
@@ -144,10 +151,24 @@ type ResMap interface {
AbsorbAll(ResMap) error
// AddOriginAnnotation will add the provided origin as
// an annotation to all resources in the Resmap, if
// an origin annotation to all resources in the ResMap, if
// the origin is not nil.
AddOriginAnnotation(origin *resource.Origin) error
// RemoveOriginAnnotation will remove the origin annotation
// from all resources in the ResMap
RemoveOriginAnnotations() error
// AddTransformerAnnotation will add the provided origin as
// an origin annotation if the resource doesn't have one; a
// transformer annotation otherwise; to all resources in
// ResMap
AddTransformerAnnotation(origin *resource.Origin) error
// RemoveTransformerAnnotation will remove the transformer annotation
// from all resources in the ResMap
RemoveTransformerAnnotations() error
// AnnotateAll annotates all resources in the ResMap with
// the provided key value pair.
AnnotateAll(key string, value string) error