diff --git a/dagger/compiler/value.go b/dagger/compiler/value.go index 0dcaa1a6..7560b4a4 100644 --- a/dagger/compiler/value.go +++ b/dagger/compiler/value.go @@ -208,7 +208,10 @@ func (v *Value) Source(opts ...cue.Option) ([]byte, error) { v.cc.rlock() defer v.cc.runlock() - return cueformat.Node(v.val.Eval().Syntax(opts...)) + return cueformat.Node(v.val.Eval().Syntax(opts...), + cueformat.UseSpaces(4), + cueformat.TabIndent(false), + ) } func (v *Value) IsEmptyStruct() bool { diff --git a/dagger/store.go b/dagger/store.go index cc1f22fd..468fc395 100644 --- a/dagger/store.go +++ b/dagger/store.go @@ -46,7 +46,11 @@ func NewStore(root string) (*Store, error) { } func DefaultStore() (*Store, error) { - return NewStore(os.ExpandEnv(defaultStoreRoot)) + root := defaultStoreRoot + if r := os.Getenv("DAGGER_STORE"); r != "" { + root = r + } + return NewStore(root) } func (s *Store) deploymentPath(name string) string { diff --git a/examples/kubernetes-aws/main.cue b/examples/kubernetes-aws/main.cue index 59607229..e2dc91f3 100644 --- a/examples/kubernetes-aws/main.cue +++ b/examples/kubernetes-aws/main.cue @@ -16,8 +16,8 @@ awsConfig: aws.#Config & { // - Instance Node Group: auto-scaling-group, ec2 instances, etc... // base config can be changed (number of EC2 instances, types, etc...) infra: #Infrastructure & { - "awsConfig": awsConfig - namePrefix: "dagger-example-" + "awsConfig": awsConfig + namePrefix: "dagger-example-" workerNodeCapacity: int | *1 workerNodeInstanceType: "t3.small" } diff --git a/tests/cli/nonconcrete/main.cue b/tests/cli/nonconcrete/main.cue new file mode 100644 index 00000000..46d2bfca --- /dev/null +++ b/tests/cli/nonconcrete/main.cue @@ -0,0 +1,3 @@ +package testing + +nonConcrete: string diff --git a/tests/cli/simple/main.cue b/tests/cli/simple/main.cue new file mode 100644 index 00000000..fa4c4d32 --- /dev/null +++ b/tests/cli/simple/main.cue @@ -0,0 +1,11 @@ +package testing + +import "dagger.io/llb" + +foo: "value" +bar: "another value" + +#compute: [ + llb.#FetchContainer & {ref: "busybox"}, + llb.#Exec & {args: ["true"]}, +] diff --git a/tests/test.sh b/tests/test.sh index aadfc4b5..49b898dd 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -21,6 +21,7 @@ test::all(){ test::dependencies "$dagger" test::compute "$dagger" test::daggerignore "$dagger" + test::cli "$dagger" test::examples "$dagger" } @@ -109,6 +110,83 @@ test::daggerignore() { "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute --input-dir TestData="$d"/ignore/testdata "$d"/ignore } +test::cli() { + local dagger="$1" + + test::cli::list "$dagger" + test::cli::newdir "$dagger" + test::cli::query "$dagger" +} + +test::cli::list() { + local dagger="$1" + + # Create temporary store + local DAGGER_STORE + DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" + export DAGGER_STORE + + test::one "CLI: list: no deployments" --stdout="" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" list + + test::one "CLI: list: create deployment" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple + + test::one "CLI: list: with deployments" --stdout="simple" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" list +} + +test::cli::newdir() { + local dagger="$1" + + # Create temporary store + local DAGGER_STORE + DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" + export DAGGER_STORE + + test::one "CLI: new: --plan-dir" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple + + test::one "CLI: new: duplicate name" --exit=1 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple + + test::one "CLI: new: verify plan can be upped" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" up -d "simple" + + test::one "CLI: new: verify we have the right plan" --stdout='{ + foo: "value" + bar: "another value" +}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c +} + +test::cli::query() { + local dagger="$1" + + # Create temporary store + local DAGGER_STORE + DAGGER_STORE="$(mktemp -d -t dagger-store-XXXXXX)" + export DAGGER_STORE + + test::one "CLI: query: initialize simple" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/simple simple + + test::one "CLI: query: concrete" --stdout='{ + foo: "value" + bar: "another value" +}' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" -c + + test::one "CLI: query: target" --stdout='"value"' \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "simple" foo + + test::one "CLI: query: initialize nonconcrete" \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" new --plan-dir "$d"/cli/nonconcrete nonconcrete + + test::one "CLI: query: non concrete" --exit=1 \ + "$dagger" "${DAGGER_BINARY_ARGS[@]}" query -d "nonconcrete" -c +} + test::examples() { test::secret "$d"/../examples/react-netlify/inputs.yaml "examples: React Netlify" --exit=0 \ "$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/../examples/react-netlify