mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-23 23:50:12 -06:00
update schemas type
This commit is contained in:
parent
d487ce20e1
commit
4e8dd5866c
@ -42,28 +42,11 @@ 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 *terraform.ProviderSchema) *terraform.MockProvider {
|
||||
func TestLocalProvider(t *testing.T, b *Local, name string, schema providers.Schemas) *terraform.MockProvider {
|
||||
// Build a mock resource provider for in-memory operations
|
||||
p := new(terraform.MockProvider)
|
||||
|
||||
if schema == nil {
|
||||
schema = &terraform.ProviderSchema{} // default schema is empty
|
||||
}
|
||||
p.GetProviderSchemaResponse = &providers.GetProviderSchemaResponse{
|
||||
Provider: providers.Schema{Block: schema.Provider},
|
||||
ProviderMeta: providers.Schema{Block: schema.ProviderMeta},
|
||||
ResourceTypes: map[string]providers.Schema{},
|
||||
DataSources: map[string]providers.Schema{},
|
||||
}
|
||||
for name, res := range schema.ResourceTypes {
|
||||
p.GetProviderSchemaResponse.ResourceTypes[name] = providers.Schema{
|
||||
Block: res,
|
||||
Version: int64(schema.ResourceTypeSchemaVersions[name]),
|
||||
}
|
||||
}
|
||||
for name, dat := range schema.DataSources {
|
||||
p.GetProviderSchemaResponse.DataSources[name] = providers.Schema{Block: dat}
|
||||
}
|
||||
p.GetProviderSchemaResponse = &schema
|
||||
|
||||
p.PlanResourceChangeFn = func(req providers.PlanResourceChangeRequest) (resp providers.PlanResourceChangeResponse) {
|
||||
// this is a destroy plan,
|
||||
|
@ -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.Schemas
|
||||
}
|
||||
|
||||
// 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.Schemas) *Analyzer {
|
||||
if !cfg.Path.IsRoot() {
|
||||
panic(fmt.Sprintf("constructing an Analyzer with non-root module %s", cfg.Path))
|
||||
}
|
||||
|
@ -200,8 +200,8 @@ func (a *Analyzer) metaReferencesResourceInstance(moduleAddr addrs.ModuleInstanc
|
||||
// available. In invalid cases we might be dealing with partial information,
|
||||
// and so the schema might be nil so we won't be able to return reference
|
||||
// information for this particular situation.
|
||||
providerSchema := a.providerSchemas[rc.Provider]
|
||||
if providerSchema == nil {
|
||||
providerSchema, ok := a.providerSchemas[rc.Provider]
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -86,13 +86,17 @@ func testAnalyzer(t *testing.T, fixtureName string) *Analyzer {
|
||||
},
|
||||
},
|
||||
}
|
||||
schemas := map[addrs.Provider]*providers.Schemas{
|
||||
schemas := map[addrs.Provider]providers.Schemas{
|
||||
addrs.MustParseProviderSourceString("hashicorp/test"): {
|
||||
ResourceTypes: map[string]*configschema.Block{
|
||||
"test_thing": resourceTypeSchema,
|
||||
ResourceTypes: map[string]providers.Schema{
|
||||
"test_thing": {
|
||||
Block: resourceTypeSchema,
|
||||
},
|
||||
},
|
||||
DataSources: map[string]*configschema.Block{
|
||||
"test_thing": resourceTypeSchema,
|
||||
DataSources: map[string]providers.Schema{
|
||||
"test_thing": {
|
||||
Block: resourceTypeSchema,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user