Skip to content

Commit

Permalink
display error logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Cerebrovinny committed Nov 15, 2024
1 parent cf24006 commit 1b5f112
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions internal/exec/vendor_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,25 @@ func ReadAndProcessVendorConfigFile(
vendorConfigFile string,
) (schema.AtmosVendorConfig, bool, string, error) {
var vendorConfig schema.AtmosVendorConfig
var foundVendorConfigFile string
var vendorConfigFileExists bool

// Initialize empty sources slice
vendorConfig.Spec.Sources = []schema.AtmosVendorSource{}

var vendorConfigFileExists bool
var foundVendorConfigFile string

// Check if vendor config is specified in atmos.yaml
if cliConfig.Vendor.BasePath != "" {
if !filepath.IsAbs(cliConfig.Vendor.BasePath) {
foundVendorConfigFile = filepath.Join(cliConfig.BasePath, cliConfig.Vendor.BasePath)
} else {
foundVendorConfigFile = cliConfig.Vendor.BasePath
}

// Check if specified path exists
if !u.FileExists(foundVendorConfigFile) {
u.LogWarning(cliConfig, fmt.Sprintf("Vendor config path '%s' specified in atmos.yaml does not exist", foundVendorConfigFile))
return vendorConfig, false, "", nil
}
} else {
// Path is not defined in atmos.yaml, proceed with existing logic
var fileExists bool
Expand All @@ -152,8 +157,8 @@ func ReadAndProcessVendorConfigFile(
pathToVendorConfig := path.Join(cliConfig.BasePath, vendorConfigFile)

if !u.FileExists(pathToVendorConfig) {
vendorConfigFileExists = false
return vendorConfig, vendorConfigFileExists, "", fmt.Errorf("vendor config file or directory '%s' does not exist", pathToVendorConfig)
// Instead of returning error, return false to indicate no vendor config exists
return vendorConfig, false, "", nil
}

foundVendorConfigFile = pathToVendorConfig
Expand Down Expand Up @@ -551,11 +556,6 @@ func ExecuteAtmosVendorInternal(
}
}

targetDir := filepath.Dir(targetPath)
if err := os.MkdirAll(targetDir, 0755); err != nil {
return fmt.Errorf("failed to create target directory '%s': %w", targetDir, err)
}

if err = cp.Copy(tempDir, targetPath, copyOptions); err != nil {
return err
}
Expand Down

0 comments on commit 1b5f112

Please sign in to comment.