Commit Graph

58 Commits

Author SHA1 Message Date
Sebastiaan van Stijn 4fe6b837b7
bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 2c0e93063b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-21 16:43:18 +02:00
Sebastiaan van Stijn fd9eedce3c
Add "host-gateway" to tests for extra_hosts / --add-host
67ebcd6dcf added an exception for
the "host-gateway" magic value to the validation rules, but didn't
add thise value to any of the tests.

This patch adds the magic value to tests, to verify the validation
is skipped for this magic value.

Note that validation on the client side is "optional" and mostly
done to provide a more user-friendly error message for regular
values (IP-addresses).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit f88ae74135)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-15 09:53:37 +02:00
Sebastiaan van Stijn a7cad2fec2
Merge pull request #2184 from thaJeztah/19.03_backport_fix_max_replicas_per_node_interpolation
[19.03 backport] Add interpolation type cast for max_replicas_per_node
2020-01-16 21:17:38 +01:00
Sebastiaan van Stijn 42ad2446e0
cli/compose/loader: Using a reference for the variable on range scope `overrideService` (scopelint)
```
cli/compose/loader/merge.go:64:41: Using a reference for the variable on range scope `overrideService` (scopelint)
			if err := mergo.Merge(&baseService, &overrideService, mergo.WithAppendSlice, mergo.WithOverride, mergo.WithTransformers(specials)); err != nil {
			                                     ^
cli/compose/loader/loader_test.go:1587:28: Using the variable on range scope `testcase` in function literal (scopelint)
			config, err := loadYAML(testcase.yaml)
			                        ^
cli/compose/loader/loader_test.go:1590:58: Using the variable on range scope `testcase` in function literal (scopelint)
			assert.Check(t, is.DeepEqual(config.Services[0].Init, testcase.init))
			                                                      ^
```

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 96ec7299d8)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-01-06 13:16:53 +01:00
Djordje Lukic e3657b0a8c
Add interpolation type cast for max_replicas_per_node
Fixes https://github.com/docker/app/issues/688

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
(cherry picked from commit cb29ef6c6d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-11-05 13:15:57 -08:00
Ulysses Souza 379470969b Add option remove `env_file` entry after merged
This avoids having a redundant `env_file` entry
output when rendering the compose file

Signed-off-by: Ulysses Souza <ulysses.souza@docker.com>
(cherry picked from commit 821f5ecf53)
Signed-off-by: Christopher Crone <christopher.crone@docker.com>
2019-10-04 17:32:48 +02:00
Sebastiaan van Stijn d473c60571
Merge pull request #1995 from thaJeztah/19.03_backport_cross_platform_bind
[19.03 backport] Detect Windows absolute paths on non-Windows CLI
2019-07-26 13:11:18 -07:00
Sebastiaan van Stijn 87e400e44e
Detect Windows absolute paths on non-Windows CLI
When deploying a stack using a relative path as bind-mount
source in the compose file, the CLI converts the relative
path to an absolute path, relative to the location of the
docker-compose file.

This causes a problem when deploying a stack that uses
an absolute Windows path, because a non-Windows client will
fail to detect that the path (e.g. `C:\somedir`) is an absolute
path (and not a relative directory named `C:\`).

The existing code did already take Windows clients deploying
a Linux stack into account (by checking if the path had a leading
slash). This patch adds the reverse, and adds detection for Windows
absolute paths on non-Windows clients.

The code used to detect Windows absolute paths is copied from the
Golang filepath package;
1d0e94b1e1/src/path/filepath/path_windows.go (L12-L65)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit d6dd08d568)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-10 23:40:22 +02:00
Silvin Lubecki 344adac7a6
Rollback config type interpolation on fields "parallelism" and "max_failure_ratio" were missing, as it uses the same type as update_config.
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
(cherry picked from commit efdf36fa81)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-07-03 19:20:41 +02:00
Sebastiaan van Stijn 6511da877f Add support for using Configs as CredentialSpecs in services
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-04-12 11:17:29 -05:00
Sune Keller ed838bff1f Add test case
Signed-off-by: Sune Keller <absukl@almbrand.dk>
2019-04-05 12:01:21 +02:00
Sebastiaan van Stijn f620349837
Add systctl support for services
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-19 13:33:32 +01:00
Vincent Demeester 7764101a54
Add support for `template_driver` in composefiles
This maps the `--template-driver` flag on secret and config creation.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-03-18 23:49:30 +01:00
Sebastiaan van Stijn 1e99ed3ca3
Disallow additional properties in credential_spec
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-02-02 18:27:50 +01:00
Mindaugas Rukas 83fd688fa2 Allow to transform any source type into the target struct
Signed-off-by: Mindaugas Rukas <momomg@gmail.com>
2018-10-02 16:06:08 +03:00
Joffrey F e7788d6f9a Allow marshalling of Compose config to JSON
Signed-off-by: Joffrey F <joffrey@docker.com>
2018-09-10 11:16:05 -07:00
Arash Deshmeh 71d650ee17 refactored cli/compose and cli/command/trust to use sort.Slice and removed custom types used for sorting
Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
2018-07-08 15:08:17 -04:00
Silvin Lubecki 38056740d6 Refactor tests
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
2018-06-25 11:13:32 +02:00
Vincent Demeester cc26da94ed Add `init` support in 3.7 schema
> Run an init inside the container that forwards signals and reaps
  processes

This is supported on `run` and now on Swarm services too, so it's also
possible to have in on a composefile :).

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-25 11:13:32 +02:00
Vincent Demeester 80c26f618e
Add an `Extras` field on the compose config types.
That field is automaticaly populated with any `x-*` field in the yaml.
And marshalling the compose config struct put them back into place.

This make it possible to get those extra fields without re-inventing
the wheel (i.e. reimplementing 80% of the `cli/compose/*` packages.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-25 10:51:56 +02:00
Vincent Demeester 2c4de4fb5e
Update tests to use gotest.tools 👼
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-08 18:24:26 +02:00
Daniel Nephin b4c108a385 Fix named network in compose file
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-12 15:15:27 -04:00
Daniel Nephin baf65a5502 Convert to assert.NilError
Using:

  git grep -l '^\s\+assert\.Check(t, err)$' | \
    xargs sed -i -e 's/^\(\s\+assert\)\.Check(t, err)$/\1.NilError(t, err)/'

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-06 15:27:34 -05:00
Daniel Nephin 5155cda716 Post migration fixes
Fix tests that failed when using cmp.Compare()
internal/test/testutil/assert
InDelta
Fix DeepEqual with kube metav1.Time
Convert some ErrorContains to assert

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-05 19:41:17 -05:00
Daniel Nephin 39c2ca57c1 Automated migration
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-05 19:41:17 -05:00
Daniel Nephin 93615dd967 Update some assertions.
and fix some tests

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-05 17:15:24 -05:00
Daniel Nephin cea4d37bca
Merge pull request #824 from ethan-haynes/820-bind-mount-source-missing-error
added check for empty source in bind mount
2018-02-21 13:33:24 -05:00
Vincent Demeester cf86a4d922
Simplify the marshaling of compose types.Config
- Add `Version` to `types.Config`
- Add a new `Services` types (that is just `[]ServiceConfig`) and add
  `MarshalYAML` method on it.
- Clean other top-level custom marshaling as `Services` is the only one
  required.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-02-21 18:47:10 +01:00
Vincent Demeester 570ee9cb54
Share the compose loading code between swarm and k8s stack deploy
To ensure we are loading the composefile the same wether we are pointing
to swarm or kubernetes, we need to share the loading code between both.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-02-14 14:07:48 +01:00
Vincent Demeester 1872bd802c
Add support for multiple composefile when deploying
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-01-29 17:27:25 -08:00
Ethan Haynes e76d8c9eae added check for empty source in bind mount
Signed-off-by: Ethan Haynes <ethanhaynes@alumni.harvard.edu>

fixed error by removing punctuation

Signed-off-by: Ethan Haynes <ethanhaynes@alumni.harvard.edu>

removed period

Signed-off-by: Ethan Haynes <ethanhaynes@alumni.harvard.edu>

backtick string to escape double quotes in error messages

Signed-off-by: Ethan Haynes <ethanhaynes@alumni.harvard.edu>

simplified test for bind no source error message

Signed-off-by: Ethan Haynes <ethanhaynes@alumni.harvard.edu>
2018-01-22 18:33:58 -06:00
Ethan Haynes cd69d082ea added support for tmpfs-mode in compose file
Signed-off-by: Ethan Haynes <ethanhaynes@alumni.harvard.edu>
2018-01-16 10:52:26 -06:00
Sebastiaan van Stijn 70a29b492d
Add "pid" to unsupported options list
Services do not support custom "pid"-modes (e.g. `--pid=host`), but this
option was ignored silently when deploying a stack.

This patch adds `pid` to the list of unsupported options so that a warning
is printed;

With this patch applied:

    $ docker stack deploy -c docker-compose.yml foobar
    Ignoring unsupported options: pid

    Creating network foobar_default
    Creating service foobar_test

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-12-27 12:45:42 +01:00
Daniel Nephin d0b8aa7701 Support network.name in the compose schema.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-12-06 10:05:24 -05:00
Renaud Gaubert 1ff73f867d Added support of Generic resources in compose file
Signed-off-by: Renaud Gaubert <renaud.gaubert@gmail.com>
2017-11-28 21:52:09 +01:00
Ilya Sotkov ec47003ecb Remove duplication for secrets / configs, combine 3.5 loader tests, remove extraneous error call, regenerate schema correctly
Signed-off-by: Ilya Sotkov <ilya@sotkov.com>
2017-11-22 13:41:16 +02:00
Ilya Sotkov 1f10b31017 Add tests for secret.name in compose files.
Signed-off-by: Ilya Sotkov <ilya@sotkov.com>
2017-11-22 13:18:05 +02:00
Simon Ferquel 47cf2ea683 Add isolation mode on service update/create and compose files
Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
2017-11-17 15:31:13 +01:00
Daniel Nephin aea9544db5 Only warn on volume.external.name for version 3.4
Also remove use of volume.external.name

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-11-06 17:04:36 -05:00
Sebastiaan van Stijn dbdf8f6468
Preserve sort-order of extra hosts, and allow duplicate entries
Extra hosts (`extra_hosts` in compose-file, or `--hosts` in services) adds
custom host/ip mappings to the container's `/etc/hosts`.

The current implementation used a `map[string]string{}` as intermediate
storage, and sorted the results alphabetically when converting to a service-spec.

As a result, duplicate hosts were removed, and order of host/ip mappings was not
preserved (in case the compose-file used a list instead of a map).

According to the **host.conf(5)** man page (http://man7.org/linux/man-pages/man5/host.conf.5.html)

    multi  Valid values are on and off.  If set to on, the resolver
      library will return all valid addresses for a host that
      appears in the /etc/hosts file, instead of only the first.
      This is off by default, as it may cause a substantial
      performance loss at sites with large hosts files.

Multiple entries for a host are allowed, and even required for some situations,
for example, to add mappings for IPv4 and IPv6 addreses for a host, as illustrated
by the example hosts file in the **hosts(5)** man page (http://man7.org/linux/man-pages/man5/hosts.5.html):

    # The following lines are desirable for IPv4 capable hosts
    127.0.0.1       localhost

    # 127.0.1.1 is often used for the FQDN of the machine
    127.0.1.1       thishost.mydomain.org  thishost
    192.168.1.10    foo.mydomain.org       foo
    192.168.1.13    bar.mydomain.org       bar
    146.82.138.7    master.debian.org      master
    209.237.226.90  www.opensource.org

    # The following lines are desirable for IPv6 capable hosts
    ::1             localhost ip6-localhost ip6-loopback
    ff02::1         ip6-allnodes
    ff02::2         ip6-allrouters

This patch changes the intermediate storage format to use a `[]string`, and only
sorts entries if the input format in the compose file is a mapping. If the input
format is a list, the original sort-order is preserved.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-10-30 01:48:09 +01:00
Daniel Nephin af8f563922 Fix load order
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-10-05 12:03:29 -04:00
Daniel Nephin 18ddec447a Cast interpolated values
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-10-04 17:36:47 -04:00
Vincent Demeester 0da9f14821
Fix loader error with different build syntax
`build: .` was not working anymore. Fixing this by adding a new
tranform function for BuildConfig.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-09-20 14:02:33 +02:00
Vincent Demeester f34655ecf8
Tidying up compose/loader test a bit
- Use `require` instead of `assert` when the assumption is "breaking" for the code
following. For example when asserting an error is not nil and then doing
`err.Error` on it ; if `err` is nil, the test will panic instead of fail.
- Use `assert.Len` when possible. The error message is better.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2017-09-19 16:48:52 +02:00
Vincent Demeester 2eb31e6b60 Merge pull request #481 from cdrage/add-build-to-service-config
Add 'build' to types.go
2017-09-13 18:20:42 +02:00
Charlie Drage 9bdb0763b9 Add 'build' to types.go
This adds 'build' to types.go in order for projects that use docker/cli
to parse Docker Compose files to correctly retrieve `build` keys

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
2017-09-13 10:47:17 -04:00
Li Yi e02fcfd34e Change the type of interval, timeout and start_period of healthcheck from string to * time.Duration
Signed-off-by: Li Yi <denverdino@gmail.com>
2017-08-30 23:39:12 +08:00
Li Yi 0abdad615f Support start_period for healthcheck in Docker Compose
Signed-off-by: Li Yi <denverdino@gmail.com>
2017-08-29 11:19:29 +08:00
Joffrey F 1667073908 Update schemas to prevent invalid properties in deploy.resources
Signed-off-by: Joffrey F <joffrey@docker.com>
2017-08-17 15:58:51 -07:00
Antonis Kalipetis 2950667f07
Support the "order" key in "update_config" for compose
Signed-off-by: Antonis Kalipetis <akalipetis@gmail.com>
2017-07-28 22:50:55 +03:00