config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDatasourceName = "test"

DefaultDatasourceName is exported to allow assertions against the resources using the default name.

View Source
const DefaultResourceName = "test"

DefaultResourceName is exported to allow assertions against the resources using the default name.

Variables

View Source
var DefaultHclConfigProvider = NewHclV1ConfigProvider(unquoteBlockType, fixBlockArguments, fixMultilinePrivateKey, unquoteArguments, unquoteArguments, removeDoubleNewlines, unquoteDependsOnReferences)
View Source
var DefaultJsonConfigProvider = NewBasicJsonConfigProvider()

Functions

func ConfigVariablesFromModel added in v0.96.0

func ConfigVariablesFromModel(t *testing.T, model ResourceModel) tfconfig.Variables

ConfigVariablesFromModel constructs config.Variables needed in acceptance tests that are using ConfigVariables in combination with ConfigDirectory. It's necessary for cases not supported by FromModel, like lists of objects. Use ResourceFromModel, DatasourceFromModel, ProviderFromModel, and FromModels instead.

func ConfigVariablesFromModels added in v0.99.0

func ConfigVariablesFromModels(t *testing.T, variableName string, models ...ResourceModel) tfconfig.Variables

ConfigVariablesFromModels can be used to create a list of objects that are referring to the same resource model. It's useful when there's a need to create associations between objects of the same type in Snowflake.

func DatasourceFromModel added in v1.0.0

func DatasourceFromModel(t *testing.T, model DatasourceModel) string

DatasourceFromModel should be used in terraform acceptance tests for Config attribute to get string config from DatasourceModel. Current implementation is an improved implementation using two steps: - .tf.json generation - conversion to HCL using hcl v1 lib It is still not ideal. HCL v2 should be considered.

func FromModel

func FromModel(t *testing.T, model ResourceModel) string

FromModel should be used in terraform acceptance tests for Config attribute to get string config from ResourceModel. Current implementation is really straightforward but it could be improved and tested. It may not handle all cases (like objects, lists, sets) correctly. TODO [SNOW-1501905]: use reflection to build config directly from model struct (or some other different way) TODO [SNOW-1501905]: add support for config.TestStepConfigFunc (to use as ConfigFile); the naive implementation would be to just create a tmp directory and save file there TODO [SNOW-1501905]: add generating MarshalJSON() function TODO [SNOW-1501905]: migrate resources to new config generation method (above needed first) Use ResourceFromModel, DatasourceFromModel, ProviderFromModel, and FromModels instead.

func FromModels added in v0.98.0

func FromModels(t *testing.T, models ...any) string

FromModels allows to combine multiple models. TODO [SNOW-1501905]: introduce some common interface for all three existing models (ResourceModel, DatasourceModel, and ProviderModel)

func FromModelsDeprecated added in v1.0.0

func FromModelsDeprecated(t *testing.T, models ...ResourceModel) string

FromModelsDeprecated allows to combine multiple resource models. Use FromModels instead.

func NullVariable added in v0.95.0

func NullVariable() nullVariable

NullVariable returns nullVariable which implements Variable.

func ProviderFromModel added in v1.0.0

func ProviderFromModel(t *testing.T, model ProviderModel) string

ProviderFromModel should be used in terraform acceptance tests for Config attribute to get string config from ProviderModel. Current implementation is an improved implementation using two steps: - .tf.json generation - conversion to HCL using hcl v1 lib It is still not ideal. HCL v2 should be considered.

func ResourceFromModel added in v1.0.0

func ResourceFromModel(t *testing.T, model ResourceModel) string

ResourceFromModel should be used in terraform acceptance tests for Config attribute to get string config from ResourceModel. Current implementation is an improved implementation using two steps: - .tf.json generation - conversion to HCL using hcl v1 lib It is still not ideal. HCL v2 should be considered.

Types

type DatasourceModel added in v1.0.0

type DatasourceModel interface {
	Datasource() datasources.Datasource
	DatasourceName() string
	SetDatasourceName(name string)
	DatasourceReference() string
	DependsOn() []string
	SetDependsOn(values ...string)
}

DatasourceModel is the base interface all of our datasource config models will implement. To allow easy implementation, DatasourceModelMeta can be embedded inside the struct (and the struct will automatically implement it). TODO [SNOW-1501905]: consider merging ResourceModel with DatasourceModel (currently the implementation is really similar)

type DatasourceModelMeta added in v1.0.0

type DatasourceModelMeta struct {
	// contains filtered or unexported fields
}

func DatasourceDefaultMeta added in v1.0.0

func DatasourceDefaultMeta(datasource datasources.Datasource) *DatasourceModelMeta

