MCPcopy
hub / github.com/opentofu/opentofu / ResourceTypeSchema

Method ResourceTypeSchema

internal/engine/plugins/plugins.go:131–160  ·  view source on GitHub ↗

ResourceTypeSchema implements evalglue.Providers.

(ctx context.Context, provider addrs.Provider, mode addrs.ResourceMode, typeName string)

Source from the content-addressed store, hash-verified

129
130// ResourceTypeSchema implements evalglue.Providers.
131func (n *newRuntimePlugins) ResourceTypeSchema(ctx context.Context, provider addrs.Provider, mode addrs.ResourceMode, typeName string) (*providers.Schema, tfdiags.Diagnostics) {
132 schema, diags := n.providers.GetProviderSchema(ctx, provider)
133 if diags.HasErrors() {
134 return nil, diags
135 }
136
137 // NOTE: Callers expect us to return nil if we successfully fetch the
138 // provider schema and then find there is no matching resource type, because
139 // the caller is typically in a better position to return a useful error
140 // message than we are.
141
142 var types map[string]providers.Schema
143 switch mode {
144 case addrs.ManagedResourceMode:
145 types = schema.ResourceTypes
146 case addrs.DataResourceMode:
147 types = schema.DataSources
148 case addrs.EphemeralResourceMode:
149 types = schema.EphemeralResources
150 default:
151 // We don't support any other modes, so we'll just treat these as
152 // a request for a resource type that doesn't exist at all.
153 return nil, nil
154 }
155 ret, ok := types[typeName]
156 if !ok {
157 return nil, diags
158 }
159 return &ret, diags
160}
161
162// ValidateProviderConfig implements evalglue.Providers.
163func (n *newRuntimePlugins) ValidateProviderConfig(ctx context.Context, provider addrs.Provider, configVal cty.Value) tfdiags.Diagnostics {

Callers

nothing calls this directly

Calls 2

HasErrorsMethod · 0.80
GetProviderSchemaMethod · 0.65

Tested by

no test coverage detected