1
0
mirror of https://github.com/docker/compose-cli.git synced 2026-10-25 06:19:18 +03:00

748 Commits

Author SHA1 Message Date
Milas Bowman
784377898f metrics: track and report non-aggregated events
Currently, "usage" reports are sent, which are aggregated.
Add "event" variant, which won't be aggregated.

For compatibility, the "usage" events remain and nothing has
changed in terms of how they parse the command args, for example.
This will ensure continued functioning of anything that relies
on these metrics.

For the "event" variants, the CLI parsing is slightly different
in an attempt to improve data analysis capabilities while still
being respectful of user privacy (i.e. only known values of Docker
CLI commands/flags are ever recorded). Additionally, execution
duration information is now reported with these events.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-02-08 14:17:04 -05:00
Milas Bowman
e7d8d05d99 metrics: initial logic for command execution duration
Add a timer around command invocations to be reported with metrics.
This isn't actually sent anywhere currently, as it's meant for
evented data which is forthcoming. (We could report it with the
current events, but it's not clear that there's any value in doing
so.)

The signature for `Track()` has been changed to take an object with
all the fields. This is both for sanity to keep the method from
getting ridiculously long, and to make it easier to unify the usage
(heartbeat) and event code paths by ensuring we have all the data
for both.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-02-06 17:08:27 -05:00
Milas Bowman
16482c0611 metrics: move helper code from Compose
Compose doesn't actually currently use this code, it's only used
here. Moving it inline so that we can drop it from Compose in the
future or make changes as needed without worrying about this as a
dependency.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-02-06 16:50:29 -05:00
Milas Bowman
3f6822e196 metrics: add debug implementation
Refactor the metrics client slightly to add the concept of a
"reporter" that actually sends the metrics.

The primary implementation is HTTP-based as before, but a key
difference now is that there's another variant that writes to
a file for simplified debugging. This is activated by setting
the `DOCKER_METRICS_DEBUG_LOG` environment variable to a file
path to write events to as JSON lines.

Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-02-02 09:20:32 -05:00
Milas Bowman
020489241f lint: update for Go 1.19 / golangci-lint 1.50.1
Signed-off-by: Milas Bowman <milas.bowman@docker.com>
2023-02-01 16:04:49 -05:00
Guillaume Tardif
4b1cbd08aa Add share command (docker extension share) in metrics whitelist
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
2023-01-19 17:51:10 +01:00
Sebastiaan van Stijn
f1aa070b81 cli/mobycli: Exec(): simplify output
The command now was showing 2 informational messages (about PAT and
Scan); the scan one had been there for a while so most users will
know about it by now.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-06 21:48:43 +01:00
Nick Santos
bb0197e198 cli: fix warnings on 'docker context use'. Fixes https://github.com/docker/cli/issues/3765
Signed-off-by: Nick Santos <nick.santos@docker.com>
2022-09-14 18:17:32 -04:00
CrazyMax
668b262605 build metrics compatibility for next 22.06
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-07-27 17:03:03 +02:00
Nick Sieger
4678a3e780 mobycli: add test for comDockerCli
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-07-27 09:07:27 -05:00
Nick Sieger
22d68602ae mobycli: append .exe to com.docker.cli on windows
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-07-27 09:00:11 -05:00
Nick Sieger
fc215287b5 mobycli: update approach for finding cli command to use
1. Use path from env variable `$DOCKER_COM_DOCKER_CLI`
2. Use path formed from parent directory of current process joined with
   `com.docker.cli`
3. Look for `com.docker.cli` on $PATH

Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-07-26 15:12:11 -05:00
Nick Sieger
d8b9310e03 Merge commit '48c999679165e8f0355f32092063ab4f0ceeee42' of https://github.com/crazy-max/compose-cli into cli-binary-path-handling
Signed-off-by: Nick Sieger <nick@nicksieger.com>
2022-07-26 14:54:13 -05:00
Piotr Stankiewicz
cfa212f15d Fall back to global CLI socket on Linux
DD relies on having the CLI socket available in /var/run when running in
WSL. So in case we can't find the CLI socket in the calling user's home
directory, fall back to /var/run.

