Skip to content

Commit

Permalink
Merge pull request #1042 from rsteube/add-terragrunt
Browse files Browse the repository at this point in the history
added terragrunt
  • Loading branch information
rsteube authored Apr 14, 2022
2 parents 080cef6 + 8d12ef2 commit 07de435
Show file tree
Hide file tree
Showing 10 changed files with 189 additions and 0 deletions.
24 changes: 24 additions & 0 deletions completers/terraform_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package cmd

import (
"os"
"strings"

"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)
Expand All @@ -18,6 +21,27 @@ func Execute() error {
})
return rootCmd.Execute()
}

func ActionExecute() carapace.Action {
return carapace.ActionCallback(func(c carapace.Context) carapace.Action {
// TODO don't change os.Args
backup := os.Args
carapace.Override(carapace.Opts{
LongShorthand: true,
})
for index, arg := range c.Args {
if strings.HasPrefix(arg, "-") && !strings.HasPrefix(arg, "--") {
c.Args[index] = "-" + arg
}
}
if strings.HasPrefix(c.CallbackValue, "-") && !strings.HasPrefix(c.CallbackValue, "--") {
c.CallbackValue = "-" + c.CallbackValue
}
os.Args = backup
return carapace.ActionExecute(rootCmd).Invoke(c).ToA()
})
}

func init() {
carapace.Gen(rootCmd).Standalone()

Expand Down
18 changes: 18 additions & 0 deletions completers/terragrunt_completer/cmd/awsProviderPatch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var awsProviderPatchCmd = &cobra.Command{
Use: "aws-provider-patch",
Short: "Overwrite settings on nested AWS providers to work around a Terraform bug",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(awsProviderPatchCmd).Standalone()

rootCmd.AddCommand(awsProviderPatchCmd)
}
18 changes: 18 additions & 0 deletions completers/terragrunt_completer/cmd/graphDependencies.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var graphDependenciesCmd = &cobra.Command{
Use: "graph-dependencies",
Short: "Prints the terragrunt dependency graph to stdout",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(graphDependenciesCmd).Standalone()

rootCmd.AddCommand(graphDependenciesCmd)
}
18 changes: 18 additions & 0 deletions completers/terragrunt_completer/cmd/hclfmt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var hclfmtCmd = &cobra.Command{
Use: "hclfmt",
Short: "Recursively find hcl files and rewrite them into a canonical format",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(hclfmtCmd).Standalone()

rootCmd.AddCommand(hclfmtCmd)
}
18 changes: 18 additions & 0 deletions completers/terragrunt_completer/cmd/renderJson.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var renderJsonCmd = &cobra.Command{
Use: "render-json",
Short: "Render the final terragrunt config as json",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(renderJsonCmd).Standalone()

rootCmd.AddCommand(renderJsonCmd)
}
26 changes: 26 additions & 0 deletions completers/terragrunt_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cmd

import (
"github.com/rsteube/carapace"
terraform "github.com/rsteube/carapace-bin/completers/terraform_completer/cmd"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "terragrunt",
Short: "Terragrunt is a thin wrapper for Terraform",
Long: "https://terragrunt.gruntwork.io/",
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}

func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()

carapace.Gen(rootCmd).PositionalAnyCompletion(
terraform.ActionExecute(),
)
}
24 changes: 24 additions & 0 deletions completers/terragrunt_completer/cmd/runAll.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"github.com/rsteube/carapace"
terraform "github.com/rsteube/carapace-bin/completers/terraform_completer/cmd"
"github.com/spf13/cobra"
)

var runAllCmd = &cobra.Command{
Use: "run-all",
Short: "Run a terraform command against a 'stack' by running the specified command in each subfolder",
Run: func(cmd *cobra.Command, args []string) {},
DisableFlagParsing: true,
}

func init() {
carapace.Gen(runAllCmd).Standalone()

rootCmd.AddCommand(runAllCmd)

carapace.Gen(runAllCmd).PositionalAnyCompletion(
terraform.ActionExecute(),
)
}
18 changes: 18 additions & 0 deletions completers/terragrunt_completer/cmd/terragruntInfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var terragruntInfoCmd = &cobra.Command{
Use: "terragrunt-info",
Short: "Emits limited terragrunt state on stdout and exits",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(terragruntInfoCmd).Standalone()

rootCmd.AddCommand(terragruntInfoCmd)
}
18 changes: 18 additions & 0 deletions completers/terragrunt_completer/cmd/validateInputs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var validateInputsCmd = &cobra.Command{
Use: "validate-inputs",
Short: "Checks if the terragrunt configured inputs align with the terraform defined variables",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(validateInputsCmd).Standalone()

rootCmd.AddCommand(validateInputsCmd)
}
7 changes: 7 additions & 0 deletions completers/terragrunt_completer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/rsteube/carapace-bin/completers/terragrunt_completer/cmd"

func main() {
cmd.Execute()
}

0 comments on commit 07de435

Please sign in to comment.