Propagate context.Context to build logic #2287
Merged
+305
−260
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.
I'm doing some work in the build code that requires a
context.Context
(adding anothercommand.Command
implementation that hits the docker engine directly). Since most of the build code doesn't accept a context, I had to make a ton of tiny changes to pass a context from a command's run function through to the dockerfile generators and the dockercommand.Command
interface.These changes shouldn't have a meaningful impact, but extracting them into a separate PR will make the next one much easier to review. 😅
The vast majority of changes are adding
ctx context.Context
to function signatures then passing it on. The only actual changes that use the context are:exec.Command(...
now useexec.CommandContext(ctx, ...
, such as this example.context.Background()
orcontext.TODO()
and are now using the parent context provided (such as this)