dependabot-terraform 0.254.0 → 0.255.0

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: ab7104d63d7e71b3988d766baa0b991b7d2559a0274758a38b0e29802d13fbd5
4
- data.tar.gz: a987b62c58f292e802a7ca1f6f9ddca00fd155ccc7d6e5769f4a35d4db50d554
3
+ metadata.gz: b86ff97e37a0fd8c3156a5bed89492c56564d444a8fea552b93498a34089ffed
4
+ data.tar.gz: e841cdee87c46bfeabd69cb7ca3bd707122ce22ed021f04289cb22bc434065ac
5
5
  SHA512:
6
- metadata.gz: e7878dbe257b3ffb736f60e837538a4cc7ddd50428468b1e049da015e3d8352965dcae679bbd94da83a33f715aac88b6fa193d10552d4abb54176838e4516a2b
7
- data.tar.gz: cee4d89fdc275e11b89f836b62f6930454bb219481ef7ea796aaec9329eebdb5689fef237fd14b30de0ddc081d7bdc3c82cb1738e44b493cc7fae690e14409a2
6
+ metadata.gz: a2010ee735c7e9674f5fd3445ecefd81d640b93caa3638377582f66180ad24237437809778ee09f4b066cbae6145ec5d4a9d9f02649bb1c690298563fa474521
7
+ data.tar.gz: 78c86fe178f4662a637faa9e6fb37b9b6755211c74e6fcf4f5eb7a6f7ac7ee6314bd67afe31fcca194b96ee424dbffc8cc60ad857b5f2dc01c0aaa6522347a5d
@@ -1,7 +1,8 @@
1
- # typed: false
1
+ # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "sorbet-runtime"
5
+
5
6
  require "dependabot/file_fetchers"
6
7
  require "dependabot/file_fetchers/base"
7
8
  require "dependabot/terraform/file_selector"
@@ -12,15 +13,17 @@ module Dependabot
12
13
  extend T::Sig
13
14
  extend T::Helpers
14
15
 
15
- include FileSelector
16
+ include FileFilter
16
17
 
17
18
  # https://www.terraform.io/docs/language/modules/sources.html#local-paths
