mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Draft: Indentify OpenTofu to providers
This change adds the TF_VARIANT=OpenTofu and OPENTOFU_VERSION environment variables so providers can identify OpenTofu as such. Signed-off-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com>
This commit is contained in:
parent
76d388b340
commit
f6ea5596ca
@ -25,6 +25,7 @@ import (
|
||||
"github.com/opentofu/opentofu/internal/providercache"
|
||||
"github.com/opentofu/opentofu/internal/providers"
|
||||
"github.com/opentofu/opentofu/internal/tfdiags"
|
||||
"github.com/opentofu/opentofu/version"
|
||||
)
|
||||
|
||||
var errUnsupportedProtocolVersion = errors.New("unsupported protocol version")
|
||||
@ -357,12 +358,23 @@ func providerFactory(meta *providercache.CachedProvider) providers.Factory {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cmd := exec.Command(execFile)
|
||||
originalEnv := os.Environ()
|
||||
additionalEnv := []string{
|
||||
"TF_VARIANT=OpenTofu",
|
||||
fmt.Sprintf("OPENTOFU_VERSION=%s", version.Version),
|
||||
}
|
||||
env := make([]string, len(originalEnv)+len(additionalEnv))
|
||||
copy(env, originalEnv)
|
||||
copy(env[len(originalEnv):], additionalEnv)
|
||||
cmd.Env = env
|
||||
|
||||
config := &plugin.ClientConfig{
|
||||
HandshakeConfig: tfplugin.Handshake,
|
||||
Logger: logging.NewProviderLogger(""),
|
||||
AllowedProtocols: []plugin.Protocol{plugin.ProtocolGRPC},
|
||||
Managed: true,
|
||||
Cmd: exec.Command(execFile),
|
||||
Cmd: cmd,
|
||||
AutoMTLS: enableProviderAutoMTLS,
|
||||
VersionedPlugins: tfplugin.VersionedPlugins,
|
||||
SyncStdout: logging.PluginOutputMonitor(fmt.Sprintf("%s:stdout", meta.Provider)),
|
||||
|
Loading…
Reference in New Issue
Block a user