From d7a50a915a28d3c09ac93336dc7c98b78b0d860b Mon Sep 17 00:00:00 2001 From: rsteube Date: Thu, 15 Feb 2024 00:06:02 +0100 Subject: [PATCH] dagger: added environment variables --- completers/go_completer/cmd/mod_edit.go | 6 ++-- pkg/actions/env/dagger.go | 48 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 pkg/actions/env/dagger.go diff --git a/completers/go_completer/cmd/mod_edit.go b/completers/go_completer/cmd/mod_edit.go index 79784bb087..e8d2d5b88a 100644 --- a/completers/go_completer/cmd/mod_edit.go +++ b/completers/go_completer/cmd/mod_edit.go @@ -38,17 +38,15 @@ func init() { "exclude": golang.ActionModuleSearch(), "go": golang.ActionVersions(), "module": carapace.ActionFiles(), - "replace": carapace.ActionMultiParts("=", func(c carapace.Context) carapace.Action { + "replace": carapace.ActionMultiPartsN("=", 2, func(c carapace.Context) carapace.Action { switch len(c.Parts) { case 0: return golang.ActionModules(golang.ModuleOpts{Direct: true, Indirect: true}).Invoke(c).Suffix("=").ToA() - case 1: + default: return carapace.Batch( carapace.ActionDirectories().ChdirF(traverse.Parent("go.mod")), golang.ActionModuleSearch().Unless(condition.CompletingPath), ).ToA() - default: - return carapace.ActionValues() } }), "require": golang.ActionModuleSearch(), diff --git a/pkg/actions/env/dagger.go b/pkg/actions/env/dagger.go new file mode 100644 index 0000000000..28f463a2cd --- /dev/null +++ b/pkg/actions/env/dagger.go @@ -0,0 +1,48 @@ +package env + +import ( + "github.com/rsteube/carapace" + "github.com/rsteube/carapace-bin/pkg/conditions" +) + +func init() { + knownVariables["dagger"] = func() variables { + return variables{ + Condition: conditions.ConditionPath("dagger"), + Variables: map[string]string{ + "DAGGER_CHECK": "check if dagger is up to date", + "DAGGER_NAME": "project name", + "DAGGER_TEMPLATE": "Template name", + "DAGGER_PRIVATE_KEY_FILE": "Private ssh key", + "DAGGER_PRIVATE_KEY_PASSWORD": "Private ssh key password", + "DAGGER_UPDATE": "Update to latest version of specified packages", + "DAGGER_PLAN": "Path to plan", + "DAGGER_CACHE_FROM": "External cache sources", + "DAGGER_CACHE_TO": "Cache destinations", + "DAGGER_DRY_RUN": "Dry run mode", + "DAGGER_NO_CACHE": "Disable caching", + "DAGGER_OUTPUT": "File path to write the action's output values", + "DAGGER_OUTPUT_FORMAT": "Format for output values", + "DAGGER_PLATFORM": "Set target build platform", + "DAGGER_WITH": "Set value of dagger value at runtime", + }, + VariableCompletion: map[string]carapace.Action{ + "DAGGER_CHECK": carapace.ActionValues("1"), + "DAGGER_NAME": carapace.ActionValues(), + "DAGGER_TEMPLATE": carapace.ActionValues(), + "DAGGER_PRIVATE_KEY_FILE": carapace.ActionFiles(), + "DAGGER_PRIVATE_KEY_PASSWORD": carapace.ActionValues(), + "DAGGER_UPDATE": carapace.ActionValues("1"), + "DAGGER_PLAN": carapace.ActionDirectories(), + "DAGGER_CACHE_FROM": carapace.ActionValues(), + "DAGGER_CACHE_TO": carapace.ActionValues(), + "DAGGER_DRY_RUN": carapace.ActionValues("1"), + "DAGGER_NO_CACHE": carapace.ActionValues("1"), + "DAGGER_OUTPUT": carapace.ActionFiles(), + "DAGGER_OUTPUT_FORMAT": carapace.ActionValues("plain", "json", "yaml"), + "DAGGER_PLATFORM": carapace.ActionValues(), + "DAGGER_WITH": carapace.ActionValues(), + }, + } + } +}