summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2019-06-24 13:37:25 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2019-09-06 12:49:40 +0000
commit6bff2fb19bd5cb2e1c08655470ff8fc7977bebee (patch)
tree5d0646468443668882ed26200c2d177cee4e7f00
parent8f4082df6d680adc07cfcd127bf34344ec799e14 (diff)
downloadflatpak-6bff2fb19bd5cb2e1c08655470ff8fc7977bebee.tar.gz
OCI: Make use of labels or annotations configurable
If repo uri has ?index=label then query for labels, otherwise keep querying for annotations like before. Closes: #2978 Approved by: alexlarsson
-rw-r--r--common/flatpak-oci-registry.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/common/flatpak-oci-registry.c b/common/flatpak-oci-registry.c
index 0cfe5fb9..8e7282cd 100644
--- a/common/flatpak-oci-registry.c
+++ b/common/flatpak-oci-registry.c
@@ -1970,6 +1970,9 @@ flatpak_oci_index_ensure_cached (SoupSession *soup_session,
const char *oci_arch = NULL;
gboolean success = FALSE;
g_autoptr(GError) local_error = NULL;
+ gboolean use_labels = FALSE;
+ const char *query_uri_part;
+ const char *metadata_query;
if (!g_str_has_prefix (uri, "oci+http:") && !g_str_has_prefix (uri, "oci+https:"))
{
@@ -2011,12 +2014,25 @@ flatpak_oci_index_ensure_cached (SoupSession *soup_session,
}
soup_uri_set_fragment (base_uri, NULL);
+ query_uri_part = soup_uri_get_query (base_uri);
+ if (query_uri_part)
+ {
+ g_autoptr(GHashTable) query_args = soup_form_decode (query_uri_part);
+ const char *index = g_hash_table_lookup (query_args, "index");
+ use_labels = g_strcmp0 (index, "labels") == 0;
+ }
+
+ if (use_labels)
+ metadata_query = "label:org.flatpak.ref:exists";
+ else
+ metadata_query = "annotation:org.flatpak.ref:exists";
+
query_uri = soup_uri_copy (base_uri);
oci_arch = flatpak_arch_to_oci_arch (flatpak_get_arch ());
soup_uri_set_query_from_fields (query_uri,
- "label:org.flatpak.ref:exists", "1",
+ metadata_query, "1",
"architecture", oci_arch,
"os", "linux",
"tag", tag,