Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Allow cache volumes as CLI parameters #6409

Closed
sagikazarmark opened this issue Jan 12, 2024 · 2 comments · Fixed by #6520
Closed

✨ Allow cache volumes as CLI parameters #6409

sagikazarmark opened this issue Jan 12, 2024 · 2 comments · Fixed by #6520

Comments

@sagikazarmark
Copy link
Contributor

What are you trying to do?

I have a module with the following constructor:

func New(
	// ...

	// Disable mounting cache volumes.
	disableCache Optional[bool],

	// Module cache volume to mount at /go/pkg/mod.
	modCache Optional[*CacheVolume],

	// Build cache volume to mount at ~/.cache/go-build.
	buildCache Optional[*CacheVolume],
) *Go {
	// ...
}

Currently, running this module in the CLI fails due to CacheVolume being an unsupported CLI argument:

❯ dagger call -m "github.com/sagikazarmark/daggerverse/go@main" --help
✘ load call ERROR [1.21s]
├ [0.56s] loading module
├ [0.65s] loading objects
┃ Error: unsupported object type "CacheVolume" for flag: mod-cache

Given cache volumes are created by their names (and that other types of objects, like files, are also referenced simply by their path or ID), I think it would be useful to do the same for cache volumes. In this instance:

❯ dagger call -m "github.com/sagikazarmark/daggerverse/go@main" --mod-cache go-build

An alternative I can imagine is adding a pragma comment for ignoring certain arguments from the CLI, but including them in the generated code. That's a temporary measure, but would still be easier for module developers, so they can utilize constructors instead of falling back to method chaining for tasks like setting cache.

Why is this important to you?

No response

How are you currently working around this?

I will probably remove those arguments from the constructor for now.

I might add them to the module API, but honestly, I'd rather not.

@helderco
Copy link
Contributor

I usually author the module to manage the cache volumes. Curious about the use cases for wanting to provide the cache volume's name in the CLI.

@sagikazarmark
Copy link
Contributor Author

I had some trouble with pipelines running in parallel using the same cache: #3345 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants