Skip to content

Commit 8e5ff1c

Browse files
authored
do not treat missing registry meta as a hard error; warn and continue (#152)
1 parent 5657170 commit 8e5ff1c

1 file changed

Lines changed: 29 additions & 23 deletions

File tree

src/cli/pull.cpp

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ int image_pull(const image_pull_args& args, const global_settings& settings) {
179179
if (pull_meta) {
180180
// the digests returned by oras::discover is a list of artifacts
181181
// that have been "oras attach"ed to our squashfs image. This
182-
// would be empty if no meta data was attached - currently we
183-
// assume that meta data has been attached
182+
// would be empty if no meta data was attached.
184183
auto digests =
185184
oras::discover(rego_url, nspace, record, credentials);
186185
if (!digests) {
@@ -189,27 +188,34 @@ int image_pull(const image_pull_args& args, const global_settings& settings) {
189188
return 1;
190189
}
191190
if (digests->empty()) {
192-
term::error("unable to pull uenv: no metadata in manifest");
193-
return 1;
194-
}
195-
spdlog::debug("manifests: {}", fmt::join(*digests, ", "));
196-
197-
// We assume that there is one, and only, digest attached to the
198-
// squashfs image: the meta data directory.
199-
// pull_digetst will download the digest: in the case of meta
200-
// data it will unpack the meta path into paths.store.
201-
//
202-
// This will change in the future, when we may attache multiple
203-
// or zero items to the squashfs image.
204-
const auto digest = *(digests->begin());
205-
206-
if (auto okay =
207-
oras::pull_digest(rego_url, nspace, record, digest,
208-
paths.store, credentials);
209-
!okay) {
210-
term::error("unable to pull uenv.\n{}",
211-
okay.error().message);
212-
return 1;
191+
// No metadata attached in the registry.
192+
// If the user explicitly requested metadata (--only-meta or
193+
// sqfs already exists), this is an error. Otherwise, warn
194+
// and continue to pull the squashfs.
195+
if (!pull_sqfs) {
196+
term::error("uenv exists in registry but has no "
197+
"attached metadata");
198+
return 1;
199+
}
200+
term::warn(
201+
"uenv exists in registry but has no attached metadata");
202+
} else {
203+
spdlog::debug("manifests: {}", fmt::join(*digests, ", "));
204+
205+
// We assume that there is one, and only, digest attached to
206+
// the squashfs image: the meta data directory.
207+
// pull_digest will download the digest: in the case of meta
208+
// data it will unpack the meta path into paths.store.
209+
const auto digest = *(digests->begin());
210+
211+
if (auto okay =
212+
oras::pull_digest(rego_url, nspace, record, digest,
213+
paths.store, credentials);
214+
!okay) {
215+
term::error("unable to pull uenv.\n{}",
216+
okay.error().message);
217+
return 1;
218+
}
213219
}
214220
}
215221

0 commit comments

Comments
 (0)