Skip to content

Action API #1598

@shykes

Description

@shykes

Overview

I propose formalizing the concept of an action, and exposing it to developers in a new Action API.

Using the Action API, developers can:

  • Customize how the DAG is presented to the user at runtime (show actual actions instead of raw CUE tree or low-level tasks)
  • Synchronize actions: Support explicit dependency #940, Terminate an action #1249 , etc.
  • Make error messages more useful. The hierarchy of actions act as a "stack frame" with less noise than raw CUE errors

This proposal is one part of a 4-part bundle:

Proposed design

This is a work in progress. Fire at will.

#Action definition

package dagger

#Action: {
  _dagger: action: {
    // Unique ID assigned by engine. Use for synchronization
    id: #ID
    // Human-friendly human name (defaults to parent field name)
    name?: string
    // Long description (defaults to comments above parent field)
    description?: string
    // Print a message to the user before executing the action
    before?: string
    // Print a message to the user after executing the action
    after?: string
  }
  ...
}

// A unique object ID allocated at runtime
#ID: string

Usage example:

package main

import (
  "dagger.io"
)

dagger.#Plan & {
  actions: {
    // Not an action
    staging: {
      // This is an action
      deploy: {
        _dagger: action {
          description: "Deploy staging environment"
          after: """
              Staging deployed:
              Frontend: \(www.url)
              Backend: \(api.url)
              """
          }
          www: netlify.#Deploy & {
             ...
          }
          api: ecs.#Deploy & {
             ...
          }
      }
}

Synchronization

TODO

Core actions

Core actions implement the #Action interface, so their output can be customized, synchronized, etc. This is not yet implemented.

Related issues

Metadata

Metadata

Assignees

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