Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
greensd4 committed Aug 25, 2024
1 parent a079ada commit b925b9d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
11 changes: 0 additions & 11 deletions internal/extractors/dockerfile_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ func extractImagesFromDockerfile(logger *logger.Logger, filePath types.FilePath,
}

func replacePlaceholders(line string, envVars, argsAndEnv map[string]string) string {
// Replace ${PLACE} style placeholders first
for varName, varValue := range envVars {
placeholderWithBraces := fmt.Sprintf("${%s}", varName)
line = strings.ReplaceAll(line, placeholderWithBraces, varValue)
Expand All @@ -124,7 +123,6 @@ func replacePlaceholders(line string, envVars, argsAndEnv map[string]string) str
line = strings.ReplaceAll(line, placeholderWithoutBraces, varValue)
}

// Replace ${PLACE} and $PLACE style placeholders for argsAndEnv as well
for varName, varValue := range argsAndEnv {
placeholderWithBraces := fmt.Sprintf("${%s}", varName)
line = strings.ReplaceAll(line, placeholderWithBraces, varValue)
Expand All @@ -139,7 +137,6 @@ func replacePlaceholders(line string, envVars, argsAndEnv map[string]string) str
func resolveEnvVariables(dockerfilePath string, envFiles map[string]map[string]string) map[string]string {
resolvedVars := make(map[string]string)

// Iterate over the hierarchy and merge environment variables
dirs := getDirsForHierarchy(dockerfilePath)
for _, dir := range dirs {
if envVars, ok := envFiles[dir]; ok {
Expand All @@ -149,14 +146,6 @@ func resolveEnvVariables(dockerfilePath string, envFiles map[string]map[string]s
}
}
}

//if envVars, ok := envFiles[filepath.Join(dir, ".env")]; ok {
// for k, v := range envVars {
// if _, exists := resolvedVars[k]; !exists {
// resolvedVars[k] = v
// }
// }
//}
}

return resolvedVars
Expand Down
1 change: 0 additions & 1 deletion internal/files/files_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func (fe *ImagesExtractor) ExtractFiles(scanPath string) (types.FileImages, map[
})
}

// Check for .env or .env_cxcontainers files
if strings.HasSuffix(info.Name(), ".env") || strings.HasSuffix(info.Name(), ".env_cxcontainers") {
dir := filepath.Dir(path)
envFiles[dir] = append(envFiles[dir], path)
Expand Down

0 comments on commit b925b9d

Please sign in to comment.