resourceconverter

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: Apache-2.0 Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendAllConverted

func SendAllConverted[T any](ctx context.Context, output chan<- model.Resource, converter ResourceConverter, resources []T, transformerLists ...Transformers[T]) error

Types

type MapConverter added in v0.0.26

type MapConverter struct {
	ResourceFactory ResourceFactory
	IdField         string
	DisplayIdField  string
	TagField        TagField
}

func (*MapConverter) ToResource added in v0.0.26

func (mc *MapConverter) ToResource(ctx context.Context, x any, tags model.Tags) (model.Resource, error)

type ReflectionConverter

type ReflectionConverter struct {
	ResourceFactory ResourceFactory
	IdField         string
	DisplayIdField  string
	TagField        TagField
}

func (*ReflectionConverter) ToResource

func (rc *ReflectionConverter) ToResource(ctx context.Context, x any, tags model.Tags) (model.Resource, error)

type ResourceConverter

type ResourceConverter interface {
	ToResource(context.Context, any, model.Tags) (model.Resource, error)
}

type ResourceFactory added in v0.2.0

type ResourceFactory func() model.Resource

ResourceFactory is a factory function configured on a ResourceConverter to create a new resource with the standard, known fields filed, namely type, region, and account ID.

type TagField

type TagField struct {
	//how to fetch the tags
	//field name
	Name string `yaml:"name"`
	//name of key attribute
	Key string `yaml:"key"`
	//name of value attribute
	Value string `yaml:"value"`
}

func (TagField) IsZero added in v0.1.0

func (f TagField) IsZero() bool

type TagFunc added in v0.2.0

type TagFunc[T any] func(context.Context, T) (model.Tags, error)

TagFunc is a function that returns the tags for a given SDK value.

type TransformFunc added in v0.2.0

type TransformFunc[T any] func(context.Context, T, *model.Resource) error

TransformFunc is a function that receives a raw SDK value and uses it to mutate the passed model.Resource in some way.

func TagTransformer added in v0.2.0

func TagTransformer[T any](f TagFunc[T]) TransformFunc[T]

TagTransformer converts a TagFunc[T] into a TransformFunc[T]

type TransformResourceFunc added in v0.2.0

type TransformResourceFunc func(context.Context, *model.Resource) error

TransformResourceFunc is a function that modifies a model.Resource in some way

type Transformers added in v0.2.0

type Transformers[T any] struct {
	// contains filtered or unexported fields
}

Transformers is a constructed sequence of TransformFunc and TransformResourceFunc to modify created model.Resources.

func (*Transformers[T]) Add added in v0.2.0

func (t *Transformers[T]) Add(funcs ...TransformFunc[T])

Add adds new TransformFuncs to the list, automatically assigning names to each.

func (*Transformers[T]) AddNamed added in v0.2.0

func (t *Transformers[T]) AddNamed(name string, f TransformFunc[T])

AddNamed adds the given TransformFunc to the list under the specified name.

func (*Transformers[T]) AddNamedResource added in v0.2.0

func (t *Transformers[T]) AddNamedResource(name string, f TransformResourceFunc)

AddNamedResource adds the given TransformResourceFunc to the list under the specified name.

func (*Transformers[T]) AddResource added in v0.2.0

func (t *Transformers[T]) AddResource(funcs ...TransformResourceFunc)

AddResource adds new TransformResourceFuncs to the list, automatically assigning names to each.

func (*Transformers[T]) AddTags added in v0.2.0

func (t *Transformers[T]) AddTags(f TagFunc[T])

AddTags is a convienience function to add a tag func as a transformer

func (Transformers[T]) Apply added in v0.2.0

func (t Transformers[T]) Apply(ctx context.Context, raw T, resource *model.Resource) error

Apply applies all transform funcs in order to the specified raw SDK value and model.Resource.

Jump to

Keyboard shortcuts

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