Skip to content

Commit

Permalink
fix linter error
Browse files Browse the repository at this point in the history
  • Loading branch information
haitham911 committed Feb 24, 2025
1 parent 0a9353a commit 462b5bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions pkg/config/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type ResolvedPaths struct {
importType importTypes
}

// processConfigImports It reads the import paths from the source configuration,
// processConfigImports It reads the import paths from the source configuration.
// It processes imports from the source configuration and merges them into the destination configuration.
func processConfigImports(source *schema.AtmosConfiguration, dst *viper.Viper) error {
if source == nil || dst == nil {
Expand Down Expand Up @@ -115,12 +115,12 @@ func processImports(basePath string, importPaths []string, tempDir string, curre
return resolvedPaths, nil
}

// Helper to determine if the import is a supported remote source
// Helper to determine if the import is a supported remote source.
func isRemoteImport(importPath string) bool {
return strings.HasPrefix(importPath, "http://") || strings.HasPrefix(importPath, "https://")
}

// Process remote imports
// Process remote imports.
func processRemoteImport(basePath, importPath, tempDir string, currentDepth, maxDepth int) ([]ResolvedPaths, error) {
parsedURL, err := url.Parse(importPath)
if err != nil || (parsedURL.Scheme != "http" && parsedURL.Scheme != "https") {
Expand Down Expand Up @@ -166,7 +166,7 @@ func processRemoteImport(basePath, importPath, tempDir string, currentDepth, max
return resolvedPaths, nil
}

// Process local imports
// Process local imports.
func processLocalImport(basePath string, importPath, tempDir string, currentDepth, maxDepth int) ([]ResolvedPaths, error) {
if importPath == "" {
return nil, fmt.Errorf("import_path required to process imports")

Check failure on line 172 in pkg/config/imports.go

View workflow job for this annotation

GitHub Actions / golangci

[golangci] pkg/config/imports.go#L172

do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"import_path required to process imports\")" (err113)
Raw output
pkg/config/imports.go:172:15: do not define dynamic errors, use wrapped static errors instead: "fmt.Errorf(\"import_path required to process imports\")" (err113)
		return nil, fmt.Errorf("import_path required to process imports")
		            ^
Expand Down Expand Up @@ -248,7 +248,7 @@ func SearchAtmosConfig(path string) ([]string, error) {
return atmosFilePathsAbsolute, nil
}

// Helper function to generate search patterns for extension yaml,yml
// Helper function to generate search patterns for extension yaml,yml.
func generatePatterns(path string) []string {
isDir := false
if stat, err := os.Stat(path); err == nil && stat.IsDir() {
Expand All @@ -275,7 +275,7 @@ func generatePatterns(path string) []string {
return []string{path}
}

// Helper function to convert paths to absolute paths
// Helper function to convert paths to absolute paths.
func convertToAbsolutePaths(filePaths []string) ([]string, error) {
var absPaths []string
for _, path := range filePaths {
Expand Down
16 changes: 8 additions & 8 deletions pkg/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func readSystemConfig(v *viper.Viper) error {
}

if len(configFilePath) > 0 {
err := mergeConfig(v, configFilePath, CliConfigFileName, false)
err := mergeConfig(v, configFilePath, false)
switch err.(type) {
case viper.ConfigFileNotFoundError:
return nil
Expand All @@ -125,7 +125,7 @@ func readHomeConfig(v *viper.Viper) error {
return err
}
configFilePath := filepath.Join(home, ".atmos")
err = mergeConfig(v, configFilePath, CliConfigFileName, true)
err = mergeConfig(v, configFilePath, true)
if err != nil {
switch err.(type) {
case viper.ConfigFileNotFoundError:
Expand All @@ -144,7 +144,7 @@ func readWorkDirConfig(v *viper.Viper) error {
if err != nil {
return err
}
err = mergeConfig(v, wd, CliConfigFileName, true)
err = mergeConfig(v, wd, true)
if err != nil {
switch err.(type) {
case viper.ConfigFileNotFoundError:
Expand All @@ -162,7 +162,7 @@ func readEnvAmosConfigPath(v *viper.Viper) error {
return nil
}
configFilePath := filepath.Join(atmosPath, CliConfigFileName)
err := mergeConfig(v, configFilePath, CliConfigFileName, true)
err := mergeConfig(v, configFilePath, true)
if err != nil {
switch err.(type) {
case viper.ConfigFileNotFoundError:
Expand All @@ -181,7 +181,7 @@ func readAtmosConfigCli(v *viper.Viper, atmosCliConfigPath string) error {
if len(atmosCliConfigPath) == 0 {
return nil
}
err := mergeConfig(v, atmosCliConfigPath, CliConfigFileName, true)
err := mergeConfig(v, atmosCliConfigPath, true)
switch err.(type) {
case viper.ConfigFileNotFoundError:
log.Debug("config not found", "file", atmosCliConfigPath)
Expand All @@ -192,10 +192,10 @@ func readAtmosConfigCli(v *viper.Viper, atmosCliConfigPath string) error {
return nil
}

// mergeConfig merge config from a specified path and process imports.return error if config file not exist .
func mergeConfig(v *viper.Viper, path string, fileName string, processImports bool) error {
// mergeConfig merge config from a specified path directory and process imports.return error if config file not exist .
func mergeConfig(v *viper.Viper, path string, processImports bool) error {
v.AddConfigPath(path)
v.SetConfigName(fileName)
v.SetConfigName(CliConfigFileName)
err := v.MergeInConfig()
if err != nil {
return err
Expand Down

0 comments on commit 462b5bf

Please sign in to comment.