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

feat: add support for minikube, terragrunt, tgenv #1014

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
19 changes: 19 additions & 0 deletions src/minikube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,25 @@ const completionSpec: Fig.Spec = {
},
],
},
{
name: "dashboard",
description:
"Access the Kubernetes dashboard running within the minikube cluster",
options: [
{
name: "--port",
description:
"Exposed port of the proxyfied dashboard. Set to 0 to pick a random port",
yinchuandong marked this conversation as resolved.
Show resolved Hide resolved
args: {
name: "int",
},
},
{
name: "--url",
description: "Display dashboard URL instead of opening a browse",
},
],
},
{
name: "status",
description: "Gets the status of a local Kubernetes cluster",
Expand Down
273 changes: 273 additions & 0 deletions src/terragrunt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
import terraform from "./terraform";

const globalOptions: Fig.Option[] = [
yinchuandong marked this conversation as resolved.
Show resolved Hide resolved
{
name: "-help",
description:
"Show this help output, or the help for a specified subcommand",
isPersistent: true,
},
{
name: "-version",
description: "Show the current terragrunt version",
isPersistent: true,
},
{
name: "--terragrunt-config",
description:
"Path to the Terragrunt config file. Default is terragrunt.hcl",
args: {
template: "filepaths",
},
isPersistent: true,
},
{
name: "--terragrunt-tfpath",
description: "Path to the Terraform binary. Default is terraform (on PATH)",
args: {
template: "filepaths",
},
isPersistent: true,
},
{
name: "--terragrunt-no-auto-init",
description:
"Don't automatically run 'terraform init' during other terragrunt commands. You must run 'terragrunt init' manually",
isPersistent: true,
},
{
name: "--terragrunt-non-interactive",
description: "Assume 'yes' for all prompts",
isPersistent: true,
},
{
name: "--terragrunt-working-dir",
description:
"The path to the Terraform templates. Default is current directory",
args: {
template: "filepaths",
},
isPersistent: true,
},
{
name: "--terragrunt-download-dir",
description:
"The path where to download Terraform code. Default is .terragrunt-cache in the working directory",
args: {
template: "filepaths",
},
isPersistent: true,
},
{
name: "--terragrunt-source",
description:
"Download Terraform configurations from the specified source into a temporary folder, and run Terraform in that temporary folder",
args: {
template: "filepaths",
},
isPersistent: true,
},
{
name: "--terragrunt-source-update",
description:
"Delete the contents of the temporary folder to clear out any old, cached source code before downloading new source code into it",
isPersistent: true,
},
{
name: "--terragrunt-iam-role",
description:
"Assume the specified IAM role before executing Terraform. Can also be set via the TERRAGRUNT_IAM_ROLE environment variable",
args: {
name: "iam-role-arn",
description: "AWS IAM role ARN",
},
isPersistent: true,
},
{
name: "--terragrunt-ignore-dependency-errors",
description:
"*-all commands continue processing components even if a dependency fails",
isPersistent: true,
},
{
name: "--terragrunt-ignore-dependency-order",
description: "*-all commands will be run disregarding the dependencie",
isPersistent: true,
},
{
name: "--terragrunt-ignore-external-dependencies",
description:
"*-all commands will not attempt to include external dependencies",
isPersistent: true,
},
{
name: "--terragrunt-include-external-dependencies",
description: "*-all commands will include external dependencies",
isPersistent: true,
},
{
name: "--terragrunt-parallelism",
description: "*-all commands parallelism set to at most N module",
args: {
name: "modules",
},
isPersistent: true,
},
{
name: "--terragrunt-exclude-dir",
description:
"Unix-style glob of directories to exclude when running *-all commands",
args: {
template: "filepaths",
},
isPersistent: true,
},
{
name: "--terragrunt-include-dir",
description:
"Unix-style glob of directories to include when running *-all command",
args: {
template: "filepaths",
},
isPersistent: true,
},
{
name: "--terragrunt-check",
description: "Enable check mode in the hclfmt command",
isPersistent: true,
},
{
name: "--terragrunt-hclfmt-file",
description:
"The path to a single terragrunt.hcl file that the hclfmt command should run on",
args: {
template: "filepaths",
},
isPersistent: true,
},
{
name: "--terragrunt-override-attr",
description:
"A key=value attribute to override in a provider block as part of the aws-provider-patch command. May be specified multiple times",
args: {
name: "attr=value",
description: "ATTR=VALUE",
},
isPersistent: true,
},
{
name: "--terragrunt-debug",
description:
"Write terragrunt-debug.tfvars to working folder to help root-cause issues",
isPersistent: true,
},
{
name: "--terragrunt-log-level",
description: "Sets the logging level for Terragrunt",
args: {
name: "level",
suggestions: [
"panic",
"fatal",
"error",
"warn",
"info",
"debug",
"trace",
],
default: "warn",
},
isPersistent: true,
},
];

const mainCommands: Fig.Subcommand[] = [
{
name: "run-all",
description:
"Run a terraform command against a 'stack' by running the specified command in each subfolder. E.g., to run 'terragrunt apply' in each subfolder, use 'terragrunt run-all apply",
subcommands: [
{
name: "plan",
description:
"Display the plans of a ‘stack’ by running ‘terragrunt plan’ in each subfolder",
},
{
name: "apply",
description:
"Apply a ‘stack’ by running ‘terragrunt apply’ in each subfolder",
},
{
name: "output",
description:
"Display the outputs of a ‘stack’ by running ‘terragrunt output’ in each subfolder",
},
{
name: "destroy",
description:
"Destroy a ‘stack’ by running ‘terragrunt destroy’ in each subfolder",
},
{
name: "validate",
description:
"Validate a ‘stack’ by running ‘terragrunt destroy’ in each subfolder",
},
],
},
];

const otherCommands: Fig.Subcommand[] = [
{
name: "terragrunt-info",
description:
"Emits limited terragrunt state on stdout in a JSON format and exits",
},
{
name: "graph-dependencies",
description:
"Prints the terragrunt dependency graph, in DOT format, to stdout",
},
{
name: "hclfmt",
description:
"Recursively find hcl files and rewrite them into a canonical format",
},
{
name: "validate-inputs",
description:
"Emits information about the input variables that are configured with the given terragrunt configuration",
options: [
{
name: "--terragrunt-strict-validate",
description: "Enable strict mode",
},
],
},
{
name: "render-json",
description: "Render out the final interpreted terragrunt.hcl file",
options: [
{
name: "--terragrunt-json-out",
description:
"Configure where terragrunt renders out the json representation",
},
],
},
];

const completionSpec: Fig.Spec = {
name: "terragrunt",
description: "Terragrunt CLI",
options: globalOptions,
parserDirectives: {
flagsArePosixNoncompliant: true,
},
subcommands: [
...(terraform as Fig.Subcommand).subcommands,
...mainCommands,
...otherCommands,
],
};

export default completionSpec;
79 changes: 79 additions & 0 deletions src/tgenv.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const generators: Record<string, Fig.Generator> = {
installedVersions: {
script: "tgenv list",
postProcess: function (out) {
return out
.trim()
.split("\n")
.map((tfversion) => {
return { name: tfversion, description: "Version" };
});
},
},
allVersions: {
script: "tgenv list-remote",
postProcess: function (out) {
return out
.trim()
.split("\n")
.map(function (line) {
return { name: line, type: "option" };
});
},
},
};

const completionSpec: Fig.Spec = {
name: "tgenv",
description: "Terragrunt version manager",
subcommands: [
{
name: "install",
description: "Install a specific version of Terragrunt",
args: {
name: "version",
description: "Possible Terragrunt Version",
suggestions: ["latest", "min-required"],
generators: generators.allVersions,
},
},
{
name: "use",
description: "Switch to a version to use",
args: {
name: "version",
description: "Installed Terragrunt Version",
generators: generators.installedVersions,
},
},
{
name: "uninstall",
description: "Uninstall a specific version of Terragrunt",
args: {
name: "version",
description: "Installed Terragrunt Version",
generators: generators.installedVersions,
},
},
{
name: "list",
description: "List all installed versions",
},
{
name: "list-remote",
description: "List all installable versions",
},
],
options: [
{
name: ["-v", "--version"],
description: "View your current tgenv version",
},
{
name: "--help",
description: "View commands",
},
],
};

export default completionSpec;