From 6bff2fb19bd5cb2e1c08655470ff8fc7977bebee Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 24 Jun 2019 13:37:25 +0200 Subject: [PATCH] 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 --- common/flatpak-oci-registry.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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,