-
Notifications
You must be signed in to change notification settings - Fork 3
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
refactor: create image trait with an impl for docker and podman #71
Conversation
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.
Very nice! I had some feedback, largely around naming, but this is definitely a step in the right direction to clean up the codebase!
src/docker.rs
Outdated
// Stop the container | ||
match self.stop(container_id).await { | ||
Ok(_) => {} | ||
Err(e) => { | ||
return Err(anyhow!("failed to stop the image: {}", e)); | ||
} | ||
} |
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: I think this should go under the stop()
function for clarity
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.
Which part, creating the error?
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.
No, I meant stopping the container. Stopping and deleting a container are related, so they can both go under stop()
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.
Ah so are you saying that instead of copy_files()
starting and stopping the container via start()
and stop()
we should have those functions be called outside of copy_files()
directly in the lib.rs
run function? Something like this:
// src/lib.rs - fn run()
// Create the container
let container_id = match container.start().await {
Ok(id) => id,
Err(e) => {
return Err(anyhow!("failed to start the image: {}", e));
}
// Copy files from the image
match container
.copy_files(
config.content_path,
config.download_path,
config.write_to_stdout,
container_id,
)
.await
{
Ok(_) => {}
Err(e) => {
return Err(anyhow!("❌ error copying the image's files: {}", e));
}
}
// Stop the container
match container.stop(container_id).await {
Ok(_) => {}
Err(e) => {
return Err(anyhow!("failed to stop the image: {}", e));
}
}
8a67b0f
to
ce6c139
Compare
ce6c139
to
d35a7af
Compare
@exdx Okay with the latest push I broke out the |
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.
LGTM! Great job working with async traits. Feel free to merge.
The only remaining nit I had was to move the container stop logic into the stop()
function instead of in the copy_files()
function, since it's more related to stopping and removing the container
Is #57 addressed by these changes, or do we still need to look into it? |
The underlying logic of |
d35a7af
to
4b072d4
Compare
Another PR in a series of refactors that I'm doing that are aimed at reducing the complexity and extensibility of our code base. This one creates a new
Image
trait with two implementations fordocker
andpodman
so they can have their own unique functionality.