Commit Graph

11 Commits

Author SHA1 Message Date
Jeff Wong d51da1fc1d
FEATURE: add --tags and --skip-tags options (#28)
* FEATURE: add --tags and --skip-tags options

Allow config manifests to be tagged, so a pups run can apply a subset of run commands.

Update to ruby 3.2.
Lots of linting. Added rubocop lint exception for Eval.
Fixing test imports, update MiniTest::Test -> Minitest::Test.
2023-10-22 17:42:24 -07:00
Michael Fitz-Payne 193242003d
FEATURE: Support generating docker cli arguments. (#22)
The --gen-docker-env-args argument makes pups process any template
environment variables and generate the command line arguments suitable
for the docker run command. The intention is to expand support for
configuring container runtime into pups such that configuration
templates can be more generally useful.

Bash special characters are safely escaped. This prevents issues where
variables contain special characters that are parsed by the calling shell.
A script which uses the pups output may have unexpected side effects
without escaping the special characters.

Note that only `env`, `label`, and `volume` config variables are escaped
as these are the most likely to contain special chacters. No attempt is
made to validate config variables against the allowed characters by
docker itself.

Other changes:
- Change some exit calls to return to prevent the tests prematurely
exiting.
2021-06-15 16:14:21 +10:00
Michael Fitz-Payne ebe1069395 Add --ignore option for specific config elements. (#26)
There are use cases where we may want pups to ignore particular
configuration elements at runtime. For example, we may want to skip over
hooks in certain circumstances or define environment variables via the
process at runtime that are already defined in a template.

The follow example demonstrates the usage (note the last log line):

```
$ cat /tmp/test.yml
env:
  MY_VAR: a_word
run:
  - exec: 'echo repeating $MY_VAR'

$ bin/pups --ignore env /tmp/test.yml
I, [2021-06-09T12:03:46.864770 #30369]  INFO -- : Reading from /tmp/test.yml
I, [2021-06-09T12:03:46.865009 #30369]  INFO -- : > echo repeating $MY_VAR
I, [2021-06-09T12:03:46.865824 #30369]  INFO -- : repeating

$ bin/pups /tmp/test.yml
I, [2021-06-09T12:03:50.694739 #30380]  INFO -- : Reading from /tmp/test.yml
I, [2021-06-09T12:03:50.694980 #30380]  INFO -- : > echo repeating $MY_VAR
I, [2021-06-09T12:03:50.695730 #30380]  INFO -- : repeating a_word
```

This will become more useful once the docker run argument generation
functionality is implemented. For example, options like `expose` may
want to be ignored if pups is being used to generate runtime arguments
for more the one container on the same machine (as published port numbers
cannot overlap between containers). Without the `--ignore` lever, all
runtime arguments will be produced all the time which limits use cases.
2021-06-10 09:02:49 +10:00
Michael Fitz-Payne 2069d66f39
Add lint step to CI, fix all lint issues. (#24)
The fixes were performend rubocop -A functionality for autocorrecting.
The linting is enforced according to the rubocop-discourse rules.
2021-06-03 12:22:29 +10:00
Michael Fitz-Payne 17f04ecde5
Add support for templating environment variables. (#20)
Templated variables can be used to parameterise container creation. This
will ensure any ENV variables are templated during config initialisation
prior to any use.

There are situations where we want to provide and config template at
runtime rather than ahead-of-time. This adds support for specifying such
a variable via the process environment, prefixed with
env_template_<name>=value.
2021-05-20 13:09:39 +10:00
David Taylor 05db637f26
Revert "FIX: coerce env to strings" (#19)
This reverts commit 262d7eb4f8 and 8f353a3778

discourse_docker's launcher, and potentially other systems, manipulate environment variables before applying them to a `docker run` command. At the moment, those tools do not necessarily apply those same manipulations to the YAML file passed to pups.

Specifically, in discourse_docker's launcher, the string `{{config}}` in container labels or environment variables is substituted with the filename of the YAML file. Launcher does not perform this replacement on the file passed to pups. Previously, that was not an issue, because pups didn't use the `env` or `labels` from the file. Now, it causes pups to run its setup using incorrect environment variables.

Reverting this until:
  - We update discourse_docker's launcher so that it performs the replacement on the YAML file passed to pups
  - We come up with a way to avoid breaking old discourse_docker installs (right now they use the latest `master` version of discourse/pups on every build)
2021-04-08 13:42:52 +01:00
Sam Saffron 262d7eb4f8
FIX: coerce env to strings
env only ever accepts strings
2021-04-08 18:06:09 +10:00
Michael Fitz-Payne 8f353a3778 Add 'env' property support to configuration.
Variables specified under the `env` property in the root of the yaml
configuration file will now be set in the pups environment during the
initialization process. Any existing environment variables are
overwritten by matching variables specified in the config `env` property.

The integration test was updated to exercise the params and env
codepath as this covers the new functionality.
2021-04-08 16:32:00 +10:00
Sam 5a4454cd00 Allow for substitutions in replace, suck in ENV and add to params 2014-03-18 17:46:20 +11:00
Sam Saffron 4cdc866c93 added hook support 2013-11-03 21:09:15 -08:00
Sam c96b19112c tests and brand new dsl 2013-10-31 13:28:01 +11:00