Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

feat: helm chart structure check #32

Conversation

tomaszbarwicki
Copy link
Contributor

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:

  • DEPENDENCIES are up to date. Dash license tool. Committers can open IP issues for restricted libs.
  • Copyright and license header are present on all affected files

Additional information

Copy link
Contributor

@SebastianBezold SebastianBezold left a 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) {

Copy link
Contributor

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 {
Copy link
Contributor

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 {

Copy link
Contributor

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)
Copy link
Contributor

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)
Copy link
Contributor

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) {
Copy link
Contributor

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

@tomaszbarwicki tomaszbarwicki force-pushed the feat/add_helmchart_structure_check branch from 51e65c7 to 7282799 Compare July 17, 2023 14:16
@SebastianBezold SebastianBezold merged commit e2ac3e6 into eclipse-tractusx:main Jul 18, 2023
@tomaszbarwicki tomaszbarwicki deleted the feat/add_helmchart_structure_check branch August 17, 2023 07:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create ghc TRG5.02 Chart structure
2 participants