mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #33543 from hashicorp/jbardin/get-schema-client-cache
always set schema caches from provider clients
This commit is contained in:
commit
62ee606752
@ -79,12 +79,14 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp
|
||||
defer p.mu.Unlock()
|
||||
|
||||
// check the global cache if we can
|
||||
if !p.Addr.IsZero() {
|
||||
if !p.Addr.IsZero() && resp.ServerCapabilities.GetProviderSchemaOptional {
|
||||
if resp, ok := providers.SchemaCache.Get(p.Addr); ok {
|
||||
return resp
|
||||
}
|
||||
}
|
||||
|
||||
// If the local cache is non-zero, we know this instance has called
|
||||
// GetProviderSchema at least once and we can return early.
|
||||
if p.schema.Provider.Block != nil {
|
||||
return p.schema
|
||||
}
|
||||
@ -139,13 +141,14 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp
|
||||
}
|
||||
|
||||
// set the global cache if we can
|
||||
if !p.Addr.IsZero() && resp.ServerCapabilities.GetProviderSchemaOptional {
|
||||
if !p.Addr.IsZero() {
|
||||
providers.SchemaCache.Set(p.Addr, resp)
|
||||
} else {
|
||||
// otherwise store it in the local cache
|
||||
p.schema = resp
|
||||
}
|
||||
|
||||
// always store this here in the client for providers that are not able to
|
||||
// use GetProviderSchemaOptional
|
||||
p.schema = resp
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
|
@ -79,12 +79,14 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp
|
||||
defer p.mu.Unlock()
|
||||
|
||||
// check the global cache if we can
|
||||
if !p.Addr.IsZero() {
|
||||
if !p.Addr.IsZero() && resp.ServerCapabilities.GetProviderSchemaOptional {
|
||||
if resp, ok := providers.SchemaCache.Get(p.Addr); ok {
|
||||
return resp
|
||||
}
|
||||
}
|
||||
|
||||
// If the local cache is non-zero, we know this instance has called
|
||||
// GetProviderSchema at least once and we can return early.
|
||||
if p.schema.Provider.Block != nil {
|
||||
return p.schema
|
||||
}
|
||||
@ -139,13 +141,14 @@ func (p *GRPCProvider) GetProviderSchema() (resp providers.GetProviderSchemaResp
|
||||
}
|
||||
|
||||
// set the global cache if we can
|
||||
if !p.Addr.IsZero() && resp.ServerCapabilities.GetProviderSchemaOptional {
|
||||
if !p.Addr.IsZero() {
|
||||
providers.SchemaCache.Set(p.Addr, resp)
|
||||
} else {
|
||||
// otherwise store it in the local cache
|
||||
p.schema = resp
|
||||
}
|
||||
|
||||
// always store this here in the client for providers that are not able to
|
||||
// use GetProviderSchemaOptional
|
||||
p.schema = resp
|
||||
|
||||
return resp
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user