diff --git a/go.mod b/go.mod index 0de5c9ec83..1be289d6c8 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/AlecAivazis/survey/v2 v2.3.5 github.com/Xuanwo/go-locale v1.1.0 github.com/blang/semver v3.5.1+incompatible - github.com/devfile/alizer v1.2.1 + github.com/devfile/alizer v1.3.1 github.com/devfile/api/v2 v2.2.2 github.com/devfile/library/v2 v2.2.2-0.20231102090733-57a7da8b8392 github.com/devfile/registry-support/index/generator v0.0.0-20230322155332-33914affc83b diff --git a/go.sum b/go.sum index 96352d9ff7..21074f7c7b 100644 --- a/go.sum +++ b/go.sum @@ -365,8 +365,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd/go.mod h1:dv4zxwHi5C/8AeI+4gX4dCWOIvNi7I6JCSX0HvlKPgE= github.com/denverdino/aliyungo v0.0.0-20190125010748-a747050bb1ba/go.mod h1:dV8lFg6daOBZbT6/BDGIz6Y3WFGn8juu6G+CQ6LHtl0= -github.com/devfile/alizer v1.2.1 h1:0CrHYGjT0xTw5CYoK/U1pYGmcpKxw9YUUVaqJWF3pZM= -github.com/devfile/alizer v1.2.1/go.mod h1:kRCsbXuzCwXIbnSR4xpVZDr8Pl8j01rl+gPfkukbf/c= +github.com/devfile/alizer v1.3.1 h1:1uT/Eb0ZKZzr/AhaKD87EVIKk5EQIb2q8Lcv7Vu7mpQ= +github.com/devfile/alizer v1.3.1/go.mod h1:RFp2nrQwm0VVrNCr1PTaUkvIp8S5KAKZLmxY+l+pGjI= github.com/devfile/api/v2 v2.0.0-20211021164004-dabee4e633ed/go.mod h1:d99eTN6QxgzihOOFyOZA+VpUyD4Q1pYRYHZ/ci9J96Q= github.com/devfile/api/v2 v2.0.0-20220117162434-6e6e6a8bc14c/go.mod h1:d99eTN6QxgzihOOFyOZA+VpUyD4Q1pYRYHZ/ci9J96Q= github.com/devfile/api/v2 v2.2.0/go.mod h1:dN7xFrOVG+iPqn4UKGibXLd5oVsdE8XyK9OEb5JL3aI= diff --git a/vendor/github.com/devfile/alizer/pkg/apis/enricher/docker_enricher.go b/vendor/github.com/devfile/alizer/pkg/apis/enricher/docker_enricher.go index 8a14364a35..8249f25372 100644 --- a/vendor/github.com/devfile/alizer/pkg/apis/enricher/docker_enricher.go +++ b/vendor/github.com/devfile/alizer/pkg/apis/enricher/docker_enricher.go @@ -32,19 +32,16 @@ func (d DockerEnricher) GetSupportedLanguages() []string { func (d DockerEnricher) DoEnrichLanguage(language *model.Language, _ *[]string) { // The Dockerfile language does not contain frameworks - return } func (d DockerEnricher) DoEnrichComponent(component *model.Component, _ model.DetectionSettings, _ *context.Context) { projectName := GetDefaultProjectName(component.Path) component.Name = projectName - var ports []int - ports = GetPortsFromDockerFile(component.Path) + ports := GetPortsFromDockerFile(component.Path) if len(ports) > 0 { component.Ports = ports } - return } func (d DockerEnricher) IsConfigValidForComponentDetection(language string, config string) bool { diff --git a/vendor/github.com/devfile/alizer/pkg/apis/enricher/enricher.go b/vendor/github.com/devfile/alizer/pkg/apis/enricher/enricher.go index 85a5823b5e..c6b8db1a2a 100644 --- a/vendor/github.com/devfile/alizer/pkg/apis/enricher/enricher.go +++ b/vendor/github.com/devfile/alizer/pkg/apis/enricher/enricher.go @@ -126,11 +126,10 @@ func GetPortsFromDockerFile(root string) []int { cleanFilePath := filepath.Clean(filePath) file, err := os.Open(cleanFilePath) if err == nil { - defer func() error { + defer func(){ if err := file.Close(); err != nil { - return fmt.Errorf("error closing file: %s", err) + fmt.Printf("error closing file: %s", err) } - return nil }() return utils.ReadPortsFromDockerfile(file) } diff --git a/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/dotnet/dotnet_detector.go b/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/dotnet/dotnet_detector.go index eb349a3ab8..4991980c85 100644 --- a/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/dotnet/dotnet_detector.go +++ b/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/dotnet/dotnet_detector.go @@ -64,20 +64,23 @@ func getFrameworks(configFilePath string) string { cleanConfigPath := filepath.Clean(configFilePath) xmlFile, err := os.Open(cleanConfigPath) if err != nil { + fmt.Printf("error opening file: %s", err) + return "" + } + byteValue, err := io.ReadAll(xmlFile) + if err != nil { + fmt.Printf("error reading file: %s", err) return "" } - byteValue, _ := io.ReadAll(xmlFile) - var proj schema.DotNetProject err = xml.Unmarshal(byteValue, &proj) if err != nil { return "" } - defer func() error { + defer func(){ if err := xmlFile.Close(); err != nil { - return fmt.Errorf("error closing file: %s", err) + fmt.Printf("error closing file: %s", err) } - return nil }() if proj.PropertyGroup.TargetFramework != "" { return proj.PropertyGroup.TargetFramework diff --git a/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/javascript/nodejs/nuxt_detector.go b/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/javascript/nodejs/nuxt_detector.go index dd3af930a2..0641f5f000 100644 --- a/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/javascript/nodejs/nuxt_detector.go +++ b/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/javascript/nodejs/nuxt_detector.go @@ -45,7 +45,7 @@ func (n NuxtDetector) DoFrameworkDetection(language *model.Language, config stri // DoPortsDetection searches for the port in package.json, and nuxt.config.js func (n NuxtDetector) DoPortsDetection(component *model.Component, ctx *context.Context) { - ports := []int{} + var ports []int regexes := []string{`--port=(\d*)`} // check if port is set in start script in package.json port := getPortFromStartScript(component.Path, regexes) diff --git a/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/javascript/nodejs/vue_detector.go b/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/javascript/nodejs/vue_detector.go index dc7e456dfa..35b86405ee 100644 --- a/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/javascript/nodejs/vue_detector.go +++ b/vendor/github.com/devfile/alizer/pkg/apis/enricher/framework/javascript/nodejs/vue_detector.go @@ -46,7 +46,7 @@ func (v VueDetector) DoFrameworkDetection(language *model.Language, config strin // DoPortsDetection searches for the port in package.json, .env file, and vue.config.js func (v VueDetector) DoPortsDetection(component *model.Component, ctx *context.Context) { regexes := []string{`--port (\d*)`, `PORT=(\d*)`} - ports := []int{} + var ports []int // check if --port or PORT is set in start script in package.json port := getPortFromStartScript(component.Path, regexes) if utils.IsValidPort(port) { diff --git a/vendor/github.com/devfile/alizer/pkg/apis/recognizer/devfile_recognizer.go b/vendor/github.com/devfile/alizer/pkg/apis/recognizer/devfile_recognizer.go index 347f37070e..dcbc3146b6 100644 --- a/vendor/github.com/devfile/alizer/pkg/apis/recognizer/devfile_recognizer.go +++ b/vendor/github.com/devfile/alizer/pkg/apis/recognizer/devfile_recognizer.go @@ -242,12 +242,8 @@ var DownloadDevfileTypesFromRegistry = func(url string, filter model.DevfileFilt if err != nil { return []model.DevfileType{}, err } - defer func() error { - if err := resp.Body.Close(); err != nil { - return fmt.Errorf("error closing file: %s", err) - } - return nil - }() + + defer utils.CloseHttpResponseBody(resp) // Check server response if resp.StatusCode != http.StatusOK { diff --git a/vendor/github.com/devfile/alizer/pkg/utils/detector.go b/vendor/github.com/devfile/alizer/pkg/utils/detector.go index 370c7e4c41..223f535721 100644 --- a/vendor/github.com/devfile/alizer/pkg/utils/detector.go +++ b/vendor/github.com/devfile/alizer/pkg/utils/detector.go @@ -26,6 +26,7 @@ import ( "regexp" "strconv" "strings" + "net/http" "github.com/devfile/alizer/pkg/apis/model" "github.com/devfile/alizer/pkg/schema" @@ -134,19 +135,18 @@ func GetPomFileContent(pomFilePath string) (schema.Pom, error) { if err != nil { return schema.Pom{}, err } - byteValue, _ := io.ReadAll(xmlFile) - + byteValue, err := io.ReadAll(xmlFile) + if err != nil { + return schema.Pom{}, err + } + var pom schema.Pom err = xml.Unmarshal(byteValue, &pom) if err != nil { return schema.Pom{}, err } - defer func() error { - if err := xmlFile.Close(); err != nil { - return fmt.Errorf("error closing file: %s", err) - } - return nil - }() + + defer CloseFile(xmlFile) return pom, nil } @@ -353,12 +353,7 @@ func GetEnvVarsFromDockerFile(root string) ([]model.EnvVar, error) { cleanFilePath := filepath.Clean(filePath) file, err := os.Open(cleanFilePath) if err == nil { - defer func() error { - if err := file.Close(); err != nil { - return fmt.Errorf("error closing file: %s", err) - } - return nil - }() + defer CloseFile(file) return readEnvVarsFromDockerfile(file) } } @@ -751,3 +746,15 @@ func NormalizeSplit(file string) (string, string) { } return dir, fileName } + +func CloseHttpResponseBody(resp *http.Response){ + if err := resp.Body.Close(); err != nil { + fmt.Printf("error closing file: %s", err) + } +} + +func CloseFile(file *os.File){ + if err := file.Close(); err != nil { + fmt.Printf("error closing file: %s", err) + } +} diff --git a/vendor/github.com/devfile/alizer/pkg/utils/langfiles/languages_file_handler.go b/vendor/github.com/devfile/alizer/pkg/utils/langfiles/languages_file_handler.go index 9237e9903c..f915d51e9b 100644 --- a/vendor/github.com/devfile/alizer/pkg/utils/langfiles/languages_file_handler.go +++ b/vendor/github.com/devfile/alizer/pkg/utils/langfiles/languages_file_handler.go @@ -184,9 +184,7 @@ func (l *LanguageFile) GetConfigurationPerLanguageMapping() map[string][]string func (l *LanguageFile) GetExcludedFolders() []string { var excludedFolders []string for _, langItem := range l.languages { - for _, exclude := range langItem.ExcludeFolders { - excludedFolders = append(excludedFolders, exclude) - } + excludedFolders = append(excludedFolders, langItem.ExcludeFolders...) } excludedFolders = removeDuplicates(excludedFolders) return excludedFolders diff --git a/vendor/modules.txt b/vendor/modules.txt index 2b8ff9d5a8..f2b07398f3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -153,7 +153,7 @@ github.com/danieljoos/wincred # github.com/davecgh/go-spew v1.1.1 ## explicit github.com/davecgh/go-spew/spew -# github.com/devfile/alizer v1.2.1 +# github.com/devfile/alizer v1.3.1 ## explicit; go 1.19 github.com/devfile/alizer/pkg/apis/enricher github.com/devfile/alizer/pkg/apis/enricher/framework/dotnet