Skip to content

Commit

Permalink
Merge pull request #2540 from vdice/feat/archive-layers-opt
Browse files Browse the repository at this point in the history
feat(oci): add env var to force use of archive layers on push
  • Loading branch information
vdice authored Jun 3, 2024
2 parents d1dabb2 + 32d200b commit bf4225a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions crates/oci/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const CONFIG_FILE: &str = "config.json";
const LATEST_TAG: &str = "latest";
const MANIFEST_FILE: &str = "manifest.json";

/// Env var to force use of archive layers when publishing a Spin app
const SPIN_OCI_ARCHIVE_LAYERS_OPT: &str = "SPIN_OCI_ARCHIVE_LAYERS";

const MAX_PARALLEL_PULL: usize = 16;
/// Maximum layer count allowed per app, set in accordance to the lowest
/// known maximum per image in well-known OCI registry implementations.
Expand Down Expand Up @@ -159,9 +162,11 @@ impl Client {
.await
.context("could not assemble layers for locked application")?;

// If layer count exceeds MAX_LAYER_COUNT-1, assemble archive layers instead.
// (We'll be adding one more layer to represent the locked application config.)
if layers.len() > MAX_LAYER_COUNT - 1 {
// If SPIN_OCI_ARCHIVE_LAYERS_OPT is set *or* if layer count exceeds MAX_LAYER_COUNT-1,
// assemble archive layers instead. (An additional layer to represent the locked
// application config is added.)
if std::env::var(SPIN_OCI_ARCHIVE_LAYERS_OPT).is_ok() || layers.len() > MAX_LAYER_COUNT - 1
{
locked_app = locked.clone();
layers = self
.assemble_layers(&mut locked_app, AssemblyMode::Archive)
Expand Down

0 comments on commit bf4225a

Please sign in to comment.