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

fix example generator lang option #183

Merged
merged 1 commit into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/templates/examples/hcl/module/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
resource "random_pet" "this" {
keepers = {
name = var.name
}
length = var.length
}
8 changes: 4 additions & 4 deletions lib/templates/examples/hcl/module/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variable "name" {
type = string
description = "pet name"
default = "example-name"
variable "length" {
type = number
description = "number of words"
default = 2
}
2 changes: 1 addition & 1 deletion lib/templates/examples/hcl/stack/main.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module "pet" {
source = "../../modules/example"
name = var.name
length = var.length
}
8 changes: 4 additions & 4 deletions lib/templates/examples/hcl/stack/variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variable "name" {
type = string
description = "pet name"
default = "demo-name"
variable "length" {
type = number
description = "number of words"
default = 2
}
4 changes: 1 addition & 3 deletions lib/templates/examples/ruby/module/main.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
resource("random_pet", "this",
keepers: {
name: var.name
}
length: var.length
)
7 changes: 4 additions & 3 deletions lib/templates/examples/ruby/module/variables.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
variable("name",
description: "pet name",
default: "example-name",
variable("length",
type: :number,
description: "number of words",
default: 2,
)
2 changes: 1 addition & 1 deletion lib/templates/examples/ruby/stack/main.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module!("pet",
source: "../../modules/example",
name: var.name,
length: var.length,
)
7 changes: 4 additions & 3 deletions lib/templates/examples/ruby/stack/variables.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
variable("name",
description: "pet name",
default: "demo-name",
variable("length",
type: :number,
description: "number of words",
default: 2,
)
27 changes: 4 additions & 23 deletions lib/templates/hcl/project/config/terraform/provider.tf
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
# This is where you put your provider declaration. Here are some examples:
# This is where you put your provider declaration.
#
# provider "aws" {
# region = "<%= ENV['AWS_REGION'] || 'us-east-1' %>"
# }
#
# Docs: https://www.terraform.io/docs/providers/aws/index.html
#
# provider "azurerm" {
# features {} # required
# }
#
# Docs: https://www.terraform.io/docs/providers/aws/index.html
#
# provider "google" {
# project = "REPLACE_ME"
# region = "us-central1" # update to your region
# zone = "us-central1-a" # update to your zone
# }
#
# Docs: https://www.terraform.io/docs/providers/google/index.html
#
# Note: If you add a provider, you should also configure a terraspace_plugin_* gem
# If you end up adding a cloud provider, you should also configure a terraspace_plugin_* gem
# in the Terraspace project Gemfile and run bundle.
#
#
# See: https://terraspace.cloud/docs/plugins/
4 changes: 3 additions & 1 deletion lib/terraspace/cli/new/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class Example < Thor::Group
def self.options
# default is nil for autodetection
[
[:plugin, aliases: %w[p], default: nil, type: :string],
[:force, aliases: %w[f], type: :boolean, desc: "Force overwrite"],
[:lang, default: "hcl", desc: "Language to use: HCL/ERB or Ruby DSL"],
[:plugin, aliases: %w[p], default: nil, type: :string],
]
end
options.each { |args| class_option(*args) }
Expand All @@ -28,6 +29,7 @@ def cli_args
['--plugin', 'none'] # override default of aws
end
args << "--force" if @options[:force]
args += ["--lang", @options[:lang]] if @options[:lang]
args
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/terraspace/cli/new/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ class Terraspace::CLI::New
class Stack < Sequence
component_options.each { |args| class_option(*args) }

argument :name
# default so terraspace new example works without a Thor warning
argument :name, default: "demo"

def create_stack
puts "=> Creating new stack called #{name}"
Expand Down