diff --git a/internal/cmd/beta/session_cmd.go b/internal/cmd/beta/session_cmd.go index 679d434df..e1278de63 100644 --- a/internal/cmd/beta/session_cmd.go +++ b/internal/cmd/beta/session_cmd.go @@ -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...)..., ), } @@ -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 { diff --git a/internal/command/env_collector.go b/internal/command/env_collector.go index d697b560a..c845b8faa 100644 --- a/internal/command/env_collector.go +++ b/internal/command/env_collector.go @@ -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" ) diff --git a/internal/command/env_collector_fifo_unix.go b/internal/command/env_collector_fifo_unix.go index 73aa60318..aa40f1801 100644 --- a/internal/command/env_collector_fifo_unix.go +++ b/internal/command/env_collector_fifo_unix.go @@ -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( diff --git a/internal/command/env_collector_file.go b/internal/command/env_collector_file.go index 5fdab47a2..3f62ff79d 100644 --- a/internal/command/env_collector_file.go +++ b/internal/command/env_collector_file.go @@ -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( diff --git a/internal/command/terminal_session.go b/internal/command/terminal_session.go new file mode 100644 index 000000000..3e80a41e9 --- /dev/null +++ b/internal/command/terminal_session.go @@ -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" +)