Skip to content

Commit 56e6e17

Browse files
authored
Merge pull request #1825 from itowlson/oci-push-locked
Expose an API to push a LockedApp to a registry
2 parents 9e8324c + 0ed4c82 commit 56e6e17

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

crates/oci/src/client.rs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use oci_distribution::{
1313
Reference,
1414
};
1515
use reqwest::Url;
16-
use spin_app::locked::{ContentPath, ContentRef};
16+
use spin_app::locked::{ContentPath, ContentRef, LockedApp};
1717
use spin_loader::cache::Cache;
1818
use spin_manifest::Application;
1919
use tokio::fs;
@@ -71,8 +71,35 @@ impl Client {
7171
// We should be able to use assets::collect instead when constructing the locked app.
7272
let locked = spin_trigger::locked::build_locked_app(app.clone(), working_dir.path())
7373
.context("cannot create locked app")?;
74-
let mut locked = locked.clone();
74+
let locked = locked.clone();
7575

76+
self.push_locked_core(locked, auth, reference).await
77+
}
78+
79+
/// Push a Spin application to an OCI registry and return the digest (or None
80+
/// if the digest cannot be determined).
81+
pub async fn push_locked(
82+
&mut self,
83+
locked: LockedApp,
84+
reference: impl AsRef<str>,
85+
) -> Result<Option<String>> {
86+
let reference: Reference = reference
87+
.as_ref()
88+
.parse()
89+
.with_context(|| format!("cannot parse reference {}", reference.as_ref()))?;
90+
let auth = Self::auth(&reference).await?;
91+
92+
self.push_locked_core(locked, auth, reference).await
93+
}
94+
95+
/// Push a Spin application to an OCI registry and return the digest (or None
96+
/// if the digest cannot be determined).
97+
async fn push_locked_core(
98+
&mut self,
99+
mut locked: LockedApp,
100+
auth: RegistryAuth,
101+
reference: Reference,
102+
) -> Result<Option<String>> {
76103
// Opt-in to omitting layers for files that have been inlined into the manifest.
77104
// TODO: After full integration this can be turned on by default.
78105
let skip_inlined_files = !std::env::var_os("SPIN_OCI_SKIP_INLINED_FILES")

0 commit comments

Comments
 (0)