Skip to content

Commit

Permalink
chore(release-automation): add exceptions to allowed base image check
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszbarwicki committed Mar 11, 2024
1 parent 1e49f1e commit 3aec77b
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions release-automation/internal/container/allowed_base_image_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
package container

import (
"fmt"
"log"
"strings"

"tractusx-release-automation/internal/exception"
"tractusx-release-automation/internal/repo"
"tractusx-release-automation/internal/tractusx"
)

Expand Down Expand Up @@ -55,20 +56,30 @@ func (a *AllowedBaseImage) ExternalDescription() string {
}

func (a *AllowedBaseImage) Test() *tractusx.QualityResult {
config, err := exception.GetData()
if err != nil {
log.Println("Can't process exceptions.")
} else {
repoInfo := repo.GetRepoBaseInfo(a.baseDir)
if config.IsExceptioned(a.Name(), "https://github.com/eclipse-tractusx/"+repoInfo.Reponame) {
return &tractusx.QualityResult{Passed: true}
}
}

foundDockerFiles := findDockerfilesAt(a.baseDir)
dockerfilesToSkip := getDockerfilePathsToIgnore(a.baseDir)

checkPassed := true
var deniedBaseImages []string
for _, dockerfilePath := range foundDockerFiles {
if containsString(dockerfilesToSkip, dockerfilePath) {
fmt.Printf("Dockerfile at path %s configured to skip", dockerfilePath)
log.Printf("Dockerfile at path %s configured to skip", dockerfilePath)
continue
}

file, err := dockerfileFromPath(dockerfilePath)
if err != nil {
fmt.Printf("Could not read dockerfile from Path %s\n", dockerfilePath)
log.Printf("Could not read dockerfile from Path %s\n", dockerfilePath)
continue
}
if !isAllowedBaseImage(strings.Split(file.baseImage(), ":")[0]) {
Expand Down

0 comments on commit 3aec77b

Please sign in to comment.