From d7173f4e497b676e697bcebafb3516d5267b6e91 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Fri, 12 Jan 2024 23:12:06 +0100 Subject: [PATCH] Add `dry-run` setting and docs.mf (#12) also change: - rename `PLUGIN_LOG` to `PLUGIN_LOG_LEVEL` - update default value of `PLUGIN_REGISTRY` --- docs.md | 40 ++++++++++++++++++++++++++++++++++++++++ plugin.sh | 6 +++--- 2 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 docs.md diff --git a/docs.md b/docs.md new file mode 100644 index 0000000..8048ff3 --- /dev/null +++ b/docs.md @@ -0,0 +1,40 @@ +--- +name: Kaniko +authors: Woodpecker Authors +description: Plugin to build container images without root privileges +tags: [docker, podman, container, build] +containerImage: woodpeckerci/plugin-kaniko +containerImageUrl: https://hub.docker.com/r/woodpeckerci/plugin-kaniko +url: https://github.com/woodpecker-ci/plugin-kaniko +--- + +Settings can be defined using the `settings` option for woodpecker plugins. All available settings and their defaults are listed below. + +## Settings + +| Settings Name | Default | Description | +| ------------- | ----------------------------- | -------------------------------------------------- | +| `dry-run` | `false` | disables docker push | +| `repo` | _none_ | sets repository name for the image (can be a list) | +| `username` | _none_ | sets username to authenticates with | +| `password` | _none_ | sets password / token to authenticates with | +| `registry` | `https://index.docker.io/v1/` | sets docker registry to authenticate with | +| `dockerfile` | `Dockerfile` | sets dockerfile to use for the image build | +| `tags` | _none_ | sets repository tags to use for the image | + +## Advanced Settings + +| Settings Name | Default | Description | +| --------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| `context` | `.` | sets the path of the build context to use | +| `build-args` | _none_ | sets custom build arguments for the build | +| `build-args-from-env` | _none_ | forwards environment variables as custom arguments to the build | +| `auto-tag` | `false` | if set generate .tags file, support format Major.Minor.Release or start with `v` docker tags: Major, Major.Minor, Major.Minor.Release and latest | +| `log-level` | `info` | set different log level | +| `target` | _none_ | +| `cache` | `false` | use a cache repo | +| `cache-repo` | _none_ | specify the cache repo | +| `cache-ttl` | _none_ | set the time to live for the cache | +| `skip-tls-verify` | `false` | ignore tls issues | +| `mirrors` | _none_ | set docker hub mirrors | +| `json-key` | _none_ | pass a json key to kaniko | diff --git a/plugin.sh b/plugin.sh index 336896d..b52d012 100755 --- a/plugin.sh +++ b/plugin.sh @@ -4,7 +4,7 @@ set -euo pipefail export PATH="$PATH:/kaniko/" -REGISTRY=${PLUGIN_REGISTRY:-index.docker.io} +REGISTRY=${PLUGIN_REGISTRY:-https://index.docker.io/v1/} if [ "${PLUGIN_USERNAME:-}" ] || [ "${PLUGIN_PASSWORD:-}" ]; then DOCKER_AUTH=$(echo -n "${PLUGIN_USERNAME}:${PLUGIN_PASSWORD}" | base64 | tr -d "\n") @@ -27,7 +27,7 @@ fi DOCKERFILE=${PLUGIN_DOCKERFILE:-Dockerfile} CONTEXT=${PLUGIN_CONTEXT:-$PWD} -LOG=${PLUGIN_LOG:-info} +LOG=${PLUGIN_LOG_LEVEL:-info} EXTRA_OPTS="" if [[ -n "${PLUGIN_TARGET:-}" ]]; then @@ -92,7 +92,7 @@ if [ -n "${PLUGIN_TAGS:-}" ]; then DESTINATIONS=$(echo "${PLUGIN_TAGS}" | tr ',' '\n' | while read tag; do echo "--destination=${REGISTRY}/${PLUGIN_REPO}:${tag} "; done) elif [ -f .tags ]; then DESTINATIONS=$(tr ',' '\n' < .tags | while read tag; do echo "--destination=${REGISTRY}/${PLUGIN_REPO}:${tag} "; done) -elif [ -n "${PLUGIN_REPO:-}" ]; then +elif [ -n "${PLUGIN_REPO:-}" ] && [ "${PLUGIN_DRY_RUN:-}" != "true" ]; then DESTINATIONS="--destination=${REGISTRY}/${PLUGIN_REPO}:latest" else DESTINATIONS="--no-push"