os.#File: simplify API
Signed-off-by: Solomon Hykes <solomon@dagger.io>
This commit is contained in:
parent
9984edad09
commit
9d85bab9e7
@ -34,7 +34,7 @@ _No output._
|
|||||||
|
|
||||||
## os.#File
|
## os.#File
|
||||||
|
|
||||||
Built-in file implementation, using buildkit
|
Built-in file implementation, using buildkit A single file
|
||||||
|
|
||||||
### os.#File Inputs
|
### os.#File Inputs
|
||||||
|
|
||||||
|
2
stdlib/.dagger/env/os/.gitignore
vendored
Normal file
2
stdlib/.dagger/env/os/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# dagger state
|
||||||
|
state/**
|
26
stdlib/.dagger/env/os/plan/main.cue
vendored
Normal file
26
stdlib/.dagger/env/os/plan/main.cue
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"dagger.io/os"
|
||||||
|
"dagger.io/alpine"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Write a file to an empty dir
|
||||||
|
EmptyDir: {
|
||||||
|
f: os.#File & {
|
||||||
|
path: "/foo.txt"
|
||||||
|
write: data: "hello world!"
|
||||||
|
}
|
||||||
|
f: contents: "hello world!"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read from a pre-existing file
|
||||||
|
Read: {
|
||||||
|
f: os.#File & {
|
||||||
|
from: alpine.#Image & {
|
||||||
|
version: "3.13.4"
|
||||||
|
}
|
||||||
|
path: "/etc/alpine-release"
|
||||||
|
}
|
||||||
|
f: contents: "3.13.4\n"
|
||||||
|
}
|
21
stdlib/.dagger/env/os/values.yaml
vendored
Normal file
21
stdlib/.dagger/env/os/values.yaml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: os
|
||||||
|
sops:
|
||||||
|
kms: []
|
||||||
|
gcp_kms: []
|
||||||
|
azure_kv: []
|
||||||
|
hc_vault: []
|
||||||
|
age:
|
||||||
|
- recipient: age1gxwmtwahzwdmrskhf90ppwlnze30lgpm056kuesrxzeuyclrwvpsupwtpk
|
||||||
|
enc: |
|
||||||
|
-----BEGIN AGE ENCRYPTED FILE-----
|
||||||
|
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSA0bDM5blE0cC9LNHkxZmEy
|
||||||
|
bitYcjhMOHhrWE5pRm90Qyt4S200ZTN0Q1d3Clh2VmdKQjdGUGdKaThmaktwN1F6
|
||||||
|
aXZpellwbHpkb3pMb1NMNXVJYnFUMmMKLS0tIFNiZGlBNjE3UjlXWnBjZ3hwSWto
|
||||||
|
STlrbFNHZGFRUVQ1S1RIaGVyWktNV0kKo9AFURi/BKI+JuGYVuOrsw3eJU3s66Im
|
||||||
|
FCc5YCzrsjX+Y26Su+XW81fTWkcC910e/g+tlZbEFWKZYa8qu1VkqA==
|
||||||
|
-----END AGE ENCRYPTED FILE-----
|
||||||
|
lastmodified: "2021-06-09T18:19:29Z"
|
||||||
|
mac: ENC[AES256_GCM,data:G/D+9UqwJXhqVHAq8rXP7YxubzGKNxjguUVuVpnxKN7awzYaAD2E5plBFDqCw++5qFSZ7HMlWZUseyKOfaOxtkT0CTRAZf8cYLXHIjzKKCFP632nLN0zCPQCMqdrhOLtWkLovtHJ94Xvd3C3Mb+bVi1YmOC6nQHhpglwTVjDw9I=,iv:0GN4vAO5QMXUTODDKYpPD/UmxjfI+RyCdYz9UXQNCso=,tag:RacQNrAUhJHtKeu5ugUadA==,type:str]
|
||||||
|
pgp: []
|
||||||
|
encrypted_suffix: secret
|
||||||
|
version: 3.7.1
|
@ -28,5 +28,5 @@ import (
|
|||||||
from: ctr
|
from: ctr
|
||||||
path: "/out"
|
path: "/out"
|
||||||
}
|
}
|
||||||
}.read.data @dagger(output)
|
}.contents @dagger(output)
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,8 @@ package op
|
|||||||
}
|
}
|
||||||
|
|
||||||
#WriteFile: {
|
#WriteFile: {
|
||||||
do: "write-file"
|
do: "write-file"
|
||||||
|
// FIXME: "contents" to follow english convention
|
||||||
content: string | bytes
|
content: string | bytes
|
||||||
dest: string
|
dest: string
|
||||||
mode: int | *0o644
|
mode: int | *0o644
|
||||||
|
@ -40,7 +40,7 @@ import (
|
|||||||
from: ctr
|
from: ctr
|
||||||
path: "/netlify/url"
|
path: "/netlify/url"
|
||||||
}
|
}
|
||||||
}.read.data @dagger(output)
|
}.contents @dagger(output)
|
||||||
|
|
||||||
// Unique Deploy URL
|
// Unique Deploy URL
|
||||||
deployUrl: {
|
deployUrl: {
|
||||||
@ -48,7 +48,7 @@ import (
|
|||||||
from: ctr
|
from: ctr
|
||||||
path: "/netlify/deployUrl"
|
path: "/netlify/deployUrl"
|
||||||
}
|
}
|
||||||
}.read.data @dagger(output)
|
}.contents @dagger(output)
|
||||||
|
|
||||||
// Logs URL for this deployment
|
// Logs URL for this deployment
|
||||||
logsUrl: {
|
logsUrl: {
|
||||||
@ -56,7 +56,7 @@ import (
|
|||||||
from: ctr
|
from: ctr
|
||||||
path: "/netlify/logsUrl"
|
path: "/netlify/logsUrl"
|
||||||
}
|
}
|
||||||
}.read.data @dagger(output)
|
}.contents @dagger(output)
|
||||||
|
|
||||||
ctr: os.#Container & {
|
ctr: os.#Container & {
|
||||||
image: alpine.#Image & {
|
image: alpine.#Image & {
|
||||||
|
@ -7,30 +7,36 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Built-in file implementation, using buildkit
|
// Built-in file implementation, using buildkit
|
||||||
|
// A single file
|
||||||
#File: {
|
#File: {
|
||||||
from: dagger.#Artifact
|
from: dagger.#Artifact | *[op.#Mkdir & {dir: "/", path: "/"}]
|
||||||
path: string
|
path: string
|
||||||
|
|
||||||
read: {
|
// Optionally write data to the file
|
||||||
// FIXME: support different data schemas for different formats
|
write: *null | {
|
||||||
format: "string"
|
data: string
|
||||||
data: {
|
// FIXME: append
|
||||||
string
|
// FIXME: create + mode
|
||||||
#up: [
|
|
||||||
op.#Load & {"from": from},
|
|
||||||
op.#Export & {source: path, "format": format},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
write: *null | {
|
// The contents of the file
|
||||||
// FIXME: support encoding in different formats
|
// If a write operation is specified, it is applied first.
|
||||||
data: string
|
contents: {
|
||||||
|
string
|
||||||
|
|
||||||
#up: [
|
#up: [
|
||||||
op.#Load & {"from": from},
|
op.#Load & {
|
||||||
op.#WriteFile & {
|
"from": from
|
||||||
dest: path
|
},
|
||||||
contents: data
|
if write != null {
|
||||||
|
op.#WriteFile & {
|
||||||
|
dest: path
|
||||||
|
content: write.data
|
||||||
|
}
|
||||||
|
},
|
||||||
|
op.#Export & {
|
||||||
|
source: path
|
||||||
|
format: "string"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,11 @@ setup() {
|
|||||||
common_setup
|
common_setup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "os" {
|
||||||
|
dagger -e os up
|
||||||
|
}
|
||||||
|
|
||||||
@test "go" {
|
@test "go" {
|
||||||
dagger -e go up
|
dagger -e go up
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user