-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1849 from rsteube/add-tofu
added tofu
- Loading branch information
Showing
45 changed files
with
1,225 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package action | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/terraform" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func ActionResources(cmd *cobra.Command) carapace.Action { | ||
return carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
if f := cmd.Flag("state"); f != nil { | ||
return terraform.ActionResources(f.Value.String()) | ||
} | ||
return terraform.ActionResources("") | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var applyCmd = &cobra.Command{ | ||
Use: "apply [options] [PLAN]", | ||
Short: "Create or update infrastructure", | ||
GroupID: "main", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(applyCmd).Standalone() | ||
|
||
applyCmd.Flags().BoolS("auto-approve", "auto-approve", false, "Skip interactive approval of plan before applying") | ||
applyCmd.Flags().StringS("backup", "backup", "", "Path to backup the existing state file before modifying") | ||
applyCmd.Flags().BoolS("compact-warnings", "compact-warnings", false, "Show wanings in a more compact form that includes only the summary messages") | ||
applyCmd.Flags().BoolS("destroy", "destroy", false, "Destroy Terraform-managed infrastructure") | ||
applyCmd.Flags().BoolS("input", "input", false, "Ask for input for variables if not directly set") | ||
applyCmd.Flags().BoolS("lock", "lock", false, "Don't hold a state lock during the operation dangerous if others might concurrently run commands against the same workspace.") | ||
applyCmd.Flags().StringS("lock-timeout", "lock-timeout", "", "Duration to retry a state lock") | ||
applyCmd.Flags().BoolS("no-color", "no-color", false, "If specified, output won't contain any color") | ||
applyCmd.Flags().StringS("parallelism", "parallelism", "", "Limit the number of parallel resource operations") | ||
applyCmd.Flags().StringS("state", "state", "", "Path to read and save state") | ||
applyCmd.Flags().StringS("state-out", "state-out", "", "Path to write state to that is different than \"-state\"") | ||
rootCmd.AddCommand(applyCmd) | ||
|
||
applyCmd.Flag("backup").NoOptDefVal = " " | ||
applyCmd.Flag("lock-timeout").NoOptDefVal = " " | ||
applyCmd.Flag("parallelism").NoOptDefVal = " " | ||
applyCmd.Flag("state").NoOptDefVal = " " | ||
applyCmd.Flag("state-out").NoOptDefVal = " " | ||
|
||
carapace.Gen(applyCmd).FlagCompletion(carapace.ActionMap{ | ||
"backup": carapace.ActionFiles(), | ||
"state": carapace.ActionFiles(), | ||
"state-out": carapace.ActionFiles(), | ||
}) | ||
|
||
carapace.Gen(applyCmd).PositionalCompletion( | ||
carapace.ActionFiles(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var consoleCmd = &cobra.Command{ | ||
Use: "console [options]", | ||
Short: "Try Terraform expressions at an interactive command prompt", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(consoleCmd).Standalone() | ||
|
||
consoleCmd.Flags().StringS("state", "state", "", "Legacy option for the local backend only") | ||
consoleCmd.Flags().StringArrayS("var", "var", []string{}, "Set a variable in the Terraform configuration") | ||
consoleCmd.Flags().StringS("var-file", "var-file", "", "Set variables in the Terraform configuration from a file") | ||
|
||
consoleCmd.Flag("state").NoOptDefVal = " " | ||
consoleCmd.Flag("var-file").NoOptDefVal = " " | ||
|
||
rootCmd.AddCommand(consoleCmd) | ||
|
||
carapace.Gen(consoleCmd).FlagCompletion(carapace.ActionMap{ | ||
"state": carapace.ActionFiles(), | ||
"var-file": carapace.ActionFiles(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/completers/tofu_completer/cmd/action" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var destroyCmd = &cobra.Command{ | ||
Use: "destroy [options]", | ||
Short: "Destroy previously-created infrastructure", | ||
GroupID: "main", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(destroyCmd).Standalone() | ||
|
||
// TODO copied flags from plan - documentation is insufficient regarding which are actually applicable to destroy as well | ||
|
||
destroyCmd.Flags().BoolS("compact-warnings", "compact-warnings", false, "Show warnings in a more compact form that includes only the summary messages.") | ||
destroyCmd.Flags().BoolS("destroy", "destroy", false, "Select the \"destroy\" planning mode.") | ||
destroyCmd.Flags().BoolS("detailed-exitcode", "detailed-exitcode", false, "Return detailed exit codes when the command exits.") | ||
destroyCmd.Flags().StringS("input", "input", "", "Ask for input for variables if not directly set.") | ||
destroyCmd.Flags().BoolS("lock", "lock", false, "Don't hold a state lock during the operation.") | ||
destroyCmd.Flags().StringS("lock-timeout", "lock-timeout", "", "Duration to retry a state lock.") | ||
destroyCmd.Flags().BoolS("no-color", "no-color", false, "If specified, output won't contain any color.") | ||
destroyCmd.Flags().StringS("out", "out", "", "Write a plan file to the given path.") | ||
destroyCmd.Flags().StringS("parallelism", "parallelism", "", "Limit the number of concurrent operations.") | ||
destroyCmd.Flags().BoolS("refresh", "refresh", false, "Skip checking for external changes to remote objects while creating the plan.") | ||
destroyCmd.Flags().BoolS("refresh-only", "refresh-only", false, "Select the \"refresh only\" planning mode.") | ||
destroyCmd.Flags().StringS("replace", "replace", "", "Force replacement of a particular resource instance using its resource address.") | ||
destroyCmd.Flags().StringS("state", "state", "", "A legacy option used for the local backend only.") | ||
destroyCmd.Flags().StringS("target", "target", "", "Limit the planning operation to only the given module, resource.") | ||
destroyCmd.Flags().StringS("var", "var", "", "Set a value for one of the input variables in the root module of the configuration.") | ||
destroyCmd.Flags().StringS("var-file", "var-file", "", "Load variable values from the given file.") | ||
rootCmd.AddCommand(destroyCmd) | ||
|
||
destroyCmd.Flag("input").NoOptDefVal = " " | ||
destroyCmd.Flag("lock-timeout").NoOptDefVal = " " | ||
destroyCmd.Flag("out").NoOptDefVal = " " | ||
destroyCmd.Flag("parallelism").NoOptDefVal = " " | ||
destroyCmd.Flag("replace").NoOptDefVal = " " | ||
destroyCmd.Flag("state").NoOptDefVal = " " | ||
destroyCmd.Flag("target").NoOptDefVal = " " | ||
destroyCmd.Flag("var-file").NoOptDefVal = " " | ||
|
||
carapace.Gen(destroyCmd).FlagCompletion(carapace.ActionMap{ | ||
"out": carapace.ActionFiles(), | ||
"replace": action.ActionResources(destroyCmd).MultiParts("."), | ||
"state": carapace.ActionFiles(), | ||
"target": action.ActionResources(destroyCmd).MultiParts("."), | ||
"var-file": carapace.ActionFiles(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var fmtCmd = &cobra.Command{ | ||
Use: "fmt [options] [target...]", | ||
Short: "Reformat your configuration in the standard style", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(fmtCmd).Standalone() | ||
|
||
fmtCmd.Flags().BoolS("check", "check", false, "Check if the input is formatted") | ||
fmtCmd.Flags().BoolS("diff", "diff", false, "Display diffs of formatting changes") | ||
fmtCmd.Flags().BoolS("list", "list", false, "Don't list files whose formatting differs") | ||
fmtCmd.Flags().BoolS("no-color", "no-color", false, "If specified, output won't contain any color") | ||
fmtCmd.Flags().BoolS("recursive", "recursive", false, "Also process files in subdirectories") | ||
fmtCmd.Flags().BoolS("write", "write", false, "Don't write to source files") | ||
rootCmd.AddCommand(fmtCmd) | ||
|
||
carapace.Gen(fmtCmd).PositionalAnyCompletion( | ||
carapace.ActionDirectories(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var forceUnlockCmd = &cobra.Command{ | ||
Use: "force-unlock LOCK_ID", | ||
Short: "Release a stuck lock on the current workspace", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(forceUnlockCmd).Standalone() | ||
|
||
forceUnlockCmd.Flags().BoolS("force", "force", false, "Don't ask for input for unlock confirmation.") | ||
rootCmd.AddCommand(forceUnlockCmd) | ||
|
||
// TODO lock_id positional completion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var getCmd = &cobra.Command{ | ||
Use: "get [options] PATH", | ||
Short: "Install or upgrade remote Terraform modules", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(getCmd).Standalone() | ||
|
||
getCmd.Flags().BoolS("no-color", "no-color", false, "Disable text coloring in the output.") | ||
getCmd.Flags().BoolS("update", "update", false, "Check already-downloaded modules for available updates") | ||
rootCmd.AddCommand(getCmd) | ||
|
||
carapace.Gen(getCmd).PositionalCompletion( | ||
carapace.ActionFiles(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var graphCmd = &cobra.Command{ | ||
Use: "graph [options]", | ||
Short: "Generate a Graphviz graph of the steps in an operation", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(graphCmd).Standalone() | ||
|
||
graphCmd.Flags().BoolS("draw-cycles", "draw-cycles", false, "Highlight any cycles in the graph with colored edges") | ||
graphCmd.Flags().StringS("plan", "plan", "", "Render graph using the specified plan file") | ||
graphCmd.Flags().StringS("type", "type", "", "Type of graph to output") | ||
rootCmd.AddCommand(graphCmd) | ||
|
||
graphCmd.Flag("plan").NoOptDefVal = " " | ||
graphCmd.Flag("type").NoOptDefVal = " " | ||
|
||
carapace.Gen(graphCmd).FlagCompletion(carapace.ActionMap{ | ||
"plan": carapace.ActionFiles(), | ||
"type": carapace.ActionValues("plan", "plan-refresh-only", "plan-destroy", "apply"), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var importCmd = &cobra.Command{ | ||
Use: "import [options] ADDR ID", | ||
Short: "Associate existing infrastructure with a Terraform resource", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(importCmd).Standalone() | ||
|
||
importCmd.Flags().StringS("config", "config", "", "Path to a directory of Terraform configuration files") | ||
importCmd.Flags().BoolS("ignore-remote-version", "ignore-remote-version", false, "A rare option used for the remote backend only") | ||
importCmd.Flags().BoolS("input", "input", false, "Disable interactive input prompts") | ||
importCmd.Flags().BoolS("lock", "lock", false, "Don't hold a state lock during the operation") | ||
importCmd.Flags().StringS("lock-timeout", "lock-timeout", "", "Duration to retry a state lock") | ||
importCmd.Flags().BoolS("no-color", "no-color", false, "If specified, output won't contain any color") | ||
importCmd.Flags().StringSliceS("var", "var", []string{}, "Set a variable in the Terraform configuration") | ||
importCmd.Flags().StringSliceS("var-file", "var-file", []string{}, "Set variables in the Terraform configuration from a file") | ||
rootCmd.AddCommand(importCmd) | ||
|
||
importCmd.Flag("config").NoOptDefVal = " " | ||
importCmd.Flag("lock-timeout").NoOptDefVal = " " | ||
importCmd.Flag("var-file").NoOptDefVal = " " | ||
|
||
carapace.Gen(importCmd).FlagCompletion(carapace.ActionMap{ | ||
"config": carapace.ActionDirectories(), | ||
"var-file": carapace.ActionFiles(), | ||
}) | ||
|
||
// TODO positional completion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var initCmd = &cobra.Command{ | ||
Use: "init [options]", | ||
Short: "Prepare your working directory for other commands", | ||
GroupID: "main", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(initCmd).Standalone() | ||
|
||
initCmd.Flags().BoolS("backend", "backend", false, "Configure the backend for this configuration") | ||
initCmd.Flags().StringSliceS("backend-config", "backend-config", []string{}, "Backend configuration") | ||
initCmd.Flags().BoolS("force-copy", "force-copy", false, "Suppress prompts about copying state data") | ||
initCmd.Flags().StringS("from-module", "from-module", "", "Copy the contents of the given module into the target directory before initialization") | ||
initCmd.Flags().BoolS("get", "get", false, "Download any modules for this configuration") | ||
initCmd.Flags().BoolS("ignore-remote-version", "ignore-remote-version", false, "A rare option used for the remote backend only") | ||
initCmd.Flags().BoolS("input", "input", false, "Ask for input if necessary") | ||
initCmd.Flags().BoolS("lock", "lock", false, "Don't hold a state lock during backend migration") | ||
initCmd.Flags().StringS("lockfile", "lockfile", "", "Set a dependency lockfile mode") | ||
initCmd.Flags().BoolS("migrate-state", "migrate-state", false, "Reconfigure the backend, and attempt to migrate any existing state") | ||
initCmd.Flags().BoolS("no-color", "no-color", false, "If specified, output won't contain any color") | ||
initCmd.Flags().BoolS("plugin-dir", "plugin-dir", false, "Directory containing plugin binaries") | ||
initCmd.Flags().BoolS("reconfigure", "reconfigure", false, "Reconfigure the backend, ignoring any saved configuration") | ||
initCmd.Flags().BoolS("upgrade", "upgrade", false, "ignore previously-downloaded objects and install the latest version allowed") | ||
rootCmd.AddCommand(initCmd) | ||
|
||
initCmd.Flag("backend-config").NoOptDefVal = " " | ||
initCmd.Flag("from-module").NoOptDefVal = " " | ||
initCmd.Flag("lockfile").NoOptDefVal = " " | ||
|
||
// TODO module completion | ||
carapace.Gen(initCmd).FlagCompletion(carapace.ActionMap{ | ||
"backend-config": carapace.ActionFiles(), | ||
"lockfile": carapace.ActionValues("readonly"), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/net" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var loginCmd = &cobra.Command{ | ||
Use: "login [hostname]", | ||
Short: "Obtain and save credentials for a remote host", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(loginCmd).Standalone() | ||
|
||
rootCmd.AddCommand(loginCmd) | ||
|
||
carapace.Gen(loginCmd).PositionalCompletion( | ||
net.ActionHosts(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/net" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var logoutCmd = &cobra.Command{ | ||
Use: "logout [hostname]", | ||
Short: "Remove locally-stored credentials for a remote host", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(logoutCmd).Standalone() | ||
|
||
rootCmd.AddCommand(logoutCmd) | ||
|
||
carapace.Gen(logoutCmd).PositionalCompletion( | ||
net.ActionHosts(), // TODO complete authorized hosts | ||
) | ||
} |
Oops, something went wrong.