#how to create func Build with no arguments but always uses current directory

1 messages ยท Page 1 of 1 (latest)

tawdry basalt
#

so i have

func (m *MyApp) Build(src *dagger.Directory) *dagger.Container {

i want to get rid of the argument and instead create a src var inside the function equivalent to running dagger call build --src=.

please help, how to create that src Directory var that points to current dir?

gaunt summit
# tawdry basalt so i have ``` func (m *MyApp) Build(src *dagger.Directory) *dagger.Container { `...

impossible to find in our current docs structure but here you go: 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.

tawdry basalt
#

ohh it looks quite complicated with the pragmas... i would like to avoid arguments at all. before there was smth like client.Host().Directory("."), but now it does not work... or am i doing smth wrong?

gaunt summit
tawdry basalt
#

thanks, i will try the recommended approach

gaunt summit
#

Once you get the hang of it it's quite pleasant ๐Ÿ™‚

tawdry basalt
#

thank you! it worked ๐Ÿ™‚

serene sparrow
serene sparrow
tawdry basalt
#

hello! i tried to find smth in the cookbook, with no success. then i walked through the quickstart, no luck. then i tried finding some clue in the dagger api, sdks section, no luck. i asked chatgpt, it recommended using "client.Host().Directory(".")`, it did not work. all the keywords i had in mind were "host" and "directory" so i used the search term "host directory" and could not find anything as well.

plucky stirrup
frozen cipher
#

... And also easier to grok

#

Raising the priority, will have a proposed fix by tomorrow

plucky stirrup
frozen cipher
tawdry basalt
frozen cipher
#

My understanding is that remote URLs are not supported. It's just for paths in the local context, relative to the dagger.json. Maybe @plucky stirrup has more info though

plucky stirrup
#

defaultPath is only to interact with the host filesystem

tawdry basalt
plucky stirrup
# gaunt summit wait really? I had no idea

you're correct Solomon, I was got confused by looking at the code with the directory argument flag parsing instead of the pragmas. So yes, @tawdry basalt sorry for the confusion, there's currently no way of providing a default repo as a directory argument ๐Ÿ˜ฌ

gaunt summit
#

but would be a great addition! And shouldn't be too hard I think

tawdry basalt
tawdry basalt
plucky stirrup
tawdry basalt