From 16553b2e2ad34a84ca98f75311644d9953776732 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Mon, 24 May 2021 16:16:23 -0700 Subject: [PATCH 1/8] cmd/input: added support for Description from cue doc string Signed-off-by: Sam Alba --- cmd/dagger/cmd/input/list.go | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/cmd/dagger/cmd/input/list.go b/cmd/dagger/cmd/input/list.go index 6dd65538..6026b8ee 100644 --- a/cmd/dagger/cmd/input/list.go +++ b/cmd/dagger/cmd/input/list.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "strings" "text/tabwriter" "go.dagger.io/dagger/client" @@ -49,7 +50,7 @@ var listCmd = &cobra.Command{ inputs := env.ScanInputs(ctx) w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - fmt.Fprintln(w, "Input\tType\tValue\tSet by user") + fmt.Fprintln(w, "Input\tType\tValue\tSet by user\tDescription") for _, inp := range inputs { isConcrete := (inp.IsConcreteR() == nil) @@ -69,11 +70,12 @@ var listCmd = &cobra.Command{ } } - fmt.Fprintf(w, "%s\t%s\t%s\t%t\n", + fmt.Fprintf(w, "%s\t%s\t%s\t%t\t%s\n", inp.Path(), getType(inp), valStr, isUserSet(st, inp), + getDocString(inp), ) } @@ -108,6 +110,34 @@ func getType(val *compiler.Value) string { return val.Cue().IncompleteKind().String() } +func getDocString(val *compiler.Value) string { + docs := []string{} + for _, c := range val.Cue().Doc() { + docs = append(docs, strings.TrimSpace(c.Text())) + } + doc := strings.Join(docs, " ") + + lines := strings.Split(doc, "\n") + + // Strip out FIXME, TODO, and INTERNAL comments + docs = []string{} + for _, line := range lines { + if strings.HasPrefix(line, "FIXME: ") || + strings.HasPrefix(line, "TODO: ") || + strings.HasPrefix(line, "INTERNAL: ") { + continue + } + if len(line) == 0 { + continue + } + docs = append(docs, line) + } + if len(docs) == 0 { + return "-" + } + return strings.Join(docs, " ") +} + func init() { listCmd.Flags().BoolP("all", "a", false, "List all inputs (include non-overridable)") From b1813009304ed6585b7386be7b062206725d916b Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Mon, 24 May 2021 18:56:41 -0700 Subject: [PATCH 2/8] examples/simple-s3: added comment for input description Signed-off-by: Sam Alba --- examples/simple-s3/main.cue | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/simple-s3/main.cue b/examples/simple-s3/main.cue index 046da4e7..848ffc96 100644 --- a/examples/simple-s3/main.cue +++ b/examples/simple-s3/main.cue @@ -14,6 +14,7 @@ awsConfig: aws.#Config & { // Name of the S3 bucket to use bucket: *"dagger-io-examples" | string @dagger(input) +// Source code to deploy source: dagger.#Artifact @dagger(input) url: "\(deploy.url)index.html" From 6568c4e6d161814a25da6461c05d5f80436193f9 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Mon, 24 May 2021 19:00:57 -0700 Subject: [PATCH 3/8] test: removed unused test Signed-off-by: Sam Alba --- tests/cli/input/scan/main.cue | 50 ----------------------------------- 1 file changed, 50 deletions(-) delete mode 100644 tests/cli/input/scan/main.cue diff --git a/tests/cli/input/scan/main.cue b/tests/cli/input/scan/main.cue deleted file mode 100644 index 5405c218..00000000 --- a/tests/cli/input/scan/main.cue +++ /dev/null @@ -1,50 +0,0 @@ -package main - -foo: string - -name: string | *"world" -message: "Hello, \(name)!" - -optional?: string - -missing: [string]: string - -bar: { - a: string - #c: string - b: int @dagger(computed) -} - -// may be missing -#inputs: { - hello: string - missing: *"" | string -} - -// substitute -let A = string -let B = bar.a - -//let Ba = bar.a -//let Bb = bar.b -let D = "hello" - -refd: { - a: string - b: { - ref1: a - ref2: A - aa: B - bb: D - } - #c: C: string -} - -#fld1: string - -exec: { - cmd: string - #up: [{foo: string}] -} - -list: [...string] From 42e91c0a30b2bf3edf5c3b7d616e908933680d7d Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Wed, 26 May 2021 12:00:59 +0200 Subject: [PATCH 4/8] test: implemented tests for input list Signed-off-by: Sam Alba --- tests/cli.bats | 33 ++++++++++++++++++++++++++ tests/cli/input/list/main.cue | 44 +++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 tests/cli/input/list/main.cue diff --git a/tests/cli.bats b/tests/cli.bats index df4d8de8..103c10e6 100644 --- a/tests/cli.bats +++ b/tests/cli.bats @@ -285,3 +285,36 @@ setup() { "foo": "bar" }' } + +@test "dagger input list" { + "$DAGGER" new --plan-dir "$TESTDIR"/cli/input/list "list" + "$DAGGER" input text cfg.str "foobar" -e "list" + + out="$("$DAGGER" input list -e "list")" + outAll="$("$DAGGER" input list --all -e "list")" + + #note: this is the recommended way to use pipes with bats + run bash -c "echo \"$out\" | grep awsConfig.accessKey | grep '#Secret' | grep false" + assert_success + + run bash -c "echo \"$out\" | grep cfgInline.source | grep '#Artifact' | grep false | grep 'source dir'" + assert_success + + run bash -c "echo \"$outAll\" | grep cfg2" + assert_failure + + run bash -c "echo \"$out\" | grep cfgInline.strDef | grep string | grep 'yolo (default)' | grep false" + assert_success + + run bash -c "echo \"$out\" | grep cfg.num" + assert_failure + + run bash -c "echo \"$outAll\" | grep cfg.num | grep int" + assert_success + + run bash -c "echo \"$out\" | grep cfg.strSet" + assert_failure + + run bash -c "echo \"$outAll\" | grep cfg.strSet | grep string | grep pipo" + assert_success +} diff --git a/tests/cli/input/list/main.cue b/tests/cli/input/list/main.cue new file mode 100644 index 00000000..30d08eee --- /dev/null +++ b/tests/cli/input/list/main.cue @@ -0,0 +1,44 @@ +package main + +import ( + "dagger.io/dagger" + "dagger.io/aws" +) + +awsConfig: aws.#Config & { + // force region + region: "us-east-1" +} + +#A: { + // source dir + source: dagger.#Artifact @dagger(input) + sourceNotInput: dagger.#Artifact + + // a secret + key: dagger.#Secret @dagger(input) + keyNotInput: dagger.#Secret + + // a string + str: string @dagger(input) + strSet: "pipo" @dagger(input) + strDef: *"yolo" | string @dagger(input) + + // a number + num: int | *42 @dagger(input) + numNotInput: int + + // aws config + cfg: awsConfig +} + +cfgInline: { + #A +} + +cfg: #A & { + // force this key + num: 21 +} + +cfg2: cfg From 7009d01835f6f59946ca04d19bad991a196d6f26 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Wed, 26 May 2021 12:23:44 +0200 Subject: [PATCH 5/8] stdlib: added @dagger(input) and @dagger(output) attributes Signed-off-by: Sam Alba --- stdlib/aws/cloudformation/cloudformation.cue | 14 +++---- stdlib/aws/ecr/ecr.cue | 2 +- stdlib/aws/ecs/run-task.cue | 12 +++--- stdlib/aws/eks/eks.cue | 6 +-- stdlib/aws/elb/elb.cue | 6 ++- stdlib/aws/rds/rds.cue | 10 ++--- stdlib/docker/docker.cue | 12 +++--- stdlib/file/file.cue | 38 +++++++++---------- stdlib/gcp/gcp.cue | 6 +-- stdlib/gcp/gcr/gcr.cue | 2 +- stdlib/gcp/gke/gke.cue | 6 +-- stdlib/git/git.cue | 6 +-- stdlib/go/go.cue | 36 +++++++++--------- stdlib/js/yarn/yarn.cue | 12 +++--- stdlib/kubernetes/helm/helm.cue | 26 ++++++------- stdlib/kubernetes/kubernetes.cue | 10 ++--- stdlib/kubernetes/kustomize/kustomization.cue | 8 ++-- stdlib/netlify/netlify.cue | 18 ++++----- stdlib/terraform/terraform.cue | 10 ++--- 19 files changed, 121 insertions(+), 119 deletions(-) diff --git a/stdlib/aws/cloudformation/cloudformation.cue b/stdlib/aws/cloudformation/cloudformation.cue index 6501803b..91f85361 100644 --- a/stdlib/aws/cloudformation/cloudformation.cue +++ b/stdlib/aws/cloudformation/cloudformation.cue @@ -14,22 +14,22 @@ import ( config: aws.#Config // Source is the Cloudformation template (JSON/YAML string) - source: string + source: string @dagger(input) // Stackname is the cloudformation stack - stackName: string + stackName: string @dagger(input) // Stack parameters - parameters: [string]: _ + parameters: [string]: _ @dagger(input) // Behavior when failure to create/update the Stack - onFailure: *"DO_NOTHING" | "ROLLBACK" | "DELETE" + onFailure: *"DO_NOTHING" | "ROLLBACK" | "DELETE" @dagger(input) // Timeout for waiting for the stack to be created/updated (in minutes) - timeout: *10 | uint + timeout: *10 | uint @dagger(input) // Never update the stack if already exists - neverUpdate: *false | bool + neverUpdate: *false | bool @dagger(input) #files: { "/entrypoint.sh": #Code @@ -44,7 +44,7 @@ import ( } } - outputs: [string]: string + outputs: [string]: string @dagger(output) outputs: #up: [ op.#Load & { diff --git a/stdlib/aws/ecr/ecr.cue b/stdlib/aws/ecr/ecr.cue index c7b6b1d4..8ffdf038 100644 --- a/stdlib/aws/ecr/ecr.cue +++ b/stdlib/aws/ecr/ecr.cue @@ -15,7 +15,7 @@ import ( // ECR credentials username: "AWS" - secret: out + secret: out @dagger(output) aws.#Script & { always: true diff --git a/stdlib/aws/ecs/run-task.cue b/stdlib/aws/ecs/run-task.cue index c1ce72cf..a6a5a656 100644 --- a/stdlib/aws/ecs/run-task.cue +++ b/stdlib/aws/ecs/run-task.cue @@ -11,22 +11,22 @@ import ( config: aws.#Config // ECS cluster name - cluster: string + cluster: string @dagger(input) // Arn of the task to run - taskArn: string + taskArn: string @dagger(input) // Environment variables of the task - containerEnvironment: [string]: string + containerEnvironment: [string]: string @dagger(input) // Container name - containerName: string + containerName: string @dagger(input) // Container command to give - containerCommand: [...string] + containerCommand: [...string] @dagger(input) // Task role ARN - roleArn: string | *"" + roleArn: string | *"" @dagger(input) containerOverrides: { containerOverrides: [{ diff --git a/stdlib/aws/eks/eks.cue b/stdlib/aws/eks/eks.cue index a56fce0d..f7aa12a1 100644 --- a/stdlib/aws/eks/eks.cue +++ b/stdlib/aws/eks/eks.cue @@ -11,15 +11,15 @@ import ( config: aws.#Config // EKS cluster name - clusterName: string + clusterName: string @dagger(input) // Kubectl version - version: *"v1.19.9" | string + version: *"v1.19.9" | string @dagger(input) // kubeconfig is the generated kube configuration file kubeconfig: { // FIXME There is a problem with dagger.#Secret type - string + string @dagger(output) #up: [ op.#Load & { diff --git a/stdlib/aws/elb/elb.cue b/stdlib/aws/elb/elb.cue index cd6a0851..5a3757c7 100644 --- a/stdlib/aws/elb/elb.cue +++ b/stdlib/aws/elb/elb.cue @@ -10,12 +10,14 @@ import ( config: aws.#Config // ListenerArn - listenerArn: string + listenerArn: string @dagger(input) // Optional vhost for reusing priorities - vhost?: string + vhost?: string @dagger(input) // exported priority + priority: out @dagger(output) + out: string aws.#Script & { diff --git a/stdlib/aws/rds/rds.cue b/stdlib/aws/rds/rds.cue index f62787f8..920f08e8 100644 --- a/stdlib/aws/rds/rds.cue +++ b/stdlib/aws/rds/rds.cue @@ -11,18 +11,18 @@ import ( config: aws.#Config // DB name - name: string + name: string @dagger(input) // ARN of the database instance - dbArn: string + dbArn: string @dagger(input) // ARN of the database secret (for connecting via rds api) - secretArn: string + secretArn: string @dagger(input) - dbType: "mysql" | "postgres" + dbType: "mysql" | "postgres" @dagger(input) // Name of the DB created - out: string + out: string @dagger(output) aws.#Script & { "config": config diff --git a/stdlib/docker/docker.cue b/stdlib/docker/docker.cue index 63763e7e..8a432bf2 100644 --- a/stdlib/docker/docker.cue +++ b/stdlib/docker/docker.cue @@ -7,7 +7,7 @@ import ( // Build a Docker image from source, using included Dockerfile #Build: { - source: dagger.#Artifact + source: dagger.#Artifact @dagger(input) #up: [ op.#DockerBuild & { @@ -20,7 +20,7 @@ import ( // Pull a docker container #Pull: { // Remote ref (example: "index.docker.io/alpine:latest") - from: string + from: string @dagger(input) #up: [ op.#FetchContainer & {ref: from}, @@ -30,10 +30,10 @@ import ( // Push a docker image #Push: { // Remote ref (example: "index.docker.io/alpine:latest") - ref: string + ref: string @dagger(input) // Image - source: dagger.#Artifact + source: dagger.#Artifact @dagger(input) #up: [ op.#Load & {from: source}, @@ -46,8 +46,8 @@ import ( // Build a Docker image from the provided Dockerfile contents // FIXME: incorporate into #Build #ImageFromDockerfile: { - dockerfile: string - context: dagger.#Artifact + dockerfile: string @dagger(input) + context: dagger.#Artifact @dagger(input) #up: [ op.#DockerBuild & { diff --git a/stdlib/file/file.cue b/stdlib/file/file.cue index 1307da17..6c2cd1e3 100644 --- a/stdlib/file/file.cue +++ b/stdlib/file/file.cue @@ -7,9 +7,9 @@ import ( ) #Create: { - filename: !="" - permissions: int | *0o644 - contents: string | bytes + filename: !="" @dagger(input) + permissions: int | *0o644 @dagger(input) + contents: string | bytes @dagger(input) #up: [ op.#WriteFile & {dest: filename, content: contents, mode: permissions}, @@ -17,12 +17,12 @@ import ( } #Append: { - filename: !="" - permissions: int | *0o644 - contents: string | bytes - from: dagger.#Artifact + filename: !="" @dagger(input) + permissions: int | *0o644 @dagger(input) + contents: string | bytes @dagger(input) + from: dagger.#Artifact @dagger(input) - orig: (#read & {path: filename, "from": from}).data + orig: (#read & {path: filename, "from": from}).data @dagger(output) #up: [ op.#WriteFile & {dest: filename, content: "\(orig)\(contents)", mode: permissions}, @@ -30,16 +30,16 @@ import ( } #Read: { - filename: !="" - from: dagger.#Artifact - contents: (#read & {path: filename, "from": from}).data + filename: !="" @dagger(input) + from: dagger.#Artifact @dagger(input) + contents: (#read & {path: filename, "from": from}).data @dagger(output) } #read: { - path: !="" - from: dagger.#Artifact + path: !="" @dagger(input) + from: dagger.#Artifact @dagger(input) data: { - string + string @dagger(output) #up: [ op.#Load & {"from": from}, op.#Export & {source: path}, @@ -48,12 +48,12 @@ import ( } #Glob: { - glob: !="" - filenames: [...string] - from: dagger.#Artifact - files: (_#glob & {"glob": glob, "from": from}).data + glob: !="" @dagger(input) + filenames: [...string] @dagger(input) + from: dagger.#Artifact @dagger(input) + files: (_#glob & {"glob": glob, "from": from}).data @dagger(output) // trim suffix because ls always ends with newline - filenames: strings.Split(strings.TrimSuffix(files, "\n"), "\n") + filenames: strings.Split(strings.TrimSuffix(files, "\n"), "\n") @dagger(output) } _#glob: { diff --git a/stdlib/gcp/gcp.cue b/stdlib/gcp/gcp.cue index 797f5f16..97b7c4a0 100644 --- a/stdlib/gcp/gcp.cue +++ b/stdlib/gcp/gcp.cue @@ -7,9 +7,9 @@ import ( // Base Google Cloud Config #Config: { // GCP region - region: string + region: string @dagger(input) // GCP projcet - project: string + project: string @dagger(input) // GCP service key - serviceKey: dagger.#Secret + serviceKey: dagger.#Secret @dagger(input) } diff --git a/stdlib/gcp/gcr/gcr.cue b/stdlib/gcp/gcr/gcr.cue index b855a96e..6a7d02b2 100644 --- a/stdlib/gcp/gcr/gcr.cue +++ b/stdlib/gcp/gcr/gcr.cue @@ -13,7 +13,7 @@ import ( // GCR credentials username: "oauth2accesstoken" secret: { - string + string @dagger(output) #up: [ op.#Load & { diff --git a/stdlib/gcp/gke/gke.cue b/stdlib/gcp/gke/gke.cue index 89ba4641..9afa0d71 100644 --- a/stdlib/gcp/gke/gke.cue +++ b/stdlib/gcp/gke/gke.cue @@ -11,15 +11,15 @@ import ( config: gcp.#Config // GKE cluster name - clusterName: string + clusterName: string @dagger(input) // Kubectl version - version: *"v1.19.9" | string + version: *"v1.19.9" | string @dagger(input) // kubeconfig is the generated kube configuration file kubeconfig: { // FIXME There is a problem with dagger.#Secret type - string + string @dagger(output) #up: [ op.#Load & { diff --git a/stdlib/git/git.cue b/stdlib/git/git.cue index 33de44c1..569360fa 100644 --- a/stdlib/git/git.cue +++ b/stdlib/git/git.cue @@ -7,9 +7,9 @@ import ( // A git repository #Repository: { - remote: string - ref: string - subdir: string | *"" + remote: string @dagger(input) + ref: string @dagger(input) + subdir: string | *"" @dagger(input) #up: [ op.#FetchGit & { diff --git a/stdlib/go/go.cue b/stdlib/go/go.cue index a183ae54..82f11e7b 100644 --- a/stdlib/go/go.cue +++ b/stdlib/go/go.cue @@ -11,8 +11,8 @@ import ( // A standalone go environment #Container: { // Go version to use - version: *"1.16" | string - source: dagger.#Artifact + version: *"1.16" | string @dagger(input) + source: dagger.#Artifact @dagger(input) os.#Container & { env: CGO_ENABLED: "0" @@ -38,16 +38,16 @@ import ( #Go: { // Go version to use - version: *"1.16" | string + version: *"1.16" | string @dagger(input) // Arguments to the Go binary - args: [...string] + args: [...string] @dagger(input) // Source Directory to build - source: dagger.#Artifact + source: dagger.#Artifact @dagger(input) // Environment variables - env: [string]: string + env: [string]: string @dagger(input) #up: [ op.#FetchContainer & { @@ -70,30 +70,30 @@ import ( #Build: { // Go version to use - version: *#Go.version | string + version: *#Go.version | string @dagger(input) // Source Directory to build - source: dagger.#Artifact + source: dagger.#Artifact @dagger(input) // Packages to build - packages: *"." | string + packages: *"." | string @dagger(input) // Target architecture - arch: *"amd64" | string + arch: *"amd64" | string @dagger(input) // Target OS - os: *"linux" | string + os: *"linux" | string @dagger(input) // Build tags to use for building - tags: *"" | string + tags: *"" | string @dagger(input) // LDFLAGS to use for linking - ldflags: *"" | string + ldflags: *"" | string @dagger(input) // Specify the targeted binary name - output: string + output: string @dagger(output) - env: [string]: string + env: [string]: string @dagger(input) #up: [ op.#Copy & { @@ -111,13 +111,13 @@ import ( #Test: { // Go version to use - version: *#Go.version | string + version: *#Go.version | string @dagger(input) // Source Directory to build - source: dagger.#Artifact + source: dagger.#Artifact @dagger(input) // Packages to test - packages: *"." | string + packages: *"." | string @dagger(input) #Go & { "version": version diff --git a/stdlib/js/yarn/yarn.cue b/stdlib/js/yarn/yarn.cue index 09e020e1..fee532c0 100644 --- a/stdlib/js/yarn/yarn.cue +++ b/stdlib/js/yarn/yarn.cue @@ -13,26 +13,26 @@ import ( // A Yarn package. #Package: { // Application source code - source: dagger.#Artifact + source: dagger.#Artifact @dagger(input) // Environment variables - env: [string]: string + env: [string]: string @dagger(input) // Write the contents of `environment` to this file, // in the "envfile" format. - writeEnvFile: string | *"" + writeEnvFile: string | *"" @dagger(input) // Read build output from this directory // (path must be relative to working directory). - buildDir: string | *"build" + buildDir: string | *"build" @dagger(input) // Run this yarn script - script: string | *"build" + script: string | *"build" @dagger(input) build: os.#Dir & { from: ctr path: "/build" - } + } @dagger(output) ctr: os.#Container & { image: alpine.#Image & { diff --git a/stdlib/kubernetes/helm/helm.cue b/stdlib/kubernetes/helm/helm.cue index d822ae9e..d821bd42 100644 --- a/stdlib/kubernetes/helm/helm.cue +++ b/stdlib/kubernetes/helm/helm.cue @@ -11,47 +11,47 @@ import ( // Install a Helm chart #Chart: { // Helm deployment name - name: string + name: string @dagger(input) // Helm chart to install from source - chartSource: dagger.#Artifact + chartSource: dagger.#Artifact @dagger(input) // Helm chart to install from repository - chart?: string + chart?: string @dagger(input) // Helm chart repository (defaults to stable) - repository: *"https://charts.helm.sh/stable" | string + repository: *"https://charts.helm.sh/stable" | string @dagger(input) // Helm values (either a YAML string or a Cue structure) - values?: string + values?: string @dagger(input) // Kubernetes Namespace to deploy to - namespace: string + namespace: string @dagger(input) // Helm action to apply - action: *"installOrUpgrade" | "install" | "upgrade" + action: *"installOrUpgrade" | "install" | "upgrade" @dagger(input) // time to wait for any individual Kubernetes operation (like Jobs for hooks) - timeout: string | *"5m" + timeout: string | *"5m" @dagger(input) // if set, will wait until all Pods, PVCs, Services, and minimum number of // Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state // before marking the release as successful. // It will wait for as long as timeout - wait: *true | bool + wait: *true | bool @dagger(input) // if set, installation process purges chart on fail. // The wait option will be set automatically if atomic is used - atomic: *true | bool + atomic: *true | bool @dagger(input) // Kube config file - kubeconfig: dagger.#Secret + kubeconfig: dagger.#Secret @dagger(input) // Helm version - version: *"3.5.2" | string + version: *"3.5.2" | string @dagger(input) // Kubectl version - kubectlVersion: *"v1.19.9" | string + kubectlVersion: *"v1.19.9" | string @dagger(input) #up: [ op.#Load & { diff --git a/stdlib/kubernetes/kubernetes.cue b/stdlib/kubernetes/kubernetes.cue index 4cac9ac0..6633b5ed 100644 --- a/stdlib/kubernetes/kubernetes.cue +++ b/stdlib/kubernetes/kubernetes.cue @@ -47,19 +47,19 @@ import ( #Apply: { // Kubernetes config to deploy - source: dagger.#Artifact + source: dagger.#Artifact @dagger(input) // Kubernetes config to deploy inlined in a string - sourceInline?: string + sourceInline?: string @dagger(input) // Kubernetes Namespace to deploy to - namespace: string + namespace: string @dagger(input) // Version of kubectl client - version: *"v1.19.9" | string + version: *"v1.19.9" | string @dagger(input) // Kube config file - kubeconfig: dagger.#Secret + kubeconfig: dagger.#Secret @dagger(input) #code: #""" kubectl create namespace "$KUBE_NAMESPACE" || true diff --git a/stdlib/kubernetes/kustomize/kustomization.cue b/stdlib/kubernetes/kustomize/kustomization.cue index 9aa5dec0..dc7e6b93 100644 --- a/stdlib/kubernetes/kustomize/kustomization.cue +++ b/stdlib/kubernetes/kustomize/kustomization.cue @@ -8,7 +8,7 @@ import ( #Kustomization: { // Kustomize binary version - version: *"v3.8.7" | string + version: *"v3.8.7" | string @dagger(input) #code: #""" [ -e /usr/local/bin/kubectl ] || { @@ -46,13 +46,13 @@ import ( // Apply a Kubernetes Kustomize folder #Kustomize: { // Kubernetes source - source: dagger.#Artifact + source: dagger.#Artifact @dagger(input) // Optional Kustomization file - kustomization: string + kustomization: string @dagger(input) // Kustomize binary version - version: *"v3.8.7" | string + version: *"v3.8.7" | string @dagger(input) #code: #""" cp /kustomization.yaml /source | true diff --git a/stdlib/netlify/netlify.cue b/stdlib/netlify/netlify.cue index be977f5e..c141da2d 100644 --- a/stdlib/netlify/netlify.cue +++ b/stdlib/netlify/netlify.cue @@ -10,10 +10,10 @@ import ( #Account: { // Use this Netlify account name // (also referred to as "team" in the Netlify docs) - name: string | *"" + name: string | *"" @dagger(input) // Netlify authentication token - token: dagger.#Secret + token: dagger.#Secret @dagger(input) } // A Netlify site @@ -22,16 +22,16 @@ import ( account: #Account // Contents of the application to deploy - contents: dagger.#Artifact + contents: dagger.#Artifact @dagger(input) // Deploy to this Netlify site - name: string + name: string @dagger(input) // Host the site at this address - customDomain?: string + customDomain?: string @dagger(input) // Create the Netlify site if it doesn't exist? - create: bool | *true + create: bool | *true @dagger(input) // Website url url: { @@ -39,7 +39,7 @@ import ( from: ctr path: "/netlify/url" } - }.read.data + }.read.data @dagger(output) // Unique Deploy URL deployUrl: { @@ -47,7 +47,7 @@ import ( from: ctr path: "/netlify/deployUrl" } - }.read.data + }.read.data @dagger(output) // Logs URL for this deployment logsUrl: { @@ -55,7 +55,7 @@ import ( from: ctr path: "/netlify/logsUrl" } - }.read.data + }.read.data @dagger(output) ctr: os.#Container & { image: alpine.#Image & { diff --git a/stdlib/terraform/terraform.cue b/stdlib/terraform/terraform.cue index d2d32c53..55310d26 100644 --- a/stdlib/terraform/terraform.cue +++ b/stdlib/terraform/terraform.cue @@ -8,13 +8,13 @@ import ( ) #Configuration: { - version: string | *"latest" + version: string | *"latest" @dagger(input) - source: dagger.#Artifact + source: dagger.#Artifact @dagger(input) - tfvars?: [string]: _ + tfvars?: [string]: _ @dagger(input) - env: [string]: string + env: [string]: string @dagger(input) state: #up: [ op.#FetchContainer & { @@ -61,5 +61,5 @@ import ( }, ] ... - } + } @dagger(output) } From a4167dc3f49d1009b4c54c0d45ff7e4841b58fff Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Wed, 26 May 2021 12:28:24 +0200 Subject: [PATCH 6/8] cue fmt Signed-off-by: Sam Alba --- stdlib/aws/cloudformation/cloudformation.cue | 8 +++++-- stdlib/aws/ecs/run-task.cue | 4 +++- stdlib/aws/eks/eks.cue | 4 ++-- stdlib/docker/docker.cue | 2 +- stdlib/file/file.cue | 22 ++++++++++---------- stdlib/gcp/gcr/gcr.cue | 4 ++-- stdlib/gcp/gke/gke.cue | 4 ++-- stdlib/git/git.cue | 4 ++-- stdlib/go/go.cue | 8 +++++-- stdlib/js/yarn/yarn.cue | 4 +++- stdlib/netlify/netlify.cue | 18 ++++++++-------- stdlib/terraform/terraform.cue | 8 +++++-- 12 files changed, 53 insertions(+), 37 deletions(-) diff --git a/stdlib/aws/cloudformation/cloudformation.cue b/stdlib/aws/cloudformation/cloudformation.cue index 91f85361..8a22f197 100644 --- a/stdlib/aws/cloudformation/cloudformation.cue +++ b/stdlib/aws/cloudformation/cloudformation.cue @@ -20,7 +20,9 @@ import ( stackName: string @dagger(input) // Stack parameters - parameters: [string]: _ @dagger(input) + parameters: { + ... + } // Behavior when failure to create/update the Stack onFailure: *"DO_NOTHING" | "ROLLBACK" | "DELETE" @dagger(input) @@ -44,7 +46,9 @@ import ( } } - outputs: [string]: string @dagger(output) + outputs: { + [string]: string @dagger(output) + } outputs: #up: [ op.#Load & { diff --git a/stdlib/aws/ecs/run-task.cue b/stdlib/aws/ecs/run-task.cue index a6a5a656..c86907eb 100644 --- a/stdlib/aws/ecs/run-task.cue +++ b/stdlib/aws/ecs/run-task.cue @@ -17,7 +17,9 @@ import ( taskArn: string @dagger(input) // Environment variables of the task - containerEnvironment: [string]: string @dagger(input) + containerEnvironment: { + [string]: string @dagger(input) + } // Container name containerName: string @dagger(input) diff --git a/stdlib/aws/eks/eks.cue b/stdlib/aws/eks/eks.cue index f7aa12a1..64dfa53a 100644 --- a/stdlib/aws/eks/eks.cue +++ b/stdlib/aws/eks/eks.cue @@ -19,7 +19,7 @@ import ( // kubeconfig is the generated kube configuration file kubeconfig: { // FIXME There is a problem with dagger.#Secret type - string @dagger(output) + string #up: [ op.#Load & { @@ -62,5 +62,5 @@ import ( format: "string" }, ] - } + } @dagger(output) } diff --git a/stdlib/docker/docker.cue b/stdlib/docker/docker.cue index 8a432bf2..eb99429b 100644 --- a/stdlib/docker/docker.cue +++ b/stdlib/docker/docker.cue @@ -46,7 +46,7 @@ import ( // Build a Docker image from the provided Dockerfile contents // FIXME: incorporate into #Build #ImageFromDockerfile: { - dockerfile: string @dagger(input) + dockerfile: string @dagger(input) context: dagger.#Artifact @dagger(input) #up: [ diff --git a/stdlib/file/file.cue b/stdlib/file/file.cue index 6c2cd1e3..1e811272 100644 --- a/stdlib/file/file.cue +++ b/stdlib/file/file.cue @@ -7,8 +7,8 @@ import ( ) #Create: { - filename: !="" @dagger(input) - permissions: int | *0o644 @dagger(input) + filename: !="" @dagger(input) + permissions: int | *0o644 @dagger(input) contents: string | bytes @dagger(input) #up: [ @@ -17,9 +17,9 @@ import ( } #Append: { - filename: !="" @dagger(input) - permissions: int | *0o644 @dagger(input) - contents: string | bytes @dagger(input) + filename: !="" @dagger(input) + permissions: int | *0o644 @dagger(input) + contents: string | bytes @dagger(input) from: dagger.#Artifact @dagger(input) orig: (#read & {path: filename, "from": from}).data @dagger(output) @@ -30,27 +30,27 @@ import ( } #Read: { - filename: !="" @dagger(input) + filename: !="" @dagger(input) from: dagger.#Artifact @dagger(input) - contents: (#read & {path: filename, "from": from}).data @dagger(output) + contents: (#read & {path: filename, "from": from}).data @dagger(output) } #read: { - path: !="" @dagger(input) + path: !="" @dagger(input) from: dagger.#Artifact @dagger(input) data: { - string @dagger(output) + string #up: [ op.#Load & {"from": from}, op.#Export & {source: path}, ] - } + } @dagger(output) } #Glob: { glob: !="" @dagger(input) filenames: [...string] @dagger(input) - from: dagger.#Artifact @dagger(input) + from: dagger.#Artifact @dagger(input) files: (_#glob & {"glob": glob, "from": from}).data @dagger(output) // trim suffix because ls always ends with newline filenames: strings.Split(strings.TrimSuffix(files, "\n"), "\n") @dagger(output) diff --git a/stdlib/gcp/gcr/gcr.cue b/stdlib/gcp/gcr/gcr.cue index 6a7d02b2..aebc1149 100644 --- a/stdlib/gcp/gcr/gcr.cue +++ b/stdlib/gcp/gcr/gcr.cue @@ -13,7 +13,7 @@ import ( // GCR credentials username: "oauth2accesstoken" secret: { - string @dagger(output) + string #up: [ op.#Load & { @@ -40,5 +40,5 @@ import ( source: "/token.txt" }, ] - } + } @dagger(output) } diff --git a/stdlib/gcp/gke/gke.cue b/stdlib/gcp/gke/gke.cue index 9afa0d71..69438fea 100644 --- a/stdlib/gcp/gke/gke.cue +++ b/stdlib/gcp/gke/gke.cue @@ -19,7 +19,7 @@ import ( // kubeconfig is the generated kube configuration file kubeconfig: { // FIXME There is a problem with dagger.#Secret type - string @dagger(output) + string #up: [ op.#Load & { @@ -54,7 +54,7 @@ import ( format: "string" }, ] - } + } @dagger(output) } #Code: #""" diff --git a/stdlib/git/git.cue b/stdlib/git/git.cue index 569360fa..35713db0 100644 --- a/stdlib/git/git.cue +++ b/stdlib/git/git.cue @@ -7,8 +7,8 @@ import ( // A git repository #Repository: { - remote: string @dagger(input) - ref: string @dagger(input) + remote: string @dagger(input) + ref: string @dagger(input) subdir: string | *"" @dagger(input) #up: [ diff --git a/stdlib/go/go.cue b/stdlib/go/go.cue index 82f11e7b..0fc62547 100644 --- a/stdlib/go/go.cue +++ b/stdlib/go/go.cue @@ -47,7 +47,9 @@ import ( source: dagger.#Artifact @dagger(input) // Environment variables - env: [string]: string @dagger(input) + env: { + [string]: string @dagger(input) + } #up: [ op.#FetchContainer & { @@ -93,7 +95,9 @@ import ( // Specify the targeted binary name output: string @dagger(output) - env: [string]: string @dagger(input) + env: { + [string]: string @dagger(input) + } #up: [ op.#Copy & { diff --git a/stdlib/js/yarn/yarn.cue b/stdlib/js/yarn/yarn.cue index fee532c0..81b9bbed 100644 --- a/stdlib/js/yarn/yarn.cue +++ b/stdlib/js/yarn/yarn.cue @@ -16,7 +16,9 @@ import ( source: dagger.#Artifact @dagger(input) // Environment variables - env: [string]: string @dagger(input) + env: { + [string]: string @dagger(input) + } // Write the contents of `environment` to this file, // in the "envfile" format. diff --git a/stdlib/netlify/netlify.cue b/stdlib/netlify/netlify.cue index c141da2d..d9618e9d 100644 --- a/stdlib/netlify/netlify.cue +++ b/stdlib/netlify/netlify.cue @@ -36,25 +36,25 @@ import ( // Website url url: { os.#File & { - from: ctr - path: "/netlify/url" - } + from: ctr + path: "/netlify/url" + } }.read.data @dagger(output) // Unique Deploy URL deployUrl: { os.#File & { - from: ctr - path: "/netlify/deployUrl" - } + from: ctr + path: "/netlify/deployUrl" + } }.read.data @dagger(output) // Logs URL for this deployment logsUrl: { os.#File & { - from: ctr - path: "/netlify/logsUrl" - } + from: ctr + path: "/netlify/logsUrl" + } }.read.data @dagger(output) ctr: os.#Container & { diff --git a/stdlib/terraform/terraform.cue b/stdlib/terraform/terraform.cue index 55310d26..9ce68852 100644 --- a/stdlib/terraform/terraform.cue +++ b/stdlib/terraform/terraform.cue @@ -12,9 +12,13 @@ import ( source: dagger.#Artifact @dagger(input) - tfvars?: [string]: _ @dagger(input) + tfvars?: { + ... + } - env: [string]: string @dagger(input) + env: { + [string]: string @dagger(input) + } state: #up: [ op.#FetchContainer & { From 3ae6b6f01b7deec6664be98fdb2cc14790cf0130 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Wed, 26 May 2021 12:33:08 +0200 Subject: [PATCH 7/8] test: cue fmt Signed-off-by: Sam Alba --- tests/cli/input/list/main.cue | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/cli/input/list/main.cue b/tests/cli/input/list/main.cue index 30d08eee..794c07be 100644 --- a/tests/cli/input/list/main.cue +++ b/tests/cli/input/list/main.cue @@ -2,12 +2,12 @@ package main import ( "dagger.io/dagger" - "dagger.io/aws" + "dagger.io/aws" ) awsConfig: aws.#Config & { - // force region - region: "us-east-1" + // force region + region: "us-east-1" } #A: { @@ -28,17 +28,17 @@ awsConfig: aws.#Config & { num: int | *42 @dagger(input) numNotInput: int - // aws config - cfg: awsConfig + // aws config + cfg: awsConfig } cfgInline: { - #A + #A } cfg: #A & { - // force this key - num: 21 + // force this key + num: 21 } cfg2: cfg From 06ed139080a1865d2adf8f45664e2a0da58cf960 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Wed, 26 May 2021 13:45:10 +0200 Subject: [PATCH 8/8] tests: moved cli input test to new syntax Signed-off-by: Sam Alba --- tests/cli.bats | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/cli.bats b/tests/cli.bats index 103c10e6..e5e0f81f 100644 --- a/tests/cli.bats +++ b/tests/cli.bats @@ -287,7 +287,9 @@ setup() { } @test "dagger input list" { - "$DAGGER" new --plan-dir "$TESTDIR"/cli/input/list "list" + "$DAGGER" init + + dagger_new_with_plan list "$TESTDIR"/cli/input/list "$DAGGER" input text cfg.str "foobar" -e "list" out="$("$DAGGER" input list -e "list")"