mirror of
https://github.com/opentofu/opentofu.git
synced 2025-01-11 08:32:19 -06:00
s/Schemas/ProviderSchema/
This commit is contained in:
parent
36d34135ad
commit
cf5ebaf685
@ -122,7 +122,7 @@ func TestLocal_applyCheck(t *testing.T) {
|
||||
func TestLocal_applyEmptyDir(t *testing.T) {
|
||||
b := TestLocal(t)
|
||||
|
||||
p := TestLocalProvider(t, b, "test", providers.Schemas{})
|
||||
p := TestLocalProvider(t, b, "test", providers.ProviderSchema{})
|
||||
p.ApplyResourceChangeResponse = &providers.ApplyResourceChangeResponse{NewState: cty.ObjectVal(map[string]cty.Value{"id": cty.StringVal("yes")})}
|
||||
|
||||
op, configCleanup, done := testOperationApply(t, "./testdata/empty")
|
||||
@ -156,7 +156,7 @@ func TestLocal_applyEmptyDir(t *testing.T) {
|
||||
func TestLocal_applyEmptyDirDestroy(t *testing.T) {
|
||||
b := TestLocal(t)
|
||||
|
||||
p := TestLocalProvider(t, b, "test", providers.Schemas{})
|
||||
p := TestLocalProvider(t, b, "test", providers.ProviderSchema{})
|
||||
p.ApplyResourceChangeResponse = &providers.ApplyResourceChangeResponse{}
|
||||
|
||||
op, configCleanup, done := testOperationApply(t, "./testdata/empty")
|
||||
@ -186,7 +186,7 @@ func TestLocal_applyEmptyDirDestroy(t *testing.T) {
|
||||
func TestLocal_applyError(t *testing.T) {
|
||||
b := TestLocal(t)
|
||||
|
||||
schema := providers.Schemas{
|
||||
schema := providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_instance": {
|
||||
Block: &configschema.Block{
|
||||
@ -387,8 +387,8 @@ func testOperationApply(t *testing.T, configDir string) (*backend.Operation, fun
|
||||
// applyFixtureSchema returns a schema suitable for processing the
|
||||
// configuration in testdata/apply . This schema should be
|
||||
// assigned to a mock provider named "test".
|
||||
func applyFixtureSchema() providers.Schemas {
|
||||
return providers.Schemas{
|
||||
func applyFixtureSchema() providers.ProviderSchema {
|
||||
return providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_instance": {
|
||||
Block: &configschema.Block{
|
||||
|
@ -89,7 +89,7 @@ func TestLocal_planInAutomation(t *testing.T) {
|
||||
|
||||
func TestLocal_planNoConfig(t *testing.T) {
|
||||
b := TestLocal(t)
|
||||
TestLocalProvider(t, b, "test", providers.Schemas{})
|
||||
TestLocalProvider(t, b, "test", providers.ProviderSchema{})
|
||||
|
||||
op, configCleanup, done := testOperationPlan(t, "./testdata/empty")
|
||||
defer configCleanup()
|
||||
@ -855,8 +855,8 @@ func testReadPlan(t *testing.T, path string) *plans.Plan {
|
||||
// planFixtureSchema returns a schema suitable for processing the
|
||||
// configuration in testdata/plan . This schema should be
|
||||
// assigned to a mock provider named "test".
|
||||
func planFixtureSchema() providers.Schemas {
|
||||
return providers.Schemas{
|
||||
func planFixtureSchema() providers.ProviderSchema {
|
||||
return providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_instance": {
|
||||
Block: &configschema.Block{
|
||||
|
@ -63,7 +63,7 @@ test_instance.foo:
|
||||
func TestLocal_refreshInput(t *testing.T) {
|
||||
b := TestLocal(t)
|
||||
|
||||
schema := providers.Schemas{
|
||||
schema := providers.ProviderSchema{
|
||||
Provider: providers.Schema{
|
||||
Block: &configschema.Block{
|
||||
Attributes: map[string]*configschema.Attribute{
|
||||
@ -158,7 +158,7 @@ test_instance.foo:
|
||||
func TestLocal_refreshValidateProviderConfigured(t *testing.T) {
|
||||
b := TestLocal(t)
|
||||
|
||||
schema := providers.Schemas{
|
||||
schema := providers.ProviderSchema{
|
||||
Provider: providers.Schema{
|
||||
Block: &configschema.Block{
|
||||
Attributes: map[string]*configschema.Attribute{
|
||||
@ -305,8 +305,8 @@ func testRefreshState() *states.State {
|
||||
// refreshFixtureSchema returns a schema suitable for processing the
|
||||
// configuration in testdata/refresh . This schema should be
|
||||
// assigned to a mock provider named "test".
|
||||
func refreshFixtureSchema() providers.Schemas {
|
||||
return providers.Schemas{
|
||||
func refreshFixtureSchema() providers.ProviderSchema {
|
||||
return providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_instance": {
|
||||
Block: &configschema.Block{
|
||||
|
@ -42,7 +42,7 @@ func TestLocal(t *testing.T) *Local {
|
||||
|
||||
// TestLocalProvider modifies the ContextOpts of the *Local parameter to
|
||||
// have a provider with the given name.
|
||||
func TestLocalProvider(t *testing.T, b *Local, name string, schema providers.Schemas) *terraform.MockProvider {
|
||||
func TestLocalProvider(t *testing.T, b *Local, name string, schema providers.ProviderSchema) *terraform.MockProvider {
|
||||
// Build a mock resource provider for in-memory operations
|
||||
p := new(terraform.MockProvider)
|
||||
|
||||
|
@ -182,7 +182,7 @@ func testLocalBackend(t *testing.T, remote *Remote) backend.Enhanced {
|
||||
b := backendLocal.NewWithBackend(remote)
|
||||
|
||||
// Add a test provider to the local backend.
|
||||
p := backendLocal.TestLocalProvider(t, b, "null", providers.Schemas{
|
||||
p := backendLocal.TestLocalProvider(t, b, "null", providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"null_resource": {
|
||||
Block: &configschema.Block{
|
||||
|
@ -345,7 +345,7 @@ func testLocalBackend(t *testing.T, cloud *Cloud) backend.Enhanced {
|
||||
b := backendLocal.NewWithBackend(cloud)
|
||||
|
||||
// Add a test provider to the local backend.
|
||||
p := backendLocal.TestLocalProvider(t, b, "null", providers.Schemas{
|
||||
p := backendLocal.TestLocalProvider(t, b, "null", providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"null_resource": {
|
||||
Block: &configschema.Block{
|
||||
|
@ -6987,7 +6987,7 @@ func runTestCases(t *testing.T, testCases map[string]testCase) {
|
||||
}
|
||||
|
||||
tfschemas := &terraform.Schemas{
|
||||
Providers: map[addrs.Provider]providers.Schemas{
|
||||
Providers: map[addrs.Provider]providers.ProviderSchema{
|
||||
src.ProviderAddr.Provider: {
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
src.Addr.Resource.Resource.Type: {
|
||||
|
@ -156,7 +156,7 @@ func testProviderSchema() *providers.GetProviderSchemaResponse {
|
||||
func testSchemas() *terraform.Schemas {
|
||||
provider := testProvider()
|
||||
return &terraform.Schemas{
|
||||
Providers: map[addrs.Provider]providers.Schemas{
|
||||
Providers: map[addrs.Provider]providers.ProviderSchema{
|
||||
addrs.NewDefaultProvider("test"): provider.GetProviderSchema(),
|
||||
},
|
||||
}
|
||||
|
@ -345,8 +345,8 @@ func TestMarshalPlanValuesNoopDeposed(t *testing.T) {
|
||||
|
||||
func testSchemas() *terraform.Schemas {
|
||||
return &terraform.Schemas{
|
||||
Providers: map[addrs.Provider]providers.Schemas{
|
||||
addrs.NewDefaultProvider("test"): providers.Schemas{
|
||||
Providers: map[addrs.Provider]providers.ProviderSchema{
|
||||
addrs.NewDefaultProvider("test"): providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_thing": {
|
||||
Version: 1,
|
||||
|
@ -54,7 +54,7 @@ func Marshal(s *terraform.Schemas) ([]byte, error) {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
func marshalProvider(tps providers.Schemas) *Provider {
|
||||
func marshalProvider(tps providers.ProviderSchema) *Provider {
|
||||
return &Provider{
|
||||
Provider: marshalSchema(tps.Provider),
|
||||
ResourceSchemas: marshalSchemas(tps.ResourceTypes),
|
||||
|
@ -17,11 +17,11 @@ import (
|
||||
|
||||
func TestMarshalProvider(t *testing.T) {
|
||||
tests := []struct {
|
||||
Input providers.Schemas
|
||||
Input providers.ProviderSchema
|
||||
Want *Provider
|
||||
}{
|
||||
{
|
||||
providers.Schemas{},
|
||||
providers.ProviderSchema{},
|
||||
&Provider{
|
||||
Provider: &Schema{},
|
||||
ResourceSchemas: map[string]*Schema{},
|
||||
@ -158,8 +158,8 @@ func TestMarshalProvider(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func testProvider() providers.Schemas {
|
||||
return providers.Schemas{
|
||||
func testProvider() providers.ProviderSchema {
|
||||
return providers.ProviderSchema{
|
||||
Provider: providers.Schema{
|
||||
Block: &configschema.Block{
|
||||
Attributes: map[string]*configschema.Attribute{
|
||||
|
@ -808,7 +808,7 @@ func TestMarshalModules_parent_no_resources(t *testing.T) {
|
||||
|
||||
func testSchemas() *terraform.Schemas {
|
||||
return &terraform.Schemas{
|
||||
Providers: map[addrs.Provider]providers.Schemas{
|
||||
Providers: map[addrs.Provider]providers.ProviderSchema{
|
||||
addrs.NewDefaultProvider("test"): {
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_thing": {
|
||||
|
@ -133,7 +133,7 @@ func testPlanWithDatasource(t *testing.T) *plans.Plan {
|
||||
func testSchemas() *terraform.Schemas {
|
||||
provider := testProvider()
|
||||
return &terraform.Schemas{
|
||||
Providers: map[addrs.Provider]providers.Schemas{
|
||||
Providers: map[addrs.Provider]providers.ProviderSchema{
|
||||
addrs.NewDefaultProvider("test"): provider.GetProviderSchema(),
|
||||
},
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ func TestShowJSON(t *testing.T) {
|
||||
v := NewShow(arguments.ViewJSON, view)
|
||||
|
||||
schemas := &terraform.Schemas{
|
||||
Providers: map[addrs.Provider]providers.Schemas{
|
||||
Providers: map[addrs.Provider]providers.ProviderSchema{
|
||||
addrs.NewDefaultProvider("test"): {
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_resource": {
|
||||
|
@ -37,7 +37,7 @@ import (
|
||||
// the Analyzer contains caches derived from data in the configuration tree.
|
||||
type Analyzer struct {
|
||||
cfg *configs.Config
|
||||
providerSchemas map[addrs.Provider]providers.Schemas
|
||||
providerSchemas map[addrs.Provider]providers.ProviderSchema
|
||||
}
|
||||
|
||||
// NewAnalyzer constructs a new analyzer bound to the given configuration and
|
||||
@ -48,7 +48,7 @@ type Analyzer struct {
|
||||
// The given provider schemas must cover at least all of the providers used
|
||||
// in the given configuration. If not then analysis results will be silently
|
||||
// incomplete for any decision that requires checking schema.
|
||||
func NewAnalyzer(cfg *configs.Config, providerSchemas map[addrs.Provider]providers.Schemas) *Analyzer {
|
||||
func NewAnalyzer(cfg *configs.Config, providerSchemas map[addrs.Provider]providers.ProviderSchema) *Analyzer {
|
||||
if !cfg.Path.IsRoot() {
|
||||
panic(fmt.Sprintf("constructing an Analyzer with non-root module %s", cfg.Path))
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ func testAnalyzer(t *testing.T, fixtureName string) *Analyzer {
|
||||
},
|
||||
},
|
||||
}
|
||||
schemas := map[addrs.Provider]providers.Schemas{
|
||||
schemas := map[addrs.Provider]providers.ProviderSchema{
|
||||
addrs.MustParseProviderSourceString("hashicorp/test"): {
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_thing": {
|
||||
|
@ -13,7 +13,7 @@ import (
|
||||
// This will be accessed by both core and the provider clients to ensure that
|
||||
// large schemas are stored in a single location.
|
||||
var SchemaCache = &schemaCache{
|
||||
m: make(map[addrs.Provider]Schemas),
|
||||
m: make(map[addrs.Provider]ProviderSchema),
|
||||
}
|
||||
|
||||
// Global cache for provider schemas
|
||||
@ -22,17 +22,17 @@ var SchemaCache = &schemaCache{
|
||||
// concurrent calls resulting in an error can be handled in the same manner.
|
||||
type schemaCache struct {
|
||||
mu sync.Mutex
|
||||
m map[addrs.Provider]Schemas
|
||||
m map[addrs.Provider]ProviderSchema
|
||||
}
|
||||
|
||||
func (c *schemaCache) Set(p addrs.Provider, s Schemas) {
|
||||
func (c *schemaCache) Set(p addrs.Provider, s ProviderSchema) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
c.m[p] = s
|
||||
}
|
||||
|
||||
func (c *schemaCache) Get(p addrs.Provider) (Schemas, bool) {
|
||||
func (c *schemaCache) Get(p addrs.Provider) (ProviderSchema, bool) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
|
@ -8,13 +8,13 @@ import (
|
||||
"github.com/hashicorp/terraform/internal/configs/configschema"
|
||||
)
|
||||
|
||||
// Schemas is an overall container for all of the schemas for all configurable
|
||||
// ProviderSchema is an overall container for all of the schemas for all configurable
|
||||
// objects defined within a particular provider.
|
||||
type Schemas = GetProviderSchemaResponse
|
||||
type ProviderSchema = GetProviderSchemaResponse
|
||||
|
||||
// SchemaForResourceType attempts to find a schema for the given mode and type.
|
||||
// Returns nil if no such schema is available.
|
||||
func (ss Schemas) SchemaForResourceType(mode addrs.ResourceMode, typeName string) (schema *configschema.Block, version uint64) {
|
||||
func (ss ProviderSchema) SchemaForResourceType(mode addrs.ResourceMode, typeName string) (schema *configschema.Block, version uint64) {
|
||||
switch mode {
|
||||
case addrs.ManagedResourceMode:
|
||||
res := ss.ResourceTypes[typeName]
|
||||
@ -30,6 +30,6 @@ func (ss Schemas) SchemaForResourceType(mode addrs.ResourceMode, typeName string
|
||||
|
||||
// SchemaForResourceAddr attempts to find a schema for the mode and type from
|
||||
// the given resource address. Returns nil if no such schema is available.
|
||||
func (ss Schemas) SchemaForResourceAddr(addr addrs.Resource) (schema *configschema.Block, version uint64) {
|
||||
func (ss ProviderSchema) SchemaForResourceAddr(addr addrs.Resource) (schema *configschema.Block, version uint64) {
|
||||
return ss.SchemaForResourceType(addr.Mode, addr.Type)
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ func (cp *contextPlugins) NewProvisionerInstance(typ string) (provisioners.Inter
|
||||
// ProviderSchema memoizes results by unique provider address, so it's fine
|
||||
// to repeatedly call this method with the same address if various different
|
||||
// parts of Terraform all need the same schema information.
|
||||
func (cp *contextPlugins) ProviderSchema(addr addrs.Provider) (providers.Schemas, error) {
|
||||
func (cp *contextPlugins) ProviderSchema(addr addrs.Provider) (providers.ProviderSchema, error) {
|
||||
log.Printf("[TRACE] terraform.contextPlugins: Initializing provider %q to read its schema", addr)
|
||||
|
||||
// check the global schema cache first
|
||||
|
@ -57,7 +57,7 @@ type EvalContext interface {
|
||||
//
|
||||
// This method expects an _absolute_ provider configuration address, since
|
||||
// resources in one module are able to use providers from other modules.
|
||||
ProviderSchema(addrs.AbsProviderConfig) (providers.Schemas, error)
|
||||
ProviderSchema(addrs.AbsProviderConfig) (providers.ProviderSchema, error)
|
||||
|
||||
// CloseProvider closes provider connections that aren't needed anymore.
|
||||
//
|
||||
|
@ -149,7 +149,7 @@ func (ctx *BuiltinEvalContext) Provider(addr addrs.AbsProviderConfig) providers.
|
||||
return ctx.ProviderCache[addr.String()]
|
||||
}
|
||||
|
||||
func (ctx *BuiltinEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) (providers.Schemas, error) {
|
||||
func (ctx *BuiltinEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) (providers.ProviderSchema, error) {
|
||||
// first see if we have already have an initialized provider to avoid
|
||||
// re-loading it only for the schema
|
||||
p := ctx.Provider(addr)
|
||||
|
@ -46,7 +46,7 @@ type MockEvalContext struct {
|
||||
|
||||
ProviderSchemaCalled bool
|
||||
ProviderSchemaAddr addrs.AbsProviderConfig
|
||||
ProviderSchemaSchema providers.Schemas
|
||||
ProviderSchemaSchema providers.ProviderSchema
|
||||
ProviderSchemaError error
|
||||
|
||||
CloseProviderCalled bool
|
||||
@ -190,7 +190,7 @@ func (c *MockEvalContext) Provider(addr addrs.AbsProviderConfig) providers.Inter
|
||||
return c.ProviderProvider
|
||||
}
|
||||
|
||||
func (c *MockEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) (providers.Schemas, error) {
|
||||
func (c *MockEvalContext) ProviderSchema(addr addrs.AbsProviderConfig) (providers.ProviderSchema, error) {
|
||||
c.ProviderSchemaCalled = true
|
||||
c.ProviderSchemaAddr = addr
|
||||
return c.ProviderSchemaSchema, c.ProviderSchemaError
|
||||
|
@ -43,20 +43,20 @@ func buildProviderConfig(ctx EvalContext, addr addrs.AbsProviderConfig, config *
|
||||
}
|
||||
|
||||
// getProvider returns the providers.Interface and schema for a given provider.
|
||||
func getProvider(ctx EvalContext, addr addrs.AbsProviderConfig) (providers.Interface, providers.Schemas, error) {
|
||||
func getProvider(ctx EvalContext, addr addrs.AbsProviderConfig) (providers.Interface, providers.ProviderSchema, error) {
|
||||
if addr.Provider.Type == "" {
|
||||
// Should never happen
|
||||
panic("GetProvider used with uninitialized provider configuration address")
|
||||
}
|
||||
provider := ctx.Provider(addr)
|
||||
if provider == nil {
|
||||
return nil, providers.Schemas{}, fmt.Errorf("provider %s not initialized", addr)
|
||||
return nil, providers.ProviderSchema{}, fmt.Errorf("provider %s not initialized", addr)
|
||||
}
|
||||
// Not all callers require a schema, so we will leave checking for a nil
|
||||
// schema to the callers.
|
||||
schema, err := ctx.ProviderSchema(addr)
|
||||
if err != nil {
|
||||
return nil, providers.Schemas{}, fmt.Errorf("failed to read schema for provider %s: %w", addr, err)
|
||||
return nil, providers.ProviderSchema{}, fmt.Errorf("failed to read schema for provider %s: %w", addr, err)
|
||||
}
|
||||
return provider, schema, nil
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ func TestEvaluatorGetResource(t *testing.T) {
|
||||
},
|
||||
},
|
||||
State: stateSync,
|
||||
Plugins: schemaOnlyProvidersForTesting(map[addrs.Provider]providers.Schemas{
|
||||
Plugins: schemaOnlyProvidersForTesting(map[addrs.Provider]providers.ProviderSchema{
|
||||
addrs.NewDefaultProvider("test"): {
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_resource": {
|
||||
@ -437,7 +437,7 @@ func TestEvaluatorGetResource_changes(t *testing.T) {
|
||||
|
||||
// Set up our schemas
|
||||
schemas := &Schemas{
|
||||
Providers: map[addrs.Provider]providers.Schemas{
|
||||
Providers: map[addrs.Provider]providers.ProviderSchema{
|
||||
addrs.NewDefaultProvider("test"): {
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_resource": {
|
||||
|
@ -84,7 +84,7 @@ For example, to correlate with indices of a referring resource, use:
|
||||
cfg := testModule(t, "static-validate-refs")
|
||||
evaluator := &Evaluator{
|
||||
Config: cfg,
|
||||
Plugins: schemaOnlyProvidersForTesting(map[addrs.Provider]providers.Schemas{
|
||||
Plugins: schemaOnlyProvidersForTesting(map[addrs.Provider]providers.ProviderSchema{
|
||||
addrs.NewDefaultProvider("aws"): {
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"aws_instance": {
|
||||
|
@ -54,7 +54,7 @@ type ContextGraphWalker struct {
|
||||
variableValues map[string]map[string]cty.Value
|
||||
variableValuesLock sync.Mutex
|
||||
providerCache map[string]providers.Interface
|
||||
providerSchemas map[string]providers.Schemas
|
||||
providerSchemas map[string]providers.ProviderSchema
|
||||
providerLock sync.Mutex
|
||||
provisionerCache map[string]provisioners.Interface
|
||||
provisionerSchemas map[string]*configschema.Block
|
||||
@ -122,7 +122,7 @@ func (w *ContextGraphWalker) EvalContext() EvalContext {
|
||||
func (w *ContextGraphWalker) init() {
|
||||
w.contexts = make(map[string]*BuiltinEvalContext)
|
||||
w.providerCache = make(map[string]providers.Interface)
|
||||
w.providerSchemas = make(map[string]providers.Schemas)
|
||||
w.providerSchemas = make(map[string]providers.ProviderSchema)
|
||||
w.provisionerCache = make(map[string]provisioners.Interface)
|
||||
w.provisionerSchemas = make(map[string]*configschema.Block)
|
||||
w.variableValues = make(map[string]map[string]cty.Value)
|
||||
|
@ -137,7 +137,7 @@ func (n *NodeAbstractResourceInstance) AttachResourceState(s *states.Resource) {
|
||||
|
||||
// readDiff returns the planned change for a particular resource instance
|
||||
// object.
|
||||
func (n *NodeAbstractResourceInstance) readDiff(ctx EvalContext, providerSchema providers.Schemas) (*plans.ResourceInstanceChange, error) {
|
||||
func (n *NodeAbstractResourceInstance) readDiff(ctx EvalContext, providerSchema providers.ProviderSchema) (*plans.ResourceInstanceChange, error) {
|
||||
changes := ctx.Changes()
|
||||
addr := n.ResourceInstanceAddr()
|
||||
|
||||
|
@ -401,7 +401,7 @@ func (n *NodeApplyableResourceInstance) managedResourcePostconditions(ctx EvalCo
|
||||
// Errors here are most often indicative of a bug in the provider, so our error
|
||||
// messages will report with that in mind. It's also possible that there's a bug
|
||||
// in Terraform's Core's own "proposed new value" code in EvalDiff.
|
||||
func (n *NodeApplyableResourceInstance) checkPlannedChange(ctx EvalContext, plannedChange, actualChange *plans.ResourceInstanceChange, providerSchema providers.Schemas) tfdiags.Diagnostics {
|
||||
func (n *NodeApplyableResourceInstance) checkPlannedChange(ctx EvalContext, plannedChange, actualChange *plans.ResourceInstanceChange, providerSchema providers.ProviderSchema) tfdiags.Diagnostics {
|
||||
var diags tfdiags.Diagnostics
|
||||
addr := n.ResourceInstanceAddr().Resource
|
||||
|
||||
|
@ -40,7 +40,7 @@ func TestNodePlanDeposedResourceInstanceObject_Execute(t *testing.T) {
|
||||
PrevRunStateState: state.DeepCopy().SyncWrapper(),
|
||||
RefreshStateState: state.DeepCopy().SyncWrapper(),
|
||||
ProviderProvider: p,
|
||||
ProviderSchemaSchema: providers.Schemas{
|
||||
ProviderSchemaSchema: providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_instance": {
|
||||
Block: &configschema.Block{
|
||||
@ -98,7 +98,7 @@ func TestNodeDestroyDeposedResourceInstanceObject_Execute(t *testing.T) {
|
||||
mustProviderConfig(`provider["registry.terraform.io/hashicorp/test"]`),
|
||||
)
|
||||
|
||||
schema := providers.Schemas{
|
||||
schema := providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_instance": {
|
||||
Block: &configschema.Block{
|
||||
|
@ -439,7 +439,7 @@ func (n *NodePlannableResourceInstance) replaceTriggered(ctx EvalContext, repDat
|
||||
return diags
|
||||
}
|
||||
|
||||
func (n *NodePlannableResourceInstance) importState(ctx EvalContext, addr addrs.AbsResourceInstance, provider providers.Interface, providerSchema providers.Schemas) (*states.ResourceInstanceObject, tfdiags.Diagnostics) {
|
||||
func (n *NodePlannableResourceInstance) importState(ctx EvalContext, addr addrs.AbsResourceInstance, provider providers.Interface, providerSchema providers.ProviderSchema) (*states.ResourceInstanceObject, tfdiags.Diagnostics) {
|
||||
var diags tfdiags.Diagnostics
|
||||
absAddr := addr.Resource.Absolute(ctx.Path())
|
||||
|
||||
|
@ -42,7 +42,7 @@ func TestNodeResourcePlanOrphanExecute(t *testing.T) {
|
||||
PrevRunStateState: state.DeepCopy().SyncWrapper(),
|
||||
InstanceExpanderExpander: instances.NewExpander(),
|
||||
ProviderProvider: p,
|
||||
ProviderSchemaSchema: providers.Schemas{
|
||||
ProviderSchemaSchema: providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_object": {
|
||||
Block: simpleTestSchema(),
|
||||
@ -108,7 +108,7 @@ func TestNodeResourcePlanOrphanExecute_alreadyDeleted(t *testing.T) {
|
||||
PrevRunStateState: prevRunState.SyncWrapper(),
|
||||
InstanceExpanderExpander: instances.NewExpander(),
|
||||
ProviderProvider: p,
|
||||
ProviderSchemaSchema: providers.Schemas{
|
||||
ProviderSchemaSchema: providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_object": {
|
||||
Block: simpleTestSchema(),
|
||||
@ -190,7 +190,7 @@ func TestNodeResourcePlanOrphanExecute_deposed(t *testing.T) {
|
||||
PrevRunStateState: prevRunState.SyncWrapper(),
|
||||
InstanceExpanderExpander: instances.NewExpander(),
|
||||
ProviderProvider: p,
|
||||
ProviderSchemaSchema: providers.Schemas{
|
||||
ProviderSchemaSchema: providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_object": {
|
||||
Block: simpleTestSchema(),
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
// Schemas is a container for various kinds of schema that Terraform needs
|
||||
// during processing.
|
||||
type Schemas struct {
|
||||
Providers map[addrs.Provider]providers.Schemas
|
||||
Providers map[addrs.Provider]providers.ProviderSchema
|
||||
Provisioners map[string]*configschema.Block
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ type Schemas struct {
|
||||
//
|
||||
// It's usually better to go use the more precise methods offered by type
|
||||
// Schemas to handle this detail automatically.
|
||||
func (ss *Schemas) ProviderSchema(provider addrs.Provider) providers.Schemas {
|
||||
func (ss *Schemas) ProviderSchema(provider addrs.Provider) providers.ProviderSchema {
|
||||
return ss.Providers[provider]
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ func (ss *Schemas) ProvisionerConfig(name string) *configschema.Block {
|
||||
// still valid but may be incomplete.
|
||||
func loadSchemas(config *configs.Config, state *states.State, plugins *contextPlugins) (*Schemas, error) {
|
||||
schemas := &Schemas{
|
||||
Providers: map[addrs.Provider]providers.Schemas{},
|
||||
Providers: map[addrs.Provider]providers.ProviderSchema{},
|
||||
Provisioners: map[string]*configschema.Block{},
|
||||
}
|
||||
var diags tfdiags.Diagnostics
|
||||
@ -85,7 +85,7 @@ func loadSchemas(config *configs.Config, state *states.State, plugins *contextPl
|
||||
return schemas, diags.Err()
|
||||
}
|
||||
|
||||
func loadProviderSchemas(schemas map[addrs.Provider]providers.Schemas, config *configs.Config, state *states.State, plugins *contextPlugins) tfdiags.Diagnostics {
|
||||
func loadProviderSchemas(schemas map[addrs.Provider]providers.ProviderSchema, config *configs.Config, state *states.State, plugins *contextPlugins) tfdiags.Diagnostics {
|
||||
var diags tfdiags.Diagnostics
|
||||
|
||||
ensure := func(fqn addrs.Provider) {
|
||||
@ -101,7 +101,7 @@ func loadProviderSchemas(schemas map[addrs.Provider]providers.Schemas, config *c
|
||||
// We'll put a stub in the map so we won't re-attempt this on
|
||||
// future calls, which would then repeat the same error message
|
||||
// multiple times.
|
||||
schemas[fqn] = providers.Schemas{}
|
||||
schemas[fqn] = providers.ProviderSchema{}
|
||||
diags = diags.Append(
|
||||
tfdiags.Sourceless(
|
||||
tfdiags.Error,
|
||||
|
@ -14,7 +14,7 @@ func simpleTestSchemas() *Schemas {
|
||||
provisioner := simpleMockProvisioner()
|
||||
|
||||
return &Schemas{
|
||||
Providers: map[addrs.Provider]providers.Schemas{
|
||||
Providers: map[addrs.Provider]providers.ProviderSchema{
|
||||
addrs.NewDefaultProvider("test"): provider.GetProviderSchema(),
|
||||
},
|
||||
Provisioners: map[string]*configschema.Block{
|
||||
@ -31,7 +31,7 @@ func simpleTestSchemas() *Schemas {
|
||||
// The intended use for this is in testing components that use schemas to
|
||||
// drive other behavior, such as reference analysis during graph construction,
|
||||
// but that don't actually need to interact with providers otherwise.
|
||||
func schemaOnlyProvidersForTesting(schemas map[addrs.Provider]providers.Schemas) *contextPlugins {
|
||||
func schemaOnlyProvidersForTesting(schemas map[addrs.Provider]providers.ProviderSchema) *contextPlugins {
|
||||
factories := make(map[addrs.Provider]providers.Factory, len(schemas))
|
||||
|
||||
for providerAddr, schema := range schemas {
|
||||
|
@ -72,7 +72,7 @@ func TestGraphNodeImportStateSubExecute(t *testing.T) {
|
||||
ctx := &MockEvalContext{
|
||||
StateState: state.SyncWrapper(),
|
||||
ProviderProvider: provider,
|
||||
ProviderSchemaSchema: providers.Schemas{
|
||||
ProviderSchemaSchema: providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"aws_instance": {
|
||||
Block: &configschema.Block{
|
||||
@ -134,7 +134,7 @@ func TestGraphNodeImportStateSubExecuteNull(t *testing.T) {
|
||||
ctx := &MockEvalContext{
|
||||
StateState: state.SyncWrapper(),
|
||||
ProviderProvider: provider,
|
||||
ProviderSchemaSchema: providers.Schemas{
|
||||
ProviderSchemaSchema: providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"aws_instance": {
|
||||
Block: &configschema.Block{
|
||||
|
@ -34,7 +34,7 @@ func TestTransitiveReductionTransformer(t *testing.T) {
|
||||
|
||||
{
|
||||
transform := &AttachSchemaTransformer{
|
||||
Plugins: schemaOnlyProvidersForTesting(map[addrs.Provider]providers.Schemas{
|
||||
Plugins: schemaOnlyProvidersForTesting(map[addrs.Provider]providers.ProviderSchema{
|
||||
addrs.NewDefaultProvider("aws"): {
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"aws_instance": {
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
|
||||
// validateSelfRef checks to ensure that expressions within a particular
|
||||
// referencable block do not reference that same block.
|
||||
func validateSelfRef(addr addrs.Referenceable, config hcl.Body, providerSchema providers.Schemas) tfdiags.Diagnostics {
|
||||
func validateSelfRef(addr addrs.Referenceable, config hcl.Body, providerSchema providers.ProviderSchema) tfdiags.Diagnostics {
|
||||
var diags tfdiags.Diagnostics
|
||||
|
||||
addrStrs := make([]string, 0, 1)
|
||||
|
@ -83,7 +83,7 @@ func TestValidateSelfRef(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
ps := providers.Schemas{
|
||||
ps := providers.ProviderSchema{
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"aws_instance": {
|
||||
Block: &configschema.Block{
|
||||
|
Loading…
Reference in New Issue
Block a user