Fix examples/simple (cannot load across package imports)

Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
Solomon Hykes 2021-01-29 23:55:47 -08:00
parent 23a1211cdf
commit fa2cfc1267
3 changed files with 32 additions and 67 deletions

View File

@ -1,50 +0,0 @@
package alpine
// Default version pinned to digest. Manually updated.
let defaultDigest="sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436"
ref: string
// Match a combination of inputs 'version' and 'digest':
*{
// no version, no digest:
ref: "index.docker.io/alpine@\(defaultDigest)"
} | {
// version, no digest
version: string
ref: "alpine:\(version)"
} | {
// digest, no version
digest: string
ref: "alpine@\(digest)"
} | {
// version and digest
version: string
digest: string
ref: "alpine:\(version)@\(digest)"
}
// Packages to install
package: [string]: true | false | string
#dagger: compute: [
{
do: "fetch-container"
"ref": ref
},
for pkg, info in package {
if (info & true) != _|_ {
do: "exec"
args: ["apk", "add", "-U", "--no-cache", pkg]
// https://github.com/blocklayerhq/dagger/issues/6
mount: foo: {}
}
if (info & string) != _|_ {
do: "exec"
args: ["apk", "add", "-U", "--no-cache", "\(pkg)\(info)"]
// https://github.com/blocklayerhq/dagger/issues/6
mount: foo: {}
}
},
]

View File

@ -51,7 +51,9 @@ package dagger
// Any component can be referenced as a directory, since
// every dagger script outputs a filesystem state (aka a directory)
#Dir: #Component
#Dir: #Component & {
#dagger: compute: _
}
#Script: [...#Op]

View File

@ -3,23 +3,33 @@
package acme
import (
"dagger.cloud/alpine"
"dagger.cloud/dagger"
)
let base=alpine & {
package: {
bash: ">3.0"
rsync: true
let alpine={
digest: "sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436"
package: [string]: true | false | string
#dagger: compute: [
{
do: "fetch-container"
ref: "index.docker.io@\(digest)"
},
for pkg, info in package {
if (info & true) != _|_ {
do: "exec"
args: ["apk", "add", "-U", "--no-cache", pkg]
}
if (info & string) != _|_ {
do: "exec"
args: ["apk", "add", "-U", "--no-cache", "\(pkg)\(info)"]
}
},
]
}
www: {
source: {
// Make this undefined on purpose to require an input directory.
#dagger: compute: _
}
source: dagger.#Dir
// List the contents of the source directory
listing: {
@ -27,7 +37,7 @@ www: {
#dagger: compute: [
dagger.#Load & {
from: base
from: alpine
},
dagger.#Exec & {
args: ["sh", "-c", "ls /src > /tmp/out"]
@ -47,7 +57,10 @@ www: {
string
#dagger: compute: [
dagger.#Load & { from: base },
{
do: "load"
from: alpine
},
dagger.#Exec & {
args: ["sh", "-c", "echo -n 'https://\(host)/foo' > /tmp/out"]
},