Skip to content

Commit

Permalink
release v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mcorbin committed Dec 22, 2021
1 parent 2098d40 commit 04b6a97
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM clojure:openjdk-17-lein as build-env

ADD . /app
WORKDIR /app

RUN lein uberjar

# -----------------------------------------------------------------------------

from openjdk:17

RUN groupadd -r ymlgen && useradd -r -s /bin/false -g ymlgen ymlgen
RUN mkdir /app
COPY --from=build-env /app/target/uberjar/ymlgen-*-standalone.jar /app/ymlgen.jar

RUN chown -R ymlgen:ymlgen /app

user ymlgen

ENTRYPOINT ["java", "-jar", "/app/ymlgen.jar"]
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@ It supports including parts of definitions into other ones, variables, generatin
The tool leverages the [EDN](https://github.com/edn-format/edn) format and the [Aero](https://github.com/juxt/aero) library.

Why `ymlgen` ? It's simple, powerful and extensible.
I think neither templating or using YAML to generate more YAML are good solutions to manage Kubernetes resources and that's why I built this tool.

## Install

For Linux (x86-64), download the `ymlgen` binary and put it in your PATH. This binary is built using [GraalVM](https://www.graalvm.org/) so more targets may be added soon (help welcome).
For Linux (x86-64), download the `ymlgen` binary from the [release page](https://github.com/mcorbin/ymlgen/releases) and put it in your PATH. This binary is built using [GraalVM](https://www.graalvm.org/), more targets may be added soon (help welcome).

You can alternatively download the `jar` file and then run it with `java -jar ymlgen.jar` (Java 17 needed).

A docker image is also provided. Note that this image uses `java` as well so executing it is a bit slower than the static binary built with GraalVM.

All example described below can be done using the Docker image by executing in the directory containing your templates `docker run -v $(pwd):/data mcorbin/ymlgen:v0.1.0 <command>`. The files will be availables in `/data`.

## Quick start

### Simple EDN example

Once `ymlgen` installed, you are ready to use it. Let's for example generate a yaml file from a simple EDN definition. Put in `pod.edn` this content:

```clojure
;; this is a comment
{:apiVersion "v1"
:kind "Pod"
:metadata {:name "dnsutils"
Expand Down
4 changes: 3 additions & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ lein test
git add .
git commit -m "release ${tag}"
git tag -a "${tag}" -m "release ${tag}"
lein uberjar
docker build -t mcorbin/ymlgen:${tag} .
docker push mcorbin/ymlgen:${tag}

lein uberjar
native-image --report-unsupported-elements-at-runtime \
--initialize-at-build-time \
--no-server \
Expand Down
3 changes: 2 additions & 1 deletion src/ymlgen/commands/yaml.clj
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@
(let [result (gen-yaml config)]
(if output-path
(spit output-path result)
(println result))))
(do (print result)
(flush)))))

0 comments on commit 04b6a97

Please sign in to comment.