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,30 @@
|
|
1
|
+
module Terraspace
|
2
|
+
class App
|
3
|
+
include Singleton
|
4
|
+
include DslEvaluator
|
5
|
+
|
6
|
+
attr_reader :config
|
7
|
+
def initialize
|
8
|
+
@config = defaults
|
9
|
+
end
|
10
|
+
|
11
|
+
def defaults
|
12
|
+
config = ActiveSupport::OrderedOptions.new
|
13
|
+
config.test_framework = "rspec"
|
14
|
+
config.logger = Logger.new($stdout)
|
15
|
+
config.logger.level = :info
|
16
|
+
config.hooks = Hooks.new
|
17
|
+
config
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure
|
21
|
+
yield(@config)
|
22
|
+
end
|
23
|
+
|
24
|
+
def load_project_config
|
25
|
+
evaluate_file("#{Terraspace.root}/config/app.rb")
|
26
|
+
path = "#{Terraspace.root}/config/env/#{Terraspace.env}.rb"
|
27
|
+
evaluate_file(path)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Terraspace::App
|
2
|
+
class Hooks
|
3
|
+
class_attribute :hooks
|
4
|
+
self.hooks = {}
|
5
|
+
|
6
|
+
def on_boot(&block)
|
7
|
+
self.class.hooks[:on_boot] = block
|
8
|
+
end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def run_hook(name)
|
12
|
+
name = name.to_sym
|
13
|
+
hook = hooks[name]
|
14
|
+
hook.call if hook
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "terraspace/bundle"
|
2
|
+
Terraspace::Bundle.setup
|
3
|
+
require "zeitwerk"
|
4
|
+
|
5
|
+
module Terraspace
|
6
|
+
class Autoloader
|
7
|
+
class Inflector < Zeitwerk::Inflector
|
8
|
+
def camelize(basename, _abspath)
|
9
|
+
map = { cli: "CLI", version: "VERSION" }
|
10
|
+
map[basename.to_sym] || super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def setup
|
16
|
+
loader = Zeitwerk::Loader.new
|
17
|
+
loader.inflector = Inflector.new
|
18
|
+
loader.push_dir(File.dirname(__dir__)) # lib
|
19
|
+
loader.log! if ENV["TS_AUTOLOAD_LOG"]
|
20
|
+
loader.ignore("#{__dir__}/core_ext.rb")
|
21
|
+
loader.setup
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Terraspace
|
2
|
+
module Booter
|
3
|
+
def boot
|
4
|
+
Terraspace::Bundle.require # load plugins
|
5
|
+
load_plugin_default_configs
|
6
|
+
Terraspace.config # load project config
|
7
|
+
Terraspace::App::Hooks.run_hook(:on_boot)
|
8
|
+
end
|
9
|
+
|
10
|
+
def load_plugin_default_configs
|
11
|
+
Terraspace::Plugin.config_classes.each do |klass|
|
12
|
+
# IE: TerraspacePluginAws::Interfaces::Config.instance.load_project_config
|
13
|
+
klass.instance.load_project_config
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
extend self
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Terraspace
|
2
|
+
class Builder < Terraspace::CLI::Base
|
3
|
+
def run
|
4
|
+
Terraspace::CLI::CheckSetup.check!
|
5
|
+
@mod.root_module = true
|
6
|
+
Compiler::Cleaner.new(@mod, @options).clean
|
7
|
+
build_dir = Util.pretty_path(@mod.cache_build_dir)
|
8
|
+
logger.info "Building #{build_dir}"
|
9
|
+
|
10
|
+
build_all("modules") # build all modules and stacks as dependencies
|
11
|
+
build_all("stacks")
|
12
|
+
build_root_module # build root module at the end
|
13
|
+
|
14
|
+
auto_create_backend
|
15
|
+
Terraform::Runner.new("init", @options).run if !auto? && @options[:init] != false # will run on @options[:init].nil?
|
16
|
+
build_remote_dependencies # runs after terraform init, which downloads remote modules
|
17
|
+
logger.info "Built in #{build_dir}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def auto?
|
21
|
+
# command is only passed from CLI in the update specifically for this check
|
22
|
+
@options[:auto] && @options[:command] == "update"
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_root_module
|
26
|
+
Compiler::Builder.new(@mod).build
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_all(type_dir)
|
30
|
+
built = []
|
31
|
+
local_paths(type_dir).each do |path|
|
32
|
+
next unless File.directory?(path)
|
33
|
+
mod_name = File.basename(path)
|
34
|
+
next if built.include?(mod_name) # ensures modules in app folder take higher precedence than vendor folder
|
35
|
+
|
36
|
+
consider_stacks = type_dir == "stacks"
|
37
|
+
mod = Mod.new(mod_name, consider_stacks: consider_stacks)
|
38
|
+
next if root?(mod) # will build root module at the end
|
39
|
+
|
40
|
+
Compiler::Builder.new(mod).build
|
41
|
+
built << mod_name
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def root?(mod)
|
46
|
+
mod.name == @mod.name && mod.type == @mod.type
|
47
|
+
end
|
48
|
+
|
49
|
+
def auto_create_backend
|
50
|
+
return unless @options[:command] == "update"
|
51
|
+
Compiler::Backend.new(@mod).create
|
52
|
+
end
|
53
|
+
|
54
|
+
def local_paths(type_dir)
|
55
|
+
dirs("app/#{type_dir}/*") + dirs("vendor/#{type_dir}/*")
|
56
|
+
end
|
57
|
+
|
58
|
+
def dirs(path)
|
59
|
+
Dir.glob("#{Terraspace.root}/#{path}")
|
60
|
+
end
|
61
|
+
|
62
|
+
# Currently only handles remote modules only one-level deep.
|
63
|
+
def build_remote_dependencies
|
64
|
+
modules_json_path = "#{@mod.cache_build_dir}/.terraform/modules/modules.json"
|
65
|
+
return unless File.exist?(modules_json_path)
|
66
|
+
|
67
|
+
initialized_modules = JSON.load(IO.read(modules_json_path))
|
68
|
+
# For example of structure see spec/fixtures/initialized/modules.json
|
69
|
+
initialized_modules["Modules"].each do |meta|
|
70
|
+
build_remote_mod(meta)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def build_remote_mod(meta)
|
75
|
+
return if local_source?(meta["Source"])
|
76
|
+
return if meta['Dir'] == '.' # root is already built
|
77
|
+
|
78
|
+
remote_mod = Mod::Remote.new(meta, @mod)
|
79
|
+
Compiler::Builder.new(remote_mod).build
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
def local_source?(s)
|
84
|
+
s =~ %r{^\.} || s =~ %r{^/}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Terraspace
|
2
|
+
# Named Bundle vs Bundler to avoid having to fully qualify ::Bundler
|
3
|
+
module Bundle
|
4
|
+
# Looks like for zeitwerk module autovivification to work `bundle exec` must be called.
|
5
|
+
# This allows zeitwork module autovivification to work even if the user has not called terraspace with `bundle exec terraspace`.
|
6
|
+
# Bundler.setup is essentially the same as `bundle exec`
|
7
|
+
# Reference: https://www.justinweiss.com/articles/what-are-the-differences-between-irb/
|
8
|
+
#
|
9
|
+
def setup
|
10
|
+
return unless gemfile?
|
11
|
+
Kernel.require "bundler/setup"
|
12
|
+
Bundler.setup # Same as Bundler.setup(:default)
|
13
|
+
rescue LoadError => e
|
14
|
+
handle_error(e)
|
15
|
+
end
|
16
|
+
|
17
|
+
def require
|
18
|
+
return unless gemfile?
|
19
|
+
Kernel.require "bundler/setup"
|
20
|
+
Bundler.require(*bundler_groups)
|
21
|
+
rescue LoadError => e
|
22
|
+
handle_error(e)
|
23
|
+
end
|
24
|
+
|
25
|
+
def handle_error(e)
|
26
|
+
puts e.message
|
27
|
+
return if e.message.include?("already activated")
|
28
|
+
puts <<~EOL.color(:yellow)
|
29
|
+
WARNING: Unable to require "bundler/setup"
|
30
|
+
There may be something funny with your ruby and bundler setup.
|
31
|
+
You can try upgrading bundler and rubygems:
|
32
|
+
|
33
|
+
gem update --system
|
34
|
+
gem install bundler
|
35
|
+
|
36
|
+
Here are some links that may be helpful:
|
37
|
+
|
38
|
+
* https://bundler.io/blog/2019/01/03/announcing-bundler-2.html
|
39
|
+
|
40
|
+
Also, running bundle exec in front of your command may remove this message.
|
41
|
+
EOL
|
42
|
+
end
|
43
|
+
|
44
|
+
def gemfile?
|
45
|
+
ENV['BUNDLE_GEMFILE'] || File.exist?("Gemfile")
|
46
|
+
end
|
47
|
+
|
48
|
+
def bundler_groups
|
49
|
+
[:default, Terraspace.env.to_sym]
|
50
|
+
end
|
51
|
+
|
52
|
+
extend self
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,185 @@
|
|
1
|
+
module Terraspace
|
2
|
+
class CLI < Command
|
3
|
+
class_option :verbose, type: :boolean
|
4
|
+
class_option :noop, type: :boolean
|
5
|
+
|
6
|
+
yes_option = Proc.new {
|
7
|
+
option :yes, aliases: :y, type: :boolean, desc: "-auto-approve the terraform apply"
|
8
|
+
}
|
9
|
+
format_option = Proc.new {
|
10
|
+
option :format, desc: "output formats: json, text"
|
11
|
+
}
|
12
|
+
out_option = Proc.new {
|
13
|
+
option :out, aliases: :o, desc: "write the output to path"
|
14
|
+
}
|
15
|
+
input_option = Proc.new {
|
16
|
+
option :input, type: :boolean, desc: "Ask for input for variables if not directly set."
|
17
|
+
}
|
18
|
+
auto_option = Proc.new {
|
19
|
+
option :auto, type: :boolean, desc: "Auto mode is useful for CI automation. It enables appropriate flags."
|
20
|
+
}
|
21
|
+
instance_option = Proc.new {
|
22
|
+
option :instance, aliases: %w[i], desc: "Instance of stack"
|
23
|
+
}
|
24
|
+
init_option = Proc.new {
|
25
|
+
option :init, type: :boolean, default: true, desc: "Instance of stack"
|
26
|
+
}
|
27
|
+
|
28
|
+
desc "new SUBCOMMAND", "new subcommands"
|
29
|
+
long_desc Help.text(:new)
|
30
|
+
subcommand "new", New
|
31
|
+
|
32
|
+
desc "build MODULE", "build"
|
33
|
+
long_desc Help.text(:build)
|
34
|
+
option :quiet, type: :boolean, default: true, desc: "quiet output"
|
35
|
+
auto_option.call
|
36
|
+
init_option.call
|
37
|
+
input_option.call
|
38
|
+
instance_option.call
|
39
|
+
def build(mod)
|
40
|
+
Build.new(options.merge(mod: mod)).run
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "bundle", "bundle"
|
44
|
+
long_desc Help.text(:bundle)
|
45
|
+
def bundle(*args)
|
46
|
+
Bundle.new(options.merge(args: args)).run
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "check_setup", "check_setup"
|
50
|
+
long_desc Help.text(:check_setup)
|
51
|
+
def check_setup
|
52
|
+
CheckSetup.new(options).run
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "clean", "clean .terraspace-cache dir"
|
56
|
+
long_desc Help.text(:clean)
|
57
|
+
def clean
|
58
|
+
Clean.new(options).run
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "console", "console .terraspace-cache dir"
|
62
|
+
long_desc Help.text(:console)
|
63
|
+
instance_option.call
|
64
|
+
def console(mod)
|
65
|
+
Commander.new("console", options.merge(mod: mod)).run
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "down MODULE", "down"
|
69
|
+
long_desc Help.text(:down)
|
70
|
+
instance_option.call
|
71
|
+
yes_option.call
|
72
|
+
def down(mod)
|
73
|
+
Commander.new("destroy", options.merge(mod: mod)).run
|
74
|
+
end
|
75
|
+
|
76
|
+
desc "info MODULE", "info"
|
77
|
+
long_desc Help.text(:info)
|
78
|
+
format_option.call
|
79
|
+
instance_option.call
|
80
|
+
def info(mod)
|
81
|
+
Info.new(options.merge(mod: mod)).run
|
82
|
+
end
|
83
|
+
|
84
|
+
desc "plan MODULE", "plan module"
|
85
|
+
long_desc Help.text(:plan)
|
86
|
+
auto_option.call
|
87
|
+
input_option.call
|
88
|
+
instance_option.call
|
89
|
+
out_option.call
|
90
|
+
def plan(mod)
|
91
|
+
Commander.new("plan", options.merge(mod: mod)).run
|
92
|
+
end
|
93
|
+
|
94
|
+
desc "providers MODULE", "providers"
|
95
|
+
long_desc Help.text(:providers)
|
96
|
+
instance_option.call
|
97
|
+
def providers(mod)
|
98
|
+
Commander.new("providers", options.merge(mod: mod)).run
|
99
|
+
end
|
100
|
+
|
101
|
+
desc "refresh", "refresh"
|
102
|
+
long_desc Help.text(:refresh)
|
103
|
+
instance_option.call
|
104
|
+
def refresh(mod)
|
105
|
+
Commander.new("refresh", options.merge(mod: mod)).run
|
106
|
+
end
|
107
|
+
|
108
|
+
desc "seed MODULE", "seed"
|
109
|
+
long_desc Help.text(:seed)
|
110
|
+
option :yes, aliases: :y, type: :boolean, desc: "bypass prompts and force overwrite files"
|
111
|
+
option :where, desc: "where to create file. either under app or seed folder structure. values: app or stack"
|
112
|
+
init_option.call
|
113
|
+
instance_option.call
|
114
|
+
def seed(mod)
|
115
|
+
Seed.new(options.merge(mod: mod)).run
|
116
|
+
end
|
117
|
+
|
118
|
+
desc "summary", "Summary of resources"
|
119
|
+
long_desc Help.text(:clean)
|
120
|
+
option :mod, desc: "Module to build to generate a backend file for discovery. By default the last module is used. Usually, it wont matter."
|
121
|
+
init_option.call
|
122
|
+
def summary
|
123
|
+
Summary.new(options).run
|
124
|
+
end
|
125
|
+
|
126
|
+
desc "show MODULE", "show"
|
127
|
+
long_desc Help.text(:show)
|
128
|
+
instance_option.call
|
129
|
+
def show(mod)
|
130
|
+
Commander.new("show", options.merge(mod: mod)).run
|
131
|
+
end
|
132
|
+
|
133
|
+
desc "test", "test"
|
134
|
+
long_desc Help.text(:test)
|
135
|
+
def test
|
136
|
+
Test.new(options).run
|
137
|
+
end
|
138
|
+
|
139
|
+
desc "output MODULE", "output"
|
140
|
+
long_desc Help.text(:output)
|
141
|
+
format_option.call
|
142
|
+
instance_option.call
|
143
|
+
out_option.call
|
144
|
+
def output(mod)
|
145
|
+
Commander.new("output", options.merge(mod: mod)).run
|
146
|
+
end
|
147
|
+
|
148
|
+
desc "update MODULE", "Update infrasturcture. IE: apply plan"
|
149
|
+
long_desc Help.text(:update)
|
150
|
+
auto_option.call
|
151
|
+
init_option.call
|
152
|
+
input_option.call
|
153
|
+
instance_option.call
|
154
|
+
yes_option.call
|
155
|
+
option :plan, desc: "Execution plan that can be used to only execute a pre-determined set of actions."
|
156
|
+
option :var_files, type: :array, desc: "list of var files"
|
157
|
+
def update(mod)
|
158
|
+
Commander.new("apply", options.merge(mod: mod, command: "update")).run
|
159
|
+
end
|
160
|
+
|
161
|
+
desc "validate MODULE", "validate"
|
162
|
+
long_desc Help.text(:validate)
|
163
|
+
instance_option.call
|
164
|
+
def validate(mod)
|
165
|
+
Commander.new("validate", options.merge(mod: mod)).run
|
166
|
+
end
|
167
|
+
|
168
|
+
desc "completion *PARAMS", "Prints words for auto-completion."
|
169
|
+
long_desc Help.text(:completion)
|
170
|
+
def completion(*params)
|
171
|
+
Completer.new(CLI, *params).run
|
172
|
+
end
|
173
|
+
|
174
|
+
desc "completion_script", "Generates a script that can be eval to setup auto-completion."
|
175
|
+
long_desc Help.text(:completion_script)
|
176
|
+
def completion_script
|
177
|
+
Completer::Script.generate
|
178
|
+
end
|
179
|
+
|
180
|
+
desc "version", "prints version"
|
181
|
+
def version
|
182
|
+
puts VERSION
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|