#dagger.File from root of the project

1 messages · Page 1 of 1 (latest)

vapid ridge
#

So this works when I copy my .golangci.yaml inside the dagger module.

config := dag.CurrentModule().Source().File(".golangci.yaml")

But I want that file inside the root of the project, I tried:

config := dag.CurrentModule().Source().Directory("..").File(".golangci.yaml")

But that doesn't seem to work, I think cause the file doesn't get transfered to the engine.

Thanks!

shell hazel
#

if you need files from the root of your project, you'll have to pass them as function arguments

vapid ridge
#

@shell hazel thanks for the quick response as always! I don't want to give the config on each lint request, is there a way to abstract that away for the user?

shell hazel
#

it's not documented yet (we're writing the docs at this moment), but the idea is that you can specify a *dagger.File as a function argument and use the // +defaultPath pragma to set it whatever file you need

#

that way the user doesn't have to specify anything

vapid ridge
#

This would mean I would upload my whole repo to my dagger-engine and then later the code to lint, right?

shell hazel
vapid ridge
#

Ohh, so providing a context doesn't mean it gets uploaded. Ok, thats nice.

shell hazel
#

in this case you could only upload the .golangci-lint.yml file from the root of your repo

vapid ridge
#

I edited the file and line as i moved the dagger folder into .github 🙂

shell hazel
#

adding a new argument to that function with:

// +defaultPath="/.github/.golangci.yaml"
golangciConfig *dagger.File

I think that should be enough

clever lichen
#

It's not that the file is the context, but rather that the file can default to a path within your context dir (usually your git repo)

vapid ridge