Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vendor pull directory creation issue #782

Merged
merged 14 commits into from
Dec 5, 2024
Merged
Empty file.
3 changes: 3 additions & 0 deletions internal/exec/stack_processor_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ func ProcessYAMLConfigFile(
return nil, nil, nil, err
}
}
if stackYamlConfig == "" {
return map[string]any{}, map[string]map[string]any{}, map[string]any{}, nil
}

stackManifestTemplatesProcessed := stackYamlConfig
stackManifestTemplatesErrorMessage := ""
Expand Down
43 changes: 24 additions & 19 deletions internal/exec/validate_stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
u "github.com/cloudposse/atmos/pkg/utils"
)

const atmosManifestDefault = "https://atmos.tools/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json"

// ExecuteValidateStacksCmd executes `validate stacks` command
func ExecuteValidateStacksCmd(cmd *cobra.Command, args []string) error {
info, err := processCommandLineArgs("", cmd, args, nil)
Expand Down Expand Up @@ -84,27 +86,30 @@ func ValidateStacks(cliConfig schema.CliConfiguration) error {
// The path to the Atmos manifest JSON Schema can be absolute path or a path relative to the `base_path` setting in `atmos.yaml`
var atmosManifestJsonSchemaFilePath string

if cliConfig.Schemas.Atmos.Manifest != "" {
atmosManifestJsonSchemaFileAbsPath := path.Join(cliConfig.BasePath, cliConfig.Schemas.Atmos.Manifest)

if u.FileExists(cliConfig.Schemas.Atmos.Manifest) {
atmosManifestJsonSchemaFilePath = cliConfig.Schemas.Atmos.Manifest
} else if u.FileExists(atmosManifestJsonSchemaFileAbsPath) {
atmosManifestJsonSchemaFilePath = atmosManifestJsonSchemaFileAbsPath
} else if u.IsURL(cliConfig.Schemas.Atmos.Manifest) {
atmosManifestJsonSchemaFilePath, err = downloadSchemaFromURL(cliConfig.Schemas.Atmos.Manifest)
if err != nil {
return err
}
} else {
return fmt.Errorf("the Atmos JSON Schema file '%s' does not exist.\n"+
"It can be configured in the 'schemas.atmos.manifest' section in 'atmos.yaml', or provided using the 'ATMOS_SCHEMAS_ATMOS_MANIFEST' "+
"ENV variable or '--schemas-atmos-manifest' command line argument.\n"+
"The path to the schema file should be an absolute path or a path relative to the 'base_path' setting in 'atmos.yaml'. \n"+
"Alternatively, you can specify a schema file using a URL that will be downloaded automatically.",
cliConfig.Schemas.Atmos.Manifest)
if cliConfig.Schemas.Atmos.Manifest == "" {
cliConfig.Schemas.Atmos.Manifest = atmosManifestDefault
u.LogTrace(cliConfig, fmt.Sprintf("The Atmos JSON Schema file is not configured. Using the default schema '%s'", atmosManifestDefault))
}
atmosManifestJsonSchemaFileAbsPath := path.Join(cliConfig.BasePath, cliConfig.Schemas.Atmos.Manifest)

if u.FileExists(cliConfig.Schemas.Atmos.Manifest) {
atmosManifestJsonSchemaFilePath = cliConfig.Schemas.Atmos.Manifest
} else if u.FileExists(atmosManifestJsonSchemaFileAbsPath) {
atmosManifestJsonSchemaFilePath = atmosManifestJsonSchemaFileAbsPath
} else if u.IsURL(cliConfig.Schemas.Atmos.Manifest) {
atmosManifestJsonSchemaFilePath, err = downloadSchemaFromURL(cliConfig.Schemas.Atmos.Manifest)
if err != nil {
return err
}
} else {
return fmt.Errorf("Schema file '%s' not found. Configure via:\n"+
"1. 'schemas.atmos.manifest' in atmos.yaml\n"+
"2. ATMOS_SCHEMAS_ATMOS_MANIFEST env var\n"+
"3. --schemas-atmos-manifest flag\n\n"+
"Accepts: absolute path, paths relative to base_path, or URL",
cliConfig.Schemas.Atmos.Manifest)
}

// Include (process and validate) all YAML files in the `stacks` folder in all subfolders
includedPaths := []string{"**/*"}
// Don't exclude any YAML files for validation
Expand Down
2 changes: 1 addition & 1 deletion internal/exec/vendor_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func ExecuteVendorPullCommand(cmd *cobra.Command, args []string) error {

// Check `vendor.yaml`
vendorConfig, vendorConfigExists, foundVendorConfigFile, err := ReadAndProcessVendorConfigFile(cliConfig, cfg.AtmosVendorConfigFileName)
if err != nil {
if vendorConfigExists && err != nil {
Cerebrovinny marked this conversation as resolved.
Show resolved Hide resolved
return err
}

Expand Down