-
Notifications
You must be signed in to change notification settings - Fork 522
[image-save-load]: support for stdin/stdout #734
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
base: main
Are you sure you want to change the base?
[image-save-load]: support for stdin/stdout #734
Conversation
3029055 to
b0de0e0
Compare
09dae23 to
023aa94
Compare
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]>
|
@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! |
f2b7f54 to
b230226
Compare
b2f6d4d to
e06ef37
Compare
jglogan
left a comment
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.
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()) |
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.
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 |
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.
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.
Type of Change
Motivation and Context
Closes #559
Testing
Example Commands with Outputs
Save the docker image to the
test.tarfileUse the
test.tarfile to load the imagecontainer image load < test.tar Loaded images: docker.io/library/nginx:latest