-
Notifications
You must be signed in to change notification settings - Fork 3
expose v1 artifacts for installinator #51
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,7 @@ use crate::error::Error; | |
| use crate::error::ErrorKind; | ||
| use crate::error::try_path; | ||
| use crate::repo::ArtifactData; | ||
| use crate::repo::InstallinatorV1Artifact; | ||
| use crate::repo::read_target; | ||
| use crate::repo::read_target_json; | ||
| use crate::repo::read_target_vec; | ||
|
|
@@ -66,6 +67,8 @@ pub(super) struct PartialRepository { | |
| pub(super) system_version: Version, | ||
| pub(super) artifacts: ArtifactSet, | ||
| pub(super) artifact_data: BTreeMap<Artifact, ArtifactData>, | ||
| pub(super) installinator_v1_document: Option<ArtifactHash>, | ||
| pub(super) installinator_v1_artifacts: Vec<InstallinatorV1Artifact>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a very small structural nit, but: would this be slightly cleaner as one field? My initial driver for this was "would it make sense to have a document of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had thought about this but I wasn't really happy with how the code was written. This implementation felt clearer to review. |
||
| } | ||
|
|
||
| impl PartialRepository { | ||
|
|
@@ -98,6 +101,8 @@ pub(crate) async fn from_loaded( | |
| system_version, | ||
| artifacts: ArtifactSet::default(), | ||
| artifact_data: BTreeMap::new(), | ||
| installinator_v1_document: None, | ||
| installinator_v1_artifacts: Vec::new(), | ||
| }; | ||
| let mut installinator_document = None; | ||
| for V1Artifact { version, kind, target } in v1_artifacts { | ||
|
|
@@ -214,6 +219,14 @@ pub(crate) async fn from_loaded( | |
| } | ||
|
|
||
| V1KnownArtifactKind::ControlPlane => { | ||
| partial.installinator_v1_artifacts.push( | ||
| InstallinatorV1Artifact { | ||
| version, | ||
| hash, | ||
| length, | ||
| target_name: target.clone(), | ||
| }, | ||
| ); | ||
| CompositeArtifact::unpack(tuf_repo, target) | ||
| .await? | ||
| .read_control_plane(&mut partial) | ||
|
|
@@ -226,6 +239,15 @@ pub(crate) async fn from_loaded( | |
| // for the v2 artifacts once all of the potential artifacts are | ||
| // extracted. | ||
| V1KnownArtifactKind::InstallinatorDocument => { | ||
| partial.installinator_v1_document = Some(hash); | ||
| partial.installinator_v1_artifacts.push( | ||
| InstallinatorV1Artifact { | ||
| version: version.clone(), | ||
| hash, | ||
| length, | ||
| target_name: target.clone(), | ||
| }, | ||
| ); | ||
| installinator_document = Some((version, target)); | ||
| continue; | ||
| } | ||
|
|
||
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.
Needing to do this makes me slightly nervous - this means any call site that uses an
ArtifactHandlehas to know to checkinstallinator_v1_target_name. Although since it's private, maybe this is the only call site and this isn't a huge deal?Would it make sense to, instead of adding a separate
installinator_v1_target_namefield, changeArtifactHandle::artifactto be an enum containing eitherArtifactor the v1 target nameString?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.
I had initially considered the enum, but we still need to create an
Artifactto support thefn artifactAPI, and that can't be a newly-generated artifact because we return a reference.This module is the only possible call site for this method,
ArtifactHandleis intentionally opaque.