-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement "runme beta session" #683
base: main
Are you sure you want to change the base?
Conversation
d76e4ee
to
d4bfd83
Compare
7351fbf can be cherry-picked to main safely. After one of the GitHub Actions update, the CI workflow does not work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this is the right direction. Essentially keeping it simple. See comments, please.
I'm getting this locally on
Same happens when I source it inside of |
@sourishkrout can you paste the output of executing |
here you go: $ runme beta session setup
#!/bin/sh
/Users/sourishkrout/Projects/stateful/oss/runme/runme env dump --insecure >
__cleanup() {
rv=$?
/Users/sourishkrout/Projects/stateful/oss/runme/runme env dump --insecure >
exit $rv
}
trap -- "__cleanup" EXIT oh, I see the problem now... no destinations for the redirects |
Thanks! Yeah, I will add a check to protect from this... Overall, |
d9d4b71
to
7a12f2d
Compare
It does not work for me. Can you provide step-by-step instructions on how to start with a clean slate? How are you running this locally? I mainly don't understand how the Isn't this a chicken/egg problem @adambabik? |
I might misunderstand the purpose of |
@sourishkrout sorry, I missed your comment. It should work exactly as it's described in the PR description. In my case:
All the shenanigans with the |
7a12f2d
to
b571b10
Compare
It shows empty for me following the exact instructions 🤔. Not sure why, @adambabik. |
if err := requireEnvs( | ||
command.EnvCollectorSessionEnvName, | ||
command.EnvCollectorSessionPrePathEnvName, | ||
command.EnvCollectorSessionPostPathEnvName, | ||
); err != nil { | ||
logger.Info("session setup is skipped because the environment variable is not set", zap.Error(err)) | ||
return writeNoopShellCommand(out) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I don't get is how these won't ever produce an error? In other words how are they set in the first place if they are expected by setup
@adambabik?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order is that beta session
starts a shell process with those envs provided first. This shell process starts and executes, in the case of zsh, the .zshrc
file inside which beta session setup
is called.
It's perfectly normal that it typically will error and output no-op shell command in .zshrc
, but from the user point of view it should be invisible. We can recommend protecting source <(/path/to/runme beta session setup)
with a conditional checking command.EnvCollectorSessionEnvName
to avoid that.
sessionSetupEnabled := os.Getenv(command.EnvCollectorSessionEnvName) | ||
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) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, is RUNME_SESSION
expected to be a bool (serialized)? We are using the env var to hold the session ID all over the place so a semantic clash here is bad if bool <> SessionID (both string).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yeah, that's a good point. I didn't notice the clash. I will change it to something like RUNME_TERM_SESSION_ENABLED
.
In order to debug it, try |
50b3adb
to
2f89508
Compare
Quality Gate failedFailed conditions |
It implements a new command that allows starting a session and collecting all exported environment variables throughout its lifetime.
Testing
As a prerequisite, add the following to your shell's startup script (
.bashrc
or.zshrc
):Then, you can start a new session in the terminal:
The session is a regular shell of your choice, inferred from
$SHELL
. You can use it like a normal shell, but any exported environment variables will be returned upon exiting the session viaexit
.Currently, the collected variables are printed out, but in the future, they will be routed to a proper store.