terraspace 0.3.4 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/README.md +56 -29
- data/lib/templates/base/project/README.md +1 -1
- data/lib/terraspace/all/preview.rb +1 -1
- data/lib/terraspace/all/runner.rb +1 -0
- data/lib/terraspace/all/summary.rb +8 -1
- data/lib/terraspace/app.rb +9 -5
- data/lib/terraspace/builder.rb +10 -6
- data/lib/terraspace/cli.rb +11 -16
- data/lib/terraspace/cli/all.rb +6 -0
- data/lib/terraspace/cli/bundle.rb +2 -1
- data/lib/terraspace/cli/clean.rb +18 -6
- data/lib/terraspace/cli/clean/all.rb +18 -0
- data/lib/terraspace/cli/clean/base.rb +15 -0
- data/lib/terraspace/cli/clean/cache.rb +25 -0
- data/lib/terraspace/cli/{logs/tasks.rb → clean/logs.rb} +16 -5
- data/lib/terraspace/cli/help/all/init.md +33 -0
- data/lib/terraspace/cli/help/clean/all.md +10 -0
- data/lib/terraspace/cli/help/clean/cache.md +12 -0
- data/lib/terraspace/cli/help/clean/logs.md +17 -0
- data/lib/terraspace/cli/help/logs.md +48 -0
- data/lib/terraspace/cli/init.rb +3 -7
- data/lib/terraspace/cli/list.rb +2 -1
- data/lib/terraspace/cli/logs.rb +106 -9
- data/lib/terraspace/cli/{log → logs}/concern.rb +2 -1
- data/lib/terraspace/cli/new/helper.rb +9 -2
- data/lib/terraspace/compiler/dependencies/helpers.rb +34 -0
- data/lib/terraspace/compiler/dsl/syntax/helpers/common.rb +0 -26
- data/lib/terraspace/compiler/dsl/syntax/tfvar.rb +1 -0
- data/lib/terraspace/compiler/erb/context.rb +1 -1
- data/lib/terraspace/compiler/erb/helpers.rb +6 -0
- data/lib/terraspace/dependency/helper/base.rb +7 -0
- data/lib/terraspace/dependency/helper/depends_on.rb +12 -0
- data/lib/terraspace/dependency/helper/output.rb +11 -0
- data/lib/terraspace/hooks/builder.rb +52 -0
- data/lib/terraspace/hooks/concern.rb +9 -0
- data/lib/terraspace/{terraform/hooks → hooks}/dsl.rb +3 -2
- data/lib/terraspace/hooks/runner.rb +23 -0
- data/lib/terraspace/mod.rb +11 -2
- data/lib/terraspace/plugin/summary/interface.rb +3 -1
- data/lib/terraspace/shell.rb +15 -10
- data/lib/terraspace/terraform/args/custom.rb +1 -1
- data/lib/terraspace/terraform/args/default.rb +9 -19
- data/lib/terraspace/terraform/remote_state/fetcher.rb +13 -4
- data/lib/terraspace/terraform/remote_state/marker/output.rb +3 -1
- data/lib/terraspace/terraform/remote_state/output_proxy.rb +18 -14
- data/lib/terraspace/terraform/remote_state/unresolved.rb +40 -0
- data/lib/terraspace/terraform/runner.rb +3 -8
- data/lib/terraspace/version.rb +1 -1
- data/spec/fixtures/dependencies/app/stacks/a1/tfvars/dev.tfvars +1 -0
- data/spec/fixtures/fetcher/c1.json +4 -0
- data/spec/terraspace/compiler/erb/render_spec.rb +15 -0
- data/spec/terraspace/dependency/helper/depends_on_spec.rb +27 -0
- data/spec/terraspace/dependency/helper/output_spec.rb +29 -0
- data/spec/terraspace/{terraform/hooks → hooks}/builder_spec.rb +4 -5
- data/spec/terraspace/terraform/remote_state/fetcher_spec.rb +108 -27
- data/spec/terraspace/terraform/remote_state/marker/output_spec.rb +36 -0
- data/spec/terraspace/terraform/remote_state/output_proxy_spec.rb +69 -0
- data/terraspace.gemspec +1 -1
- metadata +38 -13
- data/lib/terraspace/cli/help/clean.md +0 -5
- data/lib/terraspace/cli/help/log.md +0 -48
- data/lib/terraspace/cli/log.rb +0 -112
- data/lib/terraspace/terraform/hooks/builder.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0174dca33a15bfe2c0eb0a1e0f573599ab7de2850d746e6f0be4e34aec573e39
|
4
|
+
data.tar.gz: 4d2b91fb5631d3fa1c32379845cc1f3d677238edc7133015cf99050e874339f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b624c36518fd03e4b03c8ddba62dc196ea656f26921086ddb3dec4859f613b3da2534f0320f0c6197a53fd31d9f5a44ad98f5c5c4b3914164185707a42eb007e
|
7
|
+
data.tar.gz: 87b7625d52efd046193ec7ed9abfb7e311b7b143d70e492db84e60cccb4b90fea872d1f6333901d95a6c9af7d07bf2d5027980aa482794d5f60b27ed9a8e3e41
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,39 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.4.2]
|
7
|
+
* #48 add logs pid option
|
8
|
+
* default to input false, encourage set tfvars
|
9
|
+
|
10
|
+
## [0.4.1]
|
11
|
+
* #47 `terraspace list` fix and `terraspace all init` help updates
|
12
|
+
|
13
|
+
## [0.4.0]
|
14
|
+
* #46 improve hooks, bundle, auto init and bug fixes
|
15
|
+
* improve hooks: allow multiple hooks of same type, change path hooks/terraform.rb
|
16
|
+
* improve hooks: introduce terraspace-level as well as terraform-level hooks
|
17
|
+
* improve hooks: can take Ruby block or shell script
|
18
|
+
* improve auto init: reinit when module source changed, improve auto init: generalize retry check
|
19
|
+
* fix already_init? detection for case when stack does use module
|
20
|
+
* terraspace bundler options: can set any option now
|
21
|
+
* add `terraspace all init` command
|
22
|
+
* improve terraspace clean, prompt user and add `-y` option
|
23
|
+
* bundle: check if in terraspace project
|
24
|
+
* Rename NullObject to Unresolved
|
25
|
+
* improve error message when stacks not found. give `terraspace list` hint
|
26
|
+
* terraspace list. change default to `--type stack`
|
27
|
+
* change summary option to --details
|
28
|
+
* include terraspace version in generated Gemfile
|
29
|
+
* logs command to handle viewing, and clean logs to clean
|
30
|
+
|
31
|
+
## [0.3.6]
|
32
|
+
* #44 improve logs management commands: `terraspace logs remove` and `terraspace logs truncate`
|
33
|
+
|
34
|
+
## [0.3.5]
|
35
|
+
* #43 rename `terraform_output` helper to `output`. Keep `terraform_output` for backwards compatibility
|
36
|
+
* to_ruby natural interface to access output with full power of Ruby
|
37
|
+
* output formatters removed in favor for `.to_ruby` method.
|
38
|
+
|
6
39
|
## [0.3.4]
|
7
40
|
* #42 update cli docs and bug fixes
|
8
41
|
* fix console by using system instead of popen3
|
data/README.md
CHANGED
@@ -29,59 +29,77 @@ Here are commands to get started:
|
|
29
29
|
* The `up` command creates an s3 bucket.
|
30
30
|
* The `down` command cleans up and deletes the bucket.
|
31
31
|
|
32
|
-
The default plugin is aws.
|
32
|
+
The default plugin is aws. Major cloud providers are supported: [aws](https://terraspace.cloud/docs/learn/aws/), [azurerm](https://terraspace.cloud/docs/learn/azure/), [google](https://terraspace.cloud/docs/learn/gcp/).
|
33
33
|
|
34
34
|
## Usage
|
35
35
|
|
36
36
|
Create infrastructure:
|
37
37
|
|
38
|
-
$ terraspace up demo
|
38
|
+
$ terraspace up demo
|
39
39
|
Building .terraspace-cache/us-west-2/dev/stacks/demo
|
40
40
|
Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
|
41
|
-
=> terraform init -get
|
42
|
-
|
43
|
-
=> terraform apply -auto-approve
|
44
|
-
random_pet.bucket: Creating...
|
45
|
-
random_pet.bucket: Creation complete after 0s [id=amusing-mouse]
|
46
|
-
module.bucket.aws_s3_bucket.this: Creating...
|
47
|
-
module.bucket.aws_s3_bucket.this: Creation complete after 1s [id=bucket-amusing-mouse]
|
48
|
-
|
41
|
+
=> terraform init -get >> /tmp/terraspace/log/init/demo.log
|
42
|
+
=> terraform apply
|
49
43
|
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
|
50
|
-
|
51
|
-
Outputs:
|
52
|
-
|
53
|
-
bucket_name = bucket-amusing-mouse
|
54
44
|
$
|
55
45
|
|
56
46
|
Destroy infrastructure:
|
57
47
|
|
58
|
-
$ terraspace down demo
|
48
|
+
$ terraspace down demo
|
59
49
|
Building .terraspace-cache/us-west-2/dev/stacks/demo
|
60
50
|
Current directory: .terraspace-cache/us-west-2/dev/stacks/demo
|
61
|
-
=> terraform
|
62
|
-
Built in .terraspace-cache/us-west-2/dev/stacks/demo
|
63
|
-
=> terraform destroy -auto-approve
|
64
|
-
random_pet.bucket: Refreshing state... [id=amusing-mouse]
|
65
|
-
module.bucket.aws_s3_bucket.this: Refreshing state... [id=bucket-amusing-mouse]
|
66
|
-
module.bucket.aws_s3_bucket.this: Destroying... [id=bucket-amusing-mouse]
|
67
|
-
module.bucket.aws_s3_bucket.this: Destruction complete after 1s
|
68
|
-
random_pet.bucket: Destroying... [id=amusing-mouse]
|
69
|
-
random_pet.bucket: Destruction complete after 0s
|
70
|
-
|
51
|
+
=> terraform destroy
|
71
52
|
Destroy complete! Resources: 2 destroyed.
|
72
53
|
$
|
73
54
|
|
55
|
+
* Blog: [Introducing Terraspace: The Terraform Framework](https://blog.boltops.com/2020/08/22/introducing-terraspace-the-terraform-framework)
|
56
|
+
* Docs: [Terraspace Intro](https://terraspace.cloud/docs/intro/)
|
57
|
+
|
74
58
|
## Deploy Multiple Stacks
|
75
59
|
|
76
60
|
To deploy all the infrastructure stacks:
|
77
61
|
|
78
|
-
terraspace all up
|
62
|
+
$ terraspace all up
|
63
|
+
Will run:
|
64
|
+
terraspace up vpc # batch 1
|
65
|
+
terraspace up mysql # batch 2
|
66
|
+
terraspace up redis # batch 2
|
67
|
+
terraspace up instance # batch 3
|
68
|
+
Are you sure? (y/N)
|
79
69
|
|
80
70
|
To choose multiple stacks to deploy
|
81
71
|
|
82
|
-
terraspace all up
|
72
|
+
$ terraspace all up mysql redis
|
73
|
+
Will run:
|
74
|
+
terraspace up vpc # batch 1
|
75
|
+
terraspace up mysql # batch 2
|
76
|
+
terraspace up redis # batch 2
|
77
|
+
Are you sure? (y/N)
|
78
|
+
|
79
|
+
When you use the all command, the dependency graph is calculated and the stacks are deployed in the right order.
|
80
|
+
|
81
|
+
* Blog: [Terraspace All: Deploy Multiple Stacks or Terraform Modules At Once](https://blog.boltops.com/2020/09/19/terraspace-all-deploy-multiple-stacks-at-once)
|
82
|
+
* Docs: [Deploy Multiple Stacks](https://terraspace.cloud/docs/intro/deploy-all/).
|
83
|
+
|
84
|
+
## Terrafile
|
83
85
|
|
84
|
-
|
86
|
+
Terraspace makes it easy to use Terraform modules sourced from your own git repositories, other git repositories, or the Terraform Registry. Use any module you want:
|
87
|
+
|
88
|
+
Terrafile:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
# GitHub repo
|
92
|
+
mod "s3", source: "boltops-tools/terraform-aws-s3", tag: "v0.1.0"
|
93
|
+
# Terraform registry
|
94
|
+
mod "sg", source: "terraform-aws-modules/security-group/aws", version: "3.10.0"
|
95
|
+
```
|
96
|
+
|
97
|
+
To install modules:
|
98
|
+
|
99
|
+
terraspace bundle
|
100
|
+
|
101
|
+
* Blog: [Terraspace Terrafile: Using Git and Terraform Registry Modules](https://blog.boltops.com/2020/10/18/terraspace-terrafile-using-git-repos-and-terraform-registry-modules)
|
102
|
+
* Docs: [Terrafile](https://terraspace.cloud/docs/terrafile/)
|
85
103
|
|
86
104
|
## Features
|
87
105
|
|
@@ -89,8 +107,17 @@ When you use the all command, the dependency graph is calculated and the stacks
|
|
89
107
|
* [Generators](https://terraspace.cloud/docs/generators/): Built-in generators to quickly create the starter module. Focus on code instead of boilerplate structure.
|
90
108
|
* [Tfvars](https://terraspace.cloud/docs/tfvars/) & [Layering](https://terraspace.cloud/docs/tfvars/layering/): Use the same code with different tfvars to create multiple environments. Terraspace conventionally loads tfvars from the `tfvars` folder. Rich layering support allows you to build different environments like dev and prod with the same code. Examples are in [Full Layering](https://terraspace.cloud/docs/tfvars/full-layering/).
|
91
109
|
* [Deploy Multiple Stacks](https://terraspace.cloud/docs/intro/deploy-all/): The ability to deploy multiple stacks with a single command. Terraspace calculates the [dependency graph](https://terraspace.cloud/docs/dependencies/) and deploys stacks in the right order. You can also target specific stacks and deploy [subgraphs](https://terraspace.cloud/docs/dependencies/subgraphs/).
|
110
|
+
* [Terrafile](https://terraspace.cloud/docs/terrafile/}): Terraspace makes it easy to use Terraform modules sourced from your own git repositories, other git repositories, or the Terraform Registry. The git repos can be private or public. This is an incredibly powerful feature of Terraspace because it opens up a world of modules for you to use. Use any module you want.
|
92
111
|
* [Configurable CLI](https://terraspace.cloud/docs/cli/): Configurable [CLI Hooks](https://terraspace.cloud/docs/cli/hooks/) and [CLI Args](https://terraspace.cloud/docs/cli/args/) allow you to adjust the underlying terraform command.
|
93
112
|
* [Testing](https://terraspace.cloud/docs/testing/): A testing framework that allows you to create test harnesses, deploy real-resources, and have higher confidence that your code works.
|
94
113
|
* [Terraform Cloud and Terraform Enterprise Support](https://terraspace.cloud/docs/cloud/): TFC and TFE are both supported. Terraspace adds additional conveniences to make working with Terraform Cloud Workspaces easier.
|
95
114
|
|
96
|
-
|
115
|
+
## Comparison
|
116
|
+
|
117
|
+
Here are some useful comparisons to help you compare Terraspace vs other tools in the ecosystem:
|
118
|
+
|
119
|
+
* [Terraspace vs Custom Solution](https://terraspace.cloud/docs/vs/custom/)
|
120
|
+
* [Terraspace vs Terraform](https://terraspace.cloud/docs/vs/terraform/)
|
121
|
+
* [Terraform vs Terragrunt vs Terraspace](https://blog.boltops.com/2020/09/28/terraform-vs-terragrunt-vs-terraspace)
|
122
|
+
|
123
|
+
More info: [terraspace.cloud](https://terraspace.cloud)
|
@@ -22,7 +22,7 @@ module Terraspace::All
|
|
22
22
|
@batches.map do |batch|
|
23
23
|
i += 1
|
24
24
|
batch.map do |stack|
|
25
|
-
command = "
|
25
|
+
command = " terraspace #{@command}"
|
26
26
|
ljust = command.size + max_name_size + 1
|
27
27
|
command = "#{command} #{stack.name}"
|
28
28
|
command.ljust(ljust, ' ') + " # batch #{i}"
|
@@ -105,6 +105,7 @@ module Terraspace::All
|
|
105
105
|
set_log_path!(mod_name)
|
106
106
|
name = command_map(@command)
|
107
107
|
o = @options.merge(mod: mod_name, yes: true, build: false, input: false)
|
108
|
+
o.merge!(quiet: false) if @command == "init" # noisy so can filter and summarize output
|
108
109
|
case @command
|
109
110
|
when "up"
|
110
111
|
Terraspace::CLI::Up.new(o).run
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Terraspace::All
|
2
2
|
class Summary
|
3
|
-
include Terraspace::CLI::
|
3
|
+
include Terraspace::CLI::Logs::Concern
|
4
4
|
include Terraspace::Util::Logging
|
5
5
|
|
6
6
|
def initialize(data={})
|
@@ -35,6 +35,13 @@ module Terraspace::All
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def init
|
39
|
+
@lines.select! do |line|
|
40
|
+
line.include?("successfully initialized") || # success
|
41
|
+
line.include?("Error: ") # error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
38
45
|
# Example 1:
|
39
46
|
# [2020-09-07T14:45:14 #23340 terraspace plan b1]: No changes. Infrastructure is up-to-date.
|
40
47
|
# Example 2:
|
data/lib/terraspace/app.rb
CHANGED
@@ -9,6 +9,8 @@ module Terraspace
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def defaults
|
12
|
+
ts_logger = Logger.new(ENV['TS_LOG_PATH'] || $stderr)
|
13
|
+
|
12
14
|
config = ActiveSupport::OrderedOptions.new
|
13
15
|
config.all = ActiveSupport::OrderedOptions.new
|
14
16
|
config.all.concurrency = 5
|
@@ -21,14 +23,16 @@ module Terraspace
|
|
21
23
|
config.build.cache_dir = ":CACHE_ROOT/:REGION/:ENV/:BUILD_DIR"
|
22
24
|
config.build.cache_root = nil # defaults to /full/path/to/.terraspace-cache
|
23
25
|
config.build.clean_cache = nil # defaults to /full/path/to/.terraspace-cache
|
26
|
+
config.bundle = ActiveSupport::OrderedOptions.new
|
27
|
+
config.bundle.logger = ts_logger
|
24
28
|
config.cloud = ActiveSupport::OrderedOptions.new
|
25
29
|
config.cloud.auto_sync = true
|
26
|
-
config.cloud.working_dir_prefix = nil
|
27
30
|
config.cloud.hostname = nil
|
28
31
|
config.cloud.vars = ActiveSupport::OrderedOptions.new
|
29
32
|
config.cloud.vars.overwrite = true
|
30
33
|
config.cloud.vars.overwrite_sensitive = true
|
31
34
|
config.cloud.vars.show_message = "create"
|
35
|
+
config.cloud.working_dir_prefix = nil
|
32
36
|
config.cloud.workspace = ActiveSupport::OrderedOptions.new
|
33
37
|
config.cloud.workspace.attrs = ActiveSupport::OrderedOptions.new
|
34
38
|
config.hooks = Hooks.new
|
@@ -36,14 +40,14 @@ module Terraspace
|
|
36
40
|
config.init.mode = "auto" # auto, never, always
|
37
41
|
config.log = ActiveSupport::OrderedOptions.new
|
38
42
|
config.log.root = Terraspace.log_root
|
39
|
-
config.logger =
|
40
|
-
config.logger.level = ENV['TS_LOG_LEVEL'] || :info
|
43
|
+
config.logger = ts_logger
|
41
44
|
config.logger.formatter = Logger::Formatter.new
|
42
|
-
config.
|
45
|
+
config.logger.level = ENV['TS_LOG_LEVEL'] || :info
|
43
46
|
config.terraform = ActiveSupport::OrderedOptions.new
|
44
47
|
config.terraform.plugin_cache = ActiveSupport::OrderedOptions.new
|
45
|
-
config.terraform.plugin_cache.enabled = true
|
46
48
|
config.terraform.plugin_cache.dir = ENV['TF_PLUGIN_CACHE_DIR'] || "#{Terraspace.tmp_root}/plugin_cache"
|
49
|
+
config.terraform.plugin_cache.enabled = true
|
50
|
+
config.test_framework = "rspec"
|
47
51
|
config
|
48
52
|
end
|
49
53
|
|
data/lib/terraspace/builder.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Terraspace
|
2
2
|
class Builder < Terraspace::CLI::Base
|
3
|
-
include Compiler::DirsConcern
|
4
3
|
include Compiler::CommandsConcern
|
4
|
+
include Compiler::DirsConcern
|
5
|
+
include Hooks::Concern
|
5
6
|
|
6
7
|
attr_reader :graph
|
7
8
|
|
@@ -14,11 +15,14 @@ module Terraspace
|
|
14
15
|
placeholder_stack_message
|
15
16
|
logger.info "Building #{build_dir}" unless @options[:quiet] # from terraspace all
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
batches = nil
|
19
|
+
run_hooks("terraspace.rb", "build") do
|
20
|
+
build_unresolved
|
21
|
+
auto_create_backend
|
22
|
+
batches = build_batches
|
23
|
+
build_all
|
24
|
+
logger.info "Built in #{build_dir}" unless @options[:quiet] # from terraspace all
|
25
|
+
end
|
22
26
|
batches
|
23
27
|
end
|
24
28
|
|
data/lib/terraspace/cli.rb
CHANGED
@@ -32,14 +32,14 @@ module Terraspace
|
|
32
32
|
long_desc Help.text(:all)
|
33
33
|
subcommand "all", All
|
34
34
|
|
35
|
+
desc "clean SUBCOMMAND", "clean subcommands"
|
36
|
+
long_desc Help.text(:clean)
|
37
|
+
subcommand "clean", Clean
|
38
|
+
|
35
39
|
desc "cloud SUBCOMMAND", "cloud subcommands"
|
36
40
|
long_desc Help.text(:cloud)
|
37
41
|
subcommand "cloud", Cloud
|
38
42
|
|
39
|
-
desc "logs SUBCOMMAND", "logs management subcommands"
|
40
|
-
long_desc Help.text(:logs)
|
41
|
-
subcommand "logs", Logs
|
42
|
-
|
43
43
|
desc "new SUBCOMMAND", "new subcommands"
|
44
44
|
long_desc Help.text(:new)
|
45
45
|
subcommand "new", New
|
@@ -65,12 +65,6 @@ module Terraspace
|
|
65
65
|
CheckSetup.new(options).run
|
66
66
|
end
|
67
67
|
|
68
|
-
desc "clean", "Removes .terraspace-cache dir."
|
69
|
-
long_desc Help.text(:clean)
|
70
|
-
def clean
|
71
|
-
Clean.new(options).run
|
72
|
-
end
|
73
|
-
|
74
68
|
desc "console STACK", "Run console in built terraform project."
|
75
69
|
long_desc Help.text(:console)
|
76
70
|
instance_option.call
|
@@ -105,19 +99,20 @@ module Terraspace
|
|
105
99
|
|
106
100
|
desc "list", "List stacks and modules."
|
107
101
|
long_desc Help.text(:list)
|
108
|
-
option :type, aliases: %w[t], desc: "Type: stack
|
102
|
+
option :type, default: "stack", aliases: %w[t], desc: "Type: stack, module, or all"
|
109
103
|
def list
|
110
104
|
List.new(options).run
|
111
105
|
end
|
112
106
|
|
113
|
-
desc "
|
114
|
-
long_desc Help.text("
|
107
|
+
desc "logs [ACTION] [STACK]", "View and tail logs."
|
108
|
+
long_desc Help.text("logs")
|
115
109
|
option :timestamps, aliases: %w[t], type: :boolean, desc: "Whether or not to show the leading timestamp. Defaults to timestamps for multiple logs, and no timestamp if a single log is specified. Note: In follow mode, timestamp always shown"
|
116
110
|
option :follow, aliases: %w[f], type: :boolean, desc: "Follow the log in live tail fashion. Must specify a stack if using this option."
|
117
111
|
option :limit, aliases: %w[n], default: 10, type: :numeric, desc: "Number of lines to limit showing. Only applies in no-follow mode."
|
118
112
|
option :all, aliases: %w[a], type: :boolean, desc: "All mode turns off the limit. Defaults to all if a single log is specified. Only applies in no-follow mode."
|
119
|
-
|
120
|
-
|
113
|
+
option :pid, aliases: %w[p], desc: "Filter by pid. Defaults to the last pid at the bottom of the log file."
|
114
|
+
def logs(action=nil, stack=nil)
|
115
|
+
Logs.new(@options.merge(action: action, stack: stack)).run
|
121
116
|
end
|
122
117
|
|
123
118
|
desc "plan STACK", "Plan stack."
|
@@ -159,7 +154,7 @@ module Terraspace
|
|
159
154
|
long_desc Help.text(:summary)
|
160
155
|
option :mod, desc: "Module to build to generate a backend file for discovery. By default the last module is used. Usually, it wont matter."
|
161
156
|
init_option.call
|
162
|
-
option :
|
157
|
+
option :details, type: :boolean, desc: "Show details of the listed resources"
|
163
158
|
def summary
|
164
159
|
Summary.new(options).run
|
165
160
|
end
|
data/lib/terraspace/cli/all.rb
CHANGED
@@ -18,6 +18,12 @@ class Terraspace::CLI
|
|
18
18
|
Terraspace::All::Grapher.new(@options.merge(stacks: stacks)).run
|
19
19
|
end
|
20
20
|
|
21
|
+
desc "init", "Init all or multiple stacks."
|
22
|
+
long_desc Help.text("all/init")
|
23
|
+
def init(*stacks)
|
24
|
+
Terraspace::All::Runner.new("init", @options.merge(stacks: stacks)).run
|
25
|
+
end
|
26
|
+
|
21
27
|
desc "refresh", "Refresh all or multiple stacks."
|
22
28
|
long_desc Help.text("all/refresh")
|
23
29
|
def refresh(*stacks)
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require "terraspace-bundler"
|
2
|
-
TerraspaceBundler.config.logger = Terraspace.logger
|
3
2
|
|
4
3
|
class Terraspace::CLI
|
5
4
|
class Bundle
|
@@ -8,6 +7,8 @@ class Terraspace::CLI
|
|
8
7
|
end
|
9
8
|
|
10
9
|
def run
|
10
|
+
Terraspace.check_project!
|
11
|
+
TerraspaceBundler.config.deep_merge!(Terraspace.config.bundle)
|
11
12
|
TerraspaceBundler::CLI.start(args)
|
12
13
|
end
|
13
14
|
|
data/lib/terraspace/cli/clean.rb
CHANGED
@@ -1,12 +1,24 @@
|
|
1
1
|
class Terraspace::CLI
|
2
|
-
class Clean
|
3
|
-
|
4
|
-
|
2
|
+
class Clean < Terraspace::Command
|
3
|
+
class_option :yes, aliases: :y, type: :boolean, desc: "bypass are you sure prompt"
|
4
|
+
|
5
|
+
desc "all", "Runs all clean operations."
|
6
|
+
long_desc Help.text("clean/all")
|
7
|
+
def all
|
8
|
+
All.new(options).run
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "cache", "Removes cache dirs."
|
12
|
+
long_desc Help.text("clean/cache")
|
13
|
+
def cache
|
14
|
+
Cache.new(options).run
|
5
15
|
end
|
6
16
|
|
7
|
-
|
8
|
-
|
9
|
-
|
17
|
+
desc "logs", "Removes or truncate logs."
|
18
|
+
long_desc Help.text("clean/logs")
|
19
|
+
option :truncate, aliases: :t, type: :boolean, desc: "Truncate instead of remove logs"
|
20
|
+
def logs
|
21
|
+
Logs.new(options).run
|
10
22
|
end
|
11
23
|
end
|
12
24
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Terraspace::CLI::Clean
|
2
|
+
class All < Base
|
3
|
+
def run
|
4
|
+
are_you_sure?
|
5
|
+
o = @options.merge(yes: true) # override to avoid double prompt
|
6
|
+
Cache.new(o).run
|
7
|
+
Logs.new(o).run
|
8
|
+
end
|
9
|
+
|
10
|
+
def are_you_sure?
|
11
|
+
message = <<~EOL.chomp
|
12
|
+
Will remove Terraspace cache and logs.
|
13
|
+
Are you sure?
|
14
|
+
EOL
|
15
|
+
sure?(message) # from Util::Sure
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Terraspace::CLI::Clean
|
2
|
+
class Base
|
3
|
+
include Terraspace::Util::Logging
|
4
|
+
include Terraspace::Util::Sure
|
5
|
+
|
6
|
+
def initialize(options={})
|
7
|
+
@options = options
|
8
|
+
Terraspace.check_project!
|
9
|
+
end
|
10
|
+
|
11
|
+
def pretty(path)
|
12
|
+
Terraspace::Util.pretty_path(path)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|