Skip to content

Europa: output files #1317

@helderco

Description

@helderco

PR #1289 added support for plan outputs, but the contents need to be an #FS.

If you have a string to save, you have to go through #WriteFile:

// plans/gen/dagger.cue
package main

import (
    "alpha.dagger.io/europa/dagger/engine"
    "encoding/yaml"
)

engine.#Plan & {
    actions: {
        scratch: engine.#Scratch

        apps: [string]: #App & {
            output: _  // compose in CUE
            compose: engine.#WriteFile & {
                input: scratch.output
                path: "/compose.yaml"
                contents: yaml.Marshal(output)
            }
        }
    }

    for app, config in actions.apps {
        outputs: directories: "\(app)": {
            contents: config.compose.output
            dest: "../../apps/\(app)"  // output to: apps/<app>/compose.yaml
        }
    }
}

But I think this will be common enough that also supporting string directly is justified, maybe under files:

// europa/dagger/engine/plan.cue
#DAG: {
        ...
    // Send outputs to the client
    outputs: {
        directories: [name=string]: _#outputDirectory
        files: [name=string]: _#outputFile
    }
}

_#outputFile: {
	$dagger: task: _name: "OutputFile"

	// File contents to export
	contents: string

	// Export to this path ON THE CLIENT MACHINE
	dest: string
}
// plans/gen/dagger.cue
package main

import (
    "alpha.dagger.io/europa/dagger/engine"
    "encoding/yaml"
)

engine.#Plan & {
    actions: {
        apps: [string]: #App
    }

    for app, config in actions.apps {
        outputs: files: "\(app)": {
            contents: yaml.Marshal(config.output)
            dest: "../../apps/\(app)/compose.yaml"  // output to: apps/<app>/compose.yaml
        }
    }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions