Commit Graph

4553 Commits

Author SHA1 Message Date
Milas Bowman 06af729dc8
Merge pull request #11292 from laurazard/update-cli-signal-handling
Up: teardown when command context is cancelled
2024-01-02 15:48:14 -05:00
Laura Brehm dcbf005fe4
up: gracefully teardown when command ctx cancelled
Previously, if a long-lived plugin process (such as
an execution of `compose up`) was running and then
detached from a terminal, signalling the parent CLI
process to exit would leave the plugin process behind.

To address this, changes were introduced on the CLI side
(see: https://github.com/docker/cli/pull/4599) to enable
the CLI to notify a running plugin process that it should
exit. This makes it so that, when the parent CLI process
is going to exit, the command context of the plugin
command being executed is cancelled.

This commit takes advantage of these changes by tapping into
the command context's done channel and using it to teardown
on an up.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-12-23 02:49:27 +00:00
Nicolas De Loof e105f16527 introduce `stats` command
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-22 16:03:02 +01:00
Laura Brehm ce5a0c656f
Fix cancellable context detection in `AdaptCmd`
`AdaptCmd` was previously checking for a `.WithCancel` suffix
on context strings, however it's possible for a context to be
cancellable without ending in that suffix, such as when
`context.WithValue` was called after `WithContext`, e.g.:

```go
context.Background.WithCancel.WithValue(type trace.traceContextKeyType,
val <not Stringer>).WithValue(type api.DryRunKey, val <not Stringer>)
```

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-12-22 13:39:04 +00:00
Guillaume Lours d82a1a5a03
Merge pull request #11294 from thaJeztah/bump_engine2
go.mod: docker/docker and docker/cli v25.0.0-beta.3
2023-12-22 11:28:37 +01:00
Sebastiaan van Stijn 9aa5232601 go.mod: docker/docker and docker/cli v25.0.0-beta.3
- https://github.com/docker/cli/compare/70216b662dc4...v25.0.0-beta.3
- https://github.com/docker/docker/compare/v25.0.0-beta.2...v25.0.0-beta.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn ccd83b8a74 go.mod: github.com/gorilla/mux v1.8.1
full diff: https://github.com/gorilla/mux/compoare/v1.8.0...v1.8.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn 9e57850c16 go.mod: github.com/docker/distribution v2.8.3
full diff: https://github.com/docker/distribution/compare/v2.8.2...v2.8.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn 35d3a7ca56 go.mod: golang.org/x/crypto v0.17.0
update the package, which contains a fix in the ssh package.

full diff: https://github.com/golang/crypto/compare/v0.16.0...v0.17.0

from the security mailing:

> Hello gophers,
>
> Version v0.17.0 of golang.org/x/crypto fixes a protocol weakness in the
> golang.org/x/crypto/ssh package that allowed a MITM attacker to compromise
> the integrity of the secure channel before it was established, allowing
> them to prevent transmission of a number of messages immediately after
> the secure channel was established without either side being aware.
>
> The impact of this attack is relatively limited, as it does not compromise
> confidentiality of the channel. Notably this attack would allow an attacker
> to prevent the transmission of the SSH2_MSG_EXT_INFO message, disabling a
> handful of newer security features.
>
> This protocol weakness was also fixed in OpenSSH 9.6.
>
> Thanks to Fabian Bäumer, Marcus Brinkmann, and Jörg Schwenk from Ruhr
> University Bochum for reporting this issue.
>
> This is CVE-2023-48795 and Go issue https://go.dev/issue/64784.
>
> Cheers,
> Roland on behalf of the Go team

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn 6c998602bb go.mod: golang.org/x/crypto v0.16.0
full diff: https://github.com/golang/crypto/compare/v0.14.0...v0.16.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn 402f368830 go.mod: golang.org/x/text v0.14.0
full diff: https://github.com/golang/text/compare/v0.13.0...v0.14.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Sebastiaan van Stijn 30dd3e66d7 go.mod: golang.org/x/term v0.15.0
full diff: https://github.com/golang/term/compare/v0.13.0...v0.15.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-22 11:18:43 +01:00
Nicolas De Loof 0c4fa017b9 Bump compose-go v2-beta.2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-22 11:16:13 +01:00
dependabot[bot] b12e23b0bd build(deps): bump go.uber.org/mock from 0.3.0 to 0.4.0
Bumps [go.uber.org/mock](https://github.com/uber/mock) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/uber/mock/releases)
- [Changelog](https://github.com/uber-go/mock/blob/main/CHANGELOG.md)
- [Commits](https://github.com/uber/mock/compare/v0.3.0...v0.4.0)

---
updated-dependencies:
- dependency-name: go.uber.org/mock
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-21 14:52:59 +01:00
Nicolas De Loof 17da54da20 introduce build --with-dependencies
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-20 15:58:54 +01:00
horus 1baa4f4489 up: fix write/close race condition in logPrinter
The code used an atomic bool to guard channel writes. However, this
failed to synchronize with the call to close(), causing a panic.

Fix the race condition by using a mutex to guard the update to the
bool `stopped` and subsequent channel writes. This ensures atomic
execution of both updates to `stopped` and channel writes, preventing
races between writes and close().

Signed-off-by: horus <horus.li@gmail.com>
2023-12-20 15:45:12 +01:00
Guillaume Lours aefc2a111a
Merge pull request #11283 from laurazard/update-cli-version-go
deps: update docker/cli to fix go version selection issue
2023-12-19 15:26:24 +01:00
Laura Brehm 7781b7c992
deps: update docker/cli to fix go version selection issue
see: 70216b662d

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-12-19 14:15:16 +00:00
Albin Kerouanton 785835b1a2 Add support for endpoint-specific MAC address
Related to:

- https://github.com/compose-spec/compose-spec/pull/435
- https://github.com/moby/moby/pull/45905

Since API v1.44, Moby supports a per-endpoint MAC address and returns a
warning when the container-wide mac_address field is set.

A corresponding field has been added to compose-spec and compose-go, so
we need to leverage it to set the right API field.

This commit is backward-compatible with compose files that still set the
container-wide mac_address field, and older API versions that don't know
about the endpoint-specific MAC address field.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-12-18 12:04:45 +01:00
Nicolas De Loof e4fb5545f0 build do not require environment to be reslved
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-14 11:21:46 +01:00
Nicolas De Loof 74cc091225 github.com/golang/mock is deprecated
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-13 14:47:39 +01:00
Nicolas De Loof 5e61c62ecf collect services to build using WithServices
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-07 17:05:42 +01:00
Nicolas De Loof fb3868ffaf add support for start_interval
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-07 15:59:22 +01:00
Guillaume Lours 30e80d2440
Merge pull request #11251 from ndeloof/completion_disabled
include disabled services for shell completion
2023-12-06 09:47:00 +01:00
Nicolas De Loof bdbda79043 include disabled services for shell completion
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-06 09:38:11 +01:00
Guillaume Lours 862f2a19f4
Merge pull request #11249 from glours/bump-golang-1.21.5
bump golang to version 1.21.5
2023-12-06 09:37:18 +01:00
Guillaume Lours ae4fd7916c
bump golang to version 1.21.5
Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
2023-12-06 00:04:15 +01:00
Nicolas De Loof 26aca867d8 avoid use of service.Name when iterating on project.Services
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 18:54:31 +01:00
Nicolas De Loof 138facea62 project.Services is a map
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 18:54:31 +01:00
Nicolas De Loof cda04f288e adopt compose-go/v2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 18:54:31 +01:00
Milas Bowman 85a1aec123 regen docs
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Milas Bowman 9c29d2236d use custom config type for OCI v1.0
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Milas Bowman df6fe59f72 tweak help message on oci version flag
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Milas Bowman 07df9cc46e fix typo
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Milas Bowman 7c8ff36d78 move around OCI logic, auto fallback/retry 1.1 -> 1.0
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Milas Bowman 111ad3b039 fix(publish): add OCI 1.0 fallback support for AWS ECR
Currently, we publish Compose artifacts following the OCI 1.1
specification, which is still in the RC state.

As a result, not all registries support it yet. Most notably,
AWS ECR will reject certain OCI 1.1-compliant requests with
`405 Method Not Supported` with cryptic `Invalid JSON` errors.

This adds initial support for Compose to generate either an
OCI 1.0 or OCI 1.1 compatible manifest. Notably, the OCI 1.0
manifest will be missing the `application/vnd.docker.compose.project`
artifact type, as that does not exist in that version of the
spec. (Less importantly, it uses an empty `ImageConfig`
instead of the newer `application/vnd.oci.empty.v1+json` media
type for the config.)

Currently, this is not exposed as an option (via CLI flags or
env vars). By default, OCI 1.1 is used unless the registry
domain is `amazonaws.com`, which indicates an ECR registry, so
Compose will instead use OCI 1.0.

Moving forward, we should decide how much we want to expose/
support different OCI versions and investigate if there's a
more generic way to feature probe the registry to avoid
maintaining a hardcoded list of domains, which is both tedious
and insufficient.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-12-05 18:08:38 +01:00
Nicolas De Loof 8026d0e2f2 adopt container.RestartPolicy*
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 17:02:37 +01:00
Nicolas De Loof df1533a1ca [lint] don't use deprecated types
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 17:02:37 +01:00
Nicolas De Loof 8639fbae86 go mod tidy
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-05 17:02:37 +01:00
Wes Higbee 56e2ad9ee5 update to v1.25 for RunAttach
Signed-off-by: Wes Higbee <wes.mcclure@gmail.com>
2023-12-05 17:02:37 +01:00
Nicolas De Loof ce1ddb6c7e fix combination of --pull always --no-build
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-12-04 11:08:08 +01:00
dependabot[bot] c5824702bf build(deps): bump golang.org/x/sys from 0.14.0 to 0.15.0
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.14.0 to 0.15.0.
- [Commits](https://github.com/golang/sys/compare/v0.14.0...v0.15.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-30 09:42:39 +01:00
vyneer 1f148244af send out a cancel event on SIGINT/SIGTERM
Signed-off-by: vyneer <vyn33r@gmail.com>
2023-11-30 09:11:55 +01:00
johnthagen 9faef4aebb Update README.md to use standard compose.yaml file name
Signed-off-by: johnthagen <johnthagen@users.noreply.github.com>
2023-11-30 08:53:44 +01:00
Nicolas De Loof 59f11ecbeb Fix configs are mounted under /<id>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-29 16:53:22 +01:00
Amit Saha 750553c866 introduce compose logs --index to select a replica container
Signed-off-by: Amit Saha <asaha@atlassian.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2023-11-29 13:56:16 +01:00
Amit Saha 8c964f5ad3 Update E2E test
Signed-off-by: Amit Saha <asaha@atlassian.com>
2023-11-29 13:56:16 +01:00
Amit Saha 90ca13b747 Fix E2E test to have index in the correct position
Signed-off-by: Amit Saha <asaha@atlassian.com>
2023-11-29 13:56:16 +01:00
Amit Saha f9946127ce Fix docs
Signed-off-by: Amit Saha <asaha@atlassian.com>
2023-11-29 13:56:16 +01:00
Amit Saha ddda59a130 Add index option to compose logs command
Signed-off-by: Amit Saha <asaha@atlassian.com>
2023-11-29 13:56:16 +01:00