Skip to content

Commit 5164803

Browse files
remove comments
1 parent bb382aa commit 5164803

File tree

2 files changed

+0
-20
lines changed

2 files changed

+0
-20
lines changed

pkg/imagesExtractor/files_extractor.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ func (ie *imagesExtractor) ExtractFiles(scanPath string, isFullHelmDirectory ...
101101
log.Warn().Msgf("Could not extract docker or docker compose files: %s", err.Error())
102102
}
103103

104-
// Conditional Helm discovery based on isFullHelmDirectory parameter
105104
if fullHelmDir {
106-
// Use existing logic for full Helm directory
107105
helmCharts, err := findHelmCharts(filesPath)
108106
if err != nil {
109107
log.Warn().Msgf("Could not extract helm charts: %s", err.Error())
@@ -112,7 +110,6 @@ func (ie *imagesExtractor) ExtractFiles(scanPath string, isFullHelmDirectory ...
112110
f.Helm = helmCharts
113111
}
114112
} else {
115-
// Use new logic for single Helm file validation
116113
helmCharts, err := findHelmFilesInDirectory(scanPath)
117114
if err != nil {
118115
log.Warn().Msgf("Could not validate helm file: %s", err.Error())

pkg/imagesExtractor/utils.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ func findHelmFilesInDirectory(scanPath string) ([]types.HelmChartInfo, error) {
152152
return nil, err
153153
}
154154

155-
// Create and return HelmChartInfo structure
156155
return createHelmChartInfo(helmDir, valuesFiles, templateFiles), nil
157156
}
158157

@@ -162,22 +161,18 @@ func validateScanPathAndFindHelmDir(scanPath string) (string, error) {
162161
return "", fmt.Errorf("directory does not exist: %s", scanPath)
163162
}
164163

165-
// Find helm directory in the hierarchy
166164
helmDir, isUnderHelm := findHelmDirectory(scanPath)
167165
if !isUnderHelm {
168166
return "", fmt.Errorf("no helm directory found in path hierarchy: %s", scanPath)
169167
}
170168

171-
// Get relative path from helm directory to scan path
172169
relativeScanPath, err := filepath.Rel(helmDir, scanPath)
173170
if err != nil {
174171
return "", fmt.Errorf("could not get relative path: %v", err)
175172
}
176173

177-
// Build the full path to scan
178174
fullScanPath := filepath.Join(helmDir, relativeScanPath)
179175

180-
// Check if scan path is a directory
181176
scanPathInfo, err := os.Stat(fullScanPath)
182177
if err != nil {
183178
return "", fmt.Errorf("could not get scan path info: %v", err)
@@ -198,28 +193,23 @@ func collectHelmFiles(scanPath, helmDir string) ([]string, []types.FilePath, err
198193
return err
199194
}
200195

201-
// Skip directories
202196
if info.IsDir() {
203197
return nil
204198
}
205199

206-
// Check if file has .yml or .yaml extension
207200
if !isYAMLFile(path) {
208201
return nil
209202
}
210203

211-
// Exclude Chart.yaml files
212204
if info.Name() == "Chart.yaml" {
213205
return nil
214206
}
215207

216-
// Get relative path from helm directory
217208
relativePath, err := filepath.Rel(helmDir, path)
218209
if err != nil {
219210
return err
220211
}
221212

222-
// Classify file based on location
223213
if isValuesFile(path, helmDir) {
224214
valuesFiles = append(valuesFiles, relativePath)
225215
} else if isTemplateFile(relativePath) {
@@ -261,7 +251,6 @@ func createHelmChartInfo(helmDir string, valuesFiles []string, templateFiles []t
261251
return []types.HelmChartInfo{}
262252
}
263253

264-
// Group files by type
265254
helmChart := types.HelmChartInfo{
266255
Directory: helmDir,
267256
}
@@ -278,24 +267,20 @@ func createHelmChartInfo(helmDir string, valuesFiles []string, templateFiles []t
278267
}
279268
}
280269

281-
// Add template files
282270
helmChart.TemplateFiles = templateFiles
283271

284272
return []types.HelmChartInfo{helmChart}
285273
}
286274

287275
func findHelmDirectory(dirPath string) (string, bool) {
288-
// Start with the directory itself
289276
currentDir := dirPath
290277

291278
for {
292-
// Check if current directory name matches helm conventions
293279
dirName := filepath.Base(currentDir)
294280
if isHelmDirectoryName(dirName) {
295281
return currentDir, true
296282
}
297283

298-
// Move up one level
299284
parentDir := filepath.Dir(currentDir)
300285
if parentDir == currentDir {
301286
// Reached root directory
@@ -308,9 +293,7 @@ func findHelmDirectory(dirPath string) (string, bool) {
308293
}
309294

310295
func isHelmDirectoryName(dirName string) bool {
311-
// Convert to lowercase for case-insensitive comparison
312296
dirNameLower := strings.ToLower(dirName)
313297

314-
// Check if directory name contains "helm"
315298
return strings.Contains(dirNameLower, "helm")
316299
}

0 commit comments

Comments
 (0)