-
Couldn't load subscription status.
- Fork 5
[ONPREM-2408] Add entrypoint override #174
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
698732f
Add entrypoint override
christian-stephen 2d48d8e
Add changelog entry
christian-stephen d6746c2
Make entrypoint override a command
christian-stephen 66f8e8c
Fix entrypoint args
christian-stephen e96ed90
Add acceptance test
christian-stephen fd496b1
Skip acceptance test on Windows
christian-stephen bbef8d9
Add better help description for entrypoint override
christian-stephen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| Usage: test-app [flags] | ||
|
|
||
| Flags: | ||
| -h, --help Show context-sensitive help. | ||
| --entrypoint=ENTRYPOINT,... | ||
| Custom init process to execute as PID 1, overriding | ||
| orchestrator. Must accept and execute the orchestrator | ||
| command/arguments (e.g., exec "$@"), propagate signals, | ||
| and handle standard init responsibilities like reaping zombie | ||
| processes ($CIRCLECI_GOAT_ENTRYPOINT). | ||
| --termination-grace-period=10s | ||
| How long the agent will wait for the task to complete if | ||
| interrupted ($CIRCLECI_GOAT_TERMINATION_GRACE_PERIOD). | ||
| --health-check-addr=":7623" | ||
| Address for the health check API to listen on | ||
| ($CIRCLECI_GOAT_HEALTH_CHECK_ADDR). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "os" | ||
| "strings" | ||
| ) | ||
|
|
||
| func Environ(extraEnv ...string) (environ []string) { | ||
| for _, env := range os.Environ() { | ||
| if strings.HasPrefix(env, "CIRCLECI_GOAT") { | ||
| // Prevent internal configuration from being unintentionally injected in the command environment | ||
| continue | ||
| } | ||
| environ = append(environ, env) | ||
| } | ||
| if extraEnv != nil { | ||
| environ = append(environ, extraEnv...) | ||
| } | ||
|
|
||
| return environ | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package entrypoint | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "os" | ||
| "syscall" | ||
|
|
||
| "github.com/circleci/ex/o11y" | ||
| ) | ||
|
|
||
| type Entrypoint struct { | ||
| args []string | ||
| } | ||
|
|
||
| func New(args []string) Entrypoint { | ||
| return Entrypoint{args} | ||
| } | ||
|
|
||
| func (e Entrypoint) Run(ctx context.Context) (err error) { | ||
| _, span := o11y.StartSpan(ctx, "override-entrypoint") | ||
| defer o11y.End(span, &err) | ||
|
|
||
| args := append([]string{e.args[0]}, os.Args[0], "run-task") | ||
| if len(e.args) > 1 { | ||
| args = append(args, e.args[1:]...) | ||
| } | ||
|
|
||
| //#nosec:G204 // this is intentionally setting up a command | ||
| if err := syscall.Exec(e.args[0], args, os.Environ()); err != nil { | ||
| return fmt.Errorf("error executing entrypoint override: %w", err) | ||
| } | ||
|
|
||
| return nil | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 entrypoint override relies on exec for process replacement, so won't work on Windows for now.