@@ -94,11 +94,11 @@ func WithoutLogLocation() ServeOpt {
9494// logging environment variable that controls the provider's log level. It is
9595// the part following TF_LOG_PROVIDER_ and defaults to the name part of the
9696// provider's registry address, or disabled if it can't parse the provider's
97- // registry address. Name must only contain letters and numbers .
97+ // registry address. Name must only contain letters, numbers, and hyphens .
9898func WithLogEnvVarName (name string ) ServeOpt {
9999 return serveConfigFunc (func (in * ServeConfig ) error {
100- if ! regexp .MustCompile (`^[a-zA-Z0-9]+$` ).MatchString (name ) {
101- return errors .New ("environment variable names can only contain a-z, A-Z, and 0-9" )
100+ if ! regexp .MustCompile (`^[a-zA-Z0-9- ]+$` ).MatchString (name ) {
101+ return errors .New ("environment variable names can only contain a-z, A-Z, 0-9, and - " )
102102 }
103103 in .envVar = name
104104 return nil
@@ -262,9 +262,10 @@ func New(name string, serve tfprotov5.ProviderServer, opts ...ServeOpt) tfplugin
262262 if err != nil {
263263 log .Println ("[ERROR] Error parsing provider name:" , err )
264264 } else {
265- envVar = strings . ReplaceAll ( addr .Type , "-" , "_" )
265+ envVar = addr .Type
266266 }
267267 }
268+ envVar = strings .ReplaceAll (envVar , "-" , "_" )
268269 if envVar != "" {
269270 options = append (options , tflog .WithLogName (envVar ), tflog .WithLevelFromEnv ("TF" , "LOG" , "PROVIDER" , envVar ))
270271 }
0 commit comments