refactored existing tests to use #TransformSecret
Signed-off-by: Richard Jones <richard@dagger.io>
This commit is contained in:
parent
86bf3bad86
commit
86ae230261
@ -2,26 +2,38 @@ package testing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"dagger.io/dagger/engine"
|
"dagger.io/dagger/engine"
|
||||||
|
"encoding/yaml"
|
||||||
)
|
)
|
||||||
|
|
||||||
engine.#Plan & {
|
engine.#Plan & {
|
||||||
inputs: {
|
inputs: {
|
||||||
directories: testdata: path: "./testdata"
|
directories: testdata: path: "./testdata"
|
||||||
secrets: dockerHubToken: command: {
|
secrets: sops: command: {
|
||||||
name: "sops"
|
name: "sops"
|
||||||
args: ["exec-env", "../../secrets_sops.yaml", "echo $DOCKERHUB_TOKEN"]
|
args: ["-d", "../../secrets_sops.yaml"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actions: build: engine.#Build & {
|
actions: {
|
||||||
|
dockerHubToken: engine.#TransformSecret & {
|
||||||
|
input: inputs.secrets.sops.contents
|
||||||
|
#function: {
|
||||||
|
input: _
|
||||||
|
output: yaml.Unmarshal(input).DOCKERHUB_TOKEN
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
build: engine.#Build & {
|
||||||
source: inputs.directories.testdata.contents
|
source: inputs.directories.testdata.contents
|
||||||
auth: [{
|
auth: [{
|
||||||
target: "daggerio/ci-test:private-pull"
|
target: "daggerio/ci-test:private-pull"
|
||||||
username: "daggertest"
|
username: "daggertest"
|
||||||
secret: inputs.secrets.dockerHubToken.contents
|
|
||||||
|
secret: dockerHubToken.output
|
||||||
}]
|
}]
|
||||||
dockerfile: contents: """
|
dockerfile: contents: """
|
||||||
FROM daggerio/ci-test:private-pull@sha256:c74f1b1166784193ea6c8f9440263b9be6cae07dfe35e32a5df7a31358ac2060
|
FROM daggerio/ci-test:private-pull@sha256:c74f1b1166784193ea6c8f9440263b9be6cae07dfe35e32a5df7a31358ac2060
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,36 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import "dagger.io/dagger/engine"
|
import (
|
||||||
|
"encoding/yaml"
|
||||||
|
"dagger.io/dagger/engine"
|
||||||
|
)
|
||||||
|
|
||||||
engine.#Plan & {
|
engine.#Plan & {
|
||||||
inputs: secrets: token: command: {
|
inputs: secrets: sops: command: {
|
||||||
name: "sops"
|
name: "sops"
|
||||||
args: ["exec-env", "../../secrets_sops.yaml", "echo $TestPAT"]
|
args: ["-d", "../../secrets_sops.yaml"]
|
||||||
}
|
}
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
||||||
alpine: engine.#Pull & {
|
alpine: engine.#Pull & {
|
||||||
source: "alpine:3.15.0"
|
source: "alpine:3.15.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
repoPassword: engine.#TransformSecret & {
|
||||||
|
input: inputs.secrets.sops.contents
|
||||||
|
#function: {
|
||||||
|
input: _
|
||||||
|
output: yaml.Unmarshal(input).TestPAT
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
testRepo: engine.#GitPull & {
|
testRepo: engine.#GitPull & {
|
||||||
remote: "https://github.com/dagger/dagger.git"
|
remote: "https://github.com/dagger/dagger.git"
|
||||||
ref: "main"
|
ref: "main"
|
||||||
auth: {
|
auth: {
|
||||||
username: "dagger-test"
|
username: "dagger-test"
|
||||||
password: inputs.secrets.token.contents
|
password: repoPassword.output
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user