Skip to content

Commit

Permalink
feat: rename command to args for container type
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

After updating, the following configuration fields for container modules
must be renamed as indicated:

  * service.command -> service.args
  * service.hotReloadCommand -> service.hotReloadArgs
  * test.command -> test.args
  * task.command -> task.args

This is done in preparation for a new configuration option (using the
key `command`, hence the rename) that's planned for release soon,
whereby users can override the current default of running
tests / tasks / ad-hoc commands inside containers via
`/bin/sh -c [args]`.
  • Loading branch information
thsig committed Jan 25, 2019
1 parent 0074ae0 commit 84f5a8d
Show file tree
Hide file tree
Showing 86 changed files with 225 additions and 5,710 deletions.
4 changes: 2 additions & 2 deletions docs/examples/hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ Here's what it looks like in practice:
```yml
tests:
- name: unit
command: [npm, test]
args: [npm, test]
- name: integ
command: [npm, run, integ]
args: [npm, run, integ]
dependencies:
- hello-function
```
2 changes: 1 addition & 1 deletion docs/examples/simple-project.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module:
type: container
services:
- name: node-service
command: [npm, start]
args: [npm, start]
ports:
- name: http
containerPort: 8080
Expand Down
4 changes: 2 additions & 2 deletions docs/faqs.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ You can split them up and run tests by their names with the `garden test` comman
```yaml
tests:
- name: light
command: [npm, run, e2e-light]
args: [npm, run, e2e-light]
- name: full
command: [npm, run, e2e-full]
args: [npm, run, e2e-full]
```
And you'd run them with `garden test front-end --name=light`, assuming the service is called front-end.
Expand Down
41 changes: 19 additions & 22 deletions docs/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,9 @@ module:
# Optional.
image:

# When this field is used, the files or directories specified within are automatically synced
# into the running container when they're modified. Additionally, any of this module's services
# that define a `hotReloadCommand` will be run with that command instead of the one specified in
# their `command` field. Services are only deployed with hot reloading enabled when their names
# are passed to the `--hot-reload` option in a call to the `deploy` or `dev` command.
# Specifies which files or directories to sync to which paths inside the running containers of
# hot reload-enabled services when those files or directories are modified. Applies to this
# module's services, and to services with this module as their `sourceModule`.
#
# Optional.
hotReload:
Expand Down Expand Up @@ -550,7 +548,7 @@ module:
# The arguments to run the container with when starting the service.
#
# Optional.
command:
args:
-

# Whether to run the service as a daemon (to ensure only one runs per node).
Expand Down Expand Up @@ -625,10 +623,10 @@ module:
tcpPort:

# If this module uses the `hotReload` field, the container will be run with these arguments
# instead of those in `command` when the service is deployed with hot reloading enabled.
# instead of those in `args` when the service is deployed with hot reloading enabled.
#
# Optional.
hotReloadCommand:
hotReloadArgs:
-

# List of ports that the service container exposes.
Expand Down Expand Up @@ -693,9 +691,6 @@ module:
#
# Optional.
tests:
# The test specification of an exec module.
#
# Optional.
- # The name of the test.
#
# Required.
Expand All @@ -713,10 +708,14 @@ module:
# Optional.
timeout: null

# The command to run in the module build context in order to test it.
# The arguments used to run the test inside the container.
#
# Example:
# - npm
# - test
#
# Optional.
command:
args:
-

# Key/value map of environment variables. Keys must be valid POSIX environment variable
Expand All @@ -731,7 +730,7 @@ module:
#
# Optional.
tasks:
# A task that can be run in this module.
# A task that can be run in the container.
#
# Optional.
- # The name of the task.
Expand All @@ -756,10 +755,14 @@ module:
# Optional.
timeout: null

