terraspace 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56392f488a05d42760586d379da36022589979733b654ea3f5f3d5fcb879de26
4
- data.tar.gz: 690b3d0fa3e192aee02fd34ae187ab4628caccd335a1733ce10040ff2ef55b32
3
+ metadata.gz: 75c6662ef1dbdb9fc52cdde609425bf17c780b20989692491f30cae96f04a10d
4
+ data.tar.gz: 6f3723c71e6e895633f3108950afb0cabace1d927216661aad06416e588bfdd8
5
5
  SHA512:
6
- metadata.gz: 4dcc7b6c1d1f2d21be6115d02cc34bbeb9f773e6ece16e8549ac3a8e6a4167fb6392a2917399399a0ba0ddde4ff880c9dff8de2ee5261def5250fc2525527ce1
7
- data.tar.gz: 476d2c10897c2915a3cd601b556e783a639cb29a97c11505b5e34f32d8079c311e5ad8f6efeeee6cf9a143a2f63b9b46b76a9b6741d78802fd53baf8de319b29
6
+ metadata.gz: dc9c700c27a5e725532c940955316c4cad16e724a094885df3ea419b40d26fb26d9be959af5131114602efa73a5329fd9fab60b1cd09e86856efcd4f4f0942c2
7
+ data.tar.gz: 5f2f327d1aebf535ad92864c9c2cf312b426bd0e814273e12e718351015bd8652487ba34978e0bc3aeab464fb3ebf7362dba08412f02ef83fd76d1ec9ea47d60
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
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.6.5] - 2021-03-24
7
+ - [#96](https://github.com/boltops-tools/terraspace/pull/96) terraspace fmt: ability to specific module or stack
8
+
6
9
  ## [0.6.4] - 2021-03-22
7
10
  - [#94](https://github.com/boltops-tools/terraspace/pull/94) terraspace fmt command
8
11
 
@@ -27,6 +27,9 @@ module Terraspace
27
27
  reconfigure_option = Proc.new {
28
28
  option :reconfigure, type: :boolean, desc: "Add terraform -reconfigure option"
29
29
  }
30
+ type_option = Proc.new {
31
+ option :type, default: "stack", aliases: %w[t], desc: "Type: stack, module, or all"
32
+ }
30
33
 
31
34
  desc "all SUBCOMMAND", "all subcommands"
32
35
  long_desc Help.text(:all)
@@ -84,8 +87,9 @@ module Terraspace
84
87
 
85
88
  desc "fmt", "Run terraform fmt"
86
89
  long_desc Help.text(:fmt)
87
- def fmt
88
- Fmt.new(options).run
90
+ type_option.call
91
+ def fmt(mod=nil)
92
+ Fmt.new(options.merge(mod: mod)).run
89
93
  end
90
94
 
91
95
  desc "info STACK", "Get info about stack."
@@ -106,7 +110,7 @@ module Terraspace
106
110
 
107
111
  desc "list", "List stacks and modules."
108
112
  long_desc Help.text(:list)
109
- option :type, default: "stack", aliases: %w[t], desc: "Type: stack, module, or all"
113
+ type_option.call
110
114
  def list
111
115
  List.new(options).run
112
116
  end
@@ -5,11 +5,12 @@ class Terraspace::CLI
5
5
 
6
6
  def initialize(options={})
7
7
  @options = options
8
+ @mod_name = options[:mod]
8
9
  end
9
10
 
10
11
  def run
11
12
  logger.info "Formating terraform files"
12
- app_source_dirs.each do |dir|
13
+ dirs.each do |dir|
13
14
  format(dir)
14
15
  end
15
16
  end
@@ -17,5 +18,23 @@ class Terraspace::CLI
17
18
  def format(dir)
18
19
  Runner.new(dir).format!
19
20
  end
21
+
22
+ private
23
+ def dirs
24
+ if @mod_name
25
+ type_dirs.select { |p| p.include?(@mod_name) }
26
+ else
27
+ type_dirs
28
+ end
29
+ end
30
+
31
+ def type_dirs
32
+ type = @options[:type]
33
+ if type
34
+ app_source_dirs.select { |p| p.include?("/#{type.pluralize}/") }
35
+ else
36
+ app_source_dirs
37
+ end
38
+ end
20
39
  end
21
40
  end
@@ -1,5 +1,7 @@
1
1
  ## Example
2
2
 
3
+ Format all source files.
4
+
3
5
  $ terraspace fmt
4
6
  Formating terraform files
5
7
  app/modules/example
@@ -7,4 +9,14 @@
7
9
  outputs.tf
8
10
  variables.tf
9
11
  app/stacks/demo
10
- main.tf
12
+ main.tf
13
+
14
+ Format specific module or stack.
15
+
16
+ $ terraspace fmt stack1
17
+ $ terraspace fmt module1
18
+
19
+ Format scoping to module or stack types. In case there's a module and stack with the same name.
20
+
21
+ $ terraspace fmt example -t module
22
+ $ terraspace fmt demo -t stacke
@@ -1,3 +1,3 @@
1
1
  module Terraspace
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2021-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport