config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 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(replaceNullPlaceholders, unquoteBlockType, fixBlockArguments, replaceMultilinePlaceholders, 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 EmptyListVariable added in v1.0.1

func EmptyListVariable() emptyListVariable

EmptyListVariable returns Variable representing an empty list. This is because the current hcl parser handles empty SetVariable incorrectly.

func FromModels added in v0.98.0

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

FromModels should be used in terraform acceptance tests for Config attribute to get string config from all models. FromModels allows to combine multiple model types. TODO [SNOW-1501905]: introduce some common interface for all three existing models (ResourceModel, DatasourceModel, and ProviderModel)

func MultilineWrapperVariable added in v1.0.1

func MultilineWrapperVariable(content string) multilineWrapperVariable

MultilineWrapperVariable returns Variable containing multiline content wrapped with SnowflakeProviderConfigMultilineMarker later replaced by HclFormatter.

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 ReplacementPlaceholderVariable added in v1.0.1

func ReplacementPlaceholderVariable(placeholder ReplacementPlaceholder) replacementPlaceholderVariable

ReplacementPlaceholderVariable returns Variable containing one of the ReplacementPlaceholder which is later replaced by HclFormatter.

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 (
	SnowflakeProviderConfigNull            ReplacementPlaceholder = "SF_TF_TEST_NULL_PLACEHOLDER"
	SnowflakeProviderConfigMultilineMarker ReplacementPlaceholder = "SF_TF_TEST_MULTILINE_MARKER_PLACEHOLDER"
)

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/main command
gen
gen/main command
gen
gen/main command

Jump to

Keyboard shortcuts

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