Skip to content

Simplify inputs and outputs #970

Closed
Closed

Description

@shykes

Context

Dagger has a feature called inputs and outputs. Any field can be annotated with the Cue attributes @dagger(input) or @dagger(output). This serves several purposes:

  • Identify data produced and consumed by a Dagger environment at runtime. Fields marked as inputs may receive data from external sources. Fields marked as outputs may be sent to external consumers.

  • Provide missing information about the "call convention" of a Cue definition. Just like a Go function has arguments and return values, a Cue definition has input fields and output fields. Cue does not differentiate between them, so dagger doc uses input and output annotations to generate more useful package documentation.

Problem

The inputs/outputs feature is a common source of confusion for several reasons:

  • It serves several different purposes, so it's difficult to explain and to understand.

  • It makes the package development experience worse. Manually setting the cue attributes is repetitive and error-prone; Forgetting or mistyping attributes will silently break the docs; everything is more verbose; more concepts to learn even for a basic package.

  • It makes the end-user experience worse. Package developers (who set the input/output attributes) don't know which fields will actually be consumed or produced by external sources in a given environment. And dagger can't accurately detect them either. The result is that all fields with @dagger(input) are listed by dagger input list. This makes the input discovery feature unusable on larger configurations.

Solution

NOTE: this solution depends on the environment schema proposal.

Solution

  1. Deprecate @dagger(input) and @dagger(output), and the helpers dagger.#Input and dagger.#Output
  2. Each environment may define an input and output schema, by setting the input and output fields in the environment schema.
  3. Leave out of scope the problem of auto-documenting input and output fields in packages. This is better solved upstream by Cue.

Example:

package acme

import (
  "alpha.dagger.io/dagger"
)

// A complete dev environment for the ACME application
#AcmeDevEnv: dagger.#Environment & {
  name: "acme-dev"
  description: "A complete dev environment for the ACME application"
  input: {
    git: {
        // Address of the git repository
        remote: string | *"https://github.com/acme/acme"
        // Git auth
        ssh: privateKey: dagger.#Secret
        https: {
          username: string
          password: dagger.#Secret
        }
    }
  }
  output: url: "https://\(dag.hostname)"

  // Internal DAG configuration
  dag: {
    repo: git.#Repository & {
        remote: input.git.remote
        auth: sshKey: input.git.ssh.privateKey
    }
    app: netlify.#Site & {
       // ...
    }
  }
}

Activity

  1. changed the title [-]WIP: Connectors: a simpler alternative to inputs & outputs[/-] [+]WIP: simplify inputs and outputs[/+] on Sep 15, 2021
  2. changed the title [-]WIP: simplify inputs and outputs[/-] [+]Simplify inputs and outputs[/+] on Sep 15, 2021
  3. shykes commented on Sep 15, 2021

    @shykes
    ContributorAuthor

    I narrowed down the scope significantly, to make this a more incremental improvement.

    cc @aluzzardi @samalba @grouville @talentedmrjones @TomChv

  4. aluzzardi commented on Feb 1, 2022

    @aluzzardi
    Contributor

    @shykes Is this already covered by Europa's #Plan?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions