dependabot-opentofu 0.391.0 → 0.392.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef485a1857c80dad66ce7897a5f7c8cef0f5fd58dc8b5023933394a692b035e2
4
- data.tar.gz: c8a108c5acc1505e541165c61471af2974b83d4ad86b1bd95fdcea4c9905a4d6
3
+ metadata.gz: e0af2d7b0f36a4837725ad2383699096e86febe9a21ba56fb2ebea850980ef03
4
+ data.tar.gz: 96515856ea69ec31393641cdf8c43dab965aa3d5b42b49b14d408abea9567f8b
5
5
  SHA512:
6
- metadata.gz: a00e9fea4c9f10fe0acffb8803ed8f135c5c86c6bd1b398baada2bb1e2c0e4b24bc74def7292f3e611f5bb7974fe6782b5daabc7838bde6106bb926b780e054b
7
- data.tar.gz: e9ca2a44c33d9296e118433f87f9b47103a492a067cd5e21688e1ca6962eb1f2a556a3458638b589b0c3f22e4404fb88e2a976acc52da817d7105bfc7dff5897
6
+ metadata.gz: 2712d8b275467b93410176d0f0bf0a358d2d5975fb3eb6ee61a2835c23a9721223ec3f313347ef8b0be4b4ab15c0f279b086f59c971e6a53871235639e79cb49
7
+ data.tar.gz: 76c902b267173cd9f61842a931945662abfa4189d086554e3bb074a3845aef32ecb94b792cbdb56281053e6b90cd9b281691dfe6b3d9121ba027230f561cad47
@@ -1,10 +1,11 @@
1
- # typed: strict
1
+ # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "sorbet-runtime"
5
5
 
6
6
  require "dependabot/file_updaters"
7
7
  require "dependabot/file_updaters/base"
8
+ require "dependabot/dependency_requirement"
8
9
  require "dependabot/errors"
9
10
  require "dependabot/opentofu/file_selector"
10
11
  require "dependabot/opentofu/registry_client"
@@ -73,7 +74,7 @@ module Dependabot
73
74
  (dependency.requirements - T.must(dependency.previous_requirements)) |
74
75
  (T.must(dependency.previous_requirements) - dependency.requirements)
75
76
 
76
- changed_requirements.any? { |f| f[:file] == file.name }
77
+ changed_requirements.any? { |requirement| requirement.file == file.name }
77
78
  end
78
79
 
79
80
  sig { params(file: Dependabot::DependencyFile).returns(String) }
@@ -85,14 +86,15 @@ module Dependabot
85
86
 
86
87
  # Loop through each changed requirement and update the files and lockfile
87
88
  reqs.each do |new_req, old_req|
88
- raise "Bad req match" unless new_req[:file] == old_req&.fetch(:file)
89
- next unless new_req.fetch(:file) == file.name
89
+ raise "Bad req match" unless new_req.file == old_req&.file
90
+ next unless new_req.file == file.name
90
91
 
91
- case new_req[:source][:type]
92
+ source_type = T.must(new_req.source_string("type"))
93
+ case source_type
92
94
  when "git"
93
95
  update_git_declaration(new_req, old_req, content, file.name)
94
96
  when "registry", "provider"
95
- if new_req[:source][:local_variable]
97
+ if new_req.source_string("local_variable")
96
98
  update_local_variable_declaration(new_req, old_req, content)
97
99
  else
98
100
  update_registry_declaration(new_req, old_req, content)
@@ -100,8 +102,7 @@ module Dependabot
100
102
  when "oci"
101
103
  update_oci_declaration(new_req, old_req, content)
102
104
  else
103
- raise "Don't know how to update a #{new_req[:source][:type]} " \
104
- "declaration!"
105
+ raise "Don't know how to update a #{source_type} declaration!"
105
106
  end
106
107
  end
107
108
 
@@ -110,39 +111,41 @@ module Dependabot
110
111
 
111
112
  sig do
112
113
  params(
113
- new_req: T::Hash[Symbol, T.untyped],
114
- old_req: T.nilable(T::Hash[Symbol, T.untyped]),
114
+ new_req: Dependabot::DependencyRequirement,
115
+ old_req: T.nilable(Dependabot::DependencyRequirement),
115
116
  updated_content: String,
116
117
  filename: String
117
118
  )
118
119
  .void
119
120
  end
120
121
  def update_git_declaration(new_req, old_req, updated_content, filename)
121
- url = old_req&.dig(:source, :url)&.gsub(%r{^https://}, "")
122
- tag = old_req&.dig(:source, :ref)
122
+ url = T.must(old_req&.source_string("url")).gsub(%r{^https://}, "")
123
+ old_ref = T.must(old_req&.source_string("ref"))
124
+ new_ref = T.must(new_req.source_string("ref"))
125
+ tag = old_ref
123
126
  url_regex = /#{Regexp.quote(url)}.*ref=#{Regexp.quote(tag)}/
124
127
 
125
128
  declaration_regex = git_declaration_regex(filename)
126
129
 
127
130
  updated_content.sub!(declaration_regex) do |regex_match|
128
131
  regex_match.sub(url_regex) do |url_match|
129
- url_match.sub(old_req&.dig(:source, :ref), new_req[:source][:ref])
132
+ url_match.sub(old_ref, new_ref)
130
133
  end
131
134
  end
132
135
  end
133
136
 
134
137
  sig do
135
138
  params(
136
- new_req: T::Hash[Symbol, T.untyped],
137
- old_req: T.nilable(T::Hash[Symbol, T.untyped]),
139
+ new_req: Dependabot::DependencyRequirement,
140
+ old_req: T.nilable(Dependabot::DependencyRequirement),
138
141
  updated_content: String
139
142
  )
140
143
  .void
141
144
  end
142
145
  def update_oci_declaration(new_req, old_req, updated_content)
143
- old_tag = old_req&.dig(:source, :tag)
144
- new_tag = new_req[:source][:tag]
145
- artifact = old_req&.dig(:source, :artifact_identifier)
146
+ old_tag = old_req&.source_string("tag")
147
+ new_tag = new_req.source_string("tag")
148
+ artifact = old_req&.source_string("artifact_identifier")
146
149
  return if old_tag.nil? || new_tag.nil? || artifact.nil? || old_tag == new_tag
147
150
 
148
151
  # Scoped to this artifact's source string so unrelated modules with
@@ -156,43 +159,46 @@ module Dependabot
156
159
 
157
160
  sig do
158
161
  params(
159
- new_req: T::Hash[Symbol, T.untyped],
160
- old_req: T.nilable(T::Hash[Symbol, T.untyped]),
162
+ new_req: Dependabot::DependencyRequirement,
163
+ old_req: T.nilable(Dependabot::DependencyRequirement),
161
164
  updated_content: String
162
165
  )
163
166
  .void
164
167
  end
165
168
  def update_registry_declaration(new_req, old_req, updated_content)
166
- regex = if new_req[:source][:type] == "provider"
169
+ regex = if new_req.source_string("type") == "provider"
167
170
  provider_declaration_regex(updated_content)
168
171
  else
169
172
  registry_declaration_regex
170
173
  end
171
174
 
175
+ old_requirement = T.must(old_req&.requirement_string)
176
+ new_requirement = T.must(new_req.requirement_string)
177
+
172
178
  # Define and break down the version regex for better clarity
173
179
  version_key_pattern = /^\s*version\s*=\s*/
174
- version_value_pattern = /["'].*#{Regexp.escape(old_req&.fetch(:requirement))}.*['"]/
180
+ version_value_pattern = /["'].*#{Regexp.escape(old_requirement)}.*['"]/
175
181
  version_regex = /#{version_key_pattern}#{version_value_pattern}/
176
182
 
177
183
  updated_content.gsub!(regex) do |regex_match|
178
184
  regex_match.sub(version_regex) do |req_line_match|
179
- req_line_match.sub!(old_req&.fetch(:requirement), new_req[:requirement])
185
+ req_line_match.sub!(old_requirement, new_requirement)
180
186
  end
181
187
  end
182
188
  end
183
189
 
184
190
  sig do
185
191
  params(
186
- new_req: T::Hash[Symbol, T.untyped],
187
- old_req: T.nilable(T::Hash[Symbol, T.untyped]),
192
+ new_req: Dependabot::DependencyRequirement,
193
+ old_req: T.nilable(Dependabot::DependencyRequirement),
188
194
  updated_content: String
189
195
  )
190
196
  .void
191
197
  end
192
198
  def update_local_variable_declaration(new_req, old_req, updated_content)
193
- var_name = new_req[:source][:local_variable]
194
- old_version = old_req&.fetch(:requirement)
195
- new_version = new_req[:requirement]
199
+ var_name = T.must(new_req.source_string("local_variable"))
200
+ old_version = old_req&.requirement_string
201
+ new_version = new_req.requirement_string
196
202
  return if old_version.nil? || new_version.nil? || old_version == new_version
197
203
 
198
204
  local_var_regex = /
@@ -222,13 +228,15 @@ module Dependabot
222
228
 
223
229
  sig do
224
230
  params(
225
- new_req: T::Hash[Symbol, T.untyped]
231
+ new_req: Dependabot::DependencyRequirement
226
232
  )
227
233
  .returns([String, String, Regexp])
228
234
  end
229
235
  def lockfile_details(new_req)
230
236
  content = T.must(lockfile).content.dup
231
- provider_source = new_req[:source][:registry_hostname] + "/" + new_req[:source][:module_identifier]
237
+ registry_hostname = T.must(new_req.source_string("registry_hostname"))
238
+ module_identifier = T.must(new_req.source_string("module_identifier"))
239
+ provider_source = "#{registry_hostname}/#{module_identifier}"
232
240
  declaration_regex = lockfile_declaration_regex(provider_source)
233
241
 
234
242
  [T.must(content), provider_source, declaration_regex]
@@ -239,7 +247,7 @@ module Dependabot
239
247
  new_req = T.must(dependency.requirements.first)
240
248
 
241
249
  # NOTE: Only providers are included in the lockfile, modules are not
242
- return unless new_req[:source][:type] == "provider"
250
+ return unless new_req.source_string("type") == "provider"
243
251
 
244
252
  result = lookup_hash_architecture_from_registry(new_req)
245
253
  return result if result
@@ -247,22 +255,25 @@ module Dependabot
247
255
  lookup_hash_architecture_from_cli(new_req)
248
256
  end
249
257
 
250
- sig { params(new_req: T::Hash[Symbol, T.untyped]).returns(T.nilable(T::Array[Symbol])) }
258
+ sig do
259
+ params(new_req: Dependabot::DependencyRequirement)
260
+ .returns(T.nilable(T::Array[Symbol]))
261
+ end
251
262
  def lookup_hash_architecture_from_registry(new_req) # rubocop:disable Metrics/PerceivedComplexity
252
263
  content, _provider_source, declaration_regex = lockfile_details(new_req)
253
264
  existing_h1 = extract_provider_h1_hashes(content, declaration_regex)
254
265
  return nil if existing_h1.empty?
255
266
 
256
- identifier = new_req[:source][:module_identifier]
267
+ identifier = T.must(new_req.source_string("module_identifier"))
257
268
  old_version = dependency.previous_version
258
269
  return nil unless old_version
259
270
 
260
- hostname = new_req[:source][:registry_hostname] || RegistryClient::PUBLIC_HOSTNAME
271
+ hostname = new_req.source_string("registry_hostname") || RegistryClient::PUBLIC_HOSTNAME
261
272
  client = RegistryClient.new(hostname: hostname, credentials: credentials)
262
273
  packages = client.all_provider_package_hashes(identifier: identifier, version: old_version)
263
274
  return nil unless packages
264
275
 
265
- h1_to_platform = {}
276
+ h1_to_platform = T.let({}, T::Hash[String, String])
266
277
  packages.each do |platform, hashes|
267
278
  hashes.each do |h|
268
279
  h1_to_platform[h] = platform if h.start_with?("h1:")
@@ -275,7 +286,7 @@ module Dependabot
275
286
  nil
276
287
  end
277
288
 
278
- sig { params(new_req: T::Hash[Symbol, T.untyped]).returns(T::Array[Symbol]) }
289
+ sig { params(new_req: Dependabot::DependencyRequirement).returns(T::Array[Symbol]) }
279
290
  def lookup_hash_architecture_from_cli(new_req) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/PerceivedComplexity
280
291
  architectures = []
281
292
  content, provider_source, declaration_regex = lockfile_details(new_req)
@@ -346,7 +357,7 @@ module Dependabot
346
357
  return if lockfile.nil?
347
358
 
348
359
  new_req = T.must(dependency.requirements.first)
349
- return unless new_req[:source][:type] == "provider"
360
+ return unless new_req.source_string("type") == "provider"
350
361
 
351
362
  result = update_lockfile_from_registry(new_req)
352
363
  return result if result
@@ -354,17 +365,17 @@ module Dependabot
354
365
  update_lockfile_from_cli(new_req, updated_manifest_files)
355
366
  end
356
367
 
357
- sig { params(new_req: T::Hash[Symbol, T.untyped]).returns(T.nilable(String)) }
368
+ sig { params(new_req: Dependabot::DependencyRequirement).returns(T.nilable(String)) }
358
369
  def update_lockfile_from_registry(new_req) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
359
370
  content, provider_source, declaration_regex = lockfile_details(new_req)
360
371
  platforms = architecture_type
361
372
  return nil if platforms.empty?
362
373
 
363
- identifier = new_req[:source][:module_identifier]
374
+ identifier = T.must(new_req.source_string("module_identifier"))
364
375
  new_version = dependency.version
365
376
  return nil unless new_version
366
377
 
367
- hostname = new_req[:source][:registry_hostname] || RegistryClient::PUBLIC_HOSTNAME
378
+ hostname = new_req.source_string("registry_hostname") || RegistryClient::PUBLIC_HOSTNAME
368
379
  client = RegistryClient.new(hostname: hostname, credentials: credentials)
369
380
  packages = client.all_provider_package_hashes(identifier: identifier, version: new_version)
370
381
  return nil unless packages
@@ -432,7 +443,7 @@ module Dependabot
432
443
 
433
444
  sig do
434
445
  params(
435
- new_req: T::Hash[Symbol, T.untyped],
446
+ new_req: Dependabot::DependencyRequirement,
436
447
  updated_manifest_files: T::Array[Dependabot::DependencyFile]
437
448
  ).returns(T.nilable(String))
438
449
  end
@@ -509,7 +520,7 @@ module Dependabot
509
520
 
510
521
  sig { returns(T::Array[Dependabot::DependencyFile]) }
511
522
  def files_with_requirement
512
- filenames = dependency.requirements.map { |r| r[:file] }
523
+ filenames = dependency.requirements.map(&:file)
513
524
  dependency_files.select { |file| filenames.include?(file.name) }
514
525
  end
515
526
 
@@ -581,8 +592,7 @@ module Dependabot
581
592
 
582
593
  sig { params(dependency: Dependabot::Dependency).returns(String) }
583
594
  def registry_host_for(dependency)
584
- source = dependency.requirements.filter_map { |r| r[:source] }.first
585
- source[:registry_hostname] || source["registry_hostname"] || "registry.opentofu.org"
595
+ dependency.requirements.first&.source_string("registry_hostname") || "registry.opentofu.org"
586
596
  end
587
597
 
588
598
  sig { params(provider_source: String).returns(Regexp) }
@@ -1,4 +1,4 @@
1
- # typed: strict
1
+ # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "excon"
@@ -33,16 +33,13 @@ module Dependabot
33
33
 
34
34
  sig { returns(T.nilable(Dependabot::Source)) }
35
35
  def find_source_from_git_url
36
- info = dependency.requirements.filter_map { |r| r[:source] }.first
37
-
38
- url = info[:url] || info.fetch("url")
36
+ url = T.must(dependency.source_string("url", allowed_types: ["git"]))
39
37
  Source.from_url(url)
40
38
  end
41
39
 
42
40
  sig { returns(T.nilable(Dependabot::Source)) }
43
41
  def find_source_from_oci_details
44
- info = dependency.requirements.filter_map { |r| r[:source] }.first
45
- artifact_identifier = info[:artifact_identifier] || info["artifact_identifier"]
42
+ artifact_identifier = dependency.source_string("artifact_identifier", allowed_types: ["oci"])
46
43
  return unless artifact_identifier
47
44
 
48
45
  hostname, repo = artifact_identifier.split("/", 2)
@@ -58,8 +55,10 @@ module Dependabot
58
55
 
59
56
  sig { returns(T.nilable(Dependabot::Source)) }
60
57
  def find_source_from_registry_details
61
- info = dependency.requirements.filter_map { |r| r[:source] }.first
62
- hostname = info[:registry_hostname] || info["registry_hostname"]
58
+ hostname = dependency.source_string(
59
+ "registry_hostname",
60
+ allowed_types: %w(registry provider)
61
+ ) || RegistryClient::PUBLIC_HOSTNAME
63
62
 
64
63
  RegistryClient
65
64
  .new(hostname: hostname, credentials: credentials)
@@ -203,7 +203,7 @@ module Dependabot
203
203
  # @return [nil, Dependabot::Source]
204
204
  sig { params(dependency: Dependabot::Dependency).returns(T.nilable(Dependabot::Source)) }
205
205
  def source(dependency:)
206
- type = T.must(dependency.requirements.first)[:source][:type]
206
+ type = T.must(dependency.source_string("type"))
207
207
  base_url = url_for_api("/registry/docs/")
208
208
  case type
209
209
  when "module", "modules", "registry"
@@ -85,7 +85,7 @@ module Dependabot
85
85
  # requirement at index `i` to correspond to the previous requirement
86
86
  # at the same index.
87
87
  requirements.map do |req|
88
- case req.dig(:source, :type)
88
+ case req.source_string("type")
89
89
  when "git" then update_git_requirement(req)
90
90
  when "registry", "provider" then update_registry_requirement(req)
91
91
  when "oci" then update_oci_requirement(req)
@@ -107,36 +107,39 @@ module Dependabot
107
107
 
108
108
  sig { params(req: Dependabot::DependencyRequirement).returns(Dependabot::DependencyRequirement) }
109
109
  def update_git_requirement(req)
110
- return req unless req.dig(:source, :ref)
110
+ return req unless req.source_string("ref")
111
111
  return req unless tag_for_latest_version
112
112
 
113
- Dependabot::DependencyRequirement.create(req.merge(source: req[:source].merge(ref: tag_for_latest_version)))
113
+ source = updated_source(req, "ref" => tag_for_latest_version)
114
+ Dependabot::DependencyRequirement.create(req.merge(source: source))
114
115
  end
115
116
 
116
117
  sig { params(req: Dependabot::DependencyRequirement).returns(Dependabot::DependencyRequirement) }
117
118
  def update_oci_requirement(req)
118
119
  return req unless defined?(@latest_version) && @latest_version
119
- return req if req.dig(:source, :digest)
120
- return req unless req.dig(:source, :tag)
120
+ return req if req.source_string("digest")
121
+
122
+ old_tag = req.source_string("tag")
123
+ return req unless old_tag
121
124
 
122
125
  new_tag = latest_version.to_s
123
- return req if req.dig(:source, :tag) == new_tag
126
+ return req if old_tag == new_tag
124
127
 
128
+ source = updated_source(req, "tag" => new_tag, "version" => new_tag)
125
129
  Dependabot::DependencyRequirement.create(
126
- req.merge(
127
- source: req[:source].merge(tag: new_tag, version: new_tag)
128
- )
130
+ req.merge(source: source)
129
131
  )
130
132
  end
131
133
 
132
134
  sig { params(req: Dependabot::DependencyRequirement).returns(Dependabot::DependencyRequirement) }
133
135
  def update_registry_requirement(req)
134
- return req if req.fetch(:requirement).nil?
136
+ string_req = req.requirement_string
137
+ return req if string_req.nil?
135
138
 
136
139
  latest = latest_version
137
140
  return req if latest.nil?
138
141
 
139
- string_req = req.fetch(:requirement).strip
142
+ string_req = string_req.strip
140
143
  ruby_req = requirement_class.new(string_req)
141
144
  return req if ruby_req.satisfied_by?(latest)
142
145
 
@@ -152,6 +155,33 @@ module Dependabot
152
155
  Dependabot::DependencyRequirement.create(req.merge(requirement: new_req))
153
156
  end
154
157
 
158
+ sig do
159
+ params(
160
+ req: Dependabot::DependencyRequirement,
161
+ updates: T::Hash[String, String]
162
+ ).returns(Dependabot::DependencyRequirement::ObjectHash)
163
+ end
164
+ def updated_source(req, updates)
165
+ source = T.must(req.source_hash).dup
166
+ updates.each do |key, value|
167
+ source[source_key(source, key)] = value
168
+ end
169
+ source
170
+ end
171
+
172
+ sig do
173
+ params(
174
+ source: Dependabot::DependencyRequirement::ObjectHash,
175
+ key: String
176
+ ).returns(T.any(String, Symbol))
177
+ end
178
+ def source_key(source, key)
179
+ return key.to_sym if source.key?(key.to_sym)
180
+ return key if source.key?(key)
181
+
182
+ source.keys.any?(Symbol) ? key.to_sym : key
183
+ end
184
+
155
185
  # Updates the version in a "~>" constraint to allow the given version
156
186
  sig { params(req_string: String).returns(String) }
157
187
  def update_twiddle_version(req_string)
@@ -93,13 +93,13 @@ module Dependabot
93
93
 
94
94
  sig { returns(T::Array[Dependabot::Opentofu::Version]) }
95
95
  def all_module_versions
96
- identifier = dependency_source_details&.fetch(:module_identifier)
96
+ identifier = T.must(dependency.source_string("module_identifier", allowed_types: ELIGIBLE_SOURCE_TYPES))
97
97
  registry_client.all_module_versions(identifier: identifier)
98
98
  end
99
99
 
100
100
  sig { returns(T::Array[Dependabot::Opentofu::Version]) }
101
101
  def all_provider_versions
102
- identifier = dependency_source_details&.fetch(:module_identifier)
102
+ identifier = T.must(dependency.source_string("module_identifier", allowed_types: ELIGIBLE_SOURCE_TYPES))
103
103
  registry_client.all_provider_versions(identifier: identifier)
104
104
  end
105
105
 
@@ -107,7 +107,10 @@ module Dependabot
107
107
  def registry_client
108
108
  @registry_client ||= T.let(
109
109
  begin
110
- hostname = dependency_source_details&.fetch(:registry_hostname)
110
+ hostname = dependency.source_string(
111
+ "registry_hostname",
112
+ allowed_types: ELIGIBLE_SOURCE_TYPES
113
+ ) || RegistryClient::PUBLIC_HOSTNAME
111
114
  RegistryClient.new(hostname: hostname, credentials: credentials)
112
115
  end,
113
116
  T.nilable(Dependabot::Opentofu::RegistryClient)
@@ -144,7 +147,7 @@ module Dependabot
144
147
  end
145
148
 
146
149
  dependency.requirements.any? do |req|
147
- req[:requirement]&.match?(/\d-[A-Za-z0-9]/)
150
+ req.requirement_string&.match?(/\d-[A-Za-z0-9]/)
148
151
  end
149
152
  end
150
153
 
@@ -192,42 +195,36 @@ module Dependabot
192
195
 
193
196
  sig { returns(T::Boolean) }
194
197
  def proxy_requirement?
195
- dependency.requirements.any? do |req|
196
- req.fetch(:source)&.fetch(:proxy_url, nil)
197
- end
198
+ dependency.requirements.any? { |req| req.source_string("proxy_url") }
198
199
  end
199
200
 
200
201
  sig { returns(T::Boolean) }
201
202
  def registry_dependency?
202
- return false if dependency_source_details.nil?
203
-
204
- dependency_source_details&.fetch(:type) == "registry"
203
+ dependency.source_string("type", allowed_types: ELIGIBLE_SOURCE_TYPES) == "registry"
205
204
  end
206
205
 
207
206
  sig { returns(T::Boolean) }
208
207
  def provider_dependency?
209
- return false if dependency_source_details.nil?
210
-
211
- dependency_source_details&.fetch(:type) == "provider"
208
+ dependency.source_string("type", allowed_types: ELIGIBLE_SOURCE_TYPES) == "provider"
212
209
  end
213
210
 
214
211
  sig { returns(T::Boolean) }
215
212
  def oci_dependency?
216
- return false if dependency_source_details.nil?
217
-
218
- dependency_source_details&.fetch(:type) == "oci"
213
+ dependency.source_string("type", allowed_types: ELIGIBLE_SOURCE_TYPES) == "oci"
219
214
  end
220
215
 
221
216
  sig { returns(T.nilable(Dependabot::Opentofu::Version)) }
222
217
  def latest_version_for_oci_dependency
223
218
  return unless oci_dependency?
224
219
  # Digest pins are immutable; nothing to update to without a tag.
225
- return if dependency_source_details&.fetch(:digest)
220
+ return if dependency.source_string("digest", allowed_types: ELIGIBLE_SOURCE_TYPES)
226
221
 
227
222
  @latest_oci_version = T.let(@latest_oci_version, T.nilable(Dependabot::Opentofu::Version))
228
223
  return @latest_oci_version if @latest_oci_version
229
224
 
230
- identifier = T.must(dependency_source_details).fetch(:artifact_identifier)
225
+ identifier = T.must(
226
+ dependency.source_string("artifact_identifier", allowed_types: ELIGIBLE_SOURCE_TYPES)
227
+ )
231
228
  versions = RegistryClient.all_oci_tags(
232
229
  artifact_identifier: identifier,
233
230
  credentials: credentials
@@ -237,11 +234,6 @@ module Dependabot
237
234
  @latest_oci_version = versions.max
238
235
  end
239
236
 
240
- sig { returns(T.nilable(T::Hash[T.any(String, Symbol), T.untyped])) }
241
- def dependency_source_details
242
- dependency.source_details(allowed_types: ELIGIBLE_SOURCE_TYPES)
243
- end
244
-
245
237
  sig { returns(T::Boolean) }
246
238
  def git_dependency?
247
239
  git_commit_checker.git_dependency?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-opentofu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.391.0
4
+ version: 0.392.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.391.0
18
+ version: 0.392.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.391.0
25
+ version: 0.392.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: debug
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -262,7 +262,7 @@ licenses:
262
262
  - MIT
263
263
  metadata:
264
264
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
265
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.391.0
265
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.392.0
266
266
  rdoc_options: []
267
267
  require_paths:
268
268
  - lib