Skip to content

Commit 8776f81

Browse files
terraform: Remove some addrs.Provider.LegacyString uses
These are cases where we were using the legacy string only to produce a message to the user or to write to the log. It's enough to make some basic Terraform commands like "terraform validate" not panic and get far enough along to see that provider startup is working.
1 parent 68f1e3b commit 8776f81

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

terraform/context_components.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type basicComponentFactory struct {
3232
func (c *basicComponentFactory) ResourceProviders() []string {
3333
var result []string
3434
for k := range c.providers {
35-
result = append(result, k.LegacyString())
35+
result = append(result, k.String())
3636
}
3737
return result
3838
}
@@ -49,7 +49,7 @@ func (c *basicComponentFactory) ResourceProvisioners() []string {
4949
func (c *basicComponentFactory) ResourceProvider(typ addrs.Provider) (providers.Interface, error) {
5050
f, ok := c.providers[typ]
5151
if !ok {
52-
return nil, fmt.Errorf("unknown provider %q", typ.LegacyString())
52+
return nil, fmt.Errorf("unknown provider %q", typ.String())
5353
}
5454

5555
return f()

terraform/schemas.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,20 @@ func loadProviderSchemas(schemas map[addrs.Provider]*ProviderSchema, config *con
9393
var diags tfdiags.Diagnostics
9494

9595
ensure := func(fqn addrs.Provider) {
96-
// TODO: LegacyString() will be removed in an upcoming release
97-
typeName := fqn.LegacyString()
96+
name := fqn.String()
9897

9998
if _, exists := schemas[fqn]; exists {
10099
return
101100
}
102101

103-
log.Printf("[TRACE] LoadSchemas: retrieving schema for provider type %q", fqn.LegacyString())
102+
log.Printf("[TRACE] LoadSchemas: retrieving schema for provider type %q", name)
104103
provider, err := components.ResourceProvider(fqn)
105104
if err != nil {
106105
// We'll put a stub in the map so we won't re-attempt this on
107106
// future calls.
108107
schemas[fqn] = &ProviderSchema{}
109108
diags = diags.Append(
110-
fmt.Errorf("Failed to instantiate provider %q to obtain schema: %s", typeName, err),
109+
fmt.Errorf("Failed to instantiate provider %q to obtain schema: %s", name, err),
111110
)
112111
return
113112
}
@@ -121,7 +120,7 @@ func loadProviderSchemas(schemas map[addrs.Provider]*ProviderSchema, config *con
121120
// future calls.
122121
schemas[fqn] = &ProviderSchema{}
123122
diags = diags.Append(
124-
fmt.Errorf("Failed to retrieve schema from provider %q: %s", typeName, resp.Diagnostics.Err()),
123+
fmt.Errorf("Failed to retrieve schema from provider %q: %s", name, resp.Diagnostics.Err()),
125124
)
126125
return
127126
}
@@ -138,7 +137,7 @@ func loadProviderSchemas(schemas map[addrs.Provider]*ProviderSchema, config *con
138137
// We're not using the version numbers here yet, but we'll check
139138
// for validity anyway in case we start using them in future.
140139
diags = diags.Append(
141-
fmt.Errorf("invalid negative schema version provider configuration for provider %q", typeName),
140+
fmt.Errorf("invalid negative schema version provider configuration for provider %q", name),
142141
)
143142
}
144143

@@ -147,7 +146,7 @@ func loadProviderSchemas(schemas map[addrs.Provider]*ProviderSchema, config *con
147146
s.ResourceTypeSchemaVersions[t] = uint64(r.Version)
148147
if r.Version < 0 {
149148
diags = diags.Append(
150-
fmt.Errorf("invalid negative schema version for resource type %s in provider %q", t, typeName),
149+
fmt.Errorf("invalid negative schema version for resource type %s in provider %q", t, name),
151150
)
152151
}
153152
}
@@ -158,7 +157,7 @@ func loadProviderSchemas(schemas map[addrs.Provider]*ProviderSchema, config *con
158157
// We're not using the version numbers here yet, but we'll check
159158
// for validity anyway in case we start using them in future.
160159
diags = diags.Append(
161-
fmt.Errorf("invalid negative schema version for data source %s in provider %q", t, typeName),
160+
fmt.Errorf("invalid negative schema version for data source %s in provider %q", t, name),
162161
)
163162
}
164163
}

0 commit comments

Comments
 (0)