From ff323146764d3eeb7fd0ee4c94e965fa04432541 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 29 Jan 2024 17:56:39 +0100 Subject: [PATCH] confd: rename volume dir -> path, same as bind-mounted files Also, update container YANG model descriptions and ensure 'path' is mandatory for each list element and attach a regexp pattern to fix the mountpoint to an absolute path inside the container. Signed-off-by: Joachim Wiberg --- src/confd/src/infix-containers.c | 2 +- .../yang/infix-containers@2023-12-14.yang | 22 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/confd/src/infix-containers.c b/src/confd/src/infix-containers.c index 38a18c7d..7355fe1f 100644 --- a/src/confd/src/infix-containers.c +++ b/src/confd/src/infix-containers.c @@ -63,7 +63,7 @@ static int add(const char *name, struct lyd_node *cif) fprintf(fp, " --read-only"); LYX_LIST_FOR_EACH(lyd_child(cif), node, "volume") - fprintf(fp, " -v %s-%s:%s", name, lydx_get_cattr(node, "name"), lydx_get_cattr(node, "dir")); + fprintf(fp, " -v %s-%s:%s", name, lydx_get_cattr(node, "name"), lydx_get_cattr(node, "path")); LYX_LIST_FOR_EACH(lyd_child(cif), node, "file") { const char *filenm = lydx_get_cattr(node, "name"); diff --git a/src/confd/yang/infix-containers@2023-12-14.yang b/src/confd/yang/infix-containers@2023-12-14.yang index d5912423..c7cc650d 100644 --- a/src/confd/yang/infix-containers@2023-12-14.yang +++ b/src/confd/yang/infix-containers@2023-12-14.yang @@ -94,7 +94,18 @@ module infix-containers { } leaf image { - description "Docker image used for the container"; + description "Docker image for the container: [transport]name[:tag|@digest] + + quay.io/username/myimage -- Pull myimage:latest + docker://busybox -- Pull busybox:latest from Docker Hub + docker://ghcr.io/usr/img -- Pull img:latest from GitHub packages + dir:/media/usb/myimage:1.1 -- Use myimage v1.1 from USB media + docker-archive:/tmp/myimage -- Use myimage:latest from tarball + oci-archive:/tmp/myimage -- Use myimage:latest from OCI archive + + Note: if a remote repository cannot be reached, the creation of the + container will be put on a queue that retries pull every time + there is a route change in the host's system."; mandatory true; type string; } @@ -186,10 +197,12 @@ module infix-containers { type string; } - leaf dir { - description "Directory to mount the volume on inside the container, e.g., /etc"; + leaf path { + description "Directory to mount the volume on inside the container, e.g., /var/lib"; mandatory true; - type string; + type string { + pattern '/.*'; + } } } @@ -209,6 +222,7 @@ module infix-containers { type string { pattern '/.*'; } + mandatory true; } leaf content {