Skip to content

fix(envbuilder): make init command more readable #413

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion envbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/kballard/go-shellquote"
"github.com/mattn/go-isatty"
"github.com/mitchellh/go-wordwrap"
"github.com/sirupsen/logrus"
"github.com/tailscale/hujson"
"golang.org/x/xerrors"
Expand Down Expand Up @@ -104,7 +105,10 @@ func Run(ctx context.Context, opts options.Options, preExec ...func()) error {
return fmt.Errorf("set uid: %w", err)
}

opts.Logger(log.LevelInfo, "=== Running init command as user %q: %q", args.UserInfo.user.Username, append([]string{opts.InitCommand}, args.InitArgs...))
initCmd := strings.Join(append([]string{opts.InitCommand}, args.InitArgs...), " ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unfortunate side-effect of this is that it’s lossy. We’re printing ”/bin/bash -c #!… which is actually not true without quotes, so you can’t copy paste the output and run it like you could previously (as an example).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea came from a customer call. An alternative option is to soft wrap in the UI but I figured it would also be cheap enough to do on the envbuilder end. I didn't think about the copy-pastability of the output!

opts.Logger(log.LevelInfo, "=== Running init command as user %q:", args.UserInfo.user.Username)
opts.Logger(log.LevelInfo, wordwrap.WrapString(initCmd, 80))
opts.Logger(log.LevelInfo, "===")
for _, fn := range preExec {
fn()
}
Expand Down