terraspace_hooks 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -12
- data/.rubocop_todo.yml +7 -0
- data/Gemfile +6 -4
- data/Gemfile.lock +19 -5
- data/README.md +34 -0
- data/Rakefile +7 -10
- data/lib/terraspace_hooks/infracost_generator.rb +21 -15
- data/lib/terraspace_hooks/tf_fmt_validator.rb +16 -10
- data/lib/terraspace_hooks/tf_validator.rb +16 -10
- data/lib/terraspace_hooks/tflint_validator.rb +30 -0
- data/lib/terraspace_hooks/tfsec_validator.rb +16 -10
- data/lib/terraspace_hooks/version.rb +1 -1
- data/lib/terraspace_hooks.rb +6 -3
- data/terraspace_hooks.gemspec +15 -15
- metadata +20 -5
- data/lib/terraspace_hooks/tflint_validtor.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95ad9290130a4da60d9d31e1d769274f939c2929904b7fb9fe597e74ec55b7ea
|
4
|
+
data.tar.gz: d9a1439317ed5b81de0a5ec1867e6887cca137e4f95d138d90b475da59a6977d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 793ba08df148c185c24450a0d6f23c72b6352a8a6843b94ea6cab68e11be2485acb0cc6652fdcfed87d18e5b37f9ebd7a80be0c4ebd5e75c11d1054572a26a22
|
7
|
+
data.tar.gz: 9eab02f56b387d9ba2394861c8dae6c304f23d2c0bdd5479537866983e05dbb54f1e68c761a78b257630e1407da97d05234a532889cf40873a06833311dfa825
|
data/.rubocop.yml
CHANGED
@@ -1,13 +1,3 @@
|
|
1
|
-
|
2
|
-
TargetRubyVersion: 2.6
|
1
|
+
inherit_from: .rubocop_todo.yml
|
3
2
|
|
4
|
-
|
5
|
-
Enabled: true
|
6
|
-
EnforcedStyle: double_quotes
|
7
|
-
|
8
|
-
Style/StringLiteralsInInterpolation:
|
9
|
-
Enabled: true
|
10
|
-
EnforcedStyle: double_quotes
|
11
|
-
|
12
|
-
Layout/LineLength:
|
13
|
-
Max: 120
|
3
|
+
require: rubocop-rake
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2023-03-23 23:34:39 UTC using RuboCop version 1.44.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
data/Gemfile
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in terraspace_hooks.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
8
|
+
gem 'rake', '~> 13.0'
|
9
9
|
|
10
|
-
gem
|
10
|
+
gem 'minitest', '~> 5.0'
|
11
11
|
|
12
|
-
gem
|
12
|
+
gem 'standard'
|
13
|
+
|
14
|
+
gem 'rubocop-rake'
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
terraspace_hooks (0.1
|
4
|
+
terraspace_hooks (0.2.1)
|
5
|
+
zeitwerk (~> 2.6.7)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
8
9
|
specs:
|
9
10
|
ast (2.4.2)
|
10
11
|
json (2.6.3)
|
12
|
+
language_server-protocol (3.17.0.3)
|
11
13
|
minitest (5.17.0)
|
12
14
|
parallel (1.22.1)
|
13
15
|
parser (3.2.1.0)
|
@@ -16,29 +18,41 @@ GEM
|
|
16
18
|
rake (13.0.6)
|
17
19
|
regexp_parser (2.7.0)
|
18
20
|
rexml (3.2.5)
|
19
|
-
rubocop (1.
|
21
|
+
rubocop (1.44.1)
|
20
22
|
json (~> 2.3)
|
21
23
|
parallel (~> 1.10)
|
22
24
|
parser (>= 3.2.0.0)
|
23
25
|
rainbow (>= 2.2.2, < 4.0)
|
24
26
|
regexp_parser (>= 1.8, < 3.0)
|
25
27
|
rexml (>= 3.2.5, < 4.0)
|
26
|
-
rubocop-ast (>= 1.
|
28
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
27
29
|
ruby-progressbar (~> 1.7)
|
28
30
|
unicode-display_width (>= 2.4.0, < 3.0)
|
29
31
|
rubocop-ast (1.26.0)
|
30
32
|
parser (>= 3.2.1.0)
|
33
|
+
rubocop-performance (1.15.2)
|
34
|
+
rubocop (>= 1.7.0, < 2.0)
|
35
|
+
rubocop-ast (>= 0.4.0)
|
36
|
+
rubocop-rake (0.6.0)
|
37
|
+
rubocop (~> 1.0)
|
31
38
|
ruby-progressbar (1.11.0)
|
39
|
+
standard (1.24.3)
|
40
|
+
language_server-protocol (~> 3.17.0.2)
|
41
|
+
rubocop (= 1.44.1)
|
42
|
+
rubocop-performance (= 1.15.2)
|
32
43
|
unicode-display_width (2.4.2)
|
44
|
+
zeitwerk (2.6.7)
|
33
45
|
|
34
46
|
PLATFORMS
|
35
47
|
arm64-darwin-22
|
48
|
+
x86_64-linux
|
36
49
|
|
37
50
|
DEPENDENCIES
|
38
51
|
minitest (~> 5.0)
|
39
52
|
rake (~> 13.0)
|
40
|
-
rubocop
|
53
|
+
rubocop-rake
|
54
|
+
standard
|
41
55
|
terraspace_hooks!
|
42
56
|
|
43
57
|
BUNDLED WITH
|
44
|
-
2.4.
|
58
|
+
2.4.8
|
data/README.md
CHANGED
@@ -15,15 +15,49 @@ Install the gem and add to the application's Gemfile by executing:
|
|
15
15
|
```ruby
|
16
16
|
|
17
17
|
# inside config/hooks/terraform.rb
|
18
|
+
|
19
|
+
# run `tflint` before # terraform plan
|
18
20
|
before("plan", execute: TerraspaceHooks::TflintValidator)
|
21
|
+
|
22
|
+
# run `terraform validate` before terraform plan
|
19
23
|
before("plan", execute: TerraspaceHooks::TfValidator)
|
24
|
+
|
25
|
+
# generate infracost output after terraform plan
|
20
26
|
after("plan", execute: TerraspaceHooks::InfracostGenerator)
|
27
|
+
```
|
21
28
|
|
29
|
+
```ruby
|
22
30
|
# inside config/hooks/terraspace.rb
|
31
|
+
|
32
|
+
# Run `terraform fmt` after terraspace build
|
23
33
|
after("build", execute: TerraspaceHooks::TfFmtValidator)
|
34
|
+
|
35
|
+
# Run `tfsec` after terraspace build
|
24
36
|
after("build", execute: TerraspaceHooks::TfsecValidator)
|
25
37
|
```
|
26
38
|
|
39
|
+
To use InfracostGenerator, you need to add this line in
|
40
|
+
`config/args/terraform.rb`
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
command("plan", args: ["-out tfplan.binary"])
|
44
|
+
```
|
45
|
+
|
46
|
+
Setting this each environment_variable below will skip the correspondent hook.
|
47
|
+
|
48
|
+
```bash
|
49
|
+
SKIP_TERRASPACE_HOOKS_TFSEC_VALIDATOR=1
|
50
|
+
SKIP_TERRASPACE_HOOKS_TFLINT_VALIDATOR=1
|
51
|
+
SKIP_TERRASPACE_HOOKS_TF_VALIDATOR=1
|
52
|
+
SKIP_TERRASPACE_HOOKS_TF_FMT_VALIDATOR=1
|
53
|
+
SKIP_TERRASPACE_HOOKS_INFRACOST_GENERATOR=1
|
54
|
+
|
55
|
+
# or
|
56
|
+
|
57
|
+
SKIP_TERRASPACE_HOOKS_ALL=1
|
58
|
+
# to skip all the hooks
|
59
|
+
```
|
60
|
+
|
27
61
|
## License
|
28
62
|
|
29
63
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'standard/rake'
|
5
6
|
|
6
7
|
Rake::TestTask.new(:test) do |t|
|
7
|
-
t.libs <<
|
8
|
-
t.libs <<
|
9
|
-
t.test_files = FileList[
|
8
|
+
t.libs << 'test'
|
9
|
+
t.libs << 'lib'
|
10
|
+
t.test_files = FileList['test/**/test_*.rb']
|
10
11
|
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
RuboCop::RakeTask.new
|
15
|
-
|
16
|
-
task default: %i[test rubocop]
|
13
|
+
task default: %i[test standard:fix]
|
@@ -1,33 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module TerraspaceHooks
|
4
|
+
# generate infracost breakdown
|
2
5
|
class InfracostGenerator
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
3
7
|
def call(runner)
|
4
|
-
raise
|
5
|
-
raise
|
8
|
+
raise 'Infracost not available' unless infracost_available?
|
9
|
+
raise 'Terraform not available' unless terraform_available?
|
6
10
|
|
7
11
|
mod = runner.mod
|
8
|
-
command = <<-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
command = <<-COMMAND
|
13
|
+
YELLOW='\033[0;33m'
|
14
|
+
NC='\033[0m'
|
15
|
+
cd #{mod.cache_dir} && \
|
16
|
+
echo "${YELLOW}[INFO #{mod.name}]${NC} Convert to plan.json..." && \
|
17
|
+
terraform show -json tfplan.binary > plan.json && \
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
echo "${YELLOW}[INFO #{mod.name}]${NC} Infracost breakdown for #{mod.name}..." && \
|
20
|
+
infracost breakdown --project-name #{mod.name} --path plan.json --format json --out-file infracost_breakdown.json && \
|
21
|
+
infracost output --path infracost_breakdown.json --format table --show-skipped
|
22
|
+
COMMAND
|
19
23
|
|
20
|
-
return if ENV[
|
24
|
+
return if ENV['SKIP_TERRASPACE_HOOKS_ALL']
|
25
|
+
return if ENV['SKIP_TERRASPACE_HOOKS_INFRACOST_GENERATOR']
|
21
26
|
|
22
27
|
system(command)
|
23
28
|
end
|
29
|
+
# rubocop:enable Metrics/MethodLength
|
24
30
|
|
25
31
|
def infracost_available?
|
26
|
-
system(
|
32
|
+
system('which infracost')
|
27
33
|
end
|
28
34
|
|
29
35
|
def terraform_available?
|
30
|
-
system(
|
36
|
+
system('which terraform')
|
31
37
|
end
|
32
38
|
end
|
33
39
|
end
|
@@ -1,24 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module TerraspaceHooks
|
4
|
+
# validate the terraform code with terraform fmt
|
2
5
|
class TfFmtValidator
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
3
7
|
def call(runner)
|
4
|
-
raise
|
8
|
+
raise 'Terraform not available' unless terraform_available?
|
5
9
|
|
6
10
|
mod = runner.mod
|
7
|
-
command = <<-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
command = <<-COMMAND
|
12
|
+
YELLOW='\033[0;33m'
|
13
|
+
NC='\033[0m'
|
14
|
+
cd #{mod.cache_dir} && \
|
15
|
+
echo "${YELLOW}[INFO #{mod.name}]${NC} Run terraform fmt for #{mod.name}..." && \
|
16
|
+
terraform fmt
|
17
|
+
COMMAND
|
14
18
|
|
15
|
-
return if ENV[
|
19
|
+
return if ENV['SKIP_TERRASPACE_HOOKS_ALL']
|
20
|
+
return if ENV['SKIP_TERRASPACE_HOOKS_TF_FMT_VALIDATOR']
|
16
21
|
|
17
22
|
system(command)
|
18
23
|
end
|
24
|
+
# rubocop:enable Metrics/MethodLength
|
19
25
|
|
20
26
|
def terraform_available?
|
21
|
-
system(
|
27
|
+
system('which terraform')
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -1,24 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module TerraspaceHooks
|
4
|
+
# validate the terraform code with terraform validate
|
2
5
|
class TfValidator
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
3
7
|
def call(runner)
|
4
|
-
raise
|
8
|
+
raise 'Terraform not available' unless terraform_available?
|
5
9
|
|
6
10
|
mod = runner.mod
|
7
|
-
command = <<-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
command = <<-COMMAND
|
12
|
+
YELLOW='\033[0;33m'
|
13
|
+
NC='\033[0m'
|
14
|
+
cd #{mod.cache_dir} && \
|
15
|
+
echo "${YELLOW}[INFO #{mod.name}]${NC} Run terraform validate for #{mod.name}..." && \
|
16
|
+
terraform validate
|
17
|
+
COMMAND
|
14
18
|
|
15
|
-
return if ENV[
|
19
|
+
return if ENV['SKIP_TERRASPACE_HOOKS_ALL']
|
20
|
+
return if ENV['SKIP_TERRASPACE_HOOKS_TF_VALIDATOR']
|
16
21
|
|
17
22
|
system(command)
|
18
23
|
end
|
24
|
+
# rubocop:enable Metrics/MethodLength
|
19
25
|
|
20
26
|
def terraform_available?
|
21
|
-
system(
|
27
|
+
system('which terraform')
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module TerraspaceHooks
|
4
|
+
# validate the terraform code with tflint
|
5
|
+
class TflintValidator
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
7
|
+
def call(runner)
|
8
|
+
raise 'Tflint not available' unless tflint_available?
|
9
|
+
|
10
|
+
mod = runner.mod
|
11
|
+
command = <<-COMMAND
|
12
|
+
YELLOW='\033[0;33m'
|
13
|
+
NC='\033[0m'
|
14
|
+
cd #{mod.cache_dir} && \
|
15
|
+
echo "${YELLOW}[INFO #{mod.name}]${NC} Run tflint for #{mod.name}..." && \
|
16
|
+
tflint . --disable-rule=terraform_required_version --module
|
17
|
+
COMMAND
|
18
|
+
|
19
|
+
return if ENV['SKIP_TERRASPACE_HOOKS_ALL']
|
20
|
+
return if ENV['SKIP_TERRASPACE_HOOKS_TFLINT_VALIDATOR']
|
21
|
+
|
22
|
+
system(command)
|
23
|
+
end
|
24
|
+
# rubocop:enable Metrics/MethodLength
|
25
|
+
|
26
|
+
def tflint_available?
|
27
|
+
system('which tflint')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,24 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module TerraspaceHooks
|
4
|
+
# validate the terraform code with tfsec
|
2
5
|
class TfsecValidator
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
3
7
|
def call(runner)
|
4
|
-
raise
|
8
|
+
raise 'Tfsec not available' unless tfsec_available?
|
5
9
|
|
6
10
|
mod = runner.mod
|
7
|
-
command = <<-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
command = <<-COMMAND
|
12
|
+
YELLOW='\033[0;33m'
|
13
|
+
NC='\033[0m'
|
14
|
+
cd #{mod.cache_dir} && \
|
15
|
+
echo "${YELLOW}[INFO #{mod.name}]${NC} Run tfsec for #{mod.name}..." && \
|
16
|
+
tfsec --concise-output
|
17
|
+
COMMAND
|
14
18
|
|
15
|
-
return if ENV[
|
19
|
+
return if ENV['SKIP_TERRASPACE_HOOKS_ALL']
|
20
|
+
return if ENV['SKIP_TERRASPACE_HOOKS_TFSEC_VALIDATOR']
|
16
21
|
|
17
22
|
system(command)
|
18
23
|
end
|
24
|
+
# rubocop:enable Metrics/MethodLength
|
19
25
|
|
20
26
|
def tfsec_available?
|
21
|
-
system(
|
27
|
+
system('which tfsec')
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
data/lib/terraspace_hooks.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'zeitwerk'
|
4
|
+
loader = Zeitwerk::Loader.for_gem
|
5
|
+
loader.setup
|
4
6
|
|
7
|
+
# TerraspaceHooks is the namespace for all Terraspace Hooks
|
5
8
|
module TerraspaceHooks
|
6
|
-
class Error < StandardError; end
|
7
|
-
# Your code goes here...
|
8
9
|
end
|
10
|
+
|
11
|
+
loader.eager_load
|
data/terraspace_hooks.gemspec
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'lib/terraspace_hooks/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = 'terraspace_hooks'
|
7
7
|
spec.version = TerraspaceHooks::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
8
|
+
spec.authors = ['slamet kristanto']
|
9
|
+
spec.email = ['botoksgonzales@gmail.com']
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
15
|
-
spec.required_ruby_version =
|
11
|
+
spec.summary = 'Useful terraspace hook collection (infracost generator, tflint, tf validate)'
|
12
|
+
spec.description = 'Useful terraspace hook collection (infracost generator, tflint, tf validate)'
|
13
|
+
spec.homepage = 'https://github.com/drselump14/terraspace_hooks'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 2.6.0'
|
16
16
|
|
17
|
-
spec.metadata[
|
18
|
-
spec.metadata[
|
19
|
-
spec.metadata[
|
17
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
+
spec.metadata['source_code_uri'] = 'https://github.com/drselump14/terraspace_hooks'
|
19
|
+
spec.metadata['changelog_uri'] = 'https://github.com/drselump14/terraspace_hooks'
|
20
20
|
|
21
21
|
# Specify which files should be added to the gem when it is released.
|
22
22
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -25,12 +25,12 @@ Gem::Specification.new do |spec|
|
|
25
25
|
(File.expand_path(f) == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|circleci)|appveyor)})
|
26
26
|
end
|
27
27
|
end
|
28
|
-
spec.bindir =
|
28
|
+
spec.bindir = 'exe'
|
29
29
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
30
|
-
spec.require_paths = [
|
30
|
+
spec.require_paths = ['lib']
|
31
31
|
|
32
32
|
# Uncomment to register a new dependency of your gem
|
33
|
-
|
33
|
+
spec.add_dependency 'zeitwerk', '~> 2.6.7'
|
34
34
|
|
35
35
|
# For more information and examples about making a new gem, check out our
|
36
36
|
# guide at: https://bundler.io/guides/creating_gem.html
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: terraspace_hooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- slamet kristanto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
12
|
-
dependencies:
|
11
|
+
date: 2023-03-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: zeitwerk
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.6.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.6.7
|
13
27
|
description: Useful terraspace hook collection (infracost generator, tflint, tf validate)
|
14
28
|
email:
|
15
29
|
- botoksgonzales@gmail.com
|
@@ -18,6 +32,7 @@ extensions: []
|
|
18
32
|
extra_rdoc_files: []
|
19
33
|
files:
|
20
34
|
- ".rubocop.yml"
|
35
|
+
- ".rubocop_todo.yml"
|
21
36
|
- CHANGELOG.md
|
22
37
|
- CODE_OF_CONDUCT.md
|
23
38
|
- Gemfile
|
@@ -29,7 +44,7 @@ files:
|
|
29
44
|
- lib/terraspace_hooks/infracost_generator.rb
|
30
45
|
- lib/terraspace_hooks/tf_fmt_validator.rb
|
31
46
|
- lib/terraspace_hooks/tf_validator.rb
|
32
|
-
- lib/terraspace_hooks/
|
47
|
+
- lib/terraspace_hooks/tflint_validator.rb
|
33
48
|
- lib/terraspace_hooks/tfsec_validator.rb
|
34
49
|
- lib/terraspace_hooks/version.rb
|
35
50
|
- sig/terraspace_hooks.rbs
|
@@ -56,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
71
|
- !ruby/object:Gem::Version
|
57
72
|
version: '0'
|
58
73
|
requirements: []
|
59
|
-
rubygems_version: 3.4.
|
74
|
+
rubygems_version: 3.4.8
|
60
75
|
signing_key:
|
61
76
|
specification_version: 4
|
62
77
|
summary: Useful terraspace hook collection (infracost generator, tflint, tf validate)
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module TerraspaceHooks
|
2
|
-
class TflintValidator
|
3
|
-
def call(runner)
|
4
|
-
raise "Tflint not available" unless tflint_available?
|
5
|
-
|
6
|
-
mod = runner.mod
|
7
|
-
command = <<-EOF
|
8
|
-
YELLOW='\033[0;33m'
|
9
|
-
NC='\033[0m'
|
10
|
-
cd #{mod.cache_dir} && \
|
11
|
-
echo "${YELLOW}[INFO #{mod.name}]${NC} Run tflint for #{mod.name}..." && \
|
12
|
-
tflint . --disable-rule=terraform_required_version --module
|
13
|
-
EOF
|
14
|
-
|
15
|
-
return if ENV["SKIP_TERRASPACE_HOOKS_TFLINT_VALIDATOR"]
|
16
|
-
|
17
|
-
system(command)
|
18
|
-
end
|
19
|
-
|
20
|
-
def tflint_available?
|
21
|
-
system("which tflint")
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|