Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Use CONTENT_ANNOTATION in more places, change name
Browse files Browse the repository at this point in the history
Use the `const` we defined so it's easy to find the uses of it.
Also, change the name to be "namespaced" more clearly;
see https://github.com/opencontainers/image-spec/blob/main/annotations.md
for more.
  • Loading branch information
cgwalters committed May 15, 2023
1 parent 7388fd0 commit 48ef2d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/src/chunking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::num::NonZeroU32;
use std::rc::Rc;
use std::time::Instant;

use crate::container::CONTENT_ANNOTATION;
use crate::objectsource::{ContentID, ObjectMeta, ObjectMetaMap, ObjectSourceMeta};
use crate::objgv::*;
use crate::statistics;
Expand All @@ -32,7 +33,6 @@ pub(crate) type ChunkMapping = BTreeMap<RcStr, (u64, Vec<Utf8PathBuf>)>;

const LOW_PARTITION: &str = "2ls";
const HIGH_PARTITION: &str = "1hs";
const CONTENT_ANNOTATION: &str = "Content";

#[derive(Debug, Default)]
pub(crate) struct Chunk {
Expand Down
8 changes: 3 additions & 5 deletions lib/src/container/encapsulate.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! APIs for creating container images from OSTree commits
use super::ocidir::{Layer, OciDir};
use super::{ocidir, OstreeImageReference, Transport};
use super::{ocidir, OstreeImageReference, Transport, CONTENT_ANNOTATION};
use super::{ImageReference, SignatureSource, OSTREE_COMMIT_LABEL};
use crate::chunking::{Chunk, Chunking, ObjectMetaSized};
use crate::container::skopeo;
Expand Down Expand Up @@ -151,19 +151,17 @@ fn export_chunked(
.clone();

// Add the ostree layer
let mut annotation_ostree_layer = HashMap::new();
annotation_ostree_layer.insert("Content".to_string(), "ostree_commit".to_string());
ociw.push_layer(
manifest,
imgcfg,
ostree_layer,
description,
Some(annotation_ostree_layer),
None,
);
// Add the component/content layers
for (layer, name, packages) in layers {
let mut annotation_component_layer = HashMap::new();
annotation_component_layer.insert("Content".to_string(), packages.join(","));
annotation_component_layer.insert(CONTENT_ANNOTATION.to_string(), packages.join(","));
ociw.push_layer(
manifest,
imgcfg,
Expand Down
4 changes: 4 additions & 0 deletions lib/src/container/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ use std::str::FromStr;
/// The label injected into a container image that contains the ostree commit SHA-256.
pub const OSTREE_COMMIT_LABEL: &str = "ostree.commit";

/// The name of an annotation attached to a layer which names the packages/components
/// which are part of it.
pub(crate) const CONTENT_ANNOTATION: &str = "ostree.components";

/// Our generic catchall fatal error, expected to be converted
/// to a string to output to a terminal or logs.
type Result<T> = anyhow::Result<T>;
Expand Down

0 comments on commit 48ef2d3

Please sign in to comment.