Signed-off-by: Piotr Stankiewicz <piotr.stankiewicz@docker.com>
2022-07-25 15:33:00 +02:00
Guillaume Lours
1a01d2f198 update gotest.tools to v3.3.0 which support golang 1.18
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2022-07-25 12:20:42 +02:00
CrazyMax
1dce98712a Go 1.18
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-07-24 00:49:08 +02:00
Piotr Stankiewicz
f922ff963d Use Docker CLI socket from the User's home directory
We should not rely on having a global path for the Docker CLI socket. On
macOS this forces Docker Desktop to access directories which require
raised privileges. Whereas on Linux we do not create sockets in that
location at all, currently. So look for the Docker CLI socket in the
User's home directory.

Signed-off-by: Piotr Stankiewicz <piotr.stankiewicz@docker.com>
2022-07-22 11:31:22 +02:00
CrazyMax
48c9996791 Allow to override classic cli binary via env var
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-05-31 07:25:16 +02:00
CrazyMax
8092874d41 metrics: fix unexpected usage output shown on cli
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2022-05-15 03:50:45 +02:00
Guillaume Tardif
f96ef1970c Add extension commands in command metrics
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
2022-04-13 23:01:33 +02:00
Alex Goodman
29cbfa0485 add SBOM management command to metrics
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
2022-03-23 10:45:42 -04:00
CrazyMax
535fb93280 add build metrics
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-11-22 19:36:19 +01:00
CrazyMax
a4ae60a39d recover missing commands for backward compatibility
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-11-16 12:20:31 +01:00
CrazyMax
6fd97089b8 sort commands
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-11-16 12:20:30 +01:00
CrazyMax
d3f55aec6d update commands
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-11-16 12:20:30 +01:00
Mathieu Champlon
48ad1486ac Revert "signals"
Signed-off-by: Mathieu Champlon <mathieu.champlon@docker.com>
2021-11-04 17:14:28 +01:00
Ulysses Souza
5aa293cc04 Fix plugin command delegation
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-11-03 15:22:52 +01:00
Lorena Rangel
3ff346838a point to correct backend when switching context
Signed-off-by: Lorena Rangel <lorena.rangel@docker.com>
2021-10-18 14:15:04 +02:00
Lorena Rangel
7829bd2459 bump protoc and update .proto files
Signed-off-by: Lorena Rangel <lorena.rangel@docker.com>
2021-10-06 15:43:01 +02:00
Mathieu Champlon
8b76602054 Merge pull request #1879 from ndeloof/signals
signals
2021-09-21 12:09:52 +02:00
Ulysses Souza
81c53672d5 Linter fixes
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-09-18 15:50:25 +02:00
Ulysses Souza
25b335924c Store context type in the context for reusing
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-09-17 19:26:24 +02:00
Ulysses Souza
fa7e0632ba Add checks for unsupported flags
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-09-17 10:19:02 +02:00
Nicolas De Loof
07f6f804a9 use docker/compose/v2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-09-17 10:19:02 +02:00
Nicolas De Loof
c944c970ab use nicer imports
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-08-31 16:58:19 +02:00
Nicolas De Loof
fcb91096b8 remove all references to cli from compose.v2 cmd package
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-08-31 15:41:20 +02:00
Mathieu Champlon
f09336e519 Merge pull request #1953 from amineck/no_pass
Post-login msg: Ignore if password is empty
2021-07-28 07:46:17 +02:00
Lorena Rangel
657025eb94 Merge pull request #1952 from amineck/pat_suggest_url
Update personal access token url
2021-07-27 16:11:41 +02:00
Ulysses Souza
230b9b592e Merge pull request #1942 from ndeloof/heml_oras
stop using helm fork for oras dependency conflict
2021-07-26 14:50:56 -07:00
Amine Chouki
3f59e9a3ad Ignore if password is empty
Signed-off-by: Amine Chouki <amine.chouki@docker.com>
2021-07-26 10:37:58 -04:00
Amine Chouki
33454c6ebd Update personal access token url
Signed-off-by: Amine Chouki <amine.chouki@docker.com>
2021-07-26 10:33:57 -04:00
Nicolas De loof
3d83989f5d Merge pull request #1773 from ulyssessouza/completion 2021-07-26 08:23:13 +02:00
Amine Chouki
5c427ef702 Move pat_suggest.go into cli package
Signed-off-by: Amine Chouki <amine.chouki@docker.com>
2021-07-23 10:55:31 -04:00
Nicolas De Loof
c3f990f0a2 replace deprecated method after transitive dependency update
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-07-23 10:37:24 +02:00
Amine Chouki
906e1b4305 Add a post-login message to promote personal access tokens
Signed-off-by: Amine Chouki <amine.chouki@docker.com>
2021-07-22 16:58:00 -04:00
Nicolas De Loof
9215d68428 signals
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2021-07-13 10:02:48 +02:00
Ulysses Souza
37961c51ca Add completion to "compose ps"
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-07-12 14:33:37 -03:00
Ulysses Souza
3174f49dc2 Add completion to shells
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
2021-07-12 14:33:37 -03:00
Michael Irwin
08c2c44beb Fix help text when for context create and kube backend
Signed-off-by: Michael Irwin <mikesir87@gmail.com>
2021-07-06 15:46:00 -04:00
Sebastiaan van Stijn
a0db32043e Do not strip "v" prefix from version when printing
I noticed this when building the binary; `internal.Version` is set to `v2.0.0-beta.4`,
to match the tag.