func DatasourceMeta added in v1.0.0

func DatasourceMeta(resourceName string, datasource datasources.Datasource) *DatasourceModelMeta

func (*DatasourceModelMeta) Datasource added in v1.0.0

func (m *DatasourceModelMeta) Datasource() datasources.Datasource

func (*DatasourceModelMeta) DatasourceName added in v1.0.0

func (m *DatasourceModelMeta) DatasourceName() string

func (*DatasourceModelMeta) DatasourceReference added in v1.0.0

func (m *DatasourceModelMeta) DatasourceReference() string

func (*DatasourceModelMeta) DependsOn added in v1.0.0

func (m *DatasourceModelMeta) DependsOn() []string

func (*DatasourceModelMeta) SetDatasourceName added in v1.0.0

func (m *DatasourceModelMeta) SetDatasourceName(name string)

func (*DatasourceModelMeta) SetDependsOn added in v1.0.0

func (m *DatasourceModelMeta) SetDependsOn(values ...string)

type HclConfigProvider added in v1.0.0

type HclConfigProvider interface {
	HclFromJson(json []byte) (string, error)
}

HclConfigProvider defines methods to generate .tf config from .tf.json configs.

func NewHclV1ConfigProvider added in v1.0.0

func NewHclV1ConfigProvider(formatters ...HclFormatter) HclConfigProvider

type HclFormatter added in v1.0.0

type HclFormatter func(string) (string, error)

type JsonConfigProvider added in v1.0.0

type JsonConfigProvider interface {
	ResourceJsonFromModel(model ResourceModel) ([]byte, error)
	DatasourceJsonFromModel(model DatasourceModel) ([]byte, error)
	ProviderJsonFromModel(model ProviderModel) ([]byte, error)
}

JsonConfigProvider defines methods to generate .tf.json configs. TODO [SNOW-1501905]: add config builders for other block types (Variable, Output, Localsl, Module, Terraform)

func NewBasicJsonConfigProvider added in v1.0.0

func NewBasicJsonConfigProvider() JsonConfigProvider

type ProviderModel added in v1.0.0

type ProviderModel interface {
	ProviderName() string
	Alias() string
}

ProviderModel is the base interface all of our provider config models will implement. To allow easy implementation, ProviderModelMeta can be embedded inside the struct (and the struct will automatically implement it).

type ProviderModelMeta added in v1.0.0

type ProviderModelMeta struct {
	// contains filtered or unexported fields
}

func DefaultProviderMeta added in v1.0.0

func DefaultProviderMeta(name string) *ProviderModelMeta

func ProviderMeta added in v1.0.0

func ProviderMeta(name string, alias string) *ProviderModelMeta

func (*ProviderModelMeta) Alias added in v1.0.0

func (m *ProviderModelMeta) Alias() string

func (*ProviderModelMeta) ProviderName added in v1.0.0

func (m *ProviderModelMeta) ProviderName() string

type ReplacementPlaceholder added in v1.0.0

type ReplacementPlaceholder string
const SnowflakeProviderConfigPrivateKey ReplacementPlaceholder = "SF_TF_TEST_MULTILINE_PLACEHOLDER_PRIVATE_KEY"

type ResourceModel

type ResourceModel interface {
	Resource() resources.Resource
	ResourceName() string
	SetResourceName(name string)
	ResourceReference() string
	DependsOn() []string
	SetDependsOn(values ...string)
}

ResourceModel is the base interface all of our resource config models will implement. To allow easy implementation, ResourceModelMeta can be embedded inside the struct (and the struct will automatically implement it).

type ResourceModelMeta

type ResourceModelMeta struct {
	// contains filtered or unexported fields
}

func DefaultMeta

func DefaultMeta(resource resources.Resource) *ResourceModelMeta

func Meta

func Meta(resourceName string, resource resources.Resource) *ResourceModelMeta

func (*ResourceModelMeta) DependsOn added in v0.95.0

func (m *ResourceModelMeta) DependsOn() []string

func (*ResourceModelMeta) Resource

func (m *ResourceModelMeta) Resource() resources.Resource

func (*ResourceModelMeta) ResourceName

func (m *ResourceModelMeta) ResourceName() string

func (*ResourceModelMeta) ResourceReference added in v0.95.0

func (m *ResourceModelMeta) ResourceReference() string

func (*ResourceModelMeta) SetDependsOn added in v0.95.0

func (m *ResourceModelMeta) SetDependsOn(values ...string)

func (*ResourceModelMeta) SetResourceName

func (m *ResourceModelMeta) SetResourceName(name string)

Directories

Path Synopsis
gen
gen
gen

Jump to

Keyboard shortcuts

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