|
|
|
|
@ -68,9 +68,9 @@ type GRPCProvider struct {
|
|
|
|
|
ctx context.Context
|
|
|
|
|
|
|
|
|
|
// schema stores the schema for this provider. This is used to properly
|
|
|
|
|
// serialize the state for requests.
|
|
|
|
|
mu sync.Mutex
|
|
|
|
|
schemas providers.GetProviderSchemaResponse
|
|
|
|
|
// serialize the requests for schemas.
|
|
|
|
|
mu sync.Mutex
|
|
|
|
|
schema providers.GetProviderSchemaResponse
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResponse) {
|
|
|
|
|
@ -85,8 +85,8 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if p.schemas.Provider.Block != nil {
|
|
|
|
|
return p.schemas
|
|
|
|
|
if p.schema.Provider.Block != nil {
|
|
|
|
|
return p.schema
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resp.ResourceTypes = make(map[string]providers.Schema)
|
|
|
|
|
@ -135,18 +135,16 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp
|
|
|
|
|
|
|
|
|
|
if protoResp.ServerCapabilities != nil {
|
|
|
|
|
resp.ServerCapabilities.PlanDestroy = protoResp.ServerCapabilities.PlanDestroy
|
|
|
|
|
resp.ServerCapabilities.GetProviderSchemaOptional = protoResp.ServerCapabilities.GetProviderSchemaOptional
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FIXME: Waiting for a provider capability to prevent caching
|
|
|
|
|
// providers which always need GetProviderSchema called.
|
|
|
|
|
// set the global cache if we can
|
|
|
|
|
//if !p.Addr.IsZero() {
|
|
|
|
|
// providers.SchemaCache.Set(p.Addr, resp)
|
|
|
|
|
//} else {
|
|
|
|
|
// // otherwise store it in the local cache
|
|
|
|
|
// p.schemas = resp
|
|
|
|
|
//}
|
|
|
|
|
p.schemas = resp
|
|
|
|
|
if !p.Addr.IsZero() && resp.ServerCapabilities.GetProviderSchemaOptional {
|
|
|
|
|
providers.SchemaCache.Set(p.Addr, resp)
|
|
|
|
|
} else {
|
|
|
|
|
// otherwise store it in the local cache
|
|
|
|
|
p.schema = resp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return resp
|
|
|
|
|
}
|
|
|
|
|
|