ResourceTypeSchema implements evalglue.Providers.
(ctx context.Context, provider addrs.Provider, mode addrs.ResourceMode, typeName string)
| 129 | |
| 130 | // ResourceTypeSchema implements evalglue.Providers. |
| 131 | func (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. |
| 163 | func (n *newRuntimePlugins) ValidateProviderConfig(ctx context.Context, provider addrs.Provider, configVal cty.Value) tfdiags.Diagnostics { |
nothing calls this directly
no test coverage detected