Skip to content

Commit

Permalink
use TENV_DETACHED_PROXY in lightproxy (#274)
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Vaumoron <[email protected]>
  • Loading branch information
dvaumoron authored Oct 28, 2024
1 parent 408f915 commit 4a0e597
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion versionmanager/proxy/agnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/tofuutils/tenv/v3/config/cmdconst"
cmdproxy "github.com/tofuutils/tenv/v3/pkg/cmdproxy"
"github.com/tofuutils/tenv/v3/versionmanager/builder"
detachproxy "github.com/tofuutils/tenv/v3/versionmanager/proxy/detach"
)

// Always call os.Exit.
Expand Down Expand Up @@ -77,7 +78,7 @@ func ExecAgnostic(conf *config.Config, hclParser *hclparse.Parser, cmdArgs []str
execPath := ExecPath(installPath, detectedVersion, execName, conf.Displayer)

cmd := exec.CommandContext(ctx, execPath, cmdArgs...)
initDetachedBehaviorFromEnv(cmd)
detachproxy.InitBehaviorFromEnv(cmd)

cmdproxy.Run(cmd, conf.GithubActions)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
*/

package proxy
package detachproxy

import (
"fmt"
Expand All @@ -28,7 +28,7 @@ import (
configutils "github.com/tofuutils/tenv/v3/config/utils"
)

func initDetachedBehaviorFromEnv(cmd *exec.Cmd) {
func InitBehaviorFromEnv(cmd *exec.Cmd) {
detached, err := configutils.GetenvBool(false, "TENV_DETACHED_PROXY")
if err != nil {
fmt.Println("Failed to read TENV_DETACHED_PROXY environment variable, disable behavior :", err) //nolint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

package proxy
package detachproxy

import (
"fmt"
Expand All @@ -25,7 +25,7 @@ import (
configutils "github.com/tofuutils/tenv/v3/config/utils"
)

func initDetachedBehaviorFromEnv(_ *exec.Cmd) {
func InitBehaviorFromEnv(_ *exec.Cmd) {
switch detached, err := configutils.GetenvBool(false, "TENV_DETACHED_PROXY"); {
case err != nil:
fmt.Println("TENV_DETACHED_PROXY behavior is always disabled on Windows OS, failed to read environment variable :", err) //nolint
Expand Down
2 changes: 2 additions & 0 deletions versionmanager/proxy/light/light.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"os/signal"

"github.com/tofuutils/tenv/v3/config/cmdconst"
detachproxy "github.com/tofuutils/tenv/v3/versionmanager/proxy/detach"
)

func Exec(execName string) {
Expand All @@ -35,6 +36,7 @@ func Exec(execName string) {

// proxy to selected version
cmd := exec.Command(cmdconst.TenvName, cmdArgs...) //nolint
detachproxy.InitBehaviorFromEnv(cmd)
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
Expand Down
3 changes: 2 additions & 1 deletion versionmanager/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
"github.com/tofuutils/tenv/v3/pkg/loghelper"
"github.com/tofuutils/tenv/v3/versionmanager/builder"
"github.com/tofuutils/tenv/v3/versionmanager/lastuse"
detachproxy "github.com/tofuutils/tenv/v3/versionmanager/proxy/detach"
)

const chdirFlagPrefix = "-chdir="
Expand Down Expand Up @@ -60,7 +61,7 @@ func Exec(conf *config.Config, builderFunc builder.Func, hclParser *hclparse.Par
execPath := ExecPath(installPath, detectedVersion, execName, conf.Displayer)

cmd := exec.CommandContext(ctx, execPath, cmdArgs...)
initDetachedBehaviorFromEnv(cmd)
detachproxy.InitBehaviorFromEnv(cmd)

cmdproxy.Run(cmd, conf.GithubActions)
}
Expand Down

0 comments on commit 4a0e597

Please sign in to comment.