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) ...@@ -49,7 +49,12 @@ maybe_start (GbpPodmanRuntime *self)
if (self->has_started) if (self->has_started)
return; 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; return;
launcher = ide_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDERR_SILENCE | launcher = ide_subprocess_launcher_new (G_SUBPROCESS_FLAGS_STDERR_SILENCE |
...@@ -70,6 +75,7 @@ static IdeSubprocessLauncher * ...@@ -70,6 +75,7 @@ static IdeSubprocessLauncher *
gbp_podman_runtime_create_launcher (IdeRuntime *runtime, gbp_podman_runtime_create_launcher (IdeRuntime *runtime,
GError **error) GError **error)
{ {
const gchar *id;
GbpPodmanRuntime *self = (GbpPodmanRuntime *)runtime; GbpPodmanRuntime *self = (GbpPodmanRuntime *)runtime;
g_assert (IDE_IS_MAIN_THREAD ()); g_assert (IDE_IS_MAIN_THREAD ());
...@@ -77,8 +83,15 @@ gbp_podman_runtime_create_launcher (IdeRuntime *runtime, ...@@ -77,8 +83,15 @@ gbp_podman_runtime_create_launcher (IdeRuntime *runtime,
maybe_start (self); 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, return g_object_new (GBP_TYPE_PODMAN_SUBPROCESS_LAUNCHER,
"id", json_object_get_string_member (self->object, "ID"), "id", id,
"run-on-host", TRUE, "run-on-host", TRUE,
NULL); NULL);
} }
...@@ -117,11 +130,27 @@ gbp_podman_runtime_new (JsonObject *object) ...@@ -117,11 +130,27 @@ gbp_podman_runtime_new (JsonObject *object)
GbpPodmanRuntime *self; GbpPodmanRuntime *self;
const gchar *id; const gchar *id;
const gchar *names; const gchar *names;
JsonArray *names_arr;
JsonNode *names_node;
g_return_val_if_fail (object != NULL, NULL); g_return_val_if_fail (object != NULL, NULL);
id = json_object_get_string_member (object, "ID"); if (json_object_has_member (object, "ID"))
names = json_object_get_string_member (object, "Names"); id = json_object_get_string_member (object, "ID");
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); full_id = g_strdup_printf ("podman:%s", id);
name = g_strdup_printf ("%s %s", _("Podman"), names); 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