Skip to content

Commit

Permalink
Change env names
Browse files Browse the repository at this point in the history
  • Loading branch information
adambabik committed Dec 1, 2024
1 parent 5f5117b commit 4cb423d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
14 changes: 7 additions & 7 deletions internal/cmd/beta/session_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func executeDefaultShellProgram(
ProgramName: defaultShell(),
Mode: runnerv2.CommandMode_COMMAND_MODE_CLI,
Env: append(
[]string{command.CreateEnv(command.EnvCollectorSessionEnvName, "1")},
[]string{command.CreateEnv(command.EnvNameTerminalSessionEnabled, "true")},
append(envCollector.ExtraEnv(), additionalEnv...)...,
),
}
Expand Down Expand Up @@ -143,23 +143,23 @@ func sessionSetupCmd() *cobra.Command {
out := cmd.OutOrStdout()

if err := requireEnvs(
command.EnvCollectorSessionEnvName,
command.EnvCollectorSessionPrePathEnvName,
command.EnvCollectorSessionPostPathEnvName,
command.EnvNameTerminalSessionEnabled,
command.EnvNameTerminalSessionPrePath,
command.EnvNameTerminalSessionPostPath,
); err != nil {
logger.Info("session setup is skipped because the environment variable is not set", zap.Error(err))
return writeNoopShellCommand(out)
}

sessionSetupEnabled := os.Getenv(command.EnvCollectorSessionEnvName)
sessionSetupEnabled := os.Getenv(command.EnvNameTerminalSessionEnabled)
if val, err := strconv.ParseBool(sessionSetupEnabled); err != nil || !val {
logger.Debug("session setup is skipped", zap.Error(err), zap.Bool("value", val))
return writeNoopShellCommand(out)
}

envSetter := command.NewScriptEnvSetter(
os.Getenv(command.EnvCollectorSessionPrePathEnvName),
os.Getenv(command.EnvCollectorSessionPostPathEnvName),
os.Getenv(command.EnvNameTerminalSessionPrePath),
os.Getenv(command.EnvNameTerminalSessionPostPath),
debug,
)
if err := envSetter.SetOnShell(out); err != nil {
Expand Down
4 changes: 0 additions & 4 deletions internal/command/env_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ import (
const maxScannerBufferSizeInBytes = 1024 * 1024 * 1024 // 1GB

const (
EnvCollectorSessionEnvName = "RUNME_SESSION"
EnvCollectorSessionPrePathEnvName = "RUNME_SESSION_PREPATH"
EnvCollectorSessionPostPathEnvName = "RUNME_SESSION_POSTPATH"

envCollectorEncKeyEnvName = "RUNME_ENCRYPTION_KEY"
envCollectorEncNonceEnvName = "RUNME_ENCRYPTION_NONCE"
)
Expand Down
4 changes: 2 additions & 2 deletions internal/command/env_collector_fifo_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ func (c *envCollectorFifo) Diff() (changed []string, deleted []string, _ error)

func (c *envCollectorFifo) ExtraEnv() []string {
result := []string{
createEnv(EnvCollectorSessionPrePathEnvName, c.prePath()),
createEnv(EnvCollectorSessionPostPathEnvName, c.postPath()),
createEnv(EnvNameTerminalSessionPrePath, c.prePath()),
createEnv(EnvNameTerminalSessionPostPath, c.postPath()),
}
if c.encKey != nil && c.encNonce != nil {
result = append(
Expand Down
4 changes: 2 additions & 2 deletions internal/command/env_collector_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func (c *envCollectorFile) Diff() (changed []string, deleted []string, _ error)

func (c *envCollectorFile) ExtraEnv() []string {
result := []string{
createEnv(EnvCollectorSessionPrePathEnvName, c.prePath()),
createEnv(EnvCollectorSessionPostPathEnvName, c.postPath()),
createEnv(EnvNameTerminalSessionPrePath, c.prePath()),
createEnv(EnvNameTerminalSessionPostPath, c.postPath()),
}
if c.encKey != nil && c.encNonce != nil {
result = append(
Expand Down
8 changes: 8 additions & 0 deletions internal/command/terminal_session.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package command

// Constants for supporting terminal session via the "beta session" command.
const (
EnvNameTerminalSessionEnabled = "_RUNME_TERMINAL_SESSION_ENABLED"
EnvNameTerminalSessionPrePath = "_RUNME_TERMINAL_SESSION_PREPATH"
EnvNameTerminalSessionPostPath = "_RUNME_TERMINAL_SESSION_POSTPATH"
)

0 comments on commit 4cb423d

Please sign in to comment.