configs

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyTestConfig = TestConfig{TerraformCreate: "", APICreate: "{}", TerraformUpdate: "", APIUpdate: "{}"}

Functions

func SkipZeroValue

func SkipZeroValue(a interface{}) bool

SkipZeroValue is a ValueFilter that returns true if the value is golang's zero value or an empty slice.

func StringMatchesRegexp

func StringMatchesRegexp(rs string) schema.SchemaValidateDiagFunc

func StringNotMatchesRegexp

func StringNotMatchesRegexp(rs string) schema.SchemaValidateDiagFunc

Types

type ConfigConditionFunc

type ConfigConditionFunc func(config string) bool

ConfigConditionFunc is a function that checks a provided API config object for some condition and returns true if the condition is met.

func Equals

func Equals(key string, value string) ConfigConditionFunc

equals returns a ConfigConditionFunc that is true if the API config contains the specified key and it has the specified value.

type ConfigMeta

type ConfigMeta struct {
	APIType      string
	SkipConfig   bool
	ConfigSchema map[string]*schema.Schema
	Properties   []ConfigProperty
}

func (*ConfigMeta) APIToState

func (cm *ConfigMeta) APIToState(api string) (string, error)

func (*ConfigMeta) StateToAPI

func (cm *ConfigMeta) StateToAPI(state string) (string, error)

type ConfigProperty

type ConfigProperty struct {
	ToStateFunc   ToStateFunc
	FromStateFunc FromStateFunc
}

ConfigProperty defines how a property in a API config object (e.g source/destination config) maps to terraform state and vice versa.

func ArrayWithObjects

func ArrayWithObjects(rootAPIKey string, terraformKey string, fields map[string]string) ConfigProperty

func ArrayWithStrings

func ArrayWithStrings(rootAPIKey string, nestedAPIField string, terraformKey string) ConfigProperty

func Conditional

func Conditional(apiKey, terraformKey string, condition ConfigConditionFunc) ConfigProperty

conditional returns a ConfigProperty that maps an API config key to a terraform config key only if provided condition is satisfied for that API config.

func Discriminator

func Discriminator(apiKey string, values DiscriminatorValues) ConfigProperty

discriminator returns a ConfigProperty that is not stored directly in terraform state. The corresponding API config value is set based on the provided DiscriminatorValues. if a DiscriminatorValues key exists in terraform state, the corresponding value in the values object is used.

func Simple

func Simple(apiKey, terraformKey string, filters ...ValueFilter) ConfigProperty

Simple returns a ConfigProperty that maps an API config key to a terraform config key and vice versa. Additional ValueFilter filters can be applied to ignore a field in state depending on its value.

type DiscriminatorValues

type DiscriminatorValues map[string]interface{}

DiscriminatorValues is a map of API config values for discriminator fields, mapped to a terraform state key of a config.

type FromStateFunc

type FromStateFunc func(config string, state string) (string, error)

FromStateFunc modifies am API config json object using terraform state information provided by a ResourceData object. It returns the modified config and an optional error.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}
var (
	Sources      *Registry = &Registry{name: "sources"}
	Destinations *Registry = &Registry{name: "destinations"}
)

func (*Registry) Entries

func (r *Registry) Entries() map[string]ConfigMeta

func (*Registry) Register

func (r *Registry) Register(name string, cm ConfigMeta)

type TestConfig

type TestConfig struct {
	TerraformCreate string
	APICreate       string
	TerraformUpdate string
	APIUpdate       string
}

type ToStateFunc

type ToStateFunc func(state string, config string) (string, error)

ToStateFunc modifies a terraform state json object that represents a config object by extracting data from a provided API config json object. It returns the modified terraform state and an optional error.

type ValueFilter

type ValueFilter func(a interface{}) bool

Jump to

Keyboard shortcuts

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