Skip to content

Commit 32d200b

Browse files
committed
feat(oci): add env var to force use of archive layers on push
Signed-off-by: Vaughn Dice <[email protected]>
1 parent d1dabb2 commit 32d200b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

crates/oci/src/client.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ const CONFIG_FILE: &str = "config.json";
3838
const LATEST_TAG: &str = "latest";
3939
const MANIFEST_FILE: &str = "manifest.json";
4040

41+
/// Env var to force use of archive layers when publishing a Spin app
42+
const SPIN_OCI_ARCHIVE_LAYERS_OPT: &str = "SPIN_OCI_ARCHIVE_LAYERS";
43+
4144
const MAX_PARALLEL_PULL: usize = 16;
4245
/// Maximum layer count allowed per app, set in accordance to the lowest
4346
/// known maximum per image in well-known OCI registry implementations.
@@ -159,9 +162,11 @@ impl Client {
159162
.await
160163
.context("could not assemble layers for locked application")?;
161164

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

0 commit comments

Comments
 (0)