# The command that the task should run inside the container.
# The arguments used to run the task inside the container.
#
# Example:
# - rake
# - 'db:migrate'
#
# Optional.
command:
args:
-
```
Expand Down Expand Up @@ -943,9 +946,6 @@ module:
#
# Optional.
tasks:
# Required configuration for module tests.
#
# Optional.
- # The name of the test.
#
# Required.
Expand Down Expand Up @@ -1032,9 +1032,6 @@ module:
#
# Optional.
tests:
# Required configuration for module tests.
#
# Optional.
- # The name of the test.
#
# Required.
Expand Down
12 changes: 6 additions & 6 deletions docs/using-garden/configuration-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ module:
type: container
services:
- name: hello-container
command: [npm, start]
args: [npm, start]
ports:
- name: http
containerPort: 8080
Expand All @@ -153,8 +153,8 @@ module:
```

Here the `services` field defines the services exposed by the module. We only have one service in this example,
but you may add another service, for example a background worker, that is started using a different
`command`.
but you may add another service, for example a background worker, that is started using different
`args`.

For more details on how to configure services in a `container` module, please refer to the
[Config Files Reference](../reference/config.md).
Expand All @@ -174,15 +174,15 @@ module:
...
tests:
- name: unit
command: [npm, test]
args: [npm, test]
- name: integ
command: [npm, run, integ]
args: [npm, run, integ]
dependencies:
- hello-function
```

Here we define two types of tests. First are unit tests, which can be run on their own without any dependencies. The
framework only needs to know which command to run, and the rest is handled by the module's code itself.
framework only needs to know which args to run the container with, and the rest is handled by the module's code itself.

The other test suite, `integ`, leverages the Garden framework's ability to manage runtime dependencies for tests. In
this case, the integ test suite needs the `hello-function` service to be running for the tests to execute.
Expand Down
4 changes: 2 additions & 2 deletions docs/using-garden/features-and-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ Tests should be specified the same way, and in the case of integration tests the
```yaml
tests:
- name: unit
command: [npm, test]
args: [npm, test]
- name: integ
command: [npm, run, integ]
args: [npm, run, integ]
dependencies:
- go-service
```
Expand Down
6 changes: 3 additions & 3 deletions docs/using-garden/hot-reload.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ module:
- target: /app/
services:
- name: test-service
command: [npm, start] # runs `node main.js`
hotReloadCommand: [npm, run, dev] # runs `nodemon main.js`
args: [npm, start] # runs `node main.js`
hotReloadArgs: [npm, run, dev] # runs `nodemon main.js`
```
In the above, the `hotReload` field specifies the destination path inside the running container that the module's (top-level) directory (where its `garden.yml` resides) is synced to.
Expand All @@ -46,4 +46,4 @@ You can configure several such `source`/`target` pairs, but note that the `sourc
target: /app/bar
```

Lastly, `hotReloadCommand` determines which command should be run inside the container (when deployed with hot reloading enabled). If no `hotReloadCommand` is specified, `command` is also used in hot reload mode.
Lastly, `hotReloadArgs` specifies the arguments to use to run the container (when deployed with hot reloading enabled). If no `hotReloadArgs` are specified, `args` is also used in hot reload mode.
2 changes: 1 addition & 1 deletion examples/gatsby-hot-reload/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module:
source: src
services:
- name: website
command: [npm, run, dev]
args: [npm, run, dev]
hotReloadCommand: [npm, run, dev]
env:
GATSBY_WEBPACK_PUBLICPATH: /
Expand Down
6 changes: 3 additions & 3 deletions examples/hello-world/services/hello-container/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module:
name: hello-container
services:
- name: hello-container
command: [npm, start]
args: [npm, start]
ports:
- name: http
containerPort: 8080
Expand All @@ -27,9 +27,9 @@ module:
target: libraries/hello-npm-package/
tests:
- name: unit
command: [npm, test]
args: [npm, test]
- name: integ
command: [npm, run, integ]
args: [npm, run, integ]
env:
FUNCTION_ENDPOINT: ${services.hello-function.outputs.endpoint}
dependencies:
Expand Down
2 changes: 1 addition & 1 deletion examples/hot-reload/node-service/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module:
- target: /app/
services:
- name: node-service
command: [npm, start]
args: [npm, start]
hotReloadCommand: [npm, run, dev]
ports:
- name: http
Expand Down
6 changes: 3 additions & 3 deletions examples/local-tls/services/node-service/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module:
type: container
services:
- name: node-service
command: [npm, start]
args: [npm, start]
ports:
- name: http
containerPort: 8080
Expand All @@ -17,8 +17,8 @@ module:
- go-service
tests:
- name: unit
command: [npm, test]
args: [npm, test]
- name: integ
command: [npm, run, integ]
args: [npm, run, integ]
dependencies:
- go-service
6 changes: 3 additions & 3 deletions examples/remote-k8s/services/node-service/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module:
type: container
services:
- name: node-service
command: [npm, start]
args: [npm, start]
ports:
- name: http
containerPort: 8080
Expand All @@ -17,8 +17,8 @@ module:
- go-service
tests:
- name: unit
command: [npm, test]
args: [npm, test]
- name: integ
command: [npm, run, integ]
args: [npm, run, integ]
dependencies:
- go-service
2 changes: 1 addition & 1 deletion examples/tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This example uses dependency-aware database migrations to demonstrate Garden's _tasks_ functionality.

