terraspace 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cody/README.md +25 -0
- data/.cody/aws/bin/build.sh +13 -0
- data/.cody/aws/buildspec.yml +10 -0
- data/.cody/aws/project.rb +2 -0
- data/.cody/aws/role.rb +6 -0
- data/.cody/azurerm/bin/az/configure.sh +23 -0
- data/.cody/azurerm/bin/az/install.sh +17 -0
- data/.cody/azurerm/bin/build.sh +20 -0
- data/.cody/azurerm/bin/install.sh +6 -0
- data/.cody/azurerm/buildspec.yml +11 -0
- data/.cody/azurerm/project.rb +2 -0
- data/.cody/azurerm/role.rb +5 -0
- data/.cody/google/bin/build.sh +17 -0
- data/.cody/google/bin/gcloud/configure.sh +15 -0
- data/.cody/google/bin/gcloud/install.sh +18 -0
- data/.cody/google/bin/install.sh +6 -0
- data/.cody/google/buildspec.yml +11 -0
- data/.cody/google/project.rb +2 -0
- data/.cody/google/role.rb +5 -0
- data/.cody/shared/script/install.sh +6 -0
- data/.cody/shared/script/install/terraform.sh +11 -0
- data/.cody/shared/script/install/terraspace.sh +72 -0
- data/.cody/unit/bin/build.sh +4 -0
- data/.cody/unit/buildspec.yml +9 -0
- data/.cody/unit/project.rb +2 -0
- data/.github/ISSUE_TEMPLATE.md +7 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +84 -0
- data/.github/ISSUE_TEMPLATE/documentation.md +12 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +64 -0
- data/.github/ISSUE_TEMPLATE/question.md +14 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +50 -0
- data/.gitignore +18 -9
- data/.pipedream/README.md +25 -0
- data/.pipedream/pipeline.rb +17 -0
- data/.pipedream/schedule.rb +3 -0
- data/.rspec +2 -2
- data/CHANGELOG.md +7 -0
- data/CONDUCT.md +1 -0
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +1 -4
- data/Guardfile +19 -0
- data/LICENSE.txt +201 -21
- data/README.md +60 -27
- data/Rakefile +10 -2
- data/exe/terraspace +14 -0
- data/lib/templates/base/project/.gitignore +34 -0
- data/lib/templates/base/project/Gemfile.tt +9 -0
- data/lib/templates/base/project/Terrafile +14 -0
- data/lib/templates/base/project/config/app.rb +4 -0
- data/lib/templates/hcl/module/main.tf +1 -0
- data/lib/templates/hcl/module/outputs.tf +1 -0
- data/lib/templates/hcl/module/variables.tf +1 -0
- data/lib/templates/hcl/project/config/terraform/backend.tf.tt +18 -0
- data/lib/templates/hcl/project/config/terraform/provider.tf +16 -0
- data/lib/templates/hcl/stack/main.tf +1 -0
- data/lib/templates/hcl/stack/outputs.tf +1 -0
- data/lib/templates/hcl/stack/variables.tf +1 -0
- data/lib/templates/plugin/.gitignore +12 -0
- data/lib/templates/plugin/.rspec +3 -0
- data/lib/templates/plugin/CHANGELOG.md +7 -0
- data/lib/templates/plugin/Gemfile +7 -0
- data/lib/templates/plugin/LICENSE.txt +201 -0
- data/lib/templates/plugin/README.md.tt +34 -0
- data/lib/templates/plugin/Rakefile +6 -0
- data/{bin/console → lib/templates/plugin/bin/console.tt} +1 -1
- data/{bin → lib/templates/plugin/bin}/setup +0 -0
- data/lib/templates/plugin/lib/templates/hcl/module/main.tf +1 -0
- data/lib/templates/plugin/lib/templates/hcl/module/outputs.tf +1 -0
- data/lib/templates/plugin/lib/templates/hcl/module/variables.tf +1 -0
- data/lib/templates/plugin/lib/templates/hcl/project/config/terraform/backend.tf.tt +6 -0
- data/lib/templates/plugin/lib/templates/hcl/project/config/terraform/provider.tf +3 -0
- data/lib/templates/plugin/lib/templates/hcl/stack/main.tf +1 -0
- data/lib/templates/plugin/lib/templates/hcl/stack/outputs.tf +1 -0
- data/lib/templates/plugin/lib/templates/hcl/stack/variables.tf +1 -0
- data/lib/templates/plugin/lib/templates/ruby/module/main.rb +1 -0
- data/lib/templates/plugin/lib/templates/ruby/module/outputs.rb +1 -0
- data/lib/templates/plugin/lib/templates/ruby/module/variables.rb +1 -0
- data/lib/templates/plugin/lib/templates/ruby/project/config/terraform/backend.rb.tt +4 -0
- data/lib/templates/plugin/lib/templates/ruby/project/config/terraform/provider.rb +3 -0
- data/lib/templates/plugin/lib/templates/ruby/stack/main.rb +1 -0
- data/lib/templates/plugin/lib/templates/ruby/stack/outputs.rb +1 -0
- data/lib/templates/plugin/lib/templates/ruby/stack/variables.rb +1 -0
- data/lib/templates/plugin/lib/templates/test/rspec/module/test/.rspec +3 -0
- data/lib/templates/plugin/lib/templates/test/rspec/module/test/Gemfile +9 -0
- data/lib/templates/plugin/lib/templates/test/rspec/module/test/spec/fixtures/stack/main.tf +1 -0
- data/lib/templates/plugin/lib/templates/test/rspec/module/test/spec/fixtures/stack/outputs.tf +1 -0
- data/lib/templates/plugin/lib/templates/test/rspec/module/test/spec/fixtures/stack/variables.tf +1 -0
- data/lib/templates/plugin/lib/templates/test/rspec/module/test/spec/main_spec.rb +29 -0
- data/lib/templates/plugin/lib/templates/test/rspec/module/test/spec/spec_helper.rb +13 -0
- data/lib/templates/plugin/lib/terraspace_plugin_%name%.rb.tt +36 -0
- data/lib/templates/plugin/lib/terraspace_plugin_%name%/autoloader.rb.tt +23 -0
- data/lib/templates/plugin/lib/terraspace_plugin_%name%/clients.rb.tt +14 -0
- data/lib/templates/plugin/lib/terraspace_plugin_%name%/interfaces/backend.rb.tt +12 -0
- data/lib/templates/plugin/lib/terraspace_plugin_%name%/interfaces/config.rb.tt +18 -0
- data/lib/templates/plugin/lib/terraspace_plugin_%name%/interfaces/expander.rb.tt +15 -0
- data/lib/templates/plugin/lib/terraspace_plugin_%name%/interfaces/layer.rb.tt +20 -0
- data/lib/templates/plugin/lib/terraspace_plugin_%name%/version.rb.tt +3 -0
- data/lib/templates/plugin/spec/spec_helper.rb.tt +14 -0
- data/lib/templates/plugin/spec/terraspace_provider_%name%_spec.rb.tt +5 -0
- data/lib/templates/plugin/terraspace_plugin_%name%.gemspec.tt +27 -0
- data/lib/templates/ruby/module/main.rb +1 -0
- data/lib/templates/ruby/module/outputs.rb +1 -0
- data/lib/templates/ruby/module/variables.rb +1 -0
- data/lib/templates/ruby/project/config/terraform/backend.rb.tt +9 -0
- data/lib/templates/ruby/project/config/terraform/provider.rb +7 -0
- data/lib/templates/ruby/stack/main.rb +1 -0
- data/lib/templates/ruby/stack/outputs.rb +1 -0
- data/lib/templates/ruby/stack/variables.rb +1 -0
- data/lib/terraspace.rb +22 -1
- data/lib/terraspace/app.rb +30 -0
- data/lib/terraspace/app/hooks.rb +18 -0
- data/lib/terraspace/autoloader.rb +25 -0
- data/lib/terraspace/booter.rb +19 -0
- data/lib/terraspace/builder.rb +87 -0
- data/lib/terraspace/bundle.rb +54 -0
- data/lib/terraspace/cli.rb +185 -0
- data/lib/terraspace/cli/base.rb +11 -0
- data/lib/terraspace/cli/build.rb +7 -0
- data/lib/terraspace/cli/bundle.rb +28 -0
- data/lib/terraspace/cli/check_setup.rb +73 -0
- data/lib/terraspace/cli/clean.rb +12 -0
- data/lib/terraspace/cli/commander.rb +14 -0
- data/lib/terraspace/cli/help.rb +11 -0
- data/lib/terraspace/cli/help/bundle.md +14 -0
- data/lib/terraspace/cli/help/completion.md +20 -0
- data/lib/terraspace/cli/help/completion_script.md +3 -0
- data/lib/terraspace/cli/help/update.md +5 -0
- data/lib/terraspace/cli/info.rb +30 -0
- data/lib/terraspace/cli/new.rb +32 -0
- data/lib/terraspace/cli/new/helper.rb +15 -0
- data/lib/terraspace/cli/new/helper/plugin_gem.rb +12 -0
- data/lib/terraspace/cli/new/module.rb +26 -0
- data/lib/terraspace/cli/new/plugin.rb +20 -0
- data/lib/terraspace/cli/new/plugin/helper.rb +15 -0
- data/lib/terraspace/cli/new/project.rb +110 -0
- data/lib/terraspace/cli/new/sequence.rb +59 -0
- data/lib/terraspace/cli/new/source/core.rb +63 -0
- data/lib/terraspace/cli/new/source/plugin.rb +20 -0
- data/lib/terraspace/cli/new/source/test.rb +26 -0
- data/lib/terraspace/cli/new/stack.rb +26 -0
- data/lib/terraspace/cli/new/test/base.rb +17 -0
- data/lib/terraspace/cli/new/test/bootstrap.rb +18 -0
- data/lib/terraspace/cli/new/test/module.rb +15 -0
- data/lib/terraspace/cli/new/test/project.rb +15 -0
- data/lib/terraspace/cli/seed.rb +9 -0
- data/lib/terraspace/cli/summary.rb +61 -0
- data/lib/terraspace/cli/test.rb +35 -0
- data/lib/terraspace/command.rb +100 -0
- data/lib/terraspace/compiler/backend.rb +66 -0
- data/lib/terraspace/compiler/basename.rb +10 -0
- data/lib/terraspace/compiler/builder.rb +74 -0
- data/lib/terraspace/compiler/cleaner.rb +46 -0
- data/lib/terraspace/compiler/cleaner/backend_change.rb +45 -0
- data/lib/terraspace/compiler/dsl/base.rb +12 -0
- data/lib/terraspace/compiler/dsl/meta/local.rb +7 -0
- data/lib/terraspace/compiler/dsl/meta/var.rb +7 -0
- data/lib/terraspace/compiler/dsl/mod.rb +19 -0
- data/lib/terraspace/compiler/dsl/syntax/helpers/common.rb +28 -0
- data/lib/terraspace/compiler/dsl/syntax/mod.rb +6 -0
- data/lib/terraspace/compiler/dsl/syntax/mod/backend.rb +18 -0
- data/lib/terraspace/compiler/dsl/syntax/mod/data.rb +9 -0
- data/lib/terraspace/compiler/dsl/syntax/mod/locals.rb +7 -0
- data/lib/terraspace/compiler/dsl/syntax/mod/module.rb +10 -0
- data/lib/terraspace/compiler/dsl/syntax/mod/output.rb +8 -0
- data/lib/terraspace/compiler/dsl/syntax/mod/provider.rb +8 -0
- data/lib/terraspace/compiler/dsl/syntax/mod/resource.rb +24 -0
- data/lib/terraspace/compiler/dsl/syntax/mod/terraform.rb +8 -0
- data/lib/terraspace/compiler/dsl/syntax/mod/variable.rb +12 -0
- data/lib/terraspace/compiler/dsl/syntax/tfvar.rb +5 -0
- data/lib/terraspace/compiler/dsl/syntax/tfvar/common.rb +7 -0
- data/lib/terraspace/compiler/dsl/tfvars.rb +29 -0
- data/lib/terraspace/compiler/erb/context.rb +11 -0
- data/lib/terraspace/compiler/erb/render.rb +12 -0
- data/lib/terraspace/compiler/expander.rb +19 -0
- data/lib/terraspace/compiler/strategy/abstract_base.rb +7 -0
- data/lib/terraspace/compiler/strategy/mod.rb +15 -0
- data/lib/terraspace/compiler/strategy/mod/base.rb +4 -0
- data/lib/terraspace/compiler/strategy/mod/pass.rb +7 -0
- data/lib/terraspace/compiler/strategy/mod/rb.rb +7 -0
- data/lib/terraspace/compiler/strategy/mod/tf.rb +7 -0
- data/lib/terraspace/compiler/strategy/tfvar.rb +42 -0
- data/lib/terraspace/compiler/strategy/tfvar/base.rb +4 -0
- data/lib/terraspace/compiler/strategy/tfvar/layer.rb +110 -0
- data/lib/terraspace/compiler/strategy/tfvar/rb.rb +7 -0
- data/lib/terraspace/compiler/strategy/tfvar/tfvars.rb +7 -0
- data/lib/terraspace/compiler/writer.rb +36 -0
- data/lib/terraspace/completer.rb +159 -0
- data/lib/terraspace/completer/script.rb +6 -0
- data/lib/terraspace/completer/script.sh +10 -0
- data/lib/terraspace/core.rb +46 -0
- data/lib/terraspace/ext.rb +2 -0
- data/lib/terraspace/ext/bundler.rb +7 -0
- data/lib/terraspace/ext/core/module.rb +19 -0
- data/lib/terraspace/logger.rb +26 -0
- data/lib/terraspace/mod.rb +100 -0
- data/lib/terraspace/mod/remote.rb +18 -0
- data/lib/terraspace/plugin.rb +73 -0
- data/lib/terraspace/plugin/backend/interface.rb +8 -0
- data/lib/terraspace/plugin/config/interface.rb +27 -0
- data/lib/terraspace/plugin/decorator/interface.rb +8 -0
- data/lib/terraspace/plugin/expander/generic.rb +5 -0
- data/lib/terraspace/plugin/expander/interface.rb +52 -0
- data/lib/terraspace/plugin/finder.rb +45 -0
- data/lib/terraspace/plugin/meta.rb +29 -0
- data/lib/terraspace/plugin/summary/interface.rb +129 -0
- data/lib/terraspace/seeder.rb +66 -0
- data/lib/terraspace/seeder/actions.rb +24 -0
- data/lib/terraspace/seeder/content.rb +84 -0
- data/lib/terraspace/seeder/where.rb +30 -0
- data/lib/terraspace/terraform/args/custom.rb +47 -0
- data/lib/terraspace/terraform/args/default.rb +96 -0
- data/lib/terraspace/terraform/args/dsl.rb +30 -0
- data/lib/terraspace/terraform/args/shorthands.rb +47 -0
- data/lib/terraspace/terraform/hooks/builder.rb +40 -0
- data/lib/terraspace/terraform/hooks/dsl.rb +19 -0
- data/lib/terraspace/terraform/runner.rb +77 -0
- data/lib/terraspace/tester.rb +29 -0
- data/lib/terraspace/tester/finder.rb +25 -0
- data/lib/terraspace/tester/meta.rb +25 -0
- data/lib/terraspace/util.rb +13 -0
- data/lib/terraspace/util/logging.rb +7 -0
- data/lib/terraspace/util/sh.rb +19 -0
- data/lib/terraspace/util/sure.rb +22 -0
- data/lib/terraspace/version.rb +1 -1
- data/spec/cli_spec.rb +13 -0
- data/spec/fixtures/cache_build_dir/variables.tf +9 -0
- data/spec/fixtures/initialized/modules.json +29 -0
- data/spec/fixtures/orphans/config/backend.rb +8 -0
- data/spec/fixtures/orphans/config/provider.rb +3 -0
- data/spec/fixtures/orphans/config/providers_different.rb +6 -0
- data/spec/fixtures/orphans/config/providers_same.rb +16 -0
- data/spec/fixtures/orphans/data/aws_ami.rb +8 -0
- data/spec/fixtures/orphans/data/aws_instance.rb +16 -0
- data/spec/fixtures/orphans/locals/forum.rb +4 -0
- data/spec/fixtures/orphans/locals/qux.rb +7 -0
- data/spec/fixtures/orphans/module/core/main.rb +5 -0
- data/spec/fixtures/orphans/resource/security_group/hash_example.rb +18 -0
- data/spec/fixtures/orphans/resource/vpc/count_example.rb +7 -0
- data/spec/fixtures/orphans/terraform/terraform.rb +3 -0
- data/spec/fixtures/projects/hcl/aws/app/modules/instance/main.tf +30 -0
- data/spec/fixtures/projects/hcl/aws/app/modules/instance/variables.tf +7 -0
- data/spec/fixtures/projects/hcl/aws/app/modules/vpc/file.txt +1 -0
- data/spec/fixtures/projects/hcl/aws/app/modules/vpc/main.tf +7 -0
- data/spec/fixtures/projects/hcl/aws/app/modules/vpc/variables.tf +11 -0
- data/spec/fixtures/projects/hcl/aws/app/stacks/core/main.tf +3 -0
- data/spec/fixtures/projects/hcl/aws/app/stacks/monolith/main.tf +3 -0
- data/spec/fixtures/projects/hcl/aws/config/backend.tf +9 -0
- data/spec/fixtures/projects/hcl/aws/config/provider.tf +3 -0
- data/spec/fixtures/projects/hcl/google/app/modules/vpc/main.tf +4 -0
- data/spec/fixtures/projects/hcl/google/app/modules/vpc/outputs.tf +4 -0
- data/spec/fixtures/projects/hcl/google/app/modules/vpc/variables.tf +5 -0
- data/spec/fixtures/projects/hcl/google/config/backend.tf +6 -0
- data/spec/fixtures/projects/hcl/google/config/provider.tf +0 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/existing_backend/backend.rb +7 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/existing_backend/main.rb +7 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/existing_backend/outputs.rb +4 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/existing_backend/variables.rb +9 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/instance/main.rb +28 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/instance/outputs.rb +3 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/instance/variables.rb +7 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/security_group/main.rb +16 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/security_group/variables.rb +5 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/sg_child/main.rb +7 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/sg_child/variables.rb +5 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/sg_parent/main.rb +14 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/sg_parent/variables.rb +3 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/vpc/main.rb +7 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/vpc/outputs.rb +4 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/vpc/variables.rb +9 -0
- data/spec/fixtures/projects/ruby/aws/app/modules/wordpress/main.rb +0 -0
- data/spec/fixtures/projects/ruby/aws/app/stacks/core/a.tfvars +0 -0
- data/spec/fixtures/projects/ruby/aws/app/stacks/core/b.tfvars +1 -0
- data/spec/fixtures/projects/ruby/aws/app/stacks/core/main.rb +6 -0
- data/spec/fixtures/projects/ruby/aws/app/stacks/core/outputs.rb +4 -0
- data/spec/fixtures/projects/ruby/aws/app/stacks/core/variables.rb +2 -0
- data/spec/fixtures/projects/ruby/aws/app/stacks/gke/main.rb +0 -0
- data/spec/fixtures/projects/ruby/aws/app/stacks/monolith/main.rb +3 -0
- data/spec/fixtures/projects/ruby/aws/app/stacks/nested/main.rb +5 -0
- data/spec/fixtures/projects/ruby/aws/config/backend.rb +7 -0
- data/spec/fixtures/projects/ruby/aws/config/cli/args.rb +11 -0
- data/spec/fixtures/projects/ruby/aws/config/cli/hooks.rb +8 -0
- data/spec/fixtures/projects/ruby/aws/config/provider.rb +3 -0
- data/spec/fixtures/projects/ruby/aws/seed/tfvars/modules/instance/base.rb +1 -0
- data/spec/fixtures/projects/ruby/aws/seed/tfvars/modules/instance/dev.rb +1 -0
- data/spec/fixtures/projects/ruby/aws/seed/tfvars/modules/instance/prod.rb +0 -0
- data/spec/fixtures/projects/ruby/aws/seed/tfvars/modules/security_group/base.rb +1 -0
- data/spec/fixtures/projects/ruby/aws/seed/tfvars/modules/security_group/dev.rb +1 -0
- data/spec/fixtures/projects/ruby/aws/seed/tfvars/modules/vpc/base.tfvars +2 -0
- data/spec/fixtures/projects/ruby/aws/seed/tfvars/modules/vpc/dev.tfvars +1 -0
- data/spec/fixtures/projects/ruby/aws/seed/tfvars/modules/vpc/prod.tfvars +1 -0
- data/spec/fixtures/projects/ruby/aws/seed/tfvars/stacks/core/base.rb +4 -0
- data/spec/fixtures/projects/ruby/aws/seed/tfvars/stacks/core/dev.rb +1 -0
- data/spec/fixtures/projects/ruby/aws/seed/tfvars/stacks/core/prod.rb +1 -0
- data/spec/fixtures/projects/ruby/aws/vendor/modules/vpc/main.rb +7 -0
- data/spec/fixtures/projects/ruby/aws/vendor/modules/vpc/outputs.rb +4 -0
- data/spec/fixtures/projects/ruby/aws/vendor/modules/vpc/variables.rb +9 -0
- data/spec/fixtures/projects/ruby/google/app/modules/firewall/main.rb +17 -0
- data/spec/fixtures/projects/ruby/google/app/modules/network/main.rb +4 -0
- data/spec/fixtures/projects/ruby/google/app/modules/vm-simple/main.rb +28 -0
- data/spec/fixtures/projects/ruby/google/app/modules/vm/main.rb +32 -0
- data/spec/fixtures/projects/ruby/google/app/modules/vm/outputs.rb +3 -0
- data/spec/fixtures/projects/ruby/google/app/modules/vm/variables.rb +19 -0
- data/spec/fixtures/projects/ruby/google/app/stacks/core/main.rb +5 -0
- data/spec/fixtures/projects/ruby/google/config/backend.rb +4 -0
- data/spec/fixtures/projects/ruby/google/config/provider.rb +14 -0
- data/spec/fixtures/terraform/args/multiple.rb +4 -0
- data/spec/fixtures/terraform/args/single.rb +10 -0
- data/spec/fixtures/terraform/hooks/multiple.rb +3 -0
- data/spec/fixtures/terraform/hooks/single.rb +7 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/terraspace/compiler/dsl/backend_spec.rb +33 -0
- data/spec/terraspace/compiler/dsl/data_spec.rb +30 -0
- data/spec/terraspace/compiler/dsl/locals_spec.rb +44 -0
- data/spec/terraspace/compiler/dsl/meta/local_spec.rb +10 -0
- data/spec/terraspace/compiler/dsl/meta/var_spec.rb +10 -0
- data/spec/terraspace/compiler/dsl/module_spec.rb +14 -0
- data/spec/terraspace/compiler/dsl/monolith_spec.rb +23 -0
- data/spec/terraspace/compiler/dsl/output_spec.rb +22 -0
- data/spec/terraspace/compiler/dsl/provider_spec.rb +72 -0
- data/spec/terraspace/compiler/dsl/resource/security_group_spec.rb +43 -0
- data/spec/terraspace/compiler/dsl/resource_spec.rb +64 -0
- data/spec/terraspace/compiler/dsl/terraform_spec.rb +21 -0
- data/spec/terraspace/compiler/dsl/variable_spec.rb +28 -0
- data/spec/terraspace/provider/expander/generic_spec.rb +30 -0
- data/spec/terraspace/seeder/content_spec.rb +49 -0
- data/spec/terraspace/seeder_spec.rb +20 -0
- data/spec/terraspace/terraform/args/custom_spec.rb +48 -0
- data/spec/terraspace/terraform/hooks/builder_spec.rb +35 -0
- data/terraspace.gemspec +31 -15
- metadata +687 -14
- data/.travis.yml +0 -6
@@ -0,0 +1,28 @@
|
|
1
|
+
require "terraspace-bundler"
|
2
|
+
TerraspaceBundler.logger = Terraspace.logger
|
3
|
+
|
4
|
+
class Terraspace::CLI
|
5
|
+
class Bundle
|
6
|
+
def initialize(options={})
|
7
|
+
@options = options
|
8
|
+
end
|
9
|
+
|
10
|
+
def run
|
11
|
+
TerraspaceBundler::CLI.start(args)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Allows bundle to be called without install. So both work:
|
15
|
+
#
|
16
|
+
# terraspace bundle
|
17
|
+
# terraspace bundle install
|
18
|
+
#
|
19
|
+
def args
|
20
|
+
args = @options[:args]
|
21
|
+
if args.empty? or args.first.include?('--')
|
22
|
+
args.unshift("install")
|
23
|
+
end
|
24
|
+
args = ["bundle"] + args
|
25
|
+
args
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class Terraspace::CLI
|
2
|
+
class CheckSetup
|
3
|
+
extend Memoist
|
4
|
+
|
5
|
+
# Terraspace requires at least this version of terraform
|
6
|
+
REQUIRED_TERRAFORM_VERSION = "0.12"
|
7
|
+
|
8
|
+
def initialize(options={})
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
# Used for the CLI
|
13
|
+
def run
|
14
|
+
puts "Detected Terrspace version: #{Terraspace::VERSION}"
|
15
|
+
if terraform_bin
|
16
|
+
puts "Detected Terraform bin: #{terraform_bin}"
|
17
|
+
puts "Detected #{terraform_version_message}"
|
18
|
+
check_required_version!
|
19
|
+
else
|
20
|
+
puts "Terraform not installed. Unable to detect a terraform command. Please double check that terraform is installed."
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def check_required_version!
|
26
|
+
puts "Terraspace requires Terraform v#{REQUIRED_TERRAFORM_VERSION}.x"
|
27
|
+
if ok?
|
28
|
+
puts "You're all set!"
|
29
|
+
else
|
30
|
+
puts "The installed version of terraform may not work with terraspace. Recommend using terraform v#{REQUIRED_TERRAFORM_VERSION}.x"
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def ok?
|
36
|
+
version = terraform_version_message.sub(/.*v/,'') # => 0.12.24
|
37
|
+
major, minor, _ = version.split('.')
|
38
|
+
required_major, required_minor = REQUIRED_TERRAFORM_VERSION.split('.')
|
39
|
+
x = major.to_i >= required_major.to_i
|
40
|
+
y = minor.to_i >= required_minor.to_i
|
41
|
+
x && y
|
42
|
+
end
|
43
|
+
|
44
|
+
def terraform_bin
|
45
|
+
bin_path = `which terraform 2>&1`.strip
|
46
|
+
bin_path if $?.success?
|
47
|
+
end
|
48
|
+
memoize :terraform_bin
|
49
|
+
|
50
|
+
# First line contains the Terraform version info:
|
51
|
+
#
|
52
|
+
# $ terraform --version
|
53
|
+
# Terraform v0.12.24
|
54
|
+
#
|
55
|
+
# Your version of Terraform is out of date! The latest version
|
56
|
+
# is 0.12.26. You can update by downloading from https://www.terraform.io/downloads.html
|
57
|
+
#
|
58
|
+
def terraform_version_message
|
59
|
+
`terraform --version`.split("\n").first.strip
|
60
|
+
end
|
61
|
+
memoize :terraform_version_message
|
62
|
+
|
63
|
+
class << self
|
64
|
+
# Used as library call
|
65
|
+
def check!
|
66
|
+
setup = new
|
67
|
+
return if setup.ok?
|
68
|
+
# run meth designed for CLI and will puts out informative messages about installed version and exit 1 when version is not ok
|
69
|
+
setup.run
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Terraspace::CLI
|
2
|
+
class Commander < Base
|
3
|
+
def initialize(name, options={})
|
4
|
+
@name = name
|
5
|
+
super(options)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Commander always runs Build#run
|
9
|
+
def run
|
10
|
+
Build.new(@options).run # generate and init
|
11
|
+
Terraspace::Terraform::Runner.new(@name, @options).run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
## Example
|
2
|
+
|
3
|
+
terraspace bundle
|
4
|
+
|
5
|
+
## More commands
|
6
|
+
|
7
|
+
terraspace bundle install # same as bundle
|
8
|
+
terraspace bundle update # Updates Terrafile.lock
|
9
|
+
terraspace bundle clean # removes /tmp terraspace bundler folder
|
10
|
+
|
11
|
+
## Update a single module
|
12
|
+
|
13
|
+
terraspace bundle update MOD_NAME
|
14
|
+
terraspace bundle update demo
|
@@ -0,0 +1,20 @@
|
|
1
|
+
## Examples
|
2
|
+
|
3
|
+
terraspace completion
|
4
|
+
|
5
|
+
Prints words for TAB auto-completion.
|
6
|
+
|
7
|
+
terraspace completion
|
8
|
+
terraspace completion up
|
9
|
+
terraspace completion up name
|
10
|
+
|
11
|
+
To enable, TAB auto-completion add the following to your profile:
|
12
|
+
|
13
|
+
eval $(terraspace completion_script)
|
14
|
+
|
15
|
+
Auto-completion example usage:
|
16
|
+
|
17
|
+
terraspace [TAB]
|
18
|
+
terraspace up [TAB]
|
19
|
+
terraspace up name [TAB]
|
20
|
+
terraspace up name --[TAB]
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Terraspace::CLI
|
2
|
+
class Info < Base
|
3
|
+
extend Memoist
|
4
|
+
|
5
|
+
def run
|
6
|
+
format = @options[:format] || "text"
|
7
|
+
send("#{format}_output")
|
8
|
+
end
|
9
|
+
|
10
|
+
def json_output
|
11
|
+
puts JSON.pretty_generate(info)
|
12
|
+
end
|
13
|
+
|
14
|
+
def text_output
|
15
|
+
info.each do |k,v|
|
16
|
+
k = "%-#{rpad}s" % k
|
17
|
+
puts "#{k} #{v}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def rpad
|
22
|
+
info.keys.map(&:size).max
|
23
|
+
end
|
24
|
+
memoize :rpad
|
25
|
+
|
26
|
+
def info
|
27
|
+
@mod.to_info
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class Terraspace::CLI
|
2
|
+
class New < Terraspace::Command
|
3
|
+
long_desc Help.text(:module)
|
4
|
+
Module.base_options.each { |args| option(*args) }
|
5
|
+
Module.component_options.each { |args| option(*args) }
|
6
|
+
register(Module, "module", "module NAME", "Generates new module")
|
7
|
+
|
8
|
+
long_desc Help.text(:stack)
|
9
|
+
Stack.base_options.each { |args| option(*args) }
|
10
|
+
Stack.component_options.each { |args| option(*args) }
|
11
|
+
register(Stack, "stack", "stack NAME", "Generates new stack")
|
12
|
+
|
13
|
+
long_desc Help.text(:project)
|
14
|
+
Project.base_options.each { |args| option(*args) }
|
15
|
+
Project.project_options.each { |args| option(*args) }
|
16
|
+
register(Project, "project", "project NAME", "Generates new project")
|
17
|
+
|
18
|
+
long_desc Help.text(:project_test)
|
19
|
+
register(Test::Project, "project_test", "project_test NAME", "Generates new project test")
|
20
|
+
|
21
|
+
long_desc Help.text(:module_test)
|
22
|
+
register(Test::Module, "module_test", "module_test NAME", "Generates new module test")
|
23
|
+
|
24
|
+
long_desc Help.text(:bootstrap_test)
|
25
|
+
Test::Bootstrap.options.each { |args| option(*args) }
|
26
|
+
register(Test::Bootstrap, "bootstrap_test", "bootstrap_test", "Generates bootstrap test setup")
|
27
|
+
|
28
|
+
long_desc Help.text(:plugin)
|
29
|
+
Plugin.options.each { |args| option(*args) }
|
30
|
+
register(Plugin, "plugin", "plugin", "Generates plugin")
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Terraspace::CLI::New
|
2
|
+
class Module < Sequence
|
3
|
+
component_options.each { |args| class_option(*args) }
|
4
|
+
|
5
|
+
argument :name
|
6
|
+
|
7
|
+
def create_module
|
8
|
+
puts "=> Creating test for new module: #{name}"
|
9
|
+
plugin_template_source(@options[:lang], "module") # IE: plugin_template_source("hcl", "module")
|
10
|
+
dest = "app/modules/#{name}"
|
11
|
+
dest = "#{@options[:project_name]}/#{dest}" if @options[:project_name]
|
12
|
+
directory ".", dest
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_test
|
16
|
+
args = component_args(name, @options[:project_name])
|
17
|
+
Test::Module.start(args)
|
18
|
+
end
|
19
|
+
|
20
|
+
def run_generator_hook_script
|
21
|
+
script = ENV['TS_GENERATOR_MODULE']
|
22
|
+
return unless script
|
23
|
+
run_script(script, "app/modules/#{name}")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Terraspace::CLI::New
|
2
|
+
class Plugin < Sequence
|
3
|
+
include Helper
|
4
|
+
|
5
|
+
def self.options
|
6
|
+
[
|
7
|
+
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files"],
|
8
|
+
]
|
9
|
+
end
|
10
|
+
options.each { |args| class_option(*args) }
|
11
|
+
|
12
|
+
argument :name
|
13
|
+
|
14
|
+
def create_plugin
|
15
|
+
puts "=> Creating new plugin: #{name}"
|
16
|
+
core_template_source("plugin")
|
17
|
+
directory ".", "terraspace_plugin_#{name}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Terraspace::CLI::New::Plugin
|
2
|
+
module Helper
|
3
|
+
private
|
4
|
+
# helper
|
5
|
+
def camel_name
|
6
|
+
name.camelize
|
7
|
+
end
|
8
|
+
|
9
|
+
# friendly method
|
10
|
+
def core_template_source(template)
|
11
|
+
source = Terraspace::CLI::New::Source::Core.new(self, @options)
|
12
|
+
source.set_core_source(template)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
class Terraspace::CLI::New
|
2
|
+
class Project < Sequence
|
3
|
+
def self.project_options
|
4
|
+
[
|
5
|
+
[:bundle, type: :boolean, default: true, desc: "Runs bundle install on the project"],
|
6
|
+
[:config, type: :boolean, default: true, desc: "Whether or not to generate config files."],
|
7
|
+
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
|
8
|
+
[:test_structure, type: :boolean, desc: "Create project bootstrap test structure."]
|
9
|
+
]
|
10
|
+
end
|
11
|
+
|
12
|
+
base_options.each { |args| class_option(*args) }
|
13
|
+
project_options.each { |args| class_option(*args) }
|
14
|
+
|
15
|
+
def creating_messaging
|
16
|
+
puts "=> Creating new project called #{name}."
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_base
|
20
|
+
plugin_template_source("base", "project")
|
21
|
+
directory ".", "#{name}"
|
22
|
+
end
|
23
|
+
|
24
|
+
# Will generate config folder from
|
25
|
+
#
|
26
|
+
# 1. terraspace code lang templates or
|
27
|
+
# 2. example lang templates from provider gems
|
28
|
+
#
|
29
|
+
def create_project
|
30
|
+
plugin_template_source(@options[:lang], "project") # IE: plugin_template_source("hcl", "project")
|
31
|
+
|
32
|
+
options = @options[:config] == false ? {exclude_pattern: "config" } : {}
|
33
|
+
directory ".", "#{name}", options
|
34
|
+
|
35
|
+
if @options[:config] == false
|
36
|
+
empty_directory("#{name}/config")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def empty_dirs
|
41
|
+
return if @options[:examples]
|
42
|
+
empty_directory("#{name}/app/modules")
|
43
|
+
empty_directory("#{name}/app/stacks")
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_starter_module
|
47
|
+
return unless @options[:examples]
|
48
|
+
Module.start(component_args("example", name))
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_starter_stack
|
52
|
+
return unless @options[:examples]
|
53
|
+
Stack.start(component_args("demo", name))
|
54
|
+
end
|
55
|
+
|
56
|
+
def create_test
|
57
|
+
return if @options[:test_structure] == false
|
58
|
+
Test::Bootstrap.start(["--dir", name])
|
59
|
+
end
|
60
|
+
|
61
|
+
def bundle_install
|
62
|
+
return if @options[:bundle] == false
|
63
|
+
puts "=> Installing dependencies with: bundle install"
|
64
|
+
Bundler.with_unbundled_env do
|
65
|
+
system("BUNDLE_IGNORE_CONFIG=1 bundle install", chdir: name)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def welcome_message_examples
|
70
|
+
return unless options[:examples]
|
71
|
+
puts <<~EOL
|
72
|
+
#{"="*64}
|
73
|
+
Congrats! You have successfully created a terraspace project.
|
74
|
+
Check out the created files. Adjust to the examples and then deploy with:
|
75
|
+
|
76
|
+
cd #{name}
|
77
|
+
terraspace up demo -y # to deploy
|
78
|
+
terraspace down demo -y # to destroy
|
79
|
+
|
80
|
+
More info: https://terraspace.cloud/
|
81
|
+
EOL
|
82
|
+
end
|
83
|
+
|
84
|
+
def welcome_message_no_examples
|
85
|
+
return if options[:examples]
|
86
|
+
puts <<~EOL
|
87
|
+
#{"="*64}
|
88
|
+
Congrats! You have successfully created a terraspace project.
|
89
|
+
Check out the created files.
|
90
|
+
|
91
|
+
cd #{name}
|
92
|
+
|
93
|
+
You can create starter modules and stacks with their generators:
|
94
|
+
|
95
|
+
terraspace new module example
|
96
|
+
terraspace new stack demo
|
97
|
+
|
98
|
+
Add your code to them, and deploy when you are ready:
|
99
|
+
|
100
|
+
terraspace up demo -y # to deploy
|
101
|
+
|
102
|
+
Destroy with:
|
103
|
+
|
104
|
+
terraspace down demo -y # to destroy
|
105
|
+
|
106
|
+
More info: https://terraspace.cloud/
|
107
|
+
EOL
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|