diff --git a/.gitignore b/.gitignore index 9ef26b9..b0bc529 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,9 @@ # VS Code user settings /.vscode + +# Helix user settings +/.helix + +# demo output +demo.cast diff --git a/CHANGELOG.md b/CHANGELOG.md index 6519feb..e6386e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,43 @@ # Changelog +## [0.2.3] - 2023-12-31 + +### Features + +- Add support for quadlet options introduced in podman v4.7.0 ([#29](https://github.com/k9withabone/podlet/issues/29)) + - Container + - `DNS=` + - `DNSOption=` + - `DNSSearch=` + - `PidsLimit=` + - `ShmSize=` + - `Ulimit=` + - Kube + - `AutoUpdate=` + - Network + - `DNS=` +- Add `podlet generate` subcommands for generating quadlet files from existing: + - Containers ([#23](https://github.com/k9withabone/podlet/issues/23)) + - Networks + - Volumes + +### Bug Fixes + +- *(compose)* `network_mode` accept all podman values ([#38](https://github.com/k9withabone/podlet/issues/38)) + - Improved error message for unsupported values +- *(network)* Support `-` syntax for `--ip-range` + +### Documentation + +- *(readme)* Podman v4.7.0 +- *(readme)* Update demo and usage + +### Miscellaneous Tasks + +- *(ci)* Skip container run for conmon v2.1.9 +- *(lint)* Fix new rust 1.75 clippy warnings +- Update dependencies + ## [0.2.2] - 2023-12-15 ### Features diff --git a/Cargo.lock b/Cargo.lock index f05822c..4713126 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -97,7 +97,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca33f4bc4ed1babef42cad36cc1f51fa88be00420404e5b1e80ab1b18f7678c" dependencies = [ "concurrent-queue", - "event-listener 4.0.0", + "event-listener 4.0.1", "event-listener-strategy", "futures-core", "pin-project-lite", @@ -183,7 +183,7 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" dependencies = [ - "event-listener 4.0.0", + "event-listener 4.0.1", "event-listener-strategy", "pin-project-lite", ] @@ -213,7 +213,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.43", ] [[package]] @@ -236,19 +236,19 @@ dependencies = [ [[package]] name = "async-task" -version = "4.5.0" +version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4eb2cdb97421e01129ccb49169d8279ed21e829929144f4a22a6e54ac549ca1" +checksum = "e1d90cd0b264dfdd8eb5bad0a2c217c1f88fa96a8573f40e7b12de23fb468f46" [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.43", ] [[package]] @@ -360,9 +360,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.11" +version = "4.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d" dependencies = [ "clap_builder", "clap_derive", @@ -370,9 +370,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.11" +version = "4.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" dependencies = [ "anstream", "anstyle", @@ -389,7 +389,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.43", ] [[package]] @@ -451,9 +451,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c" dependencies = [ "cfg-if", ] @@ -596,7 +596,7 @@ checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.43", ] [[package]] @@ -634,9 +634,9 @@ dependencies = [ [[package]] name = "event-listener" -version = "4.0.0" +version = "4.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +checksum = "84f2cdcf274580f2d63697192d744727b3198894b1bf02923643bf59e2c26712" dependencies = [ "concurrent-queue", "parking", @@ -649,15 +649,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" dependencies = [ - "event-listener 4.0.0", + "event-listener 4.0.1", "pin-project-lite", ] [[package]] name = "eyre" -version = "0.6.9" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f656be11ddf91bd709454d15d5bd896fbaf4cc3314e69349e4d1569f5b46cd" +checksum = "b6267a1fa6f59179ea4afc8e50fd8612a3cc60bc858f786ff877a4a8cb042799" dependencies = [ "indenter", "once_cell", @@ -695,15 +695,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" @@ -735,21 +735,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-io", @@ -926,9 +926,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memoffset" @@ -939,6 +939,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -963,7 +972,7 @@ dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", - "memoffset", + "memoffset 0.7.1", ] [[package]] @@ -987,9 +996,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -1062,7 +1071,7 @@ dependencies = [ [[package]] name = "podlet" -version = "0.2.2" +version = "0.2.3" dependencies = [ "clap", "color-eyre", @@ -1128,9 +1137,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" dependencies = [ "unicode-ident", ] @@ -1288,7 +1297,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.43", ] [[package]] @@ -1310,14 +1319,14 @@ checksum = "3081f5ffbb02284dda55132aa26daecedd7372a42417bbbab6f14ab7d6bb9145" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.43", ] [[package]] name = "serde_yaml" -version = "0.9.27" +version = "0.9.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cc7a1570e38322cfe4154732e5110f887ea57e22b76f4bfd32b5bdd3368666c" +checksum = "a15e0ef66bf939a7c890a0bf6d5a733c70202225f9888a89ed5c62298b019129" dependencies = [ "indexmap", "itoa", @@ -1405,9 +1414,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.41" +version = "2.0.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" +checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" dependencies = [ "proc-macro2", "quote", @@ -1416,35 +1425,35 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.1" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa" dependencies = [ "cfg-if", "fastrand 2.0.1", "redox_syscall", "rustix 0.38.28", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "83a48fd946b02c0a526b2e9481c8e2a17755e47039164a86c4070446e3a4614d" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "e7fbe9b594d6568a6a1443250a7e67d80b74e1e96f6d1715e1e21cc1888291d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.43", ] [[package]] @@ -1508,7 +1517,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.41", + "syn 2.0.43", ] [[package]] @@ -1550,10 +1559,11 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "uds_windows" -version = "1.0.2" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce65604324d3cce9b966701489fbd0cf318cb1f7bd9dd07ac9a4ee6fb791930d" +checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" dependencies = [ + "memoffset 0.9.0", "tempfile", "winapi", ] @@ -1581,9 +1591,9 @@ dependencies = [ [[package]] name = "unsafe-libyaml" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" +checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" [[package]] name = "url" @@ -1782,9 +1792,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.28" +version = "0.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c830786f7720c2fd27a1a0e27a709dbd3c4d009b56d098fc742d4f4eab91fe2" +checksum = "97a4882e6b134d6c28953a387571f1acdd3496830d5e36c5e3a1075580ea641c" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 7c688fa..52fb2d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "podlet" -version = "0.2.2" +version = "0.2.3" authors = ["Paul Nettleton "] edition = "2021" description = "Generate podman quadlet files from a podman command or a compose file" @@ -153,7 +153,8 @@ commit_parsers = [ { message = "^test", group = "6 Testing" }, { message = "^refactor", group = "7 Refactor" }, { message = "^style", group = "8 Styling" }, - { message = "^chore|ci", group = "9 Miscellaneous Tasks" }, + { message = "^chore", group = "9 Miscellaneous Tasks" }, + { message = "^ci", default_scope = "ci", group = "9 Miscellaneous Tasks" }, { message = "^revert", group = "10 Revert" }, { message = "^release", skip = true }, { message = "^chore\\(deps\\)", skip = true }, diff --git a/README.md b/README.md index 60ea6c4..5944648 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ Podlet generates [podman](https://podman.io/) [quadlet](https://docs.podman.io/en/latest/markdown/podman-systemd.unit.5.html) files from a podman command or a compose file. -[![demo.gif](./demo.gif)](https://asciinema.org/a/591369) -You can also view the demo on [asciinema](https://asciinema.org/a/591369). +[![demo.gif](./demo.gif)](https://asciinema.org/a/629332) +Demo created with [autocast](https://github.com/k9withabone/autocast). You can also view the demo on [asciinema](https://asciinema.org/a/629332). ## Features @@ -20,6 +20,7 @@ You can also view the demo on [asciinema](https://asciinema.org/a/591369). - Convert a (docker) compose file to: - Multiple quadlet files - A pod with a quadlet kube file and Kubernetes YAML +- Generate from an existing container, network, or volume - Write to stdout or to a file - Options for including common systemd unit options - Checks for existing systemd services to avoid conflict @@ -40,14 +41,15 @@ Podlet can be acquired in several ways: ``` $ podlet -h -Podlet generates podman quadlet (systemd-like) files from a podman command. +Generate podman quadlet files from a podman command or a compose file Usage: podlet [OPTIONS] Commands: - podman Generate a podman quadlet file from a podman command - compose Generate podman quadlet files from a compose file - help Print this message or the help of the given subcommand(s) + podman Generate a podman quadlet file from a podman command + compose Generate podman quadlet files from a compose file + generate Generate a podman quadlet file from an existing container, network, or volume + help Print this message or the help of the given subcommand(s) Options: -f, --file [] Generate a file instead of printing to stdout @@ -67,6 +69,28 @@ Options: -V, --version Print version ``` +See `podlet --help` for more information. + +### Podman Command + +``` +$ podlet podman -h + +Generate a podman quadlet file from a podman command + +Usage: podlet podman + +Commands: + run Generate a podman quadlet `.container` file + kube Generate a podman quadlet `.kube` file + network Generate a podman quadlet `.network` file + volume Generate a podman quadlet `.volume` file + help Print this message or the help of the given subcommand(s) + +Options: + -h, --help Print help +``` + To generate a quadlet file, just put `podlet` in front of your podman command! ``` @@ -85,7 +109,7 @@ $ podlet --file . --install --description Caddy \ --restart always \ -p 8000:80 \ -p 8443:443 \ - -v ./Caddyfile:/etc/caddy/Caddyfile \ + -v ./Caddyfile:/etc/caddy/Caddyfile:Z \ -v caddy_data:/data \ docker.io/library/caddy:latest @@ -100,7 +124,7 @@ Description=Caddy Image=docker.io/library/caddy:latest PublishPort=8000:80 PublishPort=8443:443 -Volume=./Caddyfile:/etc/caddy/Caddyfile +Volume=./Caddyfile:/etc/caddy/Caddyfile:Z Volume=caddy_data:/data [Service] @@ -112,21 +136,148 @@ WantedBy=default.target The name for the file was automatically pulled from the image name, but can be overridden with the `--name` option. -Podlet also supports creating kube, network, and volume quadlet files. However, not all options for their corresponding podman commands are supported by quadlet. Accordingly, those options are also not supported by podlet. +Podlet also supports creating kube, network, and volume quadlet files. ``` -$ podlet podman kube play --network pasta --userns auto kube.yaml +$ podlet podman kube play --network pasta --userns auto caddy.yaml +# caddy.kube [Kube] -Yaml=kube.yaml +Yaml=caddy.yaml Network=pasta UserNS=auto ``` -Use the following commands for more usage information: -- `podlet --help` -- `podlet podman --help` -- `podlet compose --help` +### Compose + +``` +$ podlet compose -h + +Generate podman quadlet files from a compose file + +Usage: podlet compose [OPTIONS] [COMPOSE_FILE] + +Arguments: + [COMPOSE_FILE] The compose file to convert + +Options: + --pod Create a Kubernetes YAML file for a pod instead of separate containers + -h, --help Print help (see more with '--help') +``` + +Let's return to the caddy example, say you have a compose file at `compose-example.yaml`: + +```yaml +services: + caddy: + image: docker.io/library/caddy:latest + ports: + - 8000:80 + - 8443:443 + volumes: + - ./Caddyfile:/etc/caddy/Caddyfile:Z + - caddy-data:/data +volumes: + caddy-data: +``` + +`podlet compose compose-example.yaml` will create a `caddy.container` like so: + +```ini +# caddy.container +[Container] +Image=docker.io/library/caddy:latest +PublishPort=8000:80 +PublishPort=8443:443 +Volume=./Caddyfile:/etc/caddy/Caddyfile:Z +Volume=caddy-data:/data +``` + +If a compose file is not given, podlet will search for the following files in the current working directory, in order: + +- `compose.yaml` +- `compose.yml` +- `docker-compose.yaml` +- `docker-compose.yml` + +In addition, the `--pod` option will generate Kubernetes YAML which groups all compose services in a pod. + +``` +$ podlet compose --pod caddy compose-example.yaml + +# caddy.kube +[Kube] +Yaml=caddy-kube.yaml + +--- + +# caddy-kube.yaml +apiVersion: v1 +kind: Pod +metadata: + name: caddy +spec: + containers: + - image: docker.io/library/caddy:latest + name: caddy + ports: + - containerPort: 80 + hostPort: 8000 + - containerPort: 443 + hostPort: 8443 + volumeMounts: + - mountPath: /etc/caddy/Caddyfile:Z + name: caddy-etc-caddy-Caddyfile + - mountPath: /data + name: caddy-data + volumes: + - hostPath: + path: ./Caddyfile + name: caddy-etc-caddy-Caddyfile + - name: caddy-data + persistentVolumeClaim: + claimName: caddy-data +``` + +When converting compose files, not all options are supported by podman/quadlet. This is especially true when converting to a pod as some options must be applied to the pod as a whole. If podlet encounters an unsupported option an error will be returned. You will have to remove or comment out unsupported options to proceed. + +See `podlet compose --help` for more information. + +### Generate from Existing + +``` +$ podlet generate -h + +Generate a podman quadlet file from an existing container, network, or volume + +Usage: podlet generate + +Commands: + container Generate a quadlet file from an existing container + network Generate a quadlet file from an existing network + volume Generate a quadlet file from an existing volume + help Print this message or the help of the given subcommand(s) + +Options: + -h, --help Print help (see more with '--help') +``` + +If you have an existing container, network, or volume, you can use `podlet generate` to create a quadlet file from it. + +``` +$ podman container create --name hello quay.io/podman/hello:latest + +$ podlet generate container hello + +# hello.container +[Container] +ContainerName=hello +Image=quay.io/podman/hello:latest +``` + +These commands require that `podman` is installed and searchable from the [`PATH`](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable. + +See `podlet generate --help` for more information. ### In a Container @@ -146,8 +297,6 @@ Alternatively, if you just want podlet to read a specific compose file you can u Podlet is not (yet) a validator for podman commands. Some podman options are incompatible with each other and most options require specific formatting and/or only accept certain values. However, a few options are fully parsed and validated in order to facilitate creating the quadlet file. -When converting compose files, not all options are supported by podman/quadlet. This is especially true when converting to a pod as some options must be applied to the pod as a whole. If podlet encounters an unsupported option an error will be returned. You will have to remove or comment out unsupported options to proceed. - Podlet is meant to be used with podman v4.7.0 or newer. Some quadlet options are unavailable or behave differently with earlier versions of podman/quadlet. ## Contribution diff --git a/compose-example.yaml b/compose-example.yaml index 256518f..a9a6453 100644 --- a/compose-example.yaml +++ b/compose-example.yaml @@ -5,7 +5,7 @@ services: - 8000:80 - 8443:443 volumes: - - ./Caddyfile:/etc/caddy/Caddyfile + - ./Caddyfile:/etc/caddy/Caddyfile:Z - caddy-data:/data volumes: caddy-data: diff --git a/demo.cast b/demo.cast deleted file mode 100644 index e5264d4..0000000 --- a/demo.cast +++ /dev/null @@ -1,550 +0,0 @@ -{"version": 2, "width": 129, "height": 34, "timestamp": 1686723165, "env": {"SHELL": "/bin/bash", "TERM": "xterm-256color"}, "title": "podlet v0.2.0 demo"} -[0.035786, "o", "\u001b[?2004h$ "] -[0.037764, "o", "p"] -[0.137935, "o", "o"] -[0.238236, "o", "d"] -[0.338354, "o", "l"] -[0.438665, "o", "e"] -[0.538852, "o", "t"] -[0.639016, "o", " "] -[0.739366, "o", "-"] -[0.839662, "o", "h"] -[0.939667, "o", "\r\n\u001b[?2004l\r"] -[0.943095, "o", "Podlet generates podman quadlet (systemd-like) files from a podman command.\r\n\r\n\u001b[1m\u001b[4mUsage:\u001b[0m \u001b[1mpodlet\u001b[0m [OPTIONS] \r\n\r\n\u001b[1m\u001b[4mCommands:\u001b[0m\r\n \u001b[1mpodman\u001b[0m Generate a podman quadlet file from a podman command\r\n \u001b[1mcompose\u001b[0m Generate podman quadlet files from a compose file\r\n \u001b[1mhelp\u001b[0m Print this message or the help of the given subcommand(s)\r\n\r\n\u001b[1m\u001b[4mOptions:\u001b[0m\r\n \u001b[1m-f\u001b[0m, \u001b[1m--file\u001b[0m [] Generate a file instead of printing to stdout\r\n \u001b[1m-u\u001b[0m, \u001b[1m--unit-directory\u001b[0m Generate a file in the podman unit directory instead of printing to stdout [aliases: unit-dir]\r\n \u001b[1m-n\u001b[0m, \u001b[1m--name\u001b[0m Override the name of the generated file (without the extension)\r\n \u001b[1m--overwrite\u001b[0m Overwrite existing files when generating a file\r\n \u001b[1m--skip-services-check\u001b[0m Skip the check for existing services of the same name\r\n \u001b[1m-d\u001b[0m, \u001b[1m--description\u001b[0m Add a description "] -[0.943269, "o", "to the unit\r\n \u001b[1m--wants\u001b[0m Add (weak) requirement dependencies to the unit\r\n \u001b[1m--requires\u001b[0m Similar to --wants, but adds stronger requirement dependencies\r\n \u001b[1m--before\u001b[0m Configure ordering dependency between units\r\n \u001b[1m--after\u001b[0m Configure ordering dependency between units\r\n \u001b[1m-i\u001b[0m, \u001b[1m--install\u001b[0m Add an [Install] section to the unit\r\n \u001b[1m--wanted-by\u001b[0m Add (weak) parent dependencies to the unit\r\n \u001b[1m--required-by\u001b[0m Similar to --wanted-by, but adds stronger parent dependencies\r\n \u001b[1m-h\u001b[0m, \u001b[1m--help\u001b[0m Print help (see more with '--help')\r\n \u001b[1m-V\u001b[0m, \u001b[1m--version\u001b[0m Print version\r\n"] -[0.943869, "o", "\u001b[?2004h$ "] -[8.049493, "o", "\u001b[H\u001b[2J\u001b[3J"] -[8.049967, "o", "\u001b[?2004h$ "] -[8.150679, "o", "p"] -[8.251048, "o", "o"] -[8.351274, "o", "d"] -[8.451459, "o", "l"] -[8.551528, "o", "e"] -[8.651722, "o", "t"] -[8.751704, "o", " "] -[8.852111, "o", "p"] -[8.952416, "o", "o"] -[9.052625, "o", "d"] -[9.152747, "o", "m"] -[9.252927, "o", "a"] -[9.353179, "o", "n"] -[9.453471, "o", " "] -[9.553660, "o", "-"] -[9.653722, "o", "h"] -[9.754043, "o", "\r\n\u001b[?2004l\r"] -[9.757319, "o", "Generate a podman quadlet file from a podman command\r\n\r\n\u001b[1m\u001b[4mUsage:\u001b[0m \u001b[1mpodlet podman\u001b[0m \r\n\r\n\u001b[1m\u001b[4mCommands:\u001b[0m\r\n \u001b[1mrun\u001b[0m Generate a podman quadlet `.container` file\r\n \u001b[1mkube\u001b[0m Generate a podman quadlet `.kube` file\r\n \u001b[1mnetwork\u001b[0m Generate a podman quadlet `.network` file\r\n \u001b[1mvolume\u001b[0m Generate a podman quadlet `.volume` file\r\n \u001b[1mhelp\u001b[0m Print this message or the help of the given subcommand(s)\r\n\r\n\u001b[1m\u001b[4mOptions:\u001b[0m\r\n \u001b[1m-h\u001b[0m, \u001b[1m--help\u001b[0m Print help\r\n"] -[9.758050, "o", "\u001b[?2004h$ "] -[16.863609, "o", "\u001b[H\u001b[2J\u001b[3J"] -[16.863998, "o", "\u001b[?2004h$ "] -[16.964905, "o", "p"] -[17.065108, "o", "o"] -[17.165422, "o", "d"] -[17.265573, "o", "l"] -[17.365654, "o", "e"] -[17.465846, "o", "t"] -[17.566128, "o", " "] -[17.666339, "o", "\\"] -[17.766558, "o", "\r\n\u001b[?2004l\r"] -[17.766789, "o", "\u001b[?2004h> "] -[17.866808, "o", " "] -[17.966970, "o", " "] -[18.067143, "o", "p"] -[18.167347, "o", "o"] -[18.267616, "o", "d"] -[18.367771, "o", "m"] -[18.467929, "o", "a"] -[18.568077, "o", "n"] -[18.668398, "o", " "] -[18.768589, "o", "r"] -[18.868818, "o", "u"] -[18.968970, "o", "n"] -[19.069145, "o", " "] -[19.169374, "o", "\\"] -[19.269590, "o", "\r\n\u001b[?2004l\r"] -[19.269656, "o", "\u001b[?2004h> "] -[19.369841, "o", " "] -[19.469889, "o", " "] -[19.570152, "o", "-"] -[19.670380, "o", "p"] -[19.770679, "o", " "] -[19.870856, "o", "8"] -[19.971039, "o", "0"] -[20.071278, "o", "0"] -[20.171357, "o", "0"] -[20.271705, "o", ":"] -[20.371894, "o", "8"] -[20.472115, "o", "0"] -[20.572337, "o", " "] -[20.672598, "o", "\\"] -[20.772712, "o", "\r\n\u001b[?2004l\r"] -[20.772980, "o", "\u001b[?2004h> "] -[20.872950, "o", " "] -[20.972953, "o", " "] -[21.073212, "o", "-"] -[21.173367, "o", "p"] -[21.273581, "o", " "] -[21.373813, "o", "8"] -[21.473962, "o", "4"] -[21.574200, "o", "4"] -[21.674445, "o", "3"] -[21.774435, "o", ":"] -[21.874821, "o", "4"] -[21.975080, "o", "4"] -[22.075265, "o", "3"] -[22.175371, "o", " "] -[22.275659, "o", "\\"] -[22.375848, "o", "\r\n\u001b[?2004l\r"] -[22.375910, "o", "\u001b[?2004h> "] -[22.476061, "o", " "] -[22.576283, "o", " "] -[22.676457, "o", "-"] -[22.776719, "o", "v"] -[22.876798, "o", " "] -[22.977094, "o", "."] -[23.077336, "o", "/"] -[23.177545, "o", "C"] -[23.277632, "o", "a"] -[23.377961, "o", "d"] -[23.478173, "o", "d"] -[23.578383, "o", "y"] -[23.678626, "o", "f"] -[23.778876, "o", "i"] -[23.879031, "o", "l"] -[23.979246, "o", "e"] -[24.079461, "o", ":"] -[24.179677, "o", "/"] -[24.279964, "o", "e"] -[24.380169, "o", "t"] -[24.480352, "o", "c"] -[24.580613, "o", "/"] -[24.680845, "o", "c"] -[24.781065, "o", "a"] -[24.881162, "o", "d"] -[24.981355, "o", "d"] -[25.081581, "o", "y"] -[25.181875, "o", "/"] -[25.282079, "o", "C"] -[25.382330, "o", "a"] -[25.482510, "o", "d"] -[25.582785, "o", "d"] -[25.682936, "o", "y"] -[25.783171, "o", "f"] -[25.883395, "o", "i"] -[25.983584, "o", "l"] -[26.083826, "o", "e"] -[26.183990, "o", " "] -[26.284167, "o", "\\"] -[26.384365, "o", "\r\n\u001b[?2004l\r"] -[26.384422, "o", "\u001b[?2004h> "] -[26.484807, "o", " "] -[26.584933, "o", " "] -[26.685094, "o", "-"] -[26.785375, "o", "v"] -[26.885511, "o", " "] -[26.985819, "o", "c"] -[27.086027, "o", "a"] -[27.186223, "o", "d"] -[27.286315, "o", "d"] -[27.386485, "o", "y"] -[27.486745, "o", "-"] -[27.586996, "o", "d"] -[27.687154, "o", "a"] -[27.787327, "o", "t"] -[27.887554, "o", "a"] -[27.987756, "o", ":"] -[28.087932, "o", "/"] -[28.188129, "o", "d"] -[28.288386, "o", "a"] -[28.388663, "o", "t"] -[28.488900, "o", "a"] -[28.589032, "o", " "] -[28.689163, "o", "\\"] -[28.789485, "o", "\r\n\u001b[?2004l\r"] -[28.789589, "o", "\u001b[?2004h> "] -[28.889785, "o", " "] -[28.989966, "o", " "] -[29.090075, "o", "d"] -[29.190286, "o", "o"] -[29.290489, "o", "c"] -[29.390770, "o", "k"] -[29.490981, "o", "e"] -[29.591212, "o", "r"] -[29.691269, "o", "."] -[29.791543, "o", "i"] -[29.891739, "o", "o"] -[29.991961, "o", "/"] -[30.091961, "o", "l"] -[30.192264, "o", "i"] -[30.292424, "o", "b"] -[30.392664, "o", "r"] -[30.492891, "o", "a"] -[30.593147, "o", "r"] -[30.693231, "o", "y"] -[30.793435, "o", "/"] -[30.893609, "o", "c"] -[30.993847, "o", "a"] -[31.093972, "o", "d"] -[31.194266, "o", "d"] -[31.294438, "o", "y"] -[31.394787, "o", ":"] -[31.495043, "o", "l"] -[31.595204, "o", "a"] -[31.695433, "o", "t"] -[31.795651, "o", "e"] -[31.895965, "o", "s"] -[31.996115, "o", "t"] -[32.096297, "o", "\r\n\u001b[?2004l\r"] -[32.099684, "o", "# caddy.container\r\n[Container]\r\nImage=docker.io/library/caddy:latest\r\nPublishPort=8000:80\r\nPublishPort=8443:443\r\nVolume=./Caddyfile:/etc/caddy/Caddyfile\r\nVolume=caddy-data:/data\r\n"] -[32.100421, "o", "\u001b[?2004h$ "] -[40.206173, "o", "\u001b[H\u001b[2J\u001b[3J"] -[40.206655, "o", "\u001b[?2004h$ "] -[40.307470, "o", "p"] -[40.407703, "o", "o"] -[40.507934, "o", "d"] -[40.608150, "o", "l"] -[40.708295, "o", "e"] -[40.808424, "o", "t"] -[40.908631, "o", " "] -[41.008791, "o", "-"] -[41.109049, "o", "-"] -[41.209284, "o", "f"] -[41.309350, "o", "i"] -[41.409625, "o", "l"] -[41.509849, "o", "e"] -[41.609981, "o", " "] -[41.709859, "o", "."] -[41.810158, "o", " "] -[41.910382, "o", "-"] -[42.010575, "o", "-"] -[42.110769, "o", "i"] -[42.210978, "o", "n"] -[42.310978, "o", "s"] -[42.411338, "o", "t"] -[42.511515, "o", "a"] -[42.611760, "o", "l"] -[42.711918, "o", "l"] -[42.811936, "o", " "] -[42.912290, "o", "\\"] -[43.012438, "o", "\r\n\u001b[?2004l\r"] -[43.012497, "o", "\u001b[?2004h"] -[43.012516, "o", "> "] -[43.112729, "o", " "] -[43.212897, "o", " "] -[43.313018, "o", "p"] -[43.413217, "o", "o"] -[43.513462, "o", "d"] -[43.613598, "o", "m"] -[43.713695, "o", "a"] -[43.813822, "o", "n"] -[43.914067, "o", " "] -[44.014334, "o", "r"] -[44.114541, "o", "u"] -[44.214705, "o", "n"] -[44.314784, "o", " "] -[44.415074, "o", "\\"] -[44.515291, "o", "\r\n\u001b[?2004l\r"] -[44.515343, "o", "\u001b[?2004h> "] -[44.615456, "o", " "] -[44.715645, "o", " "] -[44.815933, "o", "-"] -[44.916004, "o", "-"] -[45.016088, "o", "r"] -[45.116353, "o", "e"] -[45.216460, "o", "s"] -[45.316581, "o", "t"] -[45.416800, "o", "a"] -[45.517128, "o", "r"] -[45.617235, "o", "t"] -[45.717296, "o", " "] -[45.817467, "o", "a"] -[45.917798, "o", "l"] -[46.017841, "o", "w"] -[46.118023, "o", "a"] -[46.218161, "o", "y"] -[46.318388, "o", "s"] -[46.418643, "o", " "] -[46.518846, "o", "\\"] -[46.618943, "o", "\r\n\u001b[?2004l\r"] -[46.618999, "o", "\u001b[?2004h> "] -[46.719025, "o", " "] -[46.819169, "o", " "] -[46.919380, "o", "-"] -[47.019596, "o", "p"] -[47.119765, "o", " "] -[47.219992, "o", "8"] -[47.320176, "o", "0"] -[47.420425, "o", "0"] -[47.520638, "o", "0"] -[47.620826, "o", ":"] -[47.720873, "o", "8"] -[47.821138, "o", "0"] -[47.921279, "o", " "] -[48.021531, "o", "\\"] -[48.121761, "o", "\r\n\u001b[?2004l\r"] -[48.121814, "o", "\u001b[?2004h> "] -[48.221947, "o", " "] -[48.322177, "o", " "] -[48.422409, "o", "-"] -[48.522582, "o", "p"] -[48.622761, "o", " "] -[48.722917, "o", "8"] -[48.823148, "o", "4"] -[48.923413, "o", "4"] -[49.023648, "o", "3"] -[49.123893, "o", ":"] -[49.224058, "o", "4"] -[49.324326, "o", "4"] -[49.424513, "o", "3"] -[49.524702, "o", " "] -[49.624930, "o", "\\"] -[49.725126, "o", "\r\n\u001b[?2004l\r"] -[49.725374, "o", "\u001b[?2004h> "] -[49.825327, "o", " "] -[49.925508, "o", " "] -[50.025749, "o", "-"] -[50.125957, "o", "v"] -[50.226146, "o", " "] -[50.326295, "o", "."] -[50.426543, "o", "/"] -[50.526667, "o", "C"] -[50.626935, "o", "a"] -[50.727165, "o", "d"] -[50.827324, "o", "d"] -[50.927495, "o", "y"] -[51.027591, "o", "f"] -[51.127928, "o", "i"] -[51.228208, "o", "l"] -[51.328372, "o", "e"] -[51.428631, "o", ":"] -[51.528913, "o", "/"] -[51.629026, "o", "e"] -[51.729221, "o", "t"] -[51.829489, "o", "c"] -[51.929655, "o", "/"] -[52.029816, "o", "c"] -[52.130069, "o", "a"] -[52.230331, "o", "d"] -[52.330536, "o", "d"] -[52.430709, "o", "y"] -[52.530926, "o", "/"] -[52.631127, "o", "C"] -[52.731398, "o", "a"] -[52.831607, "o", "d"] -[52.931860, "o", "d"] -[53.031821, "o", "y"] -[53.132146, "o", "f"] -[53.232136, "o", "i"] -[53.332456, "o", "l"] -[53.432656, "o", "e"] -[53.532882, "o", " "] -[53.633189, "o", "\\"] -[53.733349, "o", "\r\n\u001b[?2004l\r"] -[53.733412, "o", "\u001b[?2004h> "] -[53.833525, "o", " "] -[53.933782, "o", " "] -[54.033915, "o", "-"] -[54.134170, "o", "v"] -[54.234328, "o", " "] -[54.334535, "o", "c"] -[54.434758, "o", "a"] -[54.535025, "o", "d"] -[54.635185, "o", "d"] -[54.735422, "o", "y"] -[54.835618, "o", "-"] -[54.935842, "o", "d"] -[55.036065, "o", "a"] -[55.136324, "o", "t"] -[55.236466, "o", "a"] -[55.336641, "o", ":"] -[55.436862, "o", "/"] -[55.537133, "o", "d"] -[55.637314, "o", "a"] -[55.737429, "o", "t"] -[55.837729, "o", "a"] -[55.937827, "o", " "] -[56.037985, "o", "\\"] -[56.138343, "o", "\r\n\u001b[?2004l\r"] -[56.138432, "o", "\u001b[?2004h> "] -[56.238490, "o", " "] -[56.338652, "o", " "] -[56.439109, "o", "d"] -[56.539226, "o", "o"] -[56.639364, "o", "c"] -[56.739669, "o", "k"] -[56.839890, "o", "e"] -[56.940137, "o", "r"] -[57.040347, "o", "."] -[57.140526, "o", "i"] -[57.240789, "o", "o"] -[57.340985, "o", "/"] -[57.441170, "o", "l"] -[57.541516, "o", "i"] -[57.641659, "o", "b"] -[57.741638, "o", "r"] -[57.841957, "o", "a"] -[57.942148, "o", "r"] -[58.042325, "o", "y"] -[58.142514, "o", "/"] -[58.242758, "o", "c"] -[58.342983, "o", "a"] -[58.443236, "o", "d"] -[58.543477, "o", "d"] -[58.643653, "o", "y"] -[58.743813, "o", ":"] -[58.843859, "o", "l"] -[58.944079, "o", "a"] -[59.044350, "o", "t"] -[59.144521, "o", "e"] -[59.244731, "o", "s"] -[59.344973, "o", "t"] -[59.445182, "o", "\r\n\u001b[?2004l\r"] -[60.082085, "o", "Wrote to file: ./caddy.container\r\n"] -[60.082562, "o", "\u001b[?2004h$ "] -[63.287302, "o", "c"] -[63.387434, "o", "a"] -[63.487626, "o", "t"] -[63.587829, "o", " "] -[63.688098, "o", "c"] -[63.788246, "o", "a"] -[63.888440, "o", "d"] -[63.988678, "o", "d"] -[64.088881, "o", "y"] -[64.189115, "o", "."] -[64.289392, "o", "c"] -[64.389516, "o", "o"] -[64.489744, "o", "n"] -[64.589995, "o", "t"] -[64.690067, "o", "a"] -[64.790447, "o", "i"] -[64.890630, "o", "n"] -[64.990732, "o", "e"] -[65.090891, "o", "r"] -[65.191138, "o", "\r\n\u001b[?2004l\r"] -[65.192927, "o", "[Container]\r\nImage=docker.io/library/caddy:latest\r\nPublishPort=8000:80\r\nPublishPort=8443:443\r\nVolume=./Caddyfile:/etc/caddy/Caddyfile\r\nVolume=caddy-data:/data\r\n\r\n[Service]\r\nRestart=always\r\n\r\n[Install]\r\nWantedBy=default.target\r\n"] -[65.193321, "o", "\u001b[?2004h$ "] -[75.298845, "o", "\u001b[H\u001b[2J\u001b[3J"] -[75.299309, "o", "\u001b[?2004h$ "] -[75.400226, "o", "c"] -[75.500401, "o", "a"] -[75.600606, "o", "t"] -[75.700787, "o", " "] -[75.801001, "o", "c"] -[75.901179, "o", "o"] -[76.001345, "o", "m"] -[76.101504, "o", "p"] -[76.201678, "o", "o"] -[76.301892, "o", "s"] -[76.402184, "o", "e"] -[76.502376, "o", "-"] -[76.602637, "o", "e"] -[76.702706, "o", "x"] -[76.802981, "o", "a"] -[76.903152, "o", "m"] -[77.003334, "o", "p"] -[77.103578, "o", "l"] -[77.203681, "o", "e"] -[77.303831, "o", "."] -[77.404180, "o", "y"] -[77.504249, "o", "a"] -[77.604436, "o", "m"] -[77.704593, "o", "l"] -[77.804766, "o", "\r\n\u001b[?2004l\r"] -[77.806584, "o", "services:\r\n caddy:\r\n image: docker.io/library/caddy:latest\r\n ports:\r\n - 8000:80\r\n - 8443:443\r\n volumes:\r\n - ./Caddyfile:/etc/caddy/Caddyfile\r\n - caddy-data:/data\r\nvolumes:\r\n caddy-data:\r\n"] -[77.807013, "o", "\u001b[?2004h$ "] -[81.011869, "o", "p"] -[81.112208, "o", "o"] -[81.212335, "o", "d"] -[81.312467, "o", "l"] -[81.412621, "o", "e"] -[81.512951, "o", "t"] -[81.612855, "o", " "] -[81.713001, "o", "c"] -[81.813175, "o", "o"] -[81.913280, "o", "m"] -[82.013520, "o", "p"] -[82.113738, "o", "o"] -[82.214016, "o", "s"] -[82.314164, "o", "e"] -[82.414400, "o", " "] -[82.514523, "o", "c"] -[82.614742, "o", "o"] -[82.714945, "o", "m"] -[82.815178, "o", "p"] -[82.915399, "o", "o"] -[83.015624, "o", "s"] -[83.115671, "o", "e"] -[83.215971, "o", "-"] -[83.316094, "o", "e"] -[83.416344, "o", "x"] -[83.516483, "o", "a"] -[83.616661, "o", "m"] -[83.716846, "o", "p"] -[83.817123, "o", "l"] -[83.917174, "o", "e"] -[84.017389, "o", "."] -[84.117510, "o", "y"] -[84.217590, "o", "a"] -[84.317858, "o", "m"] -[84.418106, "o", "l"] -[84.518265, "o", "\r\n\u001b[?2004l\r"] -[84.521946, "o", "# caddy.container\r\n[Container]\r\nImage=docker.io/library/caddy:latest\r\nPublishPort=8000:80\r\nPublishPort=8443:443\r\nVolume=./Caddyfile:/etc/caddy/Caddyfile\r\nVolume=caddy-data:/data\r\n"] -[84.522630, "o", "\u001b[?2004h$ "] -[91.727125, "o", "p"] -[91.827523, "o", "o"] -[91.927696, "o", "d"] -[92.027901, "o", "l"] -[92.127877, "o", "e"] -[92.228252, "o", "t"] -[92.328473, "o", " "] -[92.428732, "o", "c"] -[92.528948, "o", "o"] -[92.629149, "o", "m"] -[92.729385, "o", "p"] -[92.829439, "o", "o"] -[92.929704, "o", "s"] -[93.029925, "o", "e"] -[93.130143, "o", " "] -[93.230416, "o", "-"] -[93.330633, "o", "-"] -[93.430848, "o", "p"] -[93.531091, "o", "o"] -[93.631299, "o", "d"] -[93.731401, "o", " "] -[93.831609, "o", "c"] -[93.931782, "o", "a"] -[94.031944, "o", "d"] -[94.132015, "o", "d"] -[94.232208, "o", "y"] -[94.332439, "o", "-"] -[94.432639, "o", "e"] -[94.532862, "o", "x"] -[94.632820, "o", "a"] -[94.733007, "o", "m"] -[94.833147, "o", "p"] -[94.933381, "o", "l"] -[95.033554, "o", "e"] -[95.133782, "o", " "] -[95.233905, "o", "c"] -[95.334140, "o", "o"] -[95.434368, "o", "m"] -[95.534609, "o", "p"] -[95.634697, "o", "o"] -[95.735014, "o", "s"] -[95.835231, "o", "e"] -[95.935397, "o", "-"] -[96.035615, "o", "e"] -[96.135771, "o", "x"] -[96.235982, "o", "a"] -[96.336212, "o", "m"] -[96.436369, "o", "p"] -[96.536630, "o", "l"] -[96.636742, "o", "e"] -[96.737008, "o", "."] -[96.837122, "o", "y"] -[96.937309, "o", "a"] -[97.037480, "o", "m"] -[97.137714, "o", "l"] -[97.237754, "o", "\r\n\u001b[?2004l\r"] -[97.241351, "o", "# caddy-example.kube\r\n[Kube]\r\nYaml=caddy-example-kube.yaml\r\n\r\n---\r\n\r\n# caddy-example-kube.yaml\r\napiVersion: v1\r\nkind: Pod\r\nmetadata:\r\n name: caddy-example\r\nspec:\r\n containers:\r\n - image: docker.io/library/caddy:latest\r\n name: caddy\r\n ports:\r\n - containerPort: 80\r\n hostPort: 8000\r\n - containerPort: 443\r\n hostPort: 8443\r\n volumeMounts:\r\n - mountPath: /etc/caddy/Caddyfile\r\n name: caddy-etc-caddy-Caddyfile\r\n - mountPath: /data\r\n name: caddy-data\r\n volumes:\r\n - hostPath:\r\n path: ./Caddyfile\r\n name: caddy-etc-caddy-Caddyfile\r\n - name: caddy-data\r\n persistentVolumeClaim:\r\n claimName: caddy-data\r\n"] -[97.242122, "o", "\u001b[?2004h$ "] -[107.856640, "o", "\u001b[?2004l\r\n"] diff --git a/demo.gif b/demo.gif index 28005ee..bba9deb 100644 Binary files a/demo.gif and b/demo.gif differ diff --git a/demo.yaml b/demo.yaml new file mode 100644 index 0000000..eca55cc --- /dev/null +++ b/demo.yaml @@ -0,0 +1,108 @@ +# demo.yaml +# autocast (https://github.com/k9withabone/autocast) configuration for podlet demo + +# Convert to a GIF and optimize: +# agg --theme monokai --idle-time-limit 20 --font-size 20 demo.cast demo.gif +# gifsicle -O2 -k 64 -Okeep-empty --lossy=80 demo.gif -o demo-opt.gif +# mv demo-opt.gif demo.gif + +settings: + width: 129 + height: 34 + title: podlet v0.2.3 demo + timeout: 90s + type_speed: 90ms + +instructions: + # setup + - !Command + command: cargo build --profile dist + hidden: true + - !Command + command: alias podlet=target/dist/podlet + hidden: true + - !Command + command: podman pull quay.io/podman/hello:latest + hidden: true + + - !Marker podlet help + - !Command + command: podlet -h + - !Wait 7s + - !Clear + + - !Marker podlet podman help + - !Command + command: podlet podman -h + - !Wait 6s + - !Clear + + - !Marker podlet podman run + - !Command + command: | + podlet + podman run + -p 8000:80 + -p 8443:443 + -v ./Caddyfile:/etc/caddy/Caddyfile:Z + -v caddy-data:/data + docker.io/library/caddy:latest + type_speed: 75ms + - !Wait 6s + - !Clear + - !Command + command: | + podlet --file . --install + podman run + --restart always + -p 8000:80 + -p 8443:443 + -v ./Caddyfile:/etc/caddy/Caddyfile:Z + -v caddy-data:/data + docker.io/library/caddy:latest + type_speed: 75ms + - !Wait 3s + - !Command + command: cat caddy.container + - !Wait 8s + - !Clear + + - !Marker podlet compose + - !Command + command: cat compose-example.yaml + - !Wait 250ms + - !Command + command: podlet compose compose-example.yaml + - !Wait 5s + - !Command + command: podlet compose --pod caddy-example compose-example.yaml + type_speed: 80ms + - !Wait 7s + - !Clear + + - !Marker podlet generate help + - !Command + command: podlet generate -h + - !Wait 6s + - !Clear + + - !Marker podlet generate container + - !Command + command: podman container create --name hello quay.io/podman/hello:latest + type_speed: 80ms + - !Wait 2s + - !Command + command: podlet generate container hello + type_speed: 80ms + - !Wait 5s + + # cleanup + - !Command + command: rm caddy.container + hidden: true + - !Command + command: podman rm hello + hidden: true + - !Command + command: unalias podlet + hidden: true diff --git a/src/cli/compose.rs b/src/cli/compose.rs index b160a65..628e756 100644 --- a/src/cli/compose.rs +++ b/src/cli/compose.rs @@ -7,7 +7,7 @@ use std::{ }; use color_eyre::{ - eyre::{self, WrapErr}, + eyre::{self, OptionExt, WrapErr}, Help, }; use docker_compose_types::{Command, Compose, ComposeNetworks, MapOrEmpty}; @@ -50,13 +50,11 @@ pub fn from_file_or_stdin(path: Option<&Path>) -> color_eyre::Result { } } - result.ok_or_else(|| { - eyre::eyre!( - "A compose file was not provided and none of \ + result.ok_or_eyre( + "A compose file was not provided and none of \ `compose.yaml`, `compose.yml`, `docker-compose.yaml`, or `docker-compose.yml` \ - exist in the current directory or could not be read" - ) - })? + exist in the current directory or could not be read", + )? }; serde_yaml::from_reader(compose_file) diff --git a/src/cli/container.rs b/src/cli/container.rs index 60dcfdd..0517992 100644 --- a/src/cli/container.rs +++ b/src/cli/container.rs @@ -5,7 +5,7 @@ pub mod security_opt; use std::mem; use clap::Args; -use color_eyre::eyre::{self, Context}; +use color_eyre::eyre::{self, Context, OptionExt}; use crate::cli::compose; @@ -84,10 +84,7 @@ impl TryFrom for Container { quadlet_options: (&mut value).try_into()?, podman_args: (&mut value.service).try_into()?, security_opt, - image: value - .service - .image - .ok_or(eyre::eyre!("image is required"))?, + image: value.service.image.ok_or_eyre("image is required")?, command: value .service .command diff --git a/src/cli/container/quadlet.rs b/src/cli/container/quadlet.rs index 69152d6..b238927 100644 --- a/src/cli/container/quadlet.rs +++ b/src/cli/container/quadlet.rs @@ -607,6 +607,7 @@ impl TryFrom<&mut ComposeService> for QuadletOptions { } } +#[allow(clippy::struct_field_names)] #[derive(Debug, Default, Clone, PartialEq)] struct Healthcheck { health_cmd: Option, diff --git a/src/cli/generate.rs b/src/cli/generate.rs index e531653..ba40634 100644 --- a/src/cli/generate.rs +++ b/src/cli/generate.rs @@ -36,7 +36,9 @@ pub enum Generate { /// /// The command used to create the container is parsed to generate the quadlet file. Container { - /// Name of the container + /// Name or ID of the container + /// + /// Passed to `podman container inspect`. container: String, }, @@ -50,12 +52,16 @@ pub enum Generate { /// precise value. Network { /// Name of the network + /// + /// Passed to `podman network inspect`. network: String, }, /// Generate a quadlet file from an existing volume Volume { /// Name of the volume + /// + /// Passed to `podman volume inspect`. volume: String, }, } diff --git a/src/cli/install.rs b/src/cli/install.rs index 4d97fd4..aedf1ea 100644 --- a/src/cli/install.rs +++ b/src/cli/install.rs @@ -6,6 +6,7 @@ pub struct Install { /// /// By default, if the --wanted-by and --required-by options are not used, /// the section will have "WantedBy=default.target". + #[allow(clippy::struct_field_names)] #[arg(short, long)] pub install: bool, diff --git a/src/cli/k8s.rs b/src/cli/k8s.rs index d47a711..c7c8f74 100644 --- a/src/cli/k8s.rs +++ b/src/cli/k8s.rs @@ -1,7 +1,7 @@ use std::collections::BTreeMap; use color_eyre::{ - eyre::{self, Context}, + eyre::{self, Context, OptionExt}, Help, }; use docker_compose_types::{ @@ -254,9 +254,7 @@ fn healthcheck_try_into_probe(healthcheck: Healthcheck) -> color_eyre::Result None, }, } - .ok_or(eyre::eyre!( - "healthcheck implicitly using a shell is not supported for pods" - )) + .ok_or_eyre("healthcheck implicitly using a shell is not supported for pods") .suggestion(r#"change healthcheck test to '["CMD", "/bin/sh", "-c", ...]'"#) }) .transpose()?; @@ -627,7 +625,7 @@ fn advanced_volume_try_into_volume_mount( bind.is_none(), "bind mount propagation is not supported by pods" ); - let source = source.ok_or(eyre::eyre!("cannot have a bind mount without a source"))?; + let source = source.ok_or_eyre("cannot have a bind mount without a source")?; let name = volume_name(container_name, &target); bind_volume(name, source) } diff --git a/src/quadlet/container.rs b/src/quadlet/container.rs index 0c38788..665101d 100644 --- a/src/quadlet/container.rs +++ b/src/quadlet/container.rs @@ -38,6 +38,7 @@ pub struct Container { pub auto_update: Option, /// The (optional) name of the Podman container. + #[allow(clippy::struct_field_names)] pub container_name: Option, /// Set network-scoped DNS resolver/nameserver for containers in this network.