Skip to content

Conversation

@saehejkang
Copy link
Contributor

@saehejkang saehejkang commented Oct 7, 2025

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Closes #559

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

Example Commands with Outputs

Save the docker image to the test.tar file

container image save docker.io/library/nginx:latest > test.tar
⠦ Saving image(s) [3s]

Use the test.tar file to load the image

container image load < test.tar
Loaded images:                  
docker.io/library/nginx:latest

@saehejkang saehejkang force-pushed the image-save-load-support-stdin-stdout branch 2 times, most recently from 3029055 to b0de0e0 Compare October 7, 2025 06:37
@saehejkang saehejkang changed the title [image-save-load]: support stdin for filepath [image-save-load]: support for stdin/stdout Oct 17, 2025
@saehejkang saehejkang force-pushed the image-save-load-support-stdin-stdout branch from 09dae23 to 023aa94 Compare November 2, 2025 05:52
jglogan added a commit that referenced this pull request Nov 15, 2025
When working on test cases for #827 and #734 the following issues
occurred
  1. There was no support to pass in `Data` for `stdin` (input pipe added
    + new argument for the data)
  2. Pipes were getting blocked during the `try process.run()` and
    `process.waitUntilExit()` (order of operations were fixed)
  3. We need the binary data for directly piping the `stdout` data to
    `stdin`, and converting the data to a `string`, returns `""` (added a
    new value to the tuple)

I opened a new PR here for this as I did not want to bloat the other PRs
with so many updates. At first I thought of creating a new function
named `runStdinStdout`, but that seemed redundant as it pretty much was
going to do the same thing as `run`.

## Testing
- [x] Tested locally
- [x] Added/updated tests
- [ ] Added/updated docs

---------

Co-authored-by: J Logan <[email protected]>
@jglogan
Copy link
Contributor

jglogan commented Nov 15, 2025

@saehejkang Just merged the underlying test change, could you resolve conflicts on this? I'll have a look after and then try building it and doing a little local testing. Thanks!

@saehejkang saehejkang force-pushed the image-save-load-support-stdin-stdout branch 2 times, most recently from f2b7f54 to b230226 Compare November 15, 2025 02:52
@saehejkang saehejkang force-pushed the image-save-load-support-stdin-stdout branch from b2f6d4d to e06ef37 Compare November 15, 2025 03:10
@saehejkang
Copy link
Contributor Author

@jglogan #827, that also relied on the underlying test change, is ready. I squashed and cleaned up the commits for readability in both PRs.

Copy link
Contributor

@jglogan jglogan left a comment

Choose a reason for hiding this comment

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

Looks good, wanted to see what your thought about making the conditionals for the stdio cases a little more straightforward. And thanks for adding the tests, that capability will likely be handy elsewhere.


progress.set(description: "Loading tar archive")
let loaded = try await ClientImage.load(from: input)
let loaded = try await ClientImage.load(from: input ?? tempFile.path())
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: What do you think about restructuring load like to only run the code that's needed for each case? The only bit of code that repeats is the ClientImage.load line, and we would be removing a conditional from that.

var loaded: ClientImage
if input == nil {
    // create tmpfile, defer delete, copy stdin to file
    loaded = try await ClientImage.load(from: tempFile.path())
} else {
    // ensure input exists
    loaded = loaded = try await ClientImage.load(from: input)
}


try await ClientImage.save(references: references, out: output ?? tempFile.path(), platform: p)

// Write to stdout
Copy link
Contributor

Choose a reason for hiding this comment

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

Same for this one, we could put an else on this that just saves the image to output, and move the above code into the output == nil case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: image save and image load should support stdin.

2 participants