Tasks are defined under `tasks` in a module's `garden.yml`. They're currently only supported for `container` modules, and consist of a `name`, a `command` and `dependencies`.
Tasks are defined under `tasks` in a module's `garden.yml`. They're currently only supported for `container` modules, and consist of a `name`, `args` and `dependencies`.

In short, a task is a _command that is run inside an ad-hoc container instance of the module_.

Expand Down
8 changes: 4 additions & 4 deletions examples/tasks/hello/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module:
type: container
services:
- name: hello
command: [npm, start]
args: [npm, start]
ports:
- name: http
containerPort: 8080
Expand All @@ -15,12 +15,12 @@ module:
- node-migration
tests:
- name: unit
command: [npm, test]
args: [npm, test]
tasks:
- name: node-migration
command: [knex, migrate:latest]
args: [knex, migrate:latest]
description: Creates the users table.
dependencies:
- postgres
- name: foo-task
command: [echo hello]
args: [echo, hello]
4 changes: 2 additions & 2 deletions examples/tasks/user/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ module:
type: container
services:
- name: user
command: [ruby, app.rb]
args: [ruby, app.rb]
ports:
- name: http
containerPort: 8084
dependencies:
- ruby-migration
tasks:
- name: ruby-migration
command: [rake, db:migrate]
args: [rake, db:migrate]
description: Populates the users table with a few records.
dependencies:
# node-migration creates the users table, which has to exist before we use
Expand Down
2 changes: 1 addition & 1 deletion examples/vote-helm/api-image/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ module:
name: api-image
tests:
- name: unit
command: [echo, ok]
args: [echo, ok]
2 changes: 1 addition & 1 deletion examples/vote-helm/vote-image/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ module:
source: src
tests:
- name: unit
command: [npm, run, test:unit]
args: [npm, run, test:unit]
4 changes: 2 additions & 2 deletions examples/vote/services/api/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module:
name: api
services:
- name: api
command: [python, app.py]
args: [python, app.py]
ingresses:
- path: /
hostname: api.local.app.garden
Expand All @@ -17,4 +17,4 @@ module:
- redis
tests:
- name: unit
command: [echo, ok]
args: [echo, ok]
4 changes: 2 additions & 2 deletions examples/vote/services/postgres/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module:
]
tasks:
- name: db-init
command: [
args: [
psql,
-w,
-U, postgres,
Expand All @@ -33,6 +33,6 @@ module:
dependencies:
- db
- name: db-clear
command: [psql, -w, -U, postgres, --host=db, --port 5432, -d, postgres, "-c 'TRUNCATE votes'"]
args: [psql, -w, -U, postgres, --host=db, --port 5432, -d, postgres, "-c 'TRUNCATE votes'"]
dependencies:
- db
Loading

0 comments on commit 84f5a8d

Please sign in to comment.