```bash
GIT_TAG=v2.0.0-beta.4
make COMPOSE_BINARY=bin/docker-compose -f builder.Makefile compose-plugin \
    GOOS=linux \
    GOARCH=amd64 \
    CGO_ENABLED=0 \
    go build \
        -trimpath \
        -ldflags="-s -w -X github.com/docker/compose-cli/internal.Version=v2.0.0-beta.4" \
        -o bin/docker-compose \
        ./cmd
```

However, the binary has the `v` prefix stripped (which caused a check to fail
when packaging):

```bash
/root/rpmbuild/BUILDROOT/docker-compose-plugin-2.0.0.beta.4-0.fc34.x86_64/usr/libexec/docker/cli-plugins/docker-compose docker-cli-plugin-metadata
++ awk '{ gsub(/[",:]/,"")}; $1 == "Version" { print $2 }'
+ ver=2.0.0-beta.4
+ test 2.0.0-beta.4 = v2.0.0-beta.4
FAIL: docker-compose version (2.0.0-beta.4) did not match
```

This also looks inconsistent with other binaries and plugins we ship:

```bash
docker info --format '{{json .ClientInfo.Plugins}}' | jq .
[
  {
    "SchemaVersion": "0.1.0",
    "Vendor": "Docker Inc.",
    "Version": "v0.5.1-docker",
    "ShortDescription": "Build with BuildKit",
    "Name": "buildx",
    "Path": "/usr/libexec/docker/cli-plugins/docker-buildx"
  },
  {
    "SchemaVersion": "0.1.0",
    "Vendor": "Docker Inc.",
    "Version": "2.0.0-beta.4",
    "ShortDescription": "Docker Compose",
    "Name": "compose",
    "Path": "/usr/libexec/docker/cli-plugins/docker-compose"
  },
  {
    "SchemaVersion": "0.1.0",
    "Vendor": "Docker Inc.",
    "Version": "v0.8.0",
    "ShortDescription": "Docker Scan",
    "Name": "scan",
    "Path": "/usr/libexec/docker/cli-plugins/docker-scan"
  }
]
```

Perhaps there was a specific reason for this, but thought I'd open this PR for
discussion (if the v-prefix should not be there, perhaps we should isntead strip
it when setting the version).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2021-07-03 15:53:21 +02:00