Commit Graph

307 Commits

Author SHA1 Message Date
Jeremiah Millay 8d84a12333 Fix LinkLocalIPs in V2
Signed-off-by: Jeremiah Millay <jmillay@fastly.com>
2022-07-29 21:19:34 +02:00
Ulysses Souza 9a131a0734
Merge pull request #9690 from ulyssessouza/fix-bump-compose-go-1.3.0
Fix go.mod on  replace for compose-go
2022-07-29 20:59:36 +02:00
Ulysses Souza c98e8ac3e1 Fix go.mod on replace for compose-go
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-29 20:49:10 +02:00
Kenny Millington 1d678b70d9
config: ignore image for config hash generation (#9350)
Do not set Image so it does not impact the config-hash

Signed-off-by: Kenny Millington <kenny@kennynet.co.uk>
2022-07-29 14:01:52 -04:00
Guillaume Lours 6d613c8cb2
Merge pull request #9636 from ulyssessouza/dotenvfile-priority
Environment variables priority
2022-07-29 19:42:50 +02:00
Guillaume Lours 150fd4b8cf
use '-' as separator by default for image name
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-29 18:55:22 +02:00
Guillaume Lours b49bd7c6ce
Merge pull request #9179 from ndeloof/no_build_image
as --no-build is set, set service image to default image name
2022-07-29 17:50:01 +02:00
Nicolas De Loof abf5f736c7
as --no-build is set, set service image to default image name
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-29 17:41:53 +02:00
Robert Schumacher f69dec2da8 Fixes #9403: Remove Named Pipes from volumeMounts
If named pipe mounts are added to the volumeMounts mapping, the docker daemon will report an error that it cannot be mapped.

Signed-off-by: Robert Schumacher <ras0219@outlook.com>
2022-07-29 02:17:32 +02:00
Ulysses Souza e9c8cfcef3 Fix environment variables priority between environment and .env
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-28 12:57:44 +02:00
Ulysses Souza bac398aa9f Fix .env and --envfile priorities
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-28 12:13:37 +02:00
Guillaume Lours c4b9ec6301
remove unused sessionConfig param for addSecretsConfig function
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-22 17:37:42 +02:00
Guillaume Lours 75bbd245c7
Merge pull request #9647 from glours/add-test-named-networks
add 2 named networks with close name in the networks test suite to gu…
2022-07-19 16:55:26 +02:00
Guillaume Lours d85751f6d4
Merge pull request #9641 from glours/fix-volumes_from
keep the container reference when volumes_from target a container and not a service
2022-07-15 18:29:14 +02:00
Ulysses Souza fc723acb3b Fix nolint issues
Reference -> https://golangci-lint.run/usage/false-positives/#nolint-directive

Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-13 19:33:06 +02:00
Ulysses Souza 96cbb1cbcf Add "style" tag to gocritic
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-13 19:33:06 +02:00
Ulysses Souza d42adf6efb Add "opinionated" tag to gocritic
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-13 19:33:06 +02:00
Ulysses Souza a81f23a199 Add "diagnostic" tag to gocritic
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-13 19:33:06 +02:00
Ulysses Souza 2e96829607 Add gocritic to linters
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2022-07-13 19:33:03 +02:00
Guillaume Lours 966cbb59ac
add 2 named networks with close name in the networks test suite to guarantee the good distinction on network names
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-13 15:09:38 +02:00
Guillaume Lours 9fdd7d81b3
Merge pull request #9640 from glours/fix-close-network-name-issue
Fix issue with close networks name on up and down command
2022-07-13 10:46:13 +02:00
Guillaume Lours f30f9d9692
keep the container reference when volumes_from target a container and not a service
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-12 13:17:46 +02:00
Pablo Rodriguez Quesada eb06e1ca56
build.go: Access customLabels directly instead of by reference
Accesing the map directly instead of the copy value, otherwise the label doesn't get set.

Signed-off-by: Pablo Rodriguez <pablo.aarch64@gmail.com>
2022-07-11 08:52:23 -06:00
Guillaume Lours 50aa9750ee
check the exact network's name before creating or stopping it
NetworkList API doesn't return the extact name match, so we can retrieve more than one network with a request

Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-11 12:17:22 +02:00
Guillaume Lours 4debb133a7
add support of environment secret during build step
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-01 11:21:49 +02:00
Milas Bowman 4aa8c4a1e5 e2e: add more start/stop test cases
* Starting a service that's already running
* Stopping a service that's already stopped
* Starting/stopping multiple services (by name) at once

Also renamed a test that was about `up` behavior but was
misleadingly labeled start/stop.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-30 09:52:14 -04:00
Milas Bowman 06649442eb
Merge pull request #9609 from milas/e2e-pause
e2e: split out `pause` tests and add more cases
2022-06-30 08:42:59 -04:00
Guillaume Lours cd940693aa
Merge pull request #9049 from ndeloof/9044
(re)start should not impact one-off containers
2022-06-29 10:43:10 +02:00
Laura Brehm 96b152f705 Update logic to keep `compose stop` and `restart` from affecting one-offs
Also add e2e tests.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-06-29 00:58:02 +02:00
Milas Bowman 8e7b6582d4
Merge pull request #9595 from abhinavnair/replace-ioutil
Replace deprecated ioutil pkg with os & io
2022-06-28 15:08:57 -04:00
Milas Bowman 26014d49a5 e2e: split out `pause` tests and add more cases
Pause/unpause was being partially tested under the start/stop test.
This removes it from that test and adds dedicated pause + unpause
tests.

Note that the tests assert on current behavior, though it's been
noted where that is undesirable due to divergence from the Docker
CLI. Will change the behavior + update tests in a subsequent PR.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-28 15:06:17 -04:00
Laura Brehm 3ccf4349e7
Merge pull request #9572 from laurazard/dont-wait-for-oneshots
Use appropriate dependency condition for one-shot containers when running `compose up --wait`
2022-06-26 14:48:49 +02:00
Laura Brehm 74fd14ec65 Use alpine instead of ubuntu for E2E compose file, no need to include version
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-06-26 14:41:23 +02:00
Abhinav Nair 11f2f2dbc4
Replace deprecated ioutil pkg with os & io
As of Go 1.16, the same functionality is now provided by package io or
package os, and those implementations should be preferred in new code.

So replacing all usage of ioutil pkg with io & os.

Signed-off-by: Abhinav Nair <11939846+abhinavnair@users.noreply.github.com>
2022-06-25 14:06:10 +08:00
Guillaume Lours 2cd9c0df5a
Merge pull request #9587 from milas/build-order-classic
build: respect dependency order for classic builder
2022-06-24 22:24:22 +02:00
Milas Bowman ec0efec839 test: add copyright notice
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-24 16:16:53 -04:00
Milas Bowman 5f89365c8f network: make test mock consistent throughout
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-22 16:34:59 -04:00
Milas Bowman b2cd089bae build: respect dependency order for classic builder
When using the "classic" (non-BuildKit) builder, ensure that
services are iterated in dependency order for a build so that
it's possible to guarantee the presence of a base image that's
been added as a dependency with `depends_on`. This is a very
common pattern when using base images with Compose.

A fix for BuildKit is blocked currently until we can rely on a
newer version of the engine (see docker/compose#9324)[^1].

[^1]: https://github.com/docker/compose/issues/9232#issuecomment-1060389808

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-22 16:24:30 -04:00
Milas Bowman 0f747419b6 networks: prevent issues due to duplicate names
Within the Docker API/engine, networks have unique IDs, and the
name is a friendly label/alias, which notably does NOT have any
guarantees around uniqueness (see moby/moby#18864 [^1]).

During day-to-day interactive/CLI Compose usage, this is rarely
an issue, as Compose itself isn't creating networks concurrently
across goroutines. However, if multiple Compose instances are
executed simultaneously (e.g. as part of a test suite that runs
in parallel), this can easily occur.

When it does happen, it's very confusing for users and resolving
it via the `docker` CLI is not straightforward either [^2].

There's two primary changes here:
 * Pass `CheckDuplicates: true` to the Docker API when creating
   networks to reduce the likelihood of Compose creating duplicates
   in the first place
 * On `down`, list networks using a name filter and then remove
   them all by ID, as the Docker API will return an error if the
   name alias is used and maps to more than one network

Hopefully, this provides a better UX, since the issue should be
less likely to occur, and if it does, it can now be resolved via
standard Compose workflow commands.

[^1]: https://github.com/moby/moby/issues/18864
[^2]: https://stackoverflow.com/questions/63776518/error-2-matches-found-based-on-name-network-nameofservice-default-is-ambiguo

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-22 12:27:30 -04:00
Laura Brehm fd8538f780 Use appropriate dependency condition for one-shot containers when running `compose up --wait`
Also add e2e tests to ensure `compose up --wait` does not get stuck forever waiting for one-shot containers

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2022-06-18 01:20:40 +02:00
Milas Bowman 7f441eb013 e2e: improve test output on failures
This is mostly marking a bunch of the run methods as helpers so
that the internal assertions they do will show the line number of
the calling test instead.

There's also some small tweaks around the plugin initialization to
help with the output in the event that it fails to make it easier
to debug what went wrong.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 17:05:43 -04:00
Guillaume Lours 4270987d7c
Merge pull request #9567 from milas/e2e-cmd
e2e: ensure all Compose cmds standalone compatible
2022-06-16 23:02:14 +02:00
Milas Bowman 3248b7b335 e2e: use Compose for exec test
This was using `docker exec` on Compose containers instead of
`docker compose exec` (and `docker-compose exec` for standalone).

Thanks to @glours for catching!

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 16:44:21 -04:00
Milas Bowman 4ea3ba77b2
Merge pull request #9559 from venthur/fix_spell
fixed some spelling mistakes
2022-06-16 15:56:44 -04:00
Milas Bowman 9622395c8a e2e: ensure all Compose cmds standalone compatible
The E2E tests can be run in plugin (`docker compose`) or standalone
(`docker-compose`) mode. Existing logic was in place to ensure that
the helper method is always used, which will invoke the right one
based on how tests are being executed.

However, this logic was too easy to (unintentionally) bypass given
the myriad of ways that commands can be run. The check has been
made stricter and pushed to a lower-level to more aggressively
catch instances.

As a result, a bunch of calls to `RunDockerCmd` are now updated
to be `RunDockerComposeCmd`, which will ensure that the invocation
is correct based on test mode.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 15:51:54 -04:00
Guillaume Lours bec4ea4ab0
Merge pull request #9566 from milas/e2e-ps-stdout
e2e: fix spurious `ps` failures
2022-06-16 18:07:22 +02:00
Guillaume Lours 3f10753178
Merge pull request #9563 from milas/e2e-env
e2e: isolate test command env from system env
2022-06-16 18:05:39 +02:00
Milas Bowman 152c2d9a33 e2e: fix spurious `ps` failures
Use the command `stdout` instead of combined `stdout` + `stderr`
for assertions to avoid failures from any CLI logging such as
warnings, which will be on `stderr`.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 11:28:29 -04:00
Milas Bowman a261682ca8 e2e: fix per-command env overrides
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 11:27:39 -04:00
Milas Bowman ccd87311e8 e2e: always set HOME + USER for cmd env
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2022-06-16 09:44:40 -04:00