From cf0fcdbe92c3c7252bbcc7ce41e4e145cae28e55 Mon Sep 17 00:00:00 2001 From: Helder Correia <174525+helderco@users.noreply.github.com> Date: Mon, 28 Mar 2022 14:34:15 +0000 Subject: [PATCH] Make docker/cli image overrideable Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com> --- pkg/universe.dagger.io/docker/cli/client.cue | 14 ++++++++----- .../docker/cli/test/run.cue | 21 +++++++++++++------ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/pkg/universe.dagger.io/docker/cli/client.cue b/pkg/universe.dagger.io/docker/cli/client.cue index 3cb7aba6..18a2547e 100644 --- a/pkg/universe.dagger.io/docker/cli/client.cue +++ b/pkg/universe.dagger.io/docker/cli/client.cue @@ -5,17 +5,21 @@ import ( "universe.dagger.io/docker" ) -// See https://github.com/dagger/dagger/issues/1856 +// See https://github.com/dagger/dagger/discussions/1874 + +// Default image +#Image: docker.#Pull & { + source: "docker:20.10.13-alpine3.15" +} // Run a docker CLI command #Run: { #RunSocket | #RunSSH | #RunTCP - _image: docker.#Pull & { - source: "docker:20.10.13-alpine3.15" - } + _defaultImage: #Image - input: _image.output + // As a convenience, input defaults to a ready-to-use docker environment + input: docker.#Image | *_defaultImage.output } // Connect via local docker socket diff --git a/pkg/universe.dagger.io/docker/cli/test/run.cue b/pkg/universe.dagger.io/docker/cli/test/run.cue index e29a043a..37da4c96 100644 --- a/pkg/universe.dagger.io/docker/cli/test/run.cue +++ b/pkg/universe.dagger.io/docker/cli/test/run.cue @@ -4,6 +4,7 @@ import ( "dagger.io/dagger" "universe.dagger.io/alpine" + "universe.dagger.io/docker" "universe.dagger.io/docker/cli" ) @@ -17,19 +18,27 @@ dagger.#Plan & { } differentImage: { - _cli: alpine.#Build & { - packages: { - bash: {} - "docker-cli": {} - } + _cli: docker.#Build & { + steps: [ + alpine.#Build & { + packages: "docker-cli": {} + }, + docker.#Run & { + command: { + name: "sh" + flags: "-c": "echo -n foobar > /test.txt" + } + }, + ] } - run: cli.#RunSocket & { + run: cli.#Run & { input: _cli.output host: client.filesystem."/var/run/docker.sock".read.contents command: { name: "docker" args: ["info"] } + export: files: "/test.txt": "foobar" } }