Files
infix/src/klish-plugin-infix/xml/containers.xml
T
Joachim Wiberg 8ea159ce5d confd: add feature flag for containers
Not all customers want Container support in their Ínfix builds.  This
patch adds build-time support for detecting if podman is enabled in
the configuration.

 - Klish container commands have been broken out to their own xml file
 - infix-interfaces have been given a 'containers' feature
 - ietf-interfces.c enables 'containers' feature on an #ifdef
 - infix-container.c is only built if --enable-containers

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
2024-02-25 19:49:27 +01:00

175 lines
6.2 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<KLISH
xmlns="https://klish.libcode.org/klish3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://src.libcode.org/pkun/klish/src/master/klish.xsd">
<PTYPE name="CONTAINERS">
<COMPL>
<ACTION sym="script">container list</ACTION>
</COMPL>
<ACTION sym="STRING"/>
</PTYPE>
<PTYPE name="CONTAINERSa">
<COMPL>
<ACTION sym="script">container -a list</ACTION>
</COMPL>
<ACTION sym="STRING"/>
</PTYPE>
<PTYPE name="IMAGES">
<COMPL>
<ACTION sym="script">container -a list images</ACTION>
</COMPL>
<ACTION sym="STRING"/>
</PTYPE>
<VIEW name="main">
<COMMAND name="container" help="Manage containers, images, and volumes" mode="switch">
<COMMAND name="cleanup" help="Clean up all unused containers, images and volume data">
<ACTION sym="script" in="tty" out="tty" interrupt="true">
podman system prune
</ACTION>
</COMMAND>
<!-- alias for -container shell' -->
<COMMAND name="connect" help="Start a shell inside a container, if available">
<PARAM name="name" ptype="/CONTAINERSa" help="Container name" />
<ACTION sym="script" in="tty" out="tty" interrupt="true">
container shell $KLISH_PARAM_name
</ACTION>
</COMMAND>
<COMMAND name="exec" help="Execute command in a running container, default: sh">
<PARAM name="name" ptype="/CONTAINERS" help="Container name" />
<SWITCH name="optional" min="0">
<COMMAND name="command" help="Command to run">
<PARAM name="command" ptype="/STRING" help="Command to run"/>
</COMMAND>
</SWITCH>
<ACTION sym="script" in="tty" out="tty" interrupt="true">
if [ -z "$KLISH_PARAM_name" ]; then
echo "Missing container name."
else
cmd=${KLISH_PARAM_command:-sh}
container exec $KLISH_PARAM_name $cmd
fi
</ACTION>
</COMMAND>
<COMMAND name="pull" help="Fetch a container image">
<PARAM name="image" ptype="/STRING" help="Image url and tag, e.g. docker://hello-world:latest" />
<SWITCH name="optional" min="0">
<COMMAND name="creds" help="Credentials">
<PARAM name="creds" ptype="/STRING" help="username[:password]"/>
</COMMAND>
</SWITCH>
<ACTION sym="script" in="tty" out="tty" interrupt="true">
creds=${KLISH_PARAM_creds:+--creds=$KLISH_PARAM_creds}
container pull $creds $KLISH_PARAM_image
</ACTION>
</COMMAND>
<COMMAND name="remove" help="Remove a container image from local storage">
<PARAM name="name" ptype="/IMAGES" help="Image name" />
<ACTION sym="script" in="tty" out="tty" interrupt="true">
container remove $KLISH_PARAM_name
</ACTION>
</COMMAND>
<COMMAND name="restart" help="Restart a crashed container">
<PARAM name="name" ptype="/CONTAINERSa" help="Container name" />
<ACTION sym="script" out="tty" interrupt="true">
container restart $KLISH_PARAM_name
</ACTION>
</COMMAND>
<COMMAND name="run" help="Interactivly run a container image, with optional command">
<PARAM name="image" ptype="/IMAGES" help="Image name" />
<SWITCH name="optional" min="0">
<COMMAND name="command" help="Command to run">
<PARAM name="command" ptype="/STRING" help="Command to run"/>
</COMMAND>
<COMMAND name="port" help="Port to publish, default all exposed">
<PARAM name="port" ptype="/STRING" help="HOST:CONTAINER[/udp]"/>
</COMMAND>
</SWITCH>
<ACTION sym="script" in="tty" out="tty" interrupt="true">
port=${KLISH_PARAM_port:+-p $KLISH_PARAM_port}
container $port run $KLISH_PARAM_image ${KLISH_PARAM_command}
</ACTION>
<SWITCH name="optional" min="0">
<COMMAND name="detach" help="Run container in background and print container ID">
<ACTION sym="script" out="tty">
container -d $port run $KLISH_PARAM_image ${KLISH_PARAM_command}
</ACTION>
</COMMAND>
</SWITCH>
</COMMAND>
<COMMAND name="shell" help="Start a shell inside a container, if available">
<PARAM name="name" ptype="/CONTAINERSa" help="Container name" />
<ACTION sym="script" in="tty" out="tty" interrupt="true">
container shell $KLISH_PARAM_name
</ACTION>
</COMMAND>
<COMMAND name="start" help="Start a container">
<PARAM name="name" ptype="/CONTAINERSa" help="Container name" />
<ACTION sym="script" out="tty" interrupt="true">
container start $KLISH_PARAM_name
</ACTION>
</COMMAND>
<COMMAND name="stop" help="Stop a container">
<PARAM name="name" ptype="/CONTAINERS" help="Container name" />
<ACTION sym="script" out="tty" interrupt="true">
container stop $KLISH_PARAM_name
</ACTION>
</COMMAND>
<COMMAND name="upgrade" help="Upgrade image of a container (writable layer is lost!)">
<PARAM name="name" ptype="/CONTAINERS" help="Container name" />
<ACTION sym="script" out="tty" interrupt="true">
container upgrade $KLISH_PARAM_name
</ACTION>
</COMMAND>
</COMMAND>
<COMMAND name="show" help="Show system status and configuration files" mode="switch">
<COMMAND name="container" help="Show container status">
<ACTION sym="script">container show</ACTION>
<SWITCH name="optional" min="0">
<COMMAND name="all" help="Show all containers (default only running)">
<ACTION sym="script">container -a show</ACTION>
</COMMAND>
<COMMAND name="log" help="Show container log (alias for show log container)">
<ACTION sym="script">cat /log/container</ACTION>
</COMMAND>
<COMMAND name="images" help="Show container images">
<ACTION sym="script">container show images</ACTION>
<SWITCH name="optional" min="0">
<COMMAND name="all" help="All images (default hides intermediate imaages)">
<ACTION sym="script">container -a show images</ACTION>
</COMMAND>
</SWITCH>
</COMMAND>
<COMMAND name="stat" help="Show continuous containers stats (Ctrl-C aborts)">
<ACTION sym="script">container stat</ACTION>
</COMMAND>
<COMMAND name="usage" help="Show container resource usage">
<ACTION sym="script">podman system df -v</ACTION>
</COMMAND>
<COMMAND name="volumes" help="Show container volumes">
<ACTION sym="script">container show volumes</ACTION>
</COMMAND>
</SWITCH>
</COMMAND>
</COMMAND>
</VIEW>
</KLISH>