Apply Solomon comments

- Remove input field
- Fix auth consistency
- Cleanup test

Signed-off-by: Vasek - Tom C <tom.chauveau@epitech.eu>
This commit is contained in:
Tom Chauveau 2022-02-17 17:48:51 +01:00 committed by Vasek - Tom C
parent c90be8423e
commit cc601a4e07
No known key found for this signature in database
GPG Key ID: 175D82E572427960
5 changed files with 78 additions and 86 deletions

View File

@ -0,0 +1,5 @@
# generated by dagger
dagger.lock
alpha.dagger.io
dagger.io
universe.dagger.io

View File

@ -61,15 +61,7 @@ import (
// Build step that executes a Dockerfile
#Dockerfile: {
// Source image
input?: #Image
// FIXME cannot replace with _source: *engine.#Scratch | input.rootfs
// Got error "$dagger" not found
_source: input.rootfs
if input == _|_ {
_source: engine.#Scratch
}
source: dagger.#FS
// Dockerfile definition or path into source
dockerfile: *{
@ -91,12 +83,9 @@ import (
label: [string]: string
hosts: [string]: string
_build: engine.#Dockerfile & {
source: _source
"auth": [ for target, creds in auth {
"target": target
creds
}]
_build: dagger.#Dockerfile & {
"source": source
"auth": auth
"dockerfile": dockerfile
"platforms": platforms
if target != _|_ {

View File

@ -1,34 +0,0 @@
package test
import (
"dagger.io/dagger"
"dagger.io/dagger/engine"
"universe.dagger.io/docker"
)
dagger.#Plan & {
inputs: directories: testdata: path: "./testdata"
actions: {
image: docker.#Build & {
steps: [
docker.#Dockerfile & {
input: rootfs: inputs.directories.testdata.contents
},
docker.#Run & {
always: true
script: """
hello >> /test.txt
"""
},
]
}
verify: engine.#ReadFile & {
input: image.output.rootfs
path: "/test.txt"
} & {
contents: "hello world"
}
}
}

View File

@ -1,37 +0,0 @@
package test
import (
"dagger.io/dagger"
"dagger.io/dagger/engine"
"universe.dagger.io/docker"
)
dagger.#Plan & {
actions: {
build: docker.#Build & {
steps: [
docker.#Dockerfile & {
dockerfile: contents: """
FROM alpine:3.15
RUN echo -n hello world >> /test.txt
"""
},
docker.#Run & {
script: """
# Verify that docker.#Dockerfile correctly connect output
# into other steps
grep -q "hello world" /test.txt
"""
},
]
}
verify: engine.#ReadFile & {
input: build.output.rootfs
path: "/test.txt"
} & {
contents: "hello world"
}
}
}

View File

@ -0,0 +1,69 @@
package docker
import (
"dagger.io/dagger"
"universe.dagger.io/docker"
)
dagger.#Plan & {
inputs: directories: testdata: path: "./testdata"
actions: tests: dockerfile: {
simple: {
build: docker.#Build & {
steps: [
docker.#Dockerfile & {
source: dagger.#Scratch
dockerfile: contents: """
FROM alpine:3.15
RUN echo -n hello world >> /test.txt
"""
},
docker.#Run & {
command: {
name: "/bin/sh"
args: ["-c", """
# Verify that docker.#Dockerfile correctly connect output
# into other steps
grep -q "hello world" /test.txt
"""]
}
},
]
}
verify: dagger.#ReadFile & {
input: build.output.rootfs
path: "/test.txt"
} & {
contents: "hello world"
}
}
withInput: {
build: docker.#Build & {
steps: [
docker.#Dockerfile & {
source: inputs.directories.testdata.contents
},
docker.#Run & {
command: {
name: "/bin/sh"
args: ["-c", """
hello >> /test.txt
"""]
}
},
]
}
verify: dagger.#ReadFile & {
input: build.output.rootfs
path: "/test.txt"
} & {
contents: "hello world"
}
}
}
}