Skip to content

Conversation

@inickles
Copy link
Collaborator

This brings the output_path parameter and functionality from the build command to other build commands, such as create-ec2-image and create-oxide-image, which enables me to make use of GitHub Artifact Attestation for the builds I'm doing.

In addition to moving output_path to build::Args, I moved the code that handles creation of the temp and persistent files it into the build::create_iso, which seemed more appropriate than leaving it a level up for each of the CLI commands to implement.

Also, I bumped the version number because this is a breaking change.

@inickles inickles requested a review from iliana May 14, 2024 17:33
src/build.rs Outdated
Comment on lines 151 to 158
pub(crate) fn create_iso(self) -> Result<(std::path::PathBuf, Metadata)> {
let output_path_arg = self.output_path.clone();
let (mut file, temp_path) = if let Some(output_path) = &output_path_arg {
NamedTempFile::new_in(output_path.parent().context("output path has no parent")?)?
.into_parts()
} else {
NamedTempFile::new()?.into_parts()
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function doesn't return either a NamedTempFile or TempPath, so the output path will be deleted when temp_path is dropped at the end of the function if output_path_arg is None.

To get the behavior you want you might need to have an enum with two variants, a PathBuf and a TempPath.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, hmm.

What do you think about using std::fs::copy instead of NamedTempFile::persist so it's not consumed and then we have this return the TempPath we created?

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.

3 participants