Skip to content
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

internal/mkcw.Archive(): handle extra image content #5252

Merged
merged 2 commits into from
Jan 17, 2024

Conversation

nalind
Copy link
Member

@nalind nalind commented Jan 8, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Add the --add-file to the mkcw command, and handle it when commit is given the --cw option: when we have extra files to add to the image, handle them by adding them to the upper overlay layer before creating the plaintext filesystem image.

Also touch up a couple of man pages.

How to verify it

Extended integration test!

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

Does this PR introduce a user-facing change?

`buildah mkcw` now accepts a `--add-file` flag, which can be used to add a file to the committed image without modifying the working container which is being committed.

@openshift-ci openshift-ci bot added kind/feature Categorizes issue or PR as related to a new feature. approved labels Jan 8, 2024
@@ -70,8 +71,6 @@ func (c chainRetrievalError) Error() string {

// Archive generates a WorkloadConfig for a specified directory and produces a
// tar archive of a container image's rootfs with the expected contents.
// The input directory will have a ".krun_config.json" file added to it while
// this function is running, but it will be removed on completion.
Copy link
Member Author

Choose a reason for hiding this comment

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

This comment was no longer correct as of #5224, but I forgot to drop it during that one.

}
defer input.Close()
if _, err := io.Copy(output, input); err != nil {
return fmt.Errorf("copying contents of %q to %q in root filesystem: %w", location, content, err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Above error stmt is using container root filesystem instead of only root filesystem, maybe we can just keep any one of them for consistency.

Suggested change
return fmt.Errorf("copying contents of %q to %q in root filesystem: %w", location, content, err)
return fmt.Errorf("copying contents of %q to %q in container root filesystem: %w", location, content, err)

Copy link
Member Author

Choose a reason for hiding this comment

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

Changing it. Also, I had the orders of location and content mixed up, switching them.

Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

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

LGTM one comment above.

if len(addFile) > 0 {
options.ExtraImageContent = make(map[string]string)
for _, spec := range addFile {
specSlice := strings.SplitN(spec, ":", 2)
Copy link
Member

Choose a reason for hiding this comment

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

Are we supposed to use strings.Cut now?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Correcting it.

@rhatdan
Copy link
Member

rhatdan commented Jan 13, 2024

LGTM
But one question.

When we have extra files to add to the image, handle them by adding them
to the upper overlay layer before creating the plaintext filesystem
image.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
And don't refer to a filename in an example as a directory in
accompanying text.

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

rhatdan commented Jan 17, 2024

/approve
/lgtm

Copy link
Contributor

openshift-ci bot commented Jan 17, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: flouthoc, nalind, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [flouthoc,nalind,rhatdan]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 8098bf2 into containers:main Jan 17, 2024
34 checks passed
@nalind nalind deleted the mkcw-add-files branch January 17, 2024 14:01
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved kind/feature Categorizes issue or PR as related to a new feature. lgtm locked - please file new issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants