Skip to content

Commit 035bdc9

Browse files
committed
Refactor ExtractImageReferences and TryRegisterStructuredImageReference methods to remove unused fileLocation parameter
1 parent 6b7d6fe commit 035bdc9

3 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/Microsoft.ComponentDetection.Detectors/dockercompose/DockerComposeComponentDetector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID
6868
{
6969
if (document.RootNode is YamlMappingNode rootMapping)
7070
{
71-
this.ExtractImageReferences(rootMapping, singleFileComponentRecorder, file.Location);
71+
this.ExtractImageReferences(rootMapping, singleFileComponentRecorder);
7272
}
7373
}
7474
}
@@ -91,7 +91,7 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID
9191
return null;
9292
}
9393

94-
private void ExtractImageReferences(YamlMappingNode rootMapping, ISingleFileComponentRecorder recorder, string fileLocation)
94+
private void ExtractImageReferences(YamlMappingNode rootMapping, ISingleFileComponentRecorder recorder)
9595
{
9696
var services = GetMappingChild(rootMapping, "services");
9797
if (services == null)

src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private void WalkYamlForImages(YamlMappingNode mapping, ISingleFileComponentReco
154154
// repository: nginx
155155
// tag: "1.21"
156156
case YamlMappingNode imageMapping:
157-
this.TryRegisterStructuredImageReference(imageMapping, recorder, fileLocation);
157+
this.TryRegisterStructuredImageReference(imageMapping, recorder);
158158
break;
159159

160160
default:
@@ -178,7 +178,7 @@ private void WalkYamlForImages(YamlMappingNode mapping, ISingleFileComponentReco
178178
}
179179
}
180180

181-
private void TryRegisterStructuredImageReference(YamlMappingNode imageMapping, ISingleFileComponentRecorder recorder, string fileLocation)
181+
private void TryRegisterStructuredImageReference(YamlMappingNode imageMapping, ISingleFileComponentRecorder recorder)
182182
{
183183
string? repository = null;
184184
string? tag = null;

src/Microsoft.ComponentDetection.Detectors/kubernetes/KubernetesComponentDetector.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID
8484
}
8585

8686
this.Logger.LogInformation("Discovered Kubernetes manifest: {Location}", file.Location);
87-
this.ExtractImageReferences(rootMapping, singleFileComponentRecorder, file.Location);
87+
this.ExtractImageReferences(rootMapping, singleFileComponentRecorder);
8888
}
8989
}
9090
catch (YamlException e)
@@ -208,7 +208,7 @@ private static bool IsKubernetesManifest(YamlMappingNode rootMapping)
208208
return !string.IsNullOrEmpty(apiVersion) && !string.IsNullOrEmpty(kind) && KubernetesKinds.Contains(kind);
209209
}
210210

211-
private void ExtractImageReferences(YamlMappingNode rootMapping, ISingleFileComponentRecorder recorder, string fileLocation)
211+
private void ExtractImageReferences(YamlMappingNode rootMapping, ISingleFileComponentRecorder recorder)
212212
{
213213
// PodTemplate has pod spec at root.template.spec.
214214
var rootTemplate = GetMappingChild(rootMapping, "template");
@@ -217,7 +217,7 @@ private void ExtractImageReferences(YamlMappingNode rootMapping, ISingleFileComp
217217
var rootTemplateSpec = GetMappingChild(rootTemplate, "spec");
218218
if (rootTemplateSpec != null)
219219
{
220-
this.ExtractContainerImages(rootTemplateSpec, recorder, fileLocation);
220+
this.ExtractContainerImages(rootTemplateSpec, recorder);
221221
}
222222
}
223223

@@ -230,7 +230,7 @@ private void ExtractImageReferences(YamlMappingNode rootMapping, ISingleFileComp
230230
}
231231

232232
// Direct pod spec (kind: Pod)
233-
this.ExtractContainerImages(spec, recorder, fileLocation);
233+
this.ExtractContainerImages(spec, recorder);
234234

235235
// Templated pod spec (kind: Deployment, StatefulSet, etc.)
236236
var template = GetMappingChild(spec, "template");
@@ -239,7 +239,7 @@ private void ExtractImageReferences(YamlMappingNode rootMapping, ISingleFileComp
239239
var templateSpec = GetMappingChild(template, "spec");
240240
if (templateSpec != null)
241241
{
242-
this.ExtractContainerImages(templateSpec, recorder, fileLocation);
242+
this.ExtractContainerImages(templateSpec, recorder);
243243
}
244244
}
245245

@@ -256,21 +256,21 @@ private void ExtractImageReferences(YamlMappingNode rootMapping, ISingleFileComp
256256
var jobPodSpec = GetMappingChild(jobPodTemplate, "spec");
257257
if (jobPodSpec != null)
258258
{
259-
this.ExtractContainerImages(jobPodSpec, recorder, fileLocation);
259+
this.ExtractContainerImages(jobPodSpec, recorder);
260260
}
261261
}
262262
}
263263
}
264264
}
265265

266-
private void ExtractContainerImages(YamlMappingNode podSpec, ISingleFileComponentRecorder recorder, string fileLocation)
266+
private void ExtractContainerImages(YamlMappingNode podSpec, ISingleFileComponentRecorder recorder)
267267
{
268-
this.ExtractImagesFromContainerList(podSpec, "containers", recorder, fileLocation);
269-
this.ExtractImagesFromContainerList(podSpec, "initContainers", recorder, fileLocation);
270-
this.ExtractImagesFromContainerList(podSpec, "ephemeralContainers", recorder, fileLocation);
268+
this.ExtractImagesFromContainerList(podSpec, "containers", recorder);
269+
this.ExtractImagesFromContainerList(podSpec, "initContainers", recorder);
270+
this.ExtractImagesFromContainerList(podSpec, "ephemeralContainers", recorder);
271271
}
272272

273-
private void ExtractImagesFromContainerList(YamlMappingNode podSpec, string containerKey, ISingleFileComponentRecorder recorder, string fileLocation)
273+
private void ExtractImagesFromContainerList(YamlMappingNode podSpec, string containerKey, ISingleFileComponentRecorder recorder)
274274
{
275275
var containers = GetSequenceChild(podSpec, containerKey);
276276
if (containers == null)

0 commit comments

Comments
 (0)