Add SSH config and env var#3938
Conversation
💡 Codex Reviewagent/internal/job/checkout.go Line 231 in cfb160e When agent/internal/job/checkout.go Lines 849 to 852 in cfb160e The deferred cleanup writes cleanup errors into the local ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
|
||
| signals := make(chan os.Signal, 1) | ||
| signal.Notify(signals, os.Interrupt, | ||
| signal.Notify( |
There was a problem hiding this comment.
This isn't really a change, it's just a result of using gofumpt for my formatting rather than gofmt, I'm happy to default to the latter, though
| if err == nil { | ||
| err = cleanupErr | ||
| } else { | ||
| err = errors.Join(err, cleanupErr) | ||
| } |
There was a problem hiding this comment.
err has (meanwhile) become retErr, and errors.Join does the right thing with nil (i.e. drops it), so:
| if err == nil { | |
| err = cleanupErr | |
| } else { | |
| err = errors.Join(err, cleanupErr) | |
| } | |
| retErr = errors.Join(retErr, cleanupErr) |
| } | ||
|
|
||
| // os.MkdirTemp creates the directory with mode 0o700 on Unix, giving the | ||
| // key file inside an additional layer of protection from sibling builds. |
There was a problem hiding this comment.
Sibling builds would have to be running under a different uid to be prevented from accessing inside a dir with mode 0o700, right?
| // | ||
| // Only the default checkout phase invokes this; custom checkout hooks must | ||
| // arrange their own credentials. | ||
| func (e *Executor) prepareGitSSHKey() (_ string, _ func() error, retErr error) { |
There was a problem hiding this comment.
Naming the return args has clear readability and documentation upsides over using _:
| func (e *Executor) prepareGitSSHKey() (_ string, _ func() error, retErr error) { | |
| func (e *Executor) prepareGitSSHKey() (sshKeyPath string, cleanup func() error, retErr error) { |
Description
This allows for folks to set the location of an SSH key, with a view to later support that setting via YAML.
Context
Part of the agent checkout improvements project.
Changes
Testing
go test ./...). Buildkite employees may check this if the pipeline has run automatically.go tool gofumpt -extra -w .)Ran locally:
Disclosures / Credits
Used AI to highlight any shortcomings or lacking test coverage; it fixed the initial issue with the tests running on Windows where explicitly closing the checkoutRoot was required.
I also used it to help write this description; scanning the files for changes to remind me what I'd done.