#is there a way to specify a default for a source?

1 messages · Page 1 of 1 (latest)

olive pike
#

I have a Dagger function that looks like this:

func (m *Beeps) Build(
    ctx context.Context,
    source *dagger.Directory,
    // +optional
    release bool,
) *dagger.Container {

I'd like the source argument to be optional—it's uniformly . on the CLI—but I don't see a good way to do that in the docs. Am I missing something? Is there some security rule where you have to explicitly specify the directory you want to build from?

smoky pilot
#

You can specify default paths for direcotries indeed:
https://docs.dagger.io/api/arguments/#directories-and-files

Dagger Functions, just like regular functions, can accept arguments. In addition to basic types (string, boolean, integer, arrays...), Dagger also defines powerful core types which Dagger Functions can use for their arguments, such as Directory, Container, Service, Secret, and many more.

#
func (m *Beeps) Build(
    ctx context.Context,
    source *dagger.Directory,
    // +optional
    // +defaultPath="/"
    release bool,
) *dagger.Container {
#

will do what you're looking for