-
Notifications
You must be signed in to change notification settings - Fork 1
feat: helm chart structure check #32
feat: helm chart structure check #32
Conversation
…ng UT for repo structure check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall implementation looks good to me.
The main change I think we should do is the dedicated package for filesystem related operations
} | ||
|
||
func CleanFiles(files []string) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary blank line
} | ||
|
||
return &txqualitychecks.QualityResult{Passed: true} | ||
} | ||
|
||
// Function to verify files existance. | ||
// Return missing ones. | ||
func checkMissingFiles(listOfFiles []string) []string { | ||
func CheckMissingFiles(listOfFiles []string) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like the functions below, I would move this to a dedicated package
} | ||
|
||
func (r *HelmStructureExists) Test() *txqualitychecks.QualityResult { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this on multiple of your files. The empty blank lines at the beginning of the function seems unnecessary for me.
if hc.IsDir() { | ||
tmpFilesStructure := []string{} | ||
for _, fname := range helmStructureFiles { | ||
tmpFilesStructure = append(tmpFilesStructure, mainDir+"/"+hc.Name()+"/"+fname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path.Join()
would be a good option here instead of concatenating "/"
manually. This also takes care of potentially already existing slashes at the end of your path fragments
|
||
func CreateDirs(dirs []string) { | ||
for _, dir := range dirs { | ||
os.Mkdir(dir, 0750) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful with Mkdir
. It is only capable of creating one level of dirs. MkdirAll
could be a better option
message := startingMessage | ||
for _, missingFile := range listOfFiles { | ||
message += missingFile + " " | ||
func CreateFiles(files []string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either do not export these functions, since it is only used in this package, or create a separate filesystem (or better name) package
51e65c7
to
7282799
Compare
Description
Introducing new check as per TRG 5.02 - Chart structure.
The check verifies if repository follows specified Helm Chart files & directory structure.
Fixes eclipse-tractusx/sig-infra#94
Updates eclipse-tractusx/sig-infra#93
Pre-review checks
Please ensure to do as many of the following checks as possible, before asking for committer review:
Additional information