Skip to content

Commit

Permalink
Merge pull request #109 from aquasecurity/108-read-version-map
Browse files Browse the repository at this point in the history
feat: move version_map.yaml into configdir, fixes #108
  • Loading branch information
ttousai authored Jan 6, 2025
2 parents 775ca29 + dbd5cea commit f928836
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 13 deletions.
1 change: 0 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ archives:
}}v{{.Arm }}{{ end }}"
files:
- cfg/*
- version_map.yaml
File renamed without changes.
5 changes: 2 additions & 3 deletions cmd/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ func (p mockPowerShell) Execute(customConfig ...interface{}) (result string, err

func init() {
here, _ := os.Getwd()
// cfgDir and rootDir are defined in root.go
rootDir = fmt.Sprintf("%s/..", here)
cfgDir = fmt.Sprintf("%s/cfg", rootDir)
// cfgDir is defined in root.go
cfgDir = fmt.Sprintf("%s/../cfg", here)
}

func TestGetControls(t *testing.T) {
Expand Down
8 changes: 0 additions & 8 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ var (

windowsCisVersion string
cfgDir string
rootDir string
cfgFile string
checkList string
jsonFmt bool
Expand Down Expand Up @@ -115,13 +114,6 @@ func init() {
goflag.CommandLine.VisitAll(func(goflag *goflag.Flag) {
RootCmd.PersistentFlags().AddGoFlag(goflag)
})

// Initialize global variables
var err error
rootDir, err = os.Getwd()
if err != nil {
glog.Fatalf("Failed to get the current working directory: %v", err)
}
}

// initConfig reads in config file and ENV variables if set.
Expand Down
2 changes: 1 addition & 1 deletion cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func loadConfig(cisVersion, serverVersion, serverType string) (string, error) {
var err error
versionMap := make(map[string]string)
key := fmt.Sprintf("%s_%s_%s", serverVersion, serverType, cisVersion)
path := filepath.Join(rootDir, "version_map.yaml")
path := filepath.Join(cfgDir, "version_map.yaml")
in, err := os.ReadFile(path)
if err != nil {
return "", err
Expand Down

0 comments on commit f928836

Please sign in to comment.