Move snippets outside of markdown

Signed-off-by: Helder Correia <174525+helderco@users.noreply.github.com>
This commit is contained in:
Helder Correia
2022-03-10 11:50:21 -01:00
parent cf0505614f
commit 6204970d53
13 changed files with 177 additions and 170 deletions

View File

@@ -0,0 +1,18 @@
dagger.#Plan & {
client: commands: {
os: {
name: "uname"
args: ["-s"]
}
arch: {
name: "uname"
args: ["-m"]
}
}
actions: build: go.#Build & {
os: client.commands.os.stdout
arch: client.commands.arch.stdout
// ...
}
}

View File

@@ -0,0 +1,14 @@
dagger.#Plan & {
client: env: {
REGISTRY_USER: string
REGISTRY_TOKEN: dagger.#Secret
}
actions: pull: docker.#Pull & {
source: "registry.example.com/image"
auth: {
username: client.env.REGISTRY_USER
secret: client.env.REGISTRY_TOKEN
}
}
}

View File

@@ -0,0 +1,15 @@
import (
"encoding/yaml"
// ...
)
dagger.#Plan & {
client: filesystem: "config.yaml": write: {
// Convert a CUE value into a YAML formatted string
contents: yaml.Marshal(actions.pull.output.config)
}
actions: pull: docker.#Pull & {
source: "alpine"
}
}

View File

@@ -0,0 +1,15 @@
dagger.#Plan & {
// Path may be absolute, or relative to current working directory
client: filesystem: ".": read: {
// CUE type defines expected content
contents: dagger.#FS
exclude: ["node_modules"]
}
actions: {
copy: docker.Copy & {
contents: client.filesystem.".".read.contents
}
// ...
}
}

View File

@@ -0,0 +1,9 @@
dagger.#Plan & {
client: _
actions: build: go.#Build & {
os: client.platform.os
arch: client.platform.arch
// ...
}
}

View File

@@ -0,0 +1,20 @@
dagger.#Plan & {
client: filesystem: "/var/run/docker.sock": read: contents: dagger.#Service
actions: {
image: alpine.#Build & {
packages: "docker-cli": {}
}
run: docker.#Run & {
input: image.output
mounts: docker: {
dest: "/var/run/docker.sock"
contents: client.filesystem."/var/run/docker.sock".read.contents
}
command: {
name: "docker"
args: ["info"]
}
}
}
}

View File

@@ -0,0 +1,23 @@
dagger.#Plan & {
client: filesystem: "//./pipe/docker_engine": read: {
contents: dagger.#Service
type: "npipe"
}
actions: {
image: alpine.#Build & {
packages: "docker-cli": {}
}
run: docker.#Run & {
input: image.output
mounts: docker: {
dest: "/var/run/docker.sock"
contents: client.filesystem."//./pipe/docker_engine".read.contents
}
command: {
name: "docker"
args: ["info"]
}
}
}
}

View File

@@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}

View File

@@ -0,0 +1,3 @@
module dagger.io/test
go 1.17

View File

@@ -0,0 +1,19 @@
dagger.#Plan & {
// Path may be absolute, or relative to current working directory
client: filesystem: ".registry": read: {
// CUE type defines expected content
contents: dagger.#Secret
}
actions: {
registry: dagger.#TrimSecret & {
input: client.filesystem.".registry".read.contents
}
pull: docker.#Pull & {
source: "registry.example.com/image"
auth: {
username: "_token_"
secret: registry.output
}
}
}
}

View File

@@ -0,0 +1,23 @@
dagger.#Plan & {
client: commands: sops: {
name: "sops"
args: ["-d", "./secrets.yaml"]
stdout: dagger.#Secret
}
actions: {
// Makes the yaml keys easily accessible
secrets: dagger.#DecodeSecret & {
input: client.commands.sops.stdout
format: "yaml"
}
run: docker.#Run & {
mounts: secret: {
dest: "/run/secrets/token"
contents: secrets.output.myToken
}
// Do something with `/run/secrets/token`
}
}
}