|
1 | 1 | //! Spin's client for distributing applications via OCI registries
|
2 | 2 |
|
| 3 | +use std::collections::HashMap; |
3 | 4 | use std::path::{Path, PathBuf};
|
4 | 5 |
|
5 | 6 | use anyhow::{bail, Context, Result};
|
@@ -174,15 +175,31 @@ impl Client {
|
174 | 175 | SPIN_APPLICATION_MEDIA_TYPE.to_string(),
|
175 | 176 | None,
|
176 | 177 | );
|
| 178 | + let config_layer_digest = locked_config_layer.sha256_digest().clone(); |
177 | 179 | layers.push(locked_config_layer);
|
178 | 180 |
|
| 181 | + let mut labels = HashMap::new(); |
| 182 | + labels.insert( |
| 183 | + "com.fermyon.spin.lockedAppDigest".to_string(), |
| 184 | + config_layer_digest, |
| 185 | + ); |
| 186 | + let cfg = oci_distribution::config::Config { |
| 187 | + labels: Some(labels), |
| 188 | + ..Default::default() |
| 189 | + }; |
| 190 | + |
179 | 191 | // Construct empty/default OCI config file. Data may be parsed according to
|
180 | 192 | // the expected config structure per the image spec, so we want to ensure it conforms.
|
181 | 193 | // (See https://github.com/opencontainers/image-spec/blob/main/config.md)
|
182 | 194 | // TODO: Explore adding data applicable to the Spin app being published.
|
183 | 195 | let oci_config_file = ConfigFile {
|
184 | 196 | architecture: oci_distribution::config::Architecture::Wasm,
|
185 | 197 | os: oci_distribution::config::Os::Wasip1,
|
| 198 | + // We need to ensure that the image config for different content is updated. |
| 199 | + // Without referencing the digest of the locked application in the OCI image config, |
| 200 | + // all Spin applications would get the same image config digest, resulting in the same |
| 201 | + // image ID in container runtimes. |
| 202 | + config: Some(cfg), |
186 | 203 | ..Default::default()
|
187 | 204 | };
|
188 | 205 | let oci_config =
|
|
0 commit comments