refactored existing tests to use #TransformSecret

Signed-off-by: Richard Jones <richard@dagger.io>
This commit is contained in:
Richard Jones 2022-01-04 20:30:58 -07:00
parent 86bf3bad86
commit 86ae230261
No known key found for this signature in database
GPG Key ID: CFB3A382EB166F4C
2 changed files with 40 additions and 16 deletions

View File

@ -2,26 +2,38 @@ package testing
import (
"dagger.io/dagger/engine"
"encoding/yaml"
)
engine.#Plan & {
inputs: {
directories: testdata: path: "./testdata"
secrets: dockerHubToken: command: {
secrets: sops: command: {
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
auth: [{
target: "daggerio/ci-test:private-pull"
username: "daggertest"
secret: inputs.secrets.dockerHubToken.contents
secret: dockerHubToken.output
}]
dockerfile: contents: """
FROM daggerio/ci-test:private-pull@sha256:c74f1b1166784193ea6c8f9440263b9be6cae07dfe35e32a5df7a31358ac2060
"""
}
}
}

View File

@ -1,24 +1,36 @@
package main
import "dagger.io/dagger/engine"
import (
"encoding/yaml"
"dagger.io/dagger/engine"
)
engine.#Plan & {
inputs: secrets: token: command: {
inputs: secrets: sops: command: {
name: "sops"
args: ["exec-env", "../../secrets_sops.yaml", "echo $TestPAT"]
args: ["-d", "../../secrets_sops.yaml"]
}
actions: {
alpine: engine.#Pull & {
source: "alpine:3.15.0"
}
repoPassword: engine.#TransformSecret & {
input: inputs.secrets.sops.contents
#function: {
input: _
output: yaml.Unmarshal(input).TestPAT
}
}
testRepo: engine.#GitPull & {
remote: "https://github.com/dagger/dagger.git"
ref: "main"
auth: {
username: "dagger-test"
password: inputs.secrets.token.contents
password: repoPassword.output
}
}