Skip to content

Environment schema #966

Closed
Closed

Description

@shykes

Problem

There is no Cue schema defining a Dagger environment: any Cue configuration is a valid Dagger configuration. This is both good and bad.

Good: Dagger is fully compatible with the nascent Cue ecosystem, which ensures that as the Cue package ecosystem grows and matures, Dagger developers automatically benefit.

Bad: there is no Cue API for Dagger-specific metadata about an environment. For example:

  • environment name and description
  • environment version
  • runtime requirements: capabilities, runtime version?
  • globally unique env ID
  • public keys and other secrets-related material
  • slugs, persistence keys or other material related to persistent state
  • user inputs / outputs?

Solution

Wrap the current schema-less Cue config (the DAG) inside a conventional schema (the Environment schema), and otherwise keep it unchanged. This gives us the best of both worlds:

  • Schema-less DAG composition, fully compatible with 100% of the Cue package ecosystem. Compose your CICD pipelines as easily as you compose code!
  • Easy access to environment metadata in a straightforward Cue schema. This pattern is familiar to the Cue community, which helps Cue developers graduate to Cue/Dagger developers.

Example

// acme.cue
package acme

import (
   “alpha.dagger.io/dagger”
   “alpha.dagger.io/os”
)

// A standard ACME development environment
#DevEnv: dagger.#Environment & {
  name: “acme-dev”
  description: “A standard ACME development environment”
  version: “0.0.1”
  // Fields under `runtime` are filled at runtime. They can be referenced in the DAG
  // NOTE: runtime fields can be mocked for testing and debugging :)
  runtime: {
      slug: _
  }
  // The good stuff starts below
  dag: {
    // The usual Dagger config goes here:
    hostname: “\(runtime.slug).dev.acme.corp”
    ctr: os.#Container & {
       // etc.
    }
  }
}

Schema definition

Activity

  1. added this to the milestone on Sep 11, 2021
  2. jlongtine commented on Sep 12, 2021

    @jlongtine
    Contributor

    @shykes Wrapping my head around this. General thought: I like the idea of creating a base schema help people understand where to begin.

    Would this schema be enforced at that base level?

    Like:

    [_]: dagger.#Environment
    

    I'll keep reading and thinking through it and see how it feels from a DX perspective.

    Also, realized this would only be for package in this file (probably), so users could still use other packages to create their own structures and schemas (and potentially import them into this file).

  3. aluzzardi commented on Jan 7, 2022

    @aluzzardi
    Contributor

    @shykes I believe this has been implemented in Europa. Closing now, please to re-open if I missed something!

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