Skip to content

Add a more generic "prepend or append instructions" method#6700

Merged
mtrmac merged 1 commit intocontainers:mainfrom
nalind:pend-instructions
Mar 2, 2026
Merged

Add a more generic "prepend or append instructions" method#6700
mtrmac merged 1 commit intocontainers:mainfrom
nalind:pend-instructions

Conversation

@nalind
Copy link
Member

@nalind nalind commented Feb 27, 2026

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Refactor our handling of --env and --label options so that it'll be easier to add more instructions at the beginning and end of stages.

How to verify it

This shouldn't break the current set of tests.

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

Does this PR introduce a user-facing change?

None

@nalind nalind added the No New Tests Allow PR to proceed without adding regression tests label Feb 27, 2026
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 27, 2026
@packit-as-a-service
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

Refactor our handling of --env and --label options so that it'll be
easier to add more instructions at the beginning and end of stages.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
@nalind
Copy link
Member Author

nalind commented Mar 2, 2026

@containers/buildah-maintainers PTAL, I'd like to make this available for use in #6556

Copy link
Contributor

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

LGTM — feel free to merge with or without the append part.


Generally, I’d aesthetically prefer an architecture where the in-memory data is constructed ~directly (perhaps with a createNameVal counterpart to parseNameVal instead of the round-trip through a text syntax (and worrying about escaping control syntax), but 1) this is pre-existing, and 2) we would need to construct Node.Original anyway, so there would not be much of a benefit.

}
stage.Node.Children = append(stage.Node.Children, additionalNode.Children...)
}
appendInstructions = slices.Concat(appendInstructions, []string{labelLine})
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn’t this just append? Also in the other code.

Copy link
Member Author

Choose a reason for hiding this comment

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

My expectation is that we'll need to turn prependInstructions and appendInstructions into arguments for this method in #6556, so we'd need to change this instance to something similar. You're right about the other one.

Copy link
Contributor

Choose a reason for hiding this comment

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

ACK, slices.Concat is certainly safer.

@mtrmac mtrmac merged commit 73f12be into containers:main Mar 2, 2026
40 checks passed
@nalind nalind deleted the pend-instructions branch March 2, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No New Tests Allow PR to proceed without adding regression tests size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants