Commit 0f32d1f4 authored by Harry Míchal's avatar Harry Míchal Committed by Christian Hergert

podman: Add suport for Podman V2

Podman V2 introduced some changes in the JSON format of some of its
commands[0]. Some changes to the format happened already in the past[1].

With this there should not be need to bump the minimal supported version
of Podman to >=v2.0.0.

[0] https://github.com/containers/libpod/pull/5159
[1] https://github.com/containers/libpod/pull/5582
parent 0c67b2d9
Pipeline #194708 canceled with stages
in 21 minutes and 31 seconds
......@@ -49,7 +49,12 @@ maybe_start (GbpPodmanRuntime *self)
if (self->has_started)
return;
if (!(id = json_object_get_string_member (self->object, "ID")))
if (json_object_has_member (self->object, "ID"))
id = json_object_get_string_member (self->object, "ID");
else
id = json_object_get_string_member (self->object, "Id");
if (id == NULL)
return;
launcher = ide_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDERR_SILENCE |
......@@ -70,6 +75,7 @@ static IdeSubprocessLauncher *
gbp_podman_runtime_create_launcher (IdeRuntime *runtime,
GError **error)
{
const gchar *id;
GbpPodmanRuntime *self = (GbpPodmanRuntime *)runtime;
g_assert (IDE_IS_MAIN_THREAD ());
......@@ -77,8 +83,15 @@ gbp_podman_runtime_create_launcher (IdeRuntime *runtime,
maybe_start (self);
if (json_object_has_member (self->object, "ID"))
id = json_object_get_string_member (self->object, "ID");
else
id = json_object_get_string_member (self->object, "Id");
g_return_val_if_fail (id != NULL, NULL);
return g_object_new (GBP_TYPE_PODMAN_SUBPROCESS_LAUNCHER,
"id", json_object_get_string_member (self->object, "ID"),
"id", id,
"run-on-host", TRUE,
NULL);
}
......@@ -117,11 +130,27 @@ gbp_podman_runtime_new (JsonObject *object)
GbpPodmanRuntime *self;
const gchar *id;
const gchar *names;
JsonArray *names_arr;
JsonNode *names_node;
g_return_val_if_fail (object != NULL, NULL);
if (json_object_has_member (object, "ID"))
id = json_object_get_string_member (object, "ID");
names = json_object_get_string_member (object, "Names");
else
id = json_object_get_string_member (object, "Id");
names_node = json_object_get_member (object, "Names");
if (JSON_NODE_HOLDS_ARRAY (names_node))
{
names_arr = json_node_get_array (names_node);
names = json_array_get_string_element (names_arr, 0);
}
else
{
names = json_node_get_string (names_node);
}
full_id = g_strdup_printf ("podman:%s", id);
name = g_strdup_printf ("%s %s", _("Podman"), names);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment