#Accessing directory when invoking as remote module

1 messages ยท Page 1 of 1 (latest)

gritty ginkgo
#

I have a project initialized with .dagger directory.
I am calling from another repo.
I was hoping the .dagger/ module being called since it's not in a monorepo, would have access to ${repo}/chart but didn't seem to work, as only had access to the directory if I moved it into .dagger/ .

While I know this behavior is for modules, I thought maybe .dagger/ with a single module in the repo might have access to the remaining directories in the repo root.

{
  "name": "ragnarok-chart",
  "engineVersion": "v0.18.18",
  "sdk": {
    "source": "go"
  },
  "source": ".dagger"
}

Is there something I can tweak to make the directory ./chart work without having to be .dagger/chart?


    // Mount the chart directory from the current module's source at /chart.
    // We assume the chart lives in ./chart within the repo containing .dagger 
    chartDir := dag.CurrentModule().Source().Directory("chart")
pure falcon
#
func (m *MyModule) dostuff(
  // +defaultPath="/chart"
  chart *dagger.Directory,
) {
 // ...
}
gritty ginkgo
#

Ok, so I made it a dagger.Directory, but didn't do a default path.
So essentially this behavior is expected relative to root of repo when I put /chart as the defaultpath?

  • That feels like it would work, albeit it's a bit of magic I wouldn't have discovered without your tip ๐Ÿ™‚
  • Since it's rooted with defaultPath i don't need to provide this as an input then correct?
  • If I wanted to achieve that without a defaultPath and just by passing it in, is it possible? Prior to this I passed in the path ./charts... and it couldn't find it, so unclear why defaultPath is meant to change this behavior from the host

appreciate the help!

pure falcon
#

Since it's rooted with defaultPath i don't need to provide this as an input then correct?

Yes correct.

#

If I wanted to achieve that without a defaultPath and just by passing it in, is it possible? Prior to this I passed in the path ./charts... and it couldn't find it, so unclear why defaultPath is meant to change this behavior from the host

This is part of what we want to clean up.

At the moment, from the CLI you can pass a Directory as either:

  1. A path on your local (host) system. Absolute is rooted in your system root, relative is from your system workdir.
  2. An absolute remote git address, eg. https://github.com/dagger/dagger#main:cmd/dagger

There is no way to pass a path relative to the module you loaded. Instead:

  • if your module is loaded from the local filesystem, you pass a local path that happens to be inside that module. Eg. dagger -m ./my/module call foo --chart ./my/module/chart
  • If your module is loaded from a remote git address, you pass a git address that happens to be inside that modue. Eg dagger -m github.com/dagger/dagger#main:cmd/dagger build --source=github.com/dagger/dagger#main:cmd/dagger. Note that the git references are guaranteed to resolve to the same commit (no risk of main resolving to 2 different commits) because that lookup is cached once per dagger session.

But yeah, for now it's much simpler to rely on the default value when you want a directory argument to be coupled to the module ๐Ÿ™‚

gritty ginkgo
#

does this mean you can use that syntax to get a specific directory (not module related) with the same "#" in the path for the remote source?

pure falcon
gritty ginkgo
#

sorry, is that syntax applicable for say

i want remote git path of dagger.Directory which could be https://dev.azure.com/myorg/projectname/_git/mychartrepo@mybranch:mychartdirectory or https://dev.azure.com/myorg/projectname/_git/mychartrepo#mybranch:mychartdirectory ? I tried to find this in last few weeks recalling something about being able to checkout a specific directory but couldn't find it. I tend to use the go module syntax version and you just showed me a dagger specific variation I think

pure falcon
#

When passing the address of a dagger module, you can use both the Go-style notation (github.com/foo/bar@baz, and the git-address notation (https://github.com/foo#baz:bar)