18
19
  LOCAL_PATH_SOURCE = %r{source\s*=\s*['"](?<path>..?\/[^'"]+)}
19
20
 
21
+ sig { override.params(filenames: T::Array[String]).returns(T::Boolean) }
20
22
  def self.required_files_in?(filenames)
21
23
  filenames.any? { |f| f.end_with?(".tf", ".hcl") }
22
24
  end
23
25
 
26
+ sig { override.returns(String) }
24
27
  def self.required_files_message
25
28
  "Repo must contain a Terraform configuration file."
26
29
  end
@@ -37,22 +40,35 @@ module Dependabot
37
40
 
38
41
  private
39
42
 
43
+ sig { returns(T::Array[Dependabot::DependencyFile]) }
40
44
  def terraform_files
41
- @terraform_files ||=
45
+ @terraform_files ||= T.let(
42
46
  repo_contents(raise_errors: false)
43
47
  .select { |f| f.type == "file" && f.name.end_with?(".tf") }
44
- .map { |f| fetch_file_from_host(f.name) }
48
+ .map { |f| fetch_file_from_host(f.name) },
49
+ T.nilable(T::Array[Dependabot::DependencyFile])
50
+ )
45
51
  end
46
52
 
53
+ sig { returns(T::Array[Dependabot::DependencyFile]) }
47
54
  def terragrunt_files
48
- @terragrunt_files ||=
55
+ @terragrunt_files ||= T.let(
49
56
  repo_contents(raise_errors: false)
50
57
  .select { |f| f.type == "file" && terragrunt_file?(f.name) }
51
- .map { |f| fetch_file_from_host(f.name) }
58
+ .map { |f| fetch_file_from_host(f.name) },
59
+ T.nilable(T::Array[Dependabot::DependencyFile])
60
+ )
52
61
  end
53
62
 
63
+ sig do
64
+ params(
65
+ files: T::Array[Dependabot::DependencyFile],
66
+ dir: String
67
+ )
68
+ .returns(T::Array[Dependabot::DependencyFile])
69
+ end
54
70
  def local_path_module_files(files, dir: ".")
55
- terraform_files = []
71
+ terraform_files = T.let([], T::Array[Dependabot::DependencyFile])
56
72
 
57
73
  files.each do |file|
58
74
  terraform_file_local_module_details(file).each do |path|
@@ -71,19 +87,22 @@ module Dependabot
71
87
  terraform_files.tap { |fs| fs.each { |f| f.support_file = true } }
72
88
  end
73
89
 
90
+ sig { params(file: Dependabot::DependencyFile).returns(T::Array[String]) }
74
91
  def terraform_file_local_module_details(file)
75
92
  return [] unless file.name.end_with?(".tf")
76
- return [] unless file.content.match?(LOCAL_PATH_SOURCE)
93
+ return [] unless file.content&.match?(LOCAL_PATH_SOURCE)
77
94
 
78
- file.content.scan(LOCAL_PATH_SOURCE).flatten.map do |path|
95
+ T.must(file.content).scan(LOCAL_PATH_SOURCE).flatten.map do |path|
79
96
  Pathname.new(path).cleanpath.to_path
80
97
  end
81
98
  end
82
99
 
100
+ sig { returns(T.nilable(Dependabot::DependencyFile)) }
83
101
  def lockfile
84
- return @lockfile if defined?(@lockfile)
85
-
86
- @lockfile = fetch_file_if_present(".terraform.lock.hcl")
102
+ @lockfile ||= T.let(
103
+ fetch_file_if_present(".terraform.lock.hcl"),
104
+ T.nilable(Dependabot::DependencyFile)
105
+ )
87
106
  end
88
107
  end
89
108
  end
@@ -0,0 +1,24 @@
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+
6
+ module Dependabot
7
+ module Terraform
8
+ module FileFilter
9
+ extend T::Sig
10
+
11
+ private
12
+
13
+ sig { params(file_name: String).returns(T::Boolean) }
14
+ def terragrunt_file?(file_name)
15
+ !lockfile?(file_name) && file_name.end_with?(".hcl")
16
+ end
17
+
18
+ sig { params(filename: String).returns(T::Boolean) }
19
+ def lockfile?(filename)
20
+ filename == ".terraform.lock.hcl"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,26 +1,39 @@
1
- # typed: false
1
+ # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
- module FileSelector
5
- private
4
+ require "sorbet-runtime"
6
5
 
7
- def terraform_files
8
- dependency_files.select { |f| f.name.end_with?(".tf") }
9
- end
6
+ require "dependabot/terraform/file_filter"
10
7
 
11
- def terragrunt_files
12
- dependency_files.select { |f| terragrunt_file?(f.name) }
13
- end
8
+ module Dependabot
9
+ module Terraform
10
+ module FileSelector
11
+ extend T::Sig
12
+ extend T::Helpers
14
13
 
15
- def terragrunt_file?(file_name)
16
- !lockfile?(file_name) && file_name.end_with?(".hcl")
17
- end
14
+ abstract!
18
15
 
19
- def lockfile?(filename)
20
- filename == ".terraform.lock.hcl"
21
- end
16
+ sig { abstract.returns(T::Array[Dependabot::DependencyFile]) }
17
+ def dependency_files; end
18
+
19
+ private
20
+
21
+ include FileFilter
22
+
23
+ sig { returns(T::Array[Dependabot::DependencyFile]) }
24
+ def terraform_files
25
+ dependency_files.select { |f| f.name.end_with?(".tf") }
26
+ end
27
+
28
+ sig { returns(T::Array[Dependabot::DependencyFile]) }
29
+ def terragrunt_files
30
+ dependency_files.select { |f| terragrunt_file?(f.name) }
31
+ end
22
32
 
23
- def lockfile
24
- dependency_files.find { |f| lockfile?(f.name) }
33
+ sig { returns(T.nilable(Dependabot::DependencyFile)) }
34
+ def lockfile
35
+ dependency_files.find { |f| lockfile?(f.name) }
36
+ end
37
+ end
25
38
  end
26
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.254.0
4
+ version: 0.255.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-24 00:00:00.000000000 Z
11
+ date: 2024-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dependabot-common
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.254.0
19
+ version: 0.255.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.254.0
26
+ version: 0.255.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: debug
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: 0.8.1
167
+ - !ruby/object:Gem::Dependency
168
+ name: simplecov
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.22.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.22.0
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: turbo_tests
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -231,6 +245,7 @@ files:
231
245
  - helpers/build
232
246
  - lib/dependabot/terraform.rb
233
247
  - lib/dependabot/terraform/file_fetcher.rb
248
+ - lib/dependabot/terraform/file_filter.rb
234
249
  - lib/dependabot/terraform/file_parser.rb
235
250
  - lib/dependabot/terraform/file_selector.rb
236
251
  - lib/dependabot/terraform/file_updater.rb
@@ -245,7 +260,7 @@ licenses:
245
260
  - Nonstandard
246
261
  metadata:
247
262
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
248
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.254.0
263
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.255.0
249
264
  post_install_message:
250
265
  rdoc_options: []
251
266
  require_paths:
@@ -261,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
261
276
  - !ruby/object:Gem::Version
262
277
  version: 3.1.0
263
278
  requirements: []
264
- rubygems_version: 3.3.26
279
+ rubygems_version: 3.5.9
265
280
  signing_key:
266
281
  specification_version: 4
267
282
  summary: Provides Dependabot support for Terraform