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,10 @@
|
|
1
|
+
_terraspace() {
|
2
|
+
COMPREPLY=()
|
3
|
+
local word="${COMP_WORDS[COMP_CWORD]}"
|
4
|
+
local words=("${COMP_WORDS[@]}")
|
5
|
+
unset words[0]
|
6
|
+
local completion=$(terraspace completion ${words[@]})
|
7
|
+
COMPREPLY=( $(compgen -W "$completion" -- "$word") )
|
8
|
+
}
|
9
|
+
|
10
|
+
complete -F _terraspace terraspace
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Terraspace
|
2
|
+
module Core
|
3
|
+
extend Memoist
|
4
|
+
|
5
|
+
def env
|
6
|
+
ENV['TS_ENV'] || "dev"
|
7
|
+
end
|
8
|
+
memoize :env
|
9
|
+
|
10
|
+
@@root = nil
|
11
|
+
def root
|
12
|
+
@@root ||= ENV['TS_ROOT'] || Dir.pwd
|
13
|
+
end
|
14
|
+
|
15
|
+
# allow testing frameworks to switch roots
|
16
|
+
def root=(v)
|
17
|
+
@@root = v
|
18
|
+
end
|
19
|
+
|
20
|
+
def cache_root
|
21
|
+
ENV['TS_CACHE_ROOT'] || "#{root}/.terraspace-cache"
|
22
|
+
end
|
23
|
+
memoize :cache_root
|
24
|
+
|
25
|
+
def tmp_root
|
26
|
+
ENV['TS_TMP_ROOT'] || "/tmp/terraspace"
|
27
|
+
end
|
28
|
+
memoize :tmp_root
|
29
|
+
|
30
|
+
def configure(&block)
|
31
|
+
App.instance.configure(&block)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Generally, use the Terraspace.config instead of App.instance.config since it guarantees the load_project_config call
|
35
|
+
def config
|
36
|
+
App.instance.load_project_config
|
37
|
+
App.instance.config
|
38
|
+
end
|
39
|
+
memoize :config
|
40
|
+
|
41
|
+
def logger
|
42
|
+
config.logger
|
43
|
+
end
|
44
|
+
memoize :logger
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Module
|
2
|
+
# Include all modules within the relative folder. IE: for dsl/syntax/mod/*
|
3
|
+
#
|
4
|
+
# include Common
|
5
|
+
# include Provider
|
6
|
+
# # etc
|
7
|
+
#
|
8
|
+
def include_dir(dir)
|
9
|
+
calling_file = caller[0].split(':').first # IE: /home/ec2-user/environment/terraspace/lib/terraspace/compiler/dsl/syntax/mod.rb
|
10
|
+
parent_dir = File.dirname(calling_file)
|
11
|
+
|
12
|
+
full_dir = "#{parent_dir}/#{dir}"
|
13
|
+
Dir.glob("#{full_dir}/**/*").each do |path|
|
14
|
+
regexp = Regexp.new(".*/lib/")
|
15
|
+
klass = path.sub(regexp, '').sub('.rb','').camelize
|
16
|
+
include klass.constantize
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
module Terraspace
|
4
|
+
class Logger < ::Logger
|
5
|
+
# Only need to override the add method as the other calls all lead to it.
|
6
|
+
def add(severity, message = nil, progname = nil)
|
7
|
+
# Taken from Logger#add source
|
8
|
+
# https://ruby-doc.org/stdlib-2.5.1/libdoc/logger/rdoc/Logger.html#method-i-add
|
9
|
+
if message.nil?
|
10
|
+
if block_given?
|
11
|
+
message = yield
|
12
|
+
else
|
13
|
+
message = progname
|
14
|
+
progname = @progname
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
super # original logic
|
19
|
+
end
|
20
|
+
|
21
|
+
# plain formatting
|
22
|
+
def format_message(severity, timestamp, progname, msg)
|
23
|
+
"#{msg}\n"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module Terraspace
|
2
|
+
# Example properties:
|
3
|
+
#
|
4
|
+
# name: vpc
|
5
|
+
# root: app/modules/vpc, app/stacks/vpc, vendor/modules/vpc or vendor/stacks/vpc
|
6
|
+
# type: module or stack
|
7
|
+
#
|
8
|
+
class Mod
|
9
|
+
extend Memoist
|
10
|
+
include Terraspace::Util
|
11
|
+
|
12
|
+
attr_reader :name, :consider_stacks, :instance, :options
|
13
|
+
def initialize(name, options={})
|
14
|
+
@name, @options = name, options
|
15
|
+
@consider_stacks = options[:consider_stacks].nil? ? true : options[:consider_stacks]
|
16
|
+
@instance = options[:instance]
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_accessor :root_module
|
20
|
+
def root_module?
|
21
|
+
@root_module
|
22
|
+
end
|
23
|
+
|
24
|
+
def check_exist!
|
25
|
+
check_terraspace_project!
|
26
|
+
return if root
|
27
|
+
|
28
|
+
pretty_paths = paths.map { |p| Terraspace::Util.pretty_path(p) }
|
29
|
+
logger.error "ERROR: Unable to find #{@name.color(:green)} module. Searched paths: #{pretty_paths}"
|
30
|
+
ENV['TS_TEST'] ? raise : exit(1)
|
31
|
+
end
|
32
|
+
|
33
|
+
def check_terraspace_project!
|
34
|
+
return if File.exist?("#{Terraspace.root}/config/app.rb")
|
35
|
+
logger.error "ERROR: It doesnt look like this is a terraspace project. Are you sure you are in a terraspace project?".color(:red)
|
36
|
+
ENV['TS_TEST'] ? raise : exit(1)
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_info
|
40
|
+
{
|
41
|
+
build_dir: build_dir,
|
42
|
+
cache_build_dir: Terraspace::Util.pretty_path(cache_build_dir),
|
43
|
+
name: name,
|
44
|
+
root: Terraspace::Util.pretty_path(root),
|
45
|
+
type: type,
|
46
|
+
type_dir: type_dir,
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def root
|
51
|
+
paths.find { |p| File.exist?(p) }
|
52
|
+
end
|
53
|
+
memoize :root
|
54
|
+
|
55
|
+
# Relative folder path without app or vendor. For example, the actual location can be found in a couple of places
|
56
|
+
#
|
57
|
+
# app/modules/vpc
|
58
|
+
# app/stacks/vpc
|
59
|
+
# vendor/modules/vpc
|
60
|
+
# vendor/stacks/vpc
|
61
|
+
#
|
62
|
+
# The build folder does not include the app or vendor info.
|
63
|
+
#
|
64
|
+
# modules/vpc
|
65
|
+
#
|
66
|
+
def build_dir(disable_instance: false)
|
67
|
+
if !disable_instance && !@instance.nil?
|
68
|
+
# add _ in front so instance doesnt collide with other default stacks
|
69
|
+
instance_name = [name, @instance].compact.join('.')
|
70
|
+
else
|
71
|
+
instance_name = name
|
72
|
+
end
|
73
|
+
[type_dir, instance_name].compact.join('/')
|
74
|
+
end
|
75
|
+
|
76
|
+
# Full path with build_dir
|
77
|
+
def cache_build_dir
|
78
|
+
"#{Terraspace.cache_root}/#{Terraspace.env}/#{build_dir}"
|
79
|
+
end
|
80
|
+
|
81
|
+
def type
|
82
|
+
root.include?("/stacks/") ? "stack" : "module"
|
83
|
+
end
|
84
|
+
|
85
|
+
def type_dir
|
86
|
+
type.pluralize
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
def paths
|
91
|
+
paths = []
|
92
|
+
root = Terraspace.root
|
93
|
+
paths << "#{root}/app/stacks/#{@name}" if @consider_stacks
|
94
|
+
paths << "#{root}/app/modules/#{@name}"
|
95
|
+
paths << "#{root}/vendor/stacks/#{@name}" if @consider_stacks
|
96
|
+
paths << "#{root}/vendor/modules/#{@name}"
|
97
|
+
paths
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Terraspace::Mod
|
2
|
+
class Remote < Terraspace::Mod
|
3
|
+
def initialize(meta, parent)
|
4
|
+
# meta: from .terraform/modules/modules.json. Example structure: spec/fixtures/initialized/modules.json
|
5
|
+
# parent: parent module or stack. IE: terraspace build MOD
|
6
|
+
@meta, @parent = meta, parent
|
7
|
+
@name = @meta['Key']
|
8
|
+
end
|
9
|
+
|
10
|
+
def root
|
11
|
+
"#{@parent.cache_build_dir}/#{@meta['Dir']}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def type
|
15
|
+
"module"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Terraspace
|
2
|
+
module Plugin
|
3
|
+
extend Memoist
|
4
|
+
|
5
|
+
# The plugin metadata
|
6
|
+
#
|
7
|
+
# Example meta:
|
8
|
+
#
|
9
|
+
# {
|
10
|
+
# "aws => {root: "/path", backend: "s3"}
|
11
|
+
# "google" => {root: "/path", backend: "gcs"},
|
12
|
+
# }
|
13
|
+
#
|
14
|
+
@@meta = {}
|
15
|
+
def meta
|
16
|
+
@@meta
|
17
|
+
end
|
18
|
+
|
19
|
+
def layer_classes
|
20
|
+
@@meta.map { |plugin, data| data[:layer_class] }.compact
|
21
|
+
end
|
22
|
+
|
23
|
+
def config_classes
|
24
|
+
@@meta.map { |plugin, data| data[:config_class] }.compact
|
25
|
+
end
|
26
|
+
|
27
|
+
# The resource map can be used to customized the mapping from the resource "first word" to the plugin.
|
28
|
+
#
|
29
|
+
# resource map is in meta structure.
|
30
|
+
#
|
31
|
+
# {
|
32
|
+
# "long_cloud_plugin_name" => {resource_map: {"long_cloud_plugin_name" => "short_name"}
|
33
|
+
# }
|
34
|
+
#
|
35
|
+
# This is use by Plugin::Finder#find_with_resource
|
36
|
+
# Allows mapping of different values in case the terraspace plugin name doesnt match with the
|
37
|
+
# resource first word.
|
38
|
+
#
|
39
|
+
# Generally we try to avoid this and the terraspace plugin name should match the resource "first word"
|
40
|
+
# when possible.
|
41
|
+
#
|
42
|
+
def resource_map
|
43
|
+
@@meta.inject({}) do |result, (plugin, data)|
|
44
|
+
map = data[:resource_map] || {}
|
45
|
+
result.merge(map.deep_stringify_keys)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def register(plugin, data)
|
50
|
+
@@meta[plugin] = data
|
51
|
+
end
|
52
|
+
|
53
|
+
# Example return:
|
54
|
+
#
|
55
|
+
# TerraspacePluginAws::Interfaces::Backend
|
56
|
+
# TerraspacePluginAws::Interfaces::Expander
|
57
|
+
# TerraspacePluginGcp::Interfaces::Backend
|
58
|
+
# TerraspacePluginGcp::Interfaces::Expander
|
59
|
+
#
|
60
|
+
def klass(interface_class, options={})
|
61
|
+
meta = find_with(options)
|
62
|
+
return unless meta
|
63
|
+
"TerraspacePlugin#{meta.plugin}::Interfaces::#{interface_class}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def find_with(options={})
|
67
|
+
Finder.new.find_with(options)
|
68
|
+
end
|
69
|
+
memoize :find_with
|
70
|
+
|
71
|
+
extend self
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Should implement methods:
|
2
|
+
# defaults
|
3
|
+
# provider
|
4
|
+
module Terraspace::Plugin::Config
|
5
|
+
module Interface
|
6
|
+
include DslEvaluator
|
7
|
+
|
8
|
+
attr_reader :config
|
9
|
+
def initialize
|
10
|
+
@config = defaults # plugin should implement defaults
|
11
|
+
end
|
12
|
+
|
13
|
+
# meant to be overridden by plugin
|
14
|
+
def defaults
|
15
|
+
ActiveSupport::OrderedOptions.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def load_project_config
|
19
|
+
project_config = "#{Terraspace.root}/config/plugins/#{provider}.rb"
|
20
|
+
evaluate_file(project_config)
|
21
|
+
end
|
22
|
+
|
23
|
+
def configure
|
24
|
+
yield(@config)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Should implement additional methods that correspond to additional provider specific variables
|
2
|
+
# available for substitution. For example:
|
3
|
+
#
|
4
|
+
# AWS has :REGION and :ACCOUNT variables.
|
5
|
+
# So the aws provider implements the region and account methods.
|
6
|
+
#
|
7
|
+
module Terraspace::Plugin::Expander
|
8
|
+
module Interface
|
9
|
+
delegate :build_dir, :type_dir, to: :mod
|
10
|
+
|
11
|
+
attr_reader :mod
|
12
|
+
def initialize(mod)
|
13
|
+
@mod = mod
|
14
|
+
end
|
15
|
+
|
16
|
+
def expand(props={})
|
17
|
+
props.each do |key, value|
|
18
|
+
props[key] = expand_string(value)
|
19
|
+
end
|
20
|
+
props
|
21
|
+
end
|
22
|
+
|
23
|
+
# Replaces variables denoted by colon in front with actual values. Example:
|
24
|
+
#
|
25
|
+
# :REGION/:ENV/:BUILD_DIR/terraform.tfstate
|
26
|
+
# =>
|
27
|
+
# us-west-2/dev/stacks/wordpress/terraform.tfstate
|
28
|
+
#
|
29
|
+
def expand_string(string)
|
30
|
+
return string unless string.is_a?(String) # in case of nil
|
31
|
+
|
32
|
+
vars = string.scan(/:\w+/) # => [":ENV", ":BUILD_DIR"]
|
33
|
+
vars.each do |var|
|
34
|
+
string.gsub!(var, var_value(var))
|
35
|
+
end
|
36
|
+
string
|
37
|
+
end
|
38
|
+
|
39
|
+
def var_value(name)
|
40
|
+
name = name.sub(':','').downcase
|
41
|
+
send(name)
|
42
|
+
end
|
43
|
+
|
44
|
+
def mod_name
|
45
|
+
@mod.name
|
46
|
+
end
|
47
|
+
|
48
|
+
def env
|
49
|
+
Terraspace.env
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Terraspace::Plugin
|
2
|
+
class Finder
|
3
|
+
def find_with(options)
|
4
|
+
result = if options.key?(:plugin)
|
5
|
+
find_with_plugin(options[:plugin])
|
6
|
+
elsif options.key?(:backend)
|
7
|
+
find_with_backend(options[:backend])
|
8
|
+
elsif options.key?(:resource)
|
9
|
+
find_with_resource(options[:resource])
|
10
|
+
else
|
11
|
+
raise "Must provide backend, plugin, or resource option."
|
12
|
+
end
|
13
|
+
return unless result
|
14
|
+
raw = Hash[*result] # convert result to Hash instead of an Array
|
15
|
+
Meta.new(raw)
|
16
|
+
end
|
17
|
+
|
18
|
+
def find_with_backend(backend)
|
19
|
+
meta.find do |provider, data|
|
20
|
+
data[:backend] == backend
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def find_with_plugin(plugin)
|
25
|
+
meta.find do |plugin_name, data|
|
26
|
+
plugin_name == plugin
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_with_resource(resource)
|
31
|
+
map = resource_map
|
32
|
+
base = resource.split('_').first # google_compute_firewall => google, aws_security_group => aws
|
33
|
+
plugin = map[base] || base
|
34
|
+
find_with_plugin(plugin)
|
35
|
+
end
|
36
|
+
|
37
|
+
def resource_map
|
38
|
+
Terraspace::Plugin.resource_map
|
39
|
+
end
|
40
|
+
|
41
|
+
def meta
|
42
|
+
Terraspace::Plugin.meta
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|