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
This commit is contained in:
Alexander Larsson
2019-06-24 13:37:25 +02:00
committed by Atomic Bot
parent 8f4082df6d
commit 6bff2fb19b

View File

@@ -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,