Skip to content

Actions inside if statements #1255

@shykes

Description

@shykes

Problem

There may or may not be a problem. It depends on whether the desired behavior is already supported.

Desired behavior

Dagger should support conditional execution of actions, using the standard if statement in CUE. Importantly, it should be possible to reference the output of other tasks in the if statement, and have task dependency be respected.

For example:

arch: docker.#Run & {
  script: “uname -m > /arch”
  output: files: “/arch”: _
}

if arch.output.files.”/arch”.contents == “x86_64\n” {
  ftw: docker.#Run & {
    script: “echo x86 FTW!”
  }
}

Note that the ftw action itself does not reference arch, but the surrounding if statement does. Therefore, there is a dependency between them.

Metadata

Metadata

Assignees

No one assigned

    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