diff --git a/internal/backend/local/backend_apply_test.go b/internal/backend/local/backend_apply_test.go index 1997a7dd32..594002e606 100644 --- a/internal/backend/local/backend_apply_test.go +++ b/internal/backend/local/backend_apply_test.go @@ -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{ diff --git a/internal/backend/local/backend_plan_test.go b/internal/backend/local/backend_plan_test.go index c6f906cf88..de2f3cc516 100644 --- a/internal/backend/local/backend_plan_test.go +++ b/internal/backend/local/backend_plan_test.go @@ -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{ diff --git a/internal/backend/local/backend_refresh_test.go b/internal/backend/local/backend_refresh_test.go index 1d9c197a87..1572d1481e 100644 --- a/internal/backend/local/backend_refresh_test.go +++ b/internal/backend/local/backend_refresh_test.go @@ -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{ diff --git a/internal/backend/local/testing.go b/internal/backend/local/testing.go index 7514ab975b..1c4e426a5d 100644 --- a/internal/backend/local/testing.go +++ b/internal/backend/local/testing.go @@ -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) diff --git a/internal/backend/remote/testing.go b/internal/backend/remote/testing.go index 282afc0dba..5f7dba18b8 100644 --- a/internal/backend/remote/testing.go +++ b/internal/backend/remote/testing.go @@ -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{ diff --git a/internal/cloud/testing.go b/internal/cloud/testing.go index 672840092f..81def5c223 100644 --- a/internal/cloud/testing.go +++ b/internal/cloud/testing.go @@ -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{ diff --git a/internal/command/jsonformat/plan_test.go b/internal/command/jsonformat/plan_test.go index d9b2fa7f09..81bdf1fc6b 100644 --- a/internal/command/jsonformat/plan_test.go +++ b/internal/command/jsonformat/plan_test.go @@ -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: { diff --git a/internal/command/jsonformat/state_test.go b/internal/command/jsonformat/state_test.go index e455ec8d12..64f9973baa 100644 --- a/internal/command/jsonformat/state_test.go +++ b/internal/command/jsonformat/state_test.go @@ -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(), }, } diff --git a/internal/command/jsonplan/values_test.go b/internal/command/jsonplan/values_test.go index 099d865ab1..bb84b5cbc4 100644 --- a/internal/command/jsonplan/values_test.go +++ b/internal/command/jsonplan/values_test.go @@ -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, diff --git a/internal/command/jsonprovider/provider.go b/internal/command/jsonprovider/provider.go index 3491bf403d..5ff01cc965 100644 --- a/internal/command/jsonprovider/provider.go +++ b/internal/command/jsonprovider/provider.go @@ -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), diff --git a/internal/command/jsonprovider/provider_test.go b/internal/command/jsonprovider/provider_test.go index b678ab9c4d..bab2c3921b 100644 --- a/internal/command/jsonprovider/provider_test.go +++ b/internal/command/jsonprovider/provider_test.go @@ -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{ diff --git a/internal/command/jsonstate/state_test.go b/internal/command/jsonstate/state_test.go index 33ad46f092..72bb17232a 100644 --- a/internal/command/jsonstate/state_test.go +++ b/internal/command/jsonstate/state_test.go @@ -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": { diff --git a/internal/command/views/plan_test.go b/internal/command/views/plan_test.go index df9fe3a27b..3cb6434410 100644 --- a/internal/command/views/plan_test.go +++ b/internal/command/views/plan_test.go @@ -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(), }, } diff --git a/internal/command/views/show_test.go b/internal/command/views/show_test.go index 7524cfa88c..cb29c5e78d 100644 --- a/internal/command/views/show_test.go +++ b/internal/command/views/show_test.go @@ -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": { diff --git a/internal/lang/globalref/analyzer.go b/internal/lang/globalref/analyzer.go index c64366ae07..eb4b586249 100644 --- a/internal/lang/globalref/analyzer.go +++ b/internal/lang/globalref/analyzer.go @@ -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)) } diff --git a/internal/lang/globalref/analyzer_test.go b/internal/lang/globalref/analyzer_test.go index 1fd3e56743..7dfe653760 100644 --- a/internal/lang/globalref/analyzer_test.go +++ b/internal/lang/globalref/analyzer_test.go @@ -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": { diff --git a/internal/providers/schema_cache.go b/internal/providers/schema_cache.go index e620571ed2..caac0504d8 100644 --- a/internal/providers/schema_cache.go +++ b/internal/providers/schema_cache.go @@ -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() diff --git a/internal/providers/schemas.go b/internal/providers/schemas.go index 662590a46b..762eca5841 100644 --- a/internal/providers/schemas.go +++ b/internal/providers/schemas.go @@ -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) } diff --git a/internal/terraform/context_plugins.go b/internal/terraform/context_plugins.go index da6d80991d..1297afef81 100644 --- a/internal/terraform/context_plugins.go +++ b/internal/terraform/context_plugins.go @@ -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 diff --git a/internal/terraform/eval_context.go b/internal/terraform/eval_context.go index c3cb0779e0..5965a083e3 100644 --- a/internal/terraform/eval_context.go +++ b/internal/terraform/eval_context.go @@ -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. // diff --git a/internal/terraform/eval_context_builtin.go b/internal/terraform/eval_context_builtin.go index d95c79e965..00de8eb7e8 100644 --- a/internal/terraform/eval_context_builtin.go +++ b/internal/terraform/eval_context_builtin.go @@ -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) diff --git a/internal/terraform/eval_context_mock.go b/internal/terraform/eval_context_mock.go index d99e667013..276730c449 100644 --- a/internal/terraform/eval_context_mock.go +++ b/internal/terraform/eval_context_mock.go @@ -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 diff --git a/internal/terraform/eval_provider.go b/internal/terraform/eval_provider.go index d21a30a293..90b9cbcc3d 100644 --- a/internal/terraform/eval_provider.go +++ b/internal/terraform/eval_provider.go @@ -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 } diff --git a/internal/terraform/evaluate_test.go b/internal/terraform/evaluate_test.go index ed8987c702..56ac09c005 100644 --- a/internal/terraform/evaluate_test.go +++ b/internal/terraform/evaluate_test.go @@ -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": { diff --git a/internal/terraform/evaluate_valid_test.go b/internal/terraform/evaluate_valid_test.go index 73dc79bd75..adf056ab36 100644 --- a/internal/terraform/evaluate_valid_test.go +++ b/internal/terraform/evaluate_valid_test.go @@ -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": { diff --git a/internal/terraform/graph_walk_context.go b/internal/terraform/graph_walk_context.go index ffdb3c2389..dc0188846a 100644 --- a/internal/terraform/graph_walk_context.go +++ b/internal/terraform/graph_walk_context.go @@ -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) diff --git a/internal/terraform/node_resource_abstract_instance.go b/internal/terraform/node_resource_abstract_instance.go index 383269f541..e0db1183d7 100644 --- a/internal/terraform/node_resource_abstract_instance.go +++ b/internal/terraform/node_resource_abstract_instance.go @@ -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() diff --git a/internal/terraform/node_resource_apply_instance.go b/internal/terraform/node_resource_apply_instance.go index 390770118f..035d4f5b05 100644 --- a/internal/terraform/node_resource_apply_instance.go +++ b/internal/terraform/node_resource_apply_instance.go @@ -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 diff --git a/internal/terraform/node_resource_destroy_deposed_test.go b/internal/terraform/node_resource_destroy_deposed_test.go index 9c01f3e869..e110649e66 100644 --- a/internal/terraform/node_resource_destroy_deposed_test.go +++ b/internal/terraform/node_resource_destroy_deposed_test.go @@ -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{ diff --git a/internal/terraform/node_resource_plan_instance.go b/internal/terraform/node_resource_plan_instance.go index 58f48d57e3..565054f160 100644 --- a/internal/terraform/node_resource_plan_instance.go +++ b/internal/terraform/node_resource_plan_instance.go @@ -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()) diff --git a/internal/terraform/node_resource_plan_orphan_test.go b/internal/terraform/node_resource_plan_orphan_test.go index a9a1c171bc..fe23c4f5b9 100644 --- a/internal/terraform/node_resource_plan_orphan_test.go +++ b/internal/terraform/node_resource_plan_orphan_test.go @@ -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(), diff --git a/internal/terraform/schemas.go b/internal/terraform/schemas.go index 1d114fcdf0..ab494df4be 100644 --- a/internal/terraform/schemas.go +++ b/internal/terraform/schemas.go @@ -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, diff --git a/internal/terraform/schemas_test.go b/internal/terraform/schemas_test.go index 4df542d4bb..d36550e60d 100644 --- a/internal/terraform/schemas_test.go +++ b/internal/terraform/schemas_test.go @@ -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 { diff --git a/internal/terraform/transform_import_state_test.go b/internal/terraform/transform_import_state_test.go index 64ad2787cd..34a21426a1 100644 --- a/internal/terraform/transform_import_state_test.go +++ b/internal/terraform/transform_import_state_test.go @@ -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{ diff --git a/internal/terraform/transform_transitive_reduction_test.go b/internal/terraform/transform_transitive_reduction_test.go index 758a50627e..28f675bfec 100644 --- a/internal/terraform/transform_transitive_reduction_test.go +++ b/internal/terraform/transform_transitive_reduction_test.go @@ -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": { diff --git a/internal/terraform/validate_selfref.go b/internal/terraform/validate_selfref.go index 3d12af440d..f697515213 100644 --- a/internal/terraform/validate_selfref.go +++ b/internal/terraform/validate_selfref.go @@ -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) diff --git a/internal/terraform/validate_selfref_test.go b/internal/terraform/validate_selfref_test.go index 18c33103e7..ca9bfe6fa6 100644 --- a/internal/terraform/validate_selfref_test.go +++ b/internal/terraform/validate_selfref_test.go @@ -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{