From ce9ce9513ae3d926571bcb8a3abc9577771ade40 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 15:43:26 -0600 Subject: [PATCH 01/13] Revert "Replace path.Join with filepath.Join (#856)" This reverts commit 2051592cf9615ebe333a0fd01468d39c8e77de3c. --- cmd/cmd_utils.go | 3 +- cmd/docs.go | 6 +- .../exec/atlantis_generate_repo_config.go | 3 +- internal/exec/aws_eks_update_kubeconfig.go | 6 +- internal/exec/describe_affected_utils.go | 16 ++--- internal/exec/helmfile.go | 10 +-- internal/exec/oci_utils.go | 6 +- internal/exec/stack_processor_utils.go | 8 +-- internal/exec/stack_utils.go | 6 +- internal/exec/terraform_generate_backend.go | 4 +- internal/exec/terraform_generate_backends.go | 5 +- internal/exec/terraform_generate_varfiles.go | 3 +- internal/exec/terraform_utils.go | 5 +- internal/exec/validate_component.go | 8 +-- internal/exec/validate_stacks.go | 8 +-- internal/exec/vendor_component_utils.go | 5 +- internal/exec/vendor_utils.go | 3 +- internal/exec/workflow.go | 3 +- internal/exec/workflow_utils.go | 7 +- pkg/config/config.go | 17 ++--- .../terraform_generate_varfiles_test.go | 4 +- pkg/utils/file_utils.go | 4 +- pkg/utils/glob_utils.go | 4 +- pkg/vender/component_vendor_test.go | 68 +++++++++---------- pkg/vender/vendor_config_test.go | 12 ++-- 25 files changed, 117 insertions(+), 107 deletions(-) diff --git a/cmd/cmd_utils.go b/cmd/cmd_utils.go index 266cbb808..c61fa4404 100644 --- a/cmd/cmd_utils.go +++ b/cmd/cmd_utils.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "os" + "path" "path/filepath" "strings" "time" @@ -404,7 +405,7 @@ func printMessageForMissingAtmosConfig(atmosConfig schema.AtmosConfiguration) { u.PrintMessageInColor("atmos.yaml", c1) fmt.Println(" CLI config file was not found.") fmt.Print("\nThe default Atmos stacks directory is set to ") - u.PrintMessageInColor(filepath.Join(atmosConfig.BasePath, atmosConfig.Stacks.BasePath), c1) + u.PrintMessageInColor(path.Join(atmosConfig.BasePath, atmosConfig.Stacks.BasePath), c1) fmt.Println(",\nbut the directory does not exist in the current path.") } else { // If Atmos found an `atmos.yaml` config file, but it defines invalid paths to Atmos stacks and components diff --git a/cmd/docs.go b/cmd/docs.go index 650a74d25..03873e9f8 100644 --- a/cmd/docs.go +++ b/cmd/docs.go @@ -4,7 +4,7 @@ import ( "fmt" "os" "os/exec" - "path/filepath" + "path" "runtime" "github.com/charmbracelet/glamour" @@ -59,7 +59,7 @@ var docsCmd = &cobra.Command{ } // Construct the full path to the Terraform component by combining the Atmos base path, Terraform base path, and component name - componentPath := filepath.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, info.Component) + componentPath := path.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, info.Component) componentPathExists, err := u.IsDirectory(componentPath) if err != nil { u.LogErrorAndExit(schema.AtmosConfiguration{}, err) @@ -68,7 +68,7 @@ var docsCmd = &cobra.Command{ u.LogErrorAndExit(schema.AtmosConfiguration{}, fmt.Errorf("Component '%s' not found in path: '%s'", info.Component, componentPath)) } - readmePath := filepath.Join(componentPath, "README.md") + readmePath := path.Join(componentPath, "README.md") if _, err := os.Stat(readmePath); err != nil { if os.IsNotExist(err) { u.LogErrorAndExit(schema.AtmosConfiguration{}, fmt.Errorf("No README found for component: %s", info.Component)) diff --git a/internal/exec/atlantis_generate_repo_config.go b/internal/exec/atlantis_generate_repo_config.go index d833740e9..8eaa8775a 100644 --- a/internal/exec/atlantis_generate_repo_config.go +++ b/internal/exec/atlantis_generate_repo_config.go @@ -2,6 +2,7 @@ package exec import ( "fmt" + "path" "path/filepath" "reflect" "strings" @@ -338,7 +339,7 @@ func ExecuteAtlantisGenerateRepoConfig( } // Absolute path to the terraform component - terraformComponentPath := filepath.Join( + terraformComponentPath := path.Join( atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, terraformComponent, diff --git a/internal/exec/aws_eks_update_kubeconfig.go b/internal/exec/aws_eks_update_kubeconfig.go index eae912ac3..9d269e1d1 100644 --- a/internal/exec/aws_eks_update_kubeconfig.go +++ b/internal/exec/aws_eks_update_kubeconfig.go @@ -2,7 +2,7 @@ package exec import ( "fmt" - "path/filepath" + "path" "strings" "github.com/pkg/errors" @@ -158,11 +158,11 @@ func ExecuteAwsEksUpdateKubeconfig(kubeconfigContext schema.AwsEksUpdateKubeconf configAndStacksInfo.ComponentType = "terraform" configAndStacksInfo, err = ProcessStacks(atmosConfig, configAndStacksInfo, true, true) - shellCommandWorkingDir = filepath.Join(atmosConfig.TerraformDirAbsolutePath, configAndStacksInfo.ComponentFolderPrefix, configAndStacksInfo.FinalComponent) + shellCommandWorkingDir = path.Join(atmosConfig.TerraformDirAbsolutePath, configAndStacksInfo.ComponentFolderPrefix, configAndStacksInfo.FinalComponent) if err != nil { configAndStacksInfo.ComponentType = "helmfile" configAndStacksInfo, err = ProcessStacks(atmosConfig, configAndStacksInfo, true, true) - shellCommandWorkingDir = filepath.Join(atmosConfig.HelmfileDirAbsolutePath, configAndStacksInfo.ComponentFolderPrefix, configAndStacksInfo.FinalComponent) + shellCommandWorkingDir = path.Join(atmosConfig.HelmfileDirAbsolutePath, configAndStacksInfo.ComponentFolderPrefix, configAndStacksInfo.FinalComponent) if err != nil { return err } diff --git a/internal/exec/describe_affected_utils.go b/internal/exec/describe_affected_utils.go index 98c982604..32707f599 100644 --- a/internal/exec/describe_affected_utils.go +++ b/internal/exec/describe_affected_utils.go @@ -432,13 +432,13 @@ func executeDescribeAffected( } // Update paths to point to the cloned remote repo dir - atmosConfig.StacksBaseAbsolutePath = filepath.Join(remoteRepoFileSystemPath, basePath, atmosConfig.Stacks.BasePath) - atmosConfig.TerraformDirAbsolutePath = filepath.Join(remoteRepoFileSystemPath, basePath, atmosConfig.Components.Terraform.BasePath) - atmosConfig.HelmfileDirAbsolutePath = filepath.Join(remoteRepoFileSystemPath, basePath, atmosConfig.Components.Helmfile.BasePath) + atmosConfig.StacksBaseAbsolutePath = path.Join(remoteRepoFileSystemPath, basePath, atmosConfig.Stacks.BasePath) + atmosConfig.TerraformDirAbsolutePath = path.Join(remoteRepoFileSystemPath, basePath, atmosConfig.Components.Terraform.BasePath) + atmosConfig.HelmfileDirAbsolutePath = path.Join(remoteRepoFileSystemPath, basePath, atmosConfig.Components.Helmfile.BasePath) atmosConfig.StackConfigFilesAbsolutePaths, err = u.JoinAbsolutePathWithPaths( filepath.Join(remoteRepoFileSystemPath, basePath, atmosConfig.Stacks.BasePath), - atmosConfig.StackConfigFilesRelativePaths, + cliConfig.StackConfigFilesRelativePaths, ) if err != nil { return nil, nil, nil, err @@ -1182,9 +1182,9 @@ func isComponentFolderChanged( switch componentType { case "terraform": - componentPath = filepath.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, component) + componentPath = path.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, component) case "helmfile": - componentPath = filepath.Join(atmosConfig.BasePath, atmosConfig.Components.Helmfile.BasePath, component) + componentPath = path.Join(atmosConfig.BasePath, atmosConfig.Components.Helmfile.BasePath, component) } componentPathAbs, err := filepath.Abs(componentPath) @@ -1220,7 +1220,7 @@ func areTerraformComponentModulesChanged( changedFiles []string, ) (bool, error) { - componentPath := filepath.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, component) + componentPath := path.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, component) componentPathAbs, err := filepath.Abs(componentPath) if err != nil { @@ -1241,7 +1241,7 @@ func areTerraformComponentModulesChanged( continue } - modulePath := filepath.Join(path.Dir(moduleConfig.Pos.Filename), moduleConfig.Source) + modulePath := path.Join(path.Dir(moduleConfig.Pos.Filename), moduleConfig.Source) modulePathAbs, err := filepath.Abs(modulePath) if err != nil { diff --git a/internal/exec/helmfile.go b/internal/exec/helmfile.go index 5aeb56361..20c5a8f2a 100644 --- a/internal/exec/helmfile.go +++ b/internal/exec/helmfile.go @@ -5,7 +5,7 @@ package exec import ( "fmt" "os" - "path/filepath" + "path" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -78,20 +78,20 @@ func ExecuteHelmfile(info schema.ConfigAndStacksInfo) error { } // Check if the component exists as a helmfile component - componentPath := filepath.Join(atmosConfig.HelmfileDirAbsolutePath, info.ComponentFolderPrefix, info.FinalComponent) + componentPath := path.Join(atmosConfig.HelmfileDirAbsolutePath, info.ComponentFolderPrefix, info.FinalComponent) componentPathExists, err := u.IsDirectory(componentPath) if err != nil || !componentPathExists { return fmt.Errorf("'%s' points to the Helmfile component '%s', but it does not exist in '%s'", info.ComponentFromArg, info.FinalComponent, - filepath.Join(atmosConfig.Components.Helmfile.BasePath, info.ComponentFolderPrefix), + path.Join(atmosConfig.Components.Helmfile.BasePath, info.ComponentFolderPrefix), ) } // Check if the component is allowed to be provisioned (`metadata.type` attribute) if (info.SubCommand == "sync" || info.SubCommand == "apply" || info.SubCommand == "deploy") && info.ComponentIsAbstract { return fmt.Errorf("abstract component '%s' cannot be provisioned since it's explicitly prohibited from being deployed "+ - "by 'metadata.type: abstract' attribute", filepath.Join(info.ComponentFolderPrefix, info.Component)) + "by 'metadata.type: abstract' attribute", path.Join(info.ComponentFolderPrefix, info.Component)) } // Print component variables @@ -196,7 +196,7 @@ func ExecuteHelmfile(info schema.ConfigAndStacksInfo) error { u.LogDebug(atmosConfig, "Stack: "+info.StackFromArg) } else { u.LogDebug(atmosConfig, "Stack: "+info.StackFromArg) - u.LogDebug(atmosConfig, "Stack path: "+filepath.Join(atmosConfig.BasePath, atmosConfig.Stacks.BasePath, info.Stack)) + u.LogDebug(atmosConfig, "Stack path: "+path.Join(cliConfig.BasePath, atmosConfig.Stacks.BasePath, info.Stack)) } workingDir := constructHelmfileComponentWorkingDir(atmosConfig, info) diff --git a/internal/exec/oci_utils.go b/internal/exec/oci_utils.go index 49b591658..84f4491e8 100644 --- a/internal/exec/oci_utils.go +++ b/internal/exec/oci_utils.go @@ -8,7 +8,7 @@ import ( "fmt" "io" "os" - "path/filepath" + "path" "github.com/google/go-containerregistry/pkg/name" "github.com/google/go-containerregistry/pkg/v1/remote" @@ -30,7 +30,7 @@ func processOciImage(atmosConfig schema.AtmosConfiguration, imageName string, de defer removeTempDir(atmosConfig, tempDir) // Temp tarball file name - tempTarFileName := filepath.Join(tempDir, uuid.New().String()) + ".tar" + tempTarFileName := path.Join(tempDir, uuid.New().String()) + ".tar" // Get the image reference from the OCI registry ref, err := name.ParseReference(imageName) @@ -91,7 +91,7 @@ func processOciImage(atmosConfig schema.AtmosConfiguration, imageName string, de // Extract the layers into the destination directory for _, l := range manifest.Layers { - layerPath := filepath.Join(tempDir, l) + layerPath := path.Join(tempDir, l) err = extractTarball(atmosConfig, layerPath, destDir) if err != nil { diff --git a/internal/exec/stack_processor_utils.go b/internal/exec/stack_processor_utils.go index ea35c1cd3..d2b9cd9ce 100644 --- a/internal/exec/stack_processor_utils.go +++ b/internal/exec/stack_processor_utils.go @@ -357,7 +357,7 @@ func ProcessYAMLConfigFile( found := false for _, extension := range extensions { - testPath := filepath.Join(basePath, imp+extension) + testPath := path.Join(basePath, imp+extension) if _, err := os.Stat(testPath); err == nil { impWithExt = imp + extension found = true @@ -372,12 +372,12 @@ func ProcessYAMLConfigFile( } else if ext == u.YamlFileExtension || ext == u.YmlFileExtension { // Check if there's a template version of this file templatePath := impWithExt + u.TemplateExtension - if _, err := os.Stat(filepath.Join(basePath, templatePath)); err == nil { + if _, err := os.Stat(path.Join(basePath, templatePath)); err == nil { impWithExt = templatePath } } - impWithExtPath := filepath.Join(basePath, impWithExt) + impWithExtPath := path.Join(basePath, impWithExt) if impWithExtPath == filePath { errorMessage := fmt.Sprintf("invalid import in the manifest '%s'\nThe file imports itself in '%s'", @@ -2180,7 +2180,7 @@ func ProcessBaseComponentConfig( if checkBaseComponentExists { // Check if the base component exists as Terraform/Helmfile component // If it does exist, don't throw errors if it is not defined in YAML config - componentPath := filepath.Join(componentBasePath, baseComponent) + componentPath := path.Join(componentBasePath, baseComponent) componentPathExists, err := u.IsDirectory(componentPath) if err != nil || !componentPathExists { return errors.New("The component '" + component + "' inherits from the base component '" + diff --git a/internal/exec/stack_utils.go b/internal/exec/stack_utils.go index 96fa24b9e..a4ff6d468 100644 --- a/internal/exec/stack_utils.go +++ b/internal/exec/stack_utils.go @@ -2,7 +2,7 @@ package exec import ( "fmt" - "path/filepath" + "path" "strings" cfg "github.com/cloudposse/atmos/pkg/config" @@ -164,9 +164,9 @@ func BuildComponentPath( if stackComponentSection, ok := componentSectionMap[cfg.ComponentSectionName].(string); ok { if componentType == "terraform" { - componentPath = filepath.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, stackComponentSection) + componentPath = path.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, stackComponentSection) } else if componentType == "helmfile" { - componentPath = filepath.Join(atmosConfig.BasePath, atmosConfig.Components.Helmfile.BasePath, stackComponentSection) + componentPath = path.Join(atmosConfig.BasePath, atmosConfig.Components.Helmfile.BasePath, stackComponentSection) } } diff --git a/internal/exec/terraform_generate_backend.go b/internal/exec/terraform_generate_backend.go index 632b8e508..5ebb95a82 100644 --- a/internal/exec/terraform_generate_backend.go +++ b/internal/exec/terraform_generate_backend.go @@ -2,7 +2,7 @@ package exec import ( "fmt" - "path/filepath" + "path" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -75,7 +75,7 @@ func ExecuteTerraformGenerateBackendCmd(cmd *cobra.Command, args []string) error } // Write backend config to file - var backendFilePath = filepath.Join( + var backendFilePath = path.Join( atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, info.ComponentFolderPrefix, diff --git a/internal/exec/terraform_generate_backends.go b/internal/exec/terraform_generate_backends.go index 9c2d32d58..7d821bb10 100644 --- a/internal/exec/terraform_generate_backends.go +++ b/internal/exec/terraform_generate_backends.go @@ -3,6 +3,7 @@ package exec import ( "errors" "fmt" + "path" "path/filepath" "strings" @@ -160,7 +161,7 @@ func ExecuteTerraformGenerateBackends( } // Path to the terraform component - terraformComponentPath := filepath.Join( + terraformComponentPath := path.Join( atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, terraformComponent, @@ -290,7 +291,7 @@ func ExecuteTerraformGenerateBackends( processedTerraformComponents[terraformComponent] = terraformComponent - backendFilePath = filepath.Join( + backendFilePath = path.Join( terraformComponentPath, "backend.tf", ) diff --git a/internal/exec/terraform_generate_varfiles.go b/internal/exec/terraform_generate_varfiles.go index 04ef9466f..3055369a3 100644 --- a/internal/exec/terraform_generate_varfiles.go +++ b/internal/exec/terraform_generate_varfiles.go @@ -3,6 +3,7 @@ package exec import ( "errors" "fmt" + "path" "path/filepath" "strings" @@ -159,7 +160,7 @@ func ExecuteTerraformGenerateVarfiles( } // Absolute path to the terraform component - terraformComponentPath := filepath.Join( + terraformComponentPath := path.Join( atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath, terraformComponent, diff --git a/internal/exec/terraform_utils.go b/internal/exec/terraform_utils.go index 03e5a656c..845ed0ea7 100644 --- a/internal/exec/terraform_utils.go +++ b/internal/exec/terraform_utils.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "os" + "path" "path/filepath" "time" @@ -87,7 +88,7 @@ func execTerraformOutput(atmosConfig schema.AtmosConfiguration, component string // Auto-generate backend file if atmosConfig.Components.Terraform.AutoGenerateBackendFile { - backendFileName := filepath.Join(componentPath, "backend.tf.json") + backendFileName := path.Join(componentPath, "backend.tf.json") u.LogTrace(atmosConfig, "\nWriting the backend config to file:") u.LogTrace(atmosConfig, backendFileName) @@ -120,7 +121,7 @@ func execTerraformOutput(atmosConfig schema.AtmosConfiguration, component string providersSection, ok := sections["providers"].(map[string]any) if ok && len(providersSection) > 0 { - providerOverrideFileName := filepath.Join(componentPath, "providers_override.tf.json") + providerOverrideFileName := path.Join(componentPath, "providers_override.tf.json") u.LogTrace(atmosConfig, "\nWriting the provider overrides to file:") u.LogTrace(atmosConfig, providerOverrideFileName) diff --git a/internal/exec/validate_component.go b/internal/exec/validate_component.go index 96875bc4c..56ce7cdfd 100644 --- a/internal/exec/validate_component.go +++ b/internal/exec/validate_component.go @@ -3,7 +3,7 @@ package exec import ( "fmt" "os" - "path/filepath" + "path" "github.com/mitchellh/mapstructure" "github.com/pkg/errors" @@ -197,11 +197,11 @@ func validateComponentInternal( switch schemaType { case "jsonschema": { - filePath = filepath.Join(atmosConfig.BasePath, atmosConfig.Schemas.JsonSchema.BasePath, schemaPath) + filePath = path.Join(atmosConfig.BasePath, atmosConfig.Schemas.JsonSchema.BasePath, schemaPath) } case "opa": { - filePath = filepath.Join(atmosConfig.BasePath, atmosConfig.Schemas.Opa.BasePath, schemaPath) + filePath = path.Join(atmosConfig.BasePath, atmosConfig.Schemas.Opa.BasePath, schemaPath) } } @@ -228,7 +228,7 @@ func validateComponentInternal( } case "opa": { - modulePathsAbsolute, err := u.JoinAbsolutePathWithPaths(filepath.Join(atmosConfig.BasePath, atmosConfig.Schemas.Opa.BasePath), modulePaths) + modulePathsAbsolute, err := u.JoinAbsolutePathWithPaths(path.Join(atmosConfig.BasePath, atmosConfig.Schemas.Opa.BasePath), modulePaths) if err != nil { return false, err } diff --git a/internal/exec/validate_stacks.go b/internal/exec/validate_stacks.go index e272340e7..40de309dd 100644 --- a/internal/exec/validate_stacks.go +++ b/internal/exec/validate_stacks.go @@ -5,7 +5,7 @@ import ( "fmt" "net/url" "os" - "path/filepath" + "path" "reflect" "strings" "time" @@ -91,7 +91,7 @@ func ValidateStacks(atmosConfig schema.AtmosConfiguration) error { u.LogTrace(atmosConfig, fmt.Sprintf("The Atmos JSON Schema file is not configured. Using the default schema '%s'", atmosManifestDefault)) } - atmosManifestJsonSchemaFileAbsPath := filepath.Join(atmosConfig.BasePath, atmosConfig.Schemas.Atmos.Manifest) + atmosManifestJsonSchemaFileAbsPath := path.Join(atmosConfig.BasePath, atmosConfig.Schemas.Atmos.Manifest) if u.FileExists(atmosConfig.Schemas.Atmos.Manifest) { atmosManifestJsonSchemaFilePath = atmosConfig.Schemas.Atmos.Manifest @@ -131,7 +131,7 @@ func ValidateStacks(atmosConfig schema.AtmosConfiguration) error { } u.LogDebug(atmosConfig, fmt.Sprintf("Validating all YAML files in the '%s' folder and all subfolders (excluding template files)\n", - filepath.Join(atmosConfig.BasePath, atmosConfig.Stacks.BasePath))) + path.Join(atmosConfig.BasePath, atmosConfig.Stacks.BasePath))) for _, filePath := range stackConfigFilesAbsolutePaths { stackConfig, importsConfig, _, _, _, err := ProcessYAMLConfigFile( @@ -376,7 +376,7 @@ func downloadSchemaFromURL(manifestURL string) (string, error) { if err != nil || fileName == "" { return "", fmt.Errorf("failed to get the file name from the URL '%s': %w", manifestURL, err) } - atmosManifestJsonSchemaFilePath := filepath.Join(tempDir, fileName) + atmosManifestJsonSchemaFilePath := path.Join(tempDir, fileName) ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() client := &getter.Client{ diff --git a/internal/exec/vendor_component_utils.go b/internal/exec/vendor_component_utils.go index a3370eeb1..419617e59 100644 --- a/internal/exec/vendor_component_utils.go +++ b/internal/exec/vendor_component_utils.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "os" + "path" "path/filepath" "strings" "text/template" @@ -25,7 +26,7 @@ func findComponentConfigFile(basePath, fileName string) (string, error) { componentConfigExtensions := []string{"yaml", "yml"} for _, ext := range componentConfigExtensions { - configFilePath := filepath.Join(basePath, fmt.Sprintf("%s.%s", fileName, ext)) + configFilePath := path.Join(basePath, fmt.Sprintf("%s.%s", fileName, ext)) if u.FileExists(configFilePath) { return configFilePath, nil } @@ -50,7 +51,7 @@ func ReadAndProcessComponentVendorConfigFile( return componentConfig, "", fmt.Errorf("type '%s' is not supported. Valid types are 'terraform' and 'helmfile'", componentType) } - componentPath := filepath.Join(atmosConfig.BasePath, componentBasePath, component) + componentPath := path.Join(atmosConfig.BasePath, componentBasePath, component) dirExists, err := u.IsDirectory(componentPath) if err != nil { diff --git a/internal/exec/vendor_utils.go b/internal/exec/vendor_utils.go index eee8ab995..5ddda6d9f 100644 --- a/internal/exec/vendor_utils.go +++ b/internal/exec/vendor_utils.go @@ -3,6 +3,7 @@ package exec import ( "fmt" "os" + "path" "path/filepath" "sort" "strings" @@ -164,7 +165,7 @@ func ReadAndProcessVendorConfigFile( if !fileExists { // Look for the vendoring manifest in the directory pointed to by the `base_path` setting in `atmos.yaml` - pathToVendorConfig := filepath.Join(atmosConfig.BasePath, vendorConfigFile) + pathToVendorConfig := path.Join(atmosConfig.BasePath, vendorConfigFile) foundVendorConfigFile, fileExists = u.SearchConfigFile(pathToVendorConfig) if !fileExists { diff --git a/internal/exec/workflow.go b/internal/exec/workflow.go index ab901a729..461f156e0 100644 --- a/internal/exec/workflow.go +++ b/internal/exec/workflow.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "os" + "path" "path/filepath" "github.com/spf13/cobra" @@ -79,7 +80,7 @@ func ExecuteWorkflowCmd(cmd *cobra.Command, args []string) error { if u.IsPathAbsolute(workflowFile) { workflowPath = workflowFile } else { - workflowPath = filepath.Join(atmosConfig.BasePath, atmosConfig.Workflows.BasePath, workflowFile) + workflowPath = path.Join(atmosConfig.BasePath, atmosConfig.Workflows.BasePath, workflowFile) } // If the workflow file is specified without an extension, use the default extension diff --git a/internal/exec/workflow_utils.go b/internal/exec/workflow_utils.go index 06fdd53fa..4ffd08a80 100644 --- a/internal/exec/workflow_utils.go +++ b/internal/exec/workflow_utils.go @@ -3,6 +3,7 @@ package exec import ( "fmt" "os" + "path" "path/filepath" "sort" "strings" @@ -146,7 +147,7 @@ func ExecuteDescribeWorkflows( if u.IsPathAbsolute(atmosConfig.Workflows.BasePath) { workflowsDir = atmosConfig.Workflows.BasePath } else { - workflowsDir = filepath.Join(atmosConfig.BasePath, atmosConfig.Workflows.BasePath) + workflowsDir = path.Join(atmosConfig.BasePath, atmosConfig.Workflows.BasePath) } isDirectory, err := u.IsDirectory(workflowsDir) @@ -163,9 +164,9 @@ func ExecuteDescribeWorkflows( for _, f := range files { var workflowPath string if u.IsPathAbsolute(atmosConfig.Workflows.BasePath) { - workflowPath = filepath.Join(atmosConfig.Workflows.BasePath, f) + workflowPath = path.Join(atmosConfig.Workflows.BasePath, f) } else { - workflowPath = filepath.Join(atmosConfig.BasePath, atmosConfig.Workflows.BasePath, f) + workflowPath = path.Join(atmosConfig.BasePath, atmosConfig.Workflows.BasePath, f) } fileContent, err := os.ReadFile(workflowPath) diff --git a/pkg/config/config.go b/pkg/config/config.go index df60ff8d5..38420ef56 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "os" + "path" "path/filepath" "runtime" @@ -132,7 +133,7 @@ func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks } if len(configFilePath1) > 0 { - configFile1 := filepath.Join(configFilePath1, CliConfigFileName) + configFile1 := path.Join(configFilePath1, CliConfigFileName) found, err = processConfigFile(atmosConfig, configFile1, v) if err != nil { return atmosConfig, err @@ -147,7 +148,7 @@ func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks if err != nil { return atmosConfig, err } - configFile2 := filepath.Join(configFilePath2, ".atmos", CliConfigFileName) + configFile2 := path.Join(configFilePath2, ".atmos", CliConfigFileName) found, err = processConfigFile(atmosConfig, configFile2, v) if err != nil { return atmosConfig, err @@ -161,7 +162,7 @@ func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks if err != nil { return atmosConfig, err } - configFile3 := filepath.Join(configFilePath3, CliConfigFileName) + configFile3 := path.Join(configFilePath3, CliConfigFileName) found, err = processConfigFile(atmosConfig, configFile3, v) if err != nil { return atmosConfig, err @@ -174,7 +175,7 @@ func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks configFilePath4 := os.Getenv("ATMOS_CLI_CONFIG_PATH") if len(configFilePath4) > 0 { u.LogTrace(atmosConfig, fmt.Sprintf("Found ENV var ATMOS_CLI_CONFIG_PATH=%s", configFilePath4)) - configFile4 := filepath.Join(configFilePath4, CliConfigFileName) + configFile4 := path.Join(configFilePath4, CliConfigFileName) found, err = processConfigFile(atmosConfig, configFile4, v) if err != nil { return atmosConfig, err @@ -188,7 +189,7 @@ func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks if configAndStacksInfo.AtmosCliConfigPath != "" { configFilePath5 := configAndStacksInfo.AtmosCliConfigPath if len(configFilePath5) > 0 { - configFile5 := filepath.Join(configFilePath5, CliConfigFileName) + configFile5 := path.Join(configFilePath5, CliConfigFileName) found, err = processConfigFile(atmosConfig, configFile5, v) if err != nil { return atmosConfig, err @@ -270,7 +271,7 @@ func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks } // Convert stacks base path to absolute path - stacksBasePath := filepath.Join(atmosConfig.BasePath, atmosConfig.Stacks.BasePath) + stacksBasePath := path.Join(atmosConfig.BasePath, atmosConfig.Stacks.BasePath) stacksBaseAbsPath, err := filepath.Abs(stacksBasePath) if err != nil { return atmosConfig, err @@ -292,7 +293,7 @@ func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks atmosConfig.ExcludeStackAbsolutePaths = excludeStackAbsPaths // Convert terraform dir to absolute path - terraformBasePath := filepath.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath) + terraformBasePath := path.Join(atmosConfig.BasePath, atmosConfig.Components.Terraform.BasePath) terraformDirAbsPath, err := filepath.Abs(terraformBasePath) if err != nil { return atmosConfig, err @@ -300,7 +301,7 @@ func InitCliConfig(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks atmosConfig.TerraformDirAbsolutePath = terraformDirAbsPath // Convert helmfile dir to absolute path - helmfileBasePath := filepath.Join(atmosConfig.BasePath, atmosConfig.Components.Helmfile.BasePath) + helmfileBasePath := path.Join(atmosConfig.BasePath, atmosConfig.Components.Helmfile.BasePath) helmfileDirAbsPath, err := filepath.Abs(helmfileBasePath) if err != nil { return atmosConfig, err diff --git a/pkg/generate/terraform_generate_varfiles_test.go b/pkg/generate/terraform_generate_varfiles_test.go index eb61b5ce7..de3385901 100644 --- a/pkg/generate/terraform_generate_varfiles_test.go +++ b/pkg/generate/terraform_generate_varfiles_test.go @@ -2,7 +2,7 @@ package generate import ( "os" - "path/filepath" + "path" "strconv" "testing" "time" @@ -28,7 +28,7 @@ func TestTerraformGenerateVarfiles(t *testing.T) { var stacks []string var components []string - filePattern := filepath.Join(tempDir, "varfiles/{tenant}-{environment}-{stage}-{component}.tfvars") + filePattern := path.Join(tempDir, "varfiles/{tenant}-{environment}-{stage}-{component}.tfvars") format := "hcl" err = e.ExecuteTerraformGenerateVarfiles(atmosConfig, filePattern, format, stacks, components) diff --git a/pkg/utils/file_utils.go b/pkg/utils/file_utils.go index 9e2f3701a..ce1509fea 100644 --- a/pkg/utils/file_utils.go +++ b/pkg/utils/file_utils.go @@ -69,7 +69,7 @@ func JoinAbsolutePathWithPaths(basePath string, paths []string) ([]string, error res := []string{} for _, p := range paths { - res = append(res, filepath.Join(basePath, p)) + res = append(res, path.Join(basePath, p)) } return res, nil @@ -93,7 +93,7 @@ func JoinAbsolutePathWithPath(basePath string, providedPath string) (string, err } // Join the base path with the provided path - joinedPath := filepath.Join(basePath, providedPath) + joinedPath := path.Join(basePath, providedPath) // If the joined path is an absolute path and exists in the file system, return it if filepath.IsAbs(joinedPath) { diff --git a/pkg/utils/glob_utils.go b/pkg/utils/glob_utils.go index 268473c53..335dfad92 100644 --- a/pkg/utils/glob_utils.go +++ b/pkg/utils/glob_utils.go @@ -3,7 +3,7 @@ package utils import ( "fmt" "os" - "path/filepath" + "path" "strings" "sync" @@ -36,7 +36,7 @@ func GetGlobMatches(pattern string) ([]string, error) { var fullMatches []string for _, match := range matches { - fullMatches = append(fullMatches, filepath.Join(base, match)) + fullMatches = append(fullMatches, path.Join(base, match)) } getGlobMatchesSyncMap.Store(pattern, strings.Join(fullMatches, ",")) diff --git a/pkg/vender/component_vendor_test.go b/pkg/vender/component_vendor_test.go index 59a61b6a1..9e54d537c 100644 --- a/pkg/vender/component_vendor_test.go +++ b/pkg/vender/component_vendor_test.go @@ -2,7 +2,7 @@ package vender import ( "os" - "path/filepath" + "path" "testing" "github.com/stretchr/testify/assert" @@ -29,12 +29,12 @@ func TestVendorComponentPullCommand(t *testing.T) { assert.Nil(t, err) // Check if the correct files were pulled and written to the correct folder - assert.FileExists(t, filepath.Join(componentPath, "context.tf")) - assert.FileExists(t, filepath.Join(componentPath, "main.tf")) - assert.FileExists(t, filepath.Join(componentPath, "outputs.tf")) - assert.FileExists(t, filepath.Join(componentPath, "providers.tf")) - assert.FileExists(t, filepath.Join(componentPath, "variables.tf")) - assert.FileExists(t, filepath.Join(componentPath, "versions.tf")) + assert.FileExists(t, path.Join(componentPath, "context.tf")) + assert.FileExists(t, path.Join(componentPath, "main.tf")) + assert.FileExists(t, path.Join(componentPath, "outputs.tf")) + assert.FileExists(t, path.Join(componentPath, "providers.tf")) + assert.FileExists(t, path.Join(componentPath, "variables.tf")) + assert.FileExists(t, path.Join(componentPath, "versions.tf")) // Test 'infra/account-map' component component = "infra/account-map" @@ -45,43 +45,43 @@ func TestVendorComponentPullCommand(t *testing.T) { assert.Nil(t, err) // Check if the correct files were pulled and written to the correct folder - assert.FileExists(t, filepath.Join(componentPath, "context.tf")) - assert.FileExists(t, filepath.Join(componentPath, "dynamic-roles.tf")) - assert.FileExists(t, filepath.Join(componentPath, "main.tf")) - assert.FileExists(t, filepath.Join(componentPath, "outputs.tf")) - assert.FileExists(t, filepath.Join(componentPath, "providers.tf")) - assert.FileExists(t, filepath.Join(componentPath, "README.md")) - assert.FileExists(t, filepath.Join(componentPath, "remote-state.tf")) - assert.FileExists(t, filepath.Join(componentPath, "variables.tf")) - assert.FileExists(t, filepath.Join(componentPath, "versions.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "context.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "main.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "outputs.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "variables.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "context.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "main.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "outputs.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "variables.tf")) + assert.FileExists(t, path.Join(componentPath, "context.tf")) + assert.FileExists(t, path.Join(componentPath, "dynamic-roles.tf")) + assert.FileExists(t, path.Join(componentPath, "main.tf")) + assert.FileExists(t, path.Join(componentPath, "outputs.tf")) + assert.FileExists(t, path.Join(componentPath, "providers.tf")) + assert.FileExists(t, path.Join(componentPath, "README.md")) + assert.FileExists(t, path.Join(componentPath, "remote-state.tf")) + assert.FileExists(t, path.Join(componentPath, "variables.tf")) + assert.FileExists(t, path.Join(componentPath, "versions.tf")) + assert.FileExists(t, path.Join(componentPath, "modules", "iam-roles", "context.tf")) + assert.FileExists(t, path.Join(componentPath, "modules", "iam-roles", "main.tf")) + assert.FileExists(t, path.Join(componentPath, "modules", "iam-roles", "outputs.tf")) + assert.FileExists(t, path.Join(componentPath, "modules", "iam-roles", "variables.tf")) + assert.FileExists(t, path.Join(componentPath, "modules", "roles-to-principals", "context.tf")) + assert.FileExists(t, path.Join(componentPath, "modules", "roles-to-principals", "main.tf")) + assert.FileExists(t, path.Join(componentPath, "modules", "roles-to-principals", "outputs.tf")) + assert.FileExists(t, path.Join(componentPath, "modules", "roles-to-principals", "variables.tf")) // Delete the files and folders - err = os.Remove(filepath.Join(componentPath, "context.tf")) + err = os.Remove(path.Join(componentPath, "context.tf")) assert.Nil(t, err) - err = os.Remove(filepath.Join(componentPath, "dynamic-roles.tf")) + err = os.Remove(path.Join(componentPath, "dynamic-roles.tf")) assert.Nil(t, err) - err = os.Remove(filepath.Join(componentPath, "main.tf")) + err = os.Remove(path.Join(componentPath, "main.tf")) assert.Nil(t, err) - err = os.Remove(filepath.Join(componentPath, "outputs.tf")) + err = os.Remove(path.Join(componentPath, "outputs.tf")) assert.Nil(t, err) - err = os.Remove(filepath.Join(componentPath, "providers.tf")) + err = os.Remove(path.Join(componentPath, "providers.tf")) assert.Nil(t, err) - err = os.Remove(filepath.Join(componentPath, "README.md")) + err = os.Remove(path.Join(componentPath, "README.md")) assert.Nil(t, err) - err = os.Remove(filepath.Join(componentPath, "remote-state.tf")) + err = os.Remove(path.Join(componentPath, "remote-state.tf")) assert.Nil(t, err) - err = os.Remove(filepath.Join(componentPath, "variables.tf")) + err = os.Remove(path.Join(componentPath, "variables.tf")) assert.Nil(t, err) - err = os.Remove(filepath.Join(componentPath, "versions.tf")) + err = os.Remove(path.Join(componentPath, "versions.tf")) assert.Nil(t, err) - err = os.RemoveAll(filepath.Join(componentPath, "modules")) + err = os.RemoveAll(path.Join(componentPath, "modules")) assert.Nil(t, err) } diff --git a/pkg/vender/vendor_config_test.go b/pkg/vender/vendor_config_test.go index f310221be..84af2ad6f 100644 --- a/pkg/vender/vendor_config_test.go +++ b/pkg/vender/vendor_config_test.go @@ -4,7 +4,7 @@ package vender import ( "os" - "path/filepath" + "path" "testing" "github.com/stretchr/testify/assert" @@ -28,7 +28,7 @@ func TestVendorConfigScenarios(t *testing.T) { atmosConfig.Logs.Level = "Trace" // Setup test component directory - componentPath := filepath.Join(testDir, "components", "terraform", "myapp") + componentPath := path.Join(testDir, "components", "terraform", "myapp") err := os.MkdirAll(componentPath, 0755) assert.Nil(t, err) @@ -47,7 +47,7 @@ spec: included_paths: - "**/*.tf" ` - vendorYamlPath := filepath.Join(testDir, "vendor.yaml") + vendorYamlPath := path.Join(testDir, "vendor.yaml") err := os.WriteFile(vendorYamlPath, []byte(vendorYaml), 0644) assert.Nil(t, err) @@ -84,7 +84,7 @@ spec: uri: github.com/cloudposse/terraform-null-label.git//exports?ref={{.Version}} version: 0.25.0 ` - componentYamlPath := filepath.Join(componentPath, "component.yaml") + componentYamlPath := path.Join(componentPath, "component.yaml") err := os.WriteFile(componentYamlPath, []byte(componentYaml), 0644) assert.Nil(t, err) @@ -102,7 +102,7 @@ spec: // Test Case 3: Neither vendor.yaml nor component.yaml exists t.Run("no vendor.yaml or component.yaml", func(t *testing.T) { // Test vendoring with component flag - vendorYamlPath := filepath.Join(testDir, "vendor.yaml") + vendorYamlPath := path.Join(testDir, "vendor.yaml") _, exists, _, err := e.ReadAndProcessVendorConfigFile(atmosConfig, vendorYamlPath, true) assert.Nil(t, err) assert.False(t, exists) @@ -126,7 +126,7 @@ spec: source: github.com/cloudposse/terraform-null-label.git//exports?ref={{.Version}} version: 0.25.0 ` - vendorYamlPath := filepath.Join(testDir, "vendor.yaml") + vendorYamlPath := path.Join(testDir, "vendor.yaml") err := os.WriteFile(vendorYamlPath, []byte(vendorYaml), 0644) assert.Nil(t, err) From 0c56cbc85c676ac1cba7d18961fc318f69466c53 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 15:46:09 -0600 Subject: [PATCH 02/13] fix some missing atmosConfig changes --- internal/exec/describe_affected_utils.go | 2 +- internal/exec/helmfile.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/exec/describe_affected_utils.go b/internal/exec/describe_affected_utils.go index 32707f599..643e324b6 100644 --- a/internal/exec/describe_affected_utils.go +++ b/internal/exec/describe_affected_utils.go @@ -438,7 +438,7 @@ func executeDescribeAffected( atmosConfig.StackConfigFilesAbsolutePaths, err = u.JoinAbsolutePathWithPaths( filepath.Join(remoteRepoFileSystemPath, basePath, atmosConfig.Stacks.BasePath), - cliConfig.StackConfigFilesRelativePaths, + atmosConfig.StackConfigFilesRelativePaths, ) if err != nil { return nil, nil, nil, err diff --git a/internal/exec/helmfile.go b/internal/exec/helmfile.go index 20c5a8f2a..9d8639421 100644 --- a/internal/exec/helmfile.go +++ b/internal/exec/helmfile.go @@ -196,7 +196,7 @@ func ExecuteHelmfile(info schema.ConfigAndStacksInfo) error { u.LogDebug(atmosConfig, "Stack: "+info.StackFromArg) } else { u.LogDebug(atmosConfig, "Stack: "+info.StackFromArg) - u.LogDebug(atmosConfig, "Stack path: "+path.Join(cliConfig.BasePath, atmosConfig.Stacks.BasePath, info.Stack)) + u.LogDebug(atmosConfig, "Stack path: "+path.Join(atmosConfig.BasePath, atmosConfig.Stacks.BasePath, info.Stack)) } workingDir := constructHelmfileComponentWorkingDir(atmosConfig, info) From 6b3b9469fd780b8a749168b08cb85f9078d7de0d Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 16:12:19 -0600 Subject: [PATCH 03/13] get a go test report --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3c589351e..081b105b0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -142,8 +142,7 @@ jobs: - name: Acceptance tests timeout-minutes: 10 - run: | - make testacc + uses: robherley/go-test-action@v0 docker: name: "Docker Lint" From b6e0a54e5fcdb004ce98a4898977c9aa8a456647 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 16:21:41 -0600 Subject: [PATCH 04/13] attempt to fix vendor errors --- pkg/logger/logger_test.go | 11 ++-- pkg/vender/component_vendor_test.go | 79 +++++++++++++---------------- 2 files changed, 42 insertions(+), 48 deletions(-) diff --git a/pkg/logger/logger_test.go b/pkg/logger/logger_test.go index f6dccd5b0..a6dba2e49 100644 --- a/pkg/logger/logger_test.go +++ b/pkg/logger/logger_test.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "os" + "path/filepath" "testing" "github.com/fatih/color" @@ -147,13 +148,15 @@ func TestLogger_Error(t *testing.T) { } func TestLogger_FileLogging(t *testing.T) { - tempFile := "/tmp/test.log" - defer os.Remove(tempFile) + tempDir := os.TempDir() + logFile := filepath.Join(tempDir, "test.log") - logger, _ := NewLogger(LogLevelInfo, tempFile) + defer os.Remove(logFile) + + logger, _ := NewLogger(LogLevelInfo, logFile) logger.Info("File logging test") - data, err := os.ReadFile(tempFile) + data, err := os.ReadFile(logFile) assert.NoError(t, err) assert.Contains(t, string(data), "File logging test") } diff --git a/pkg/vender/component_vendor_test.go b/pkg/vender/component_vendor_test.go index 9e54d537c..1fec94ec6 100644 --- a/pkg/vender/component_vendor_test.go +++ b/pkg/vender/component_vendor_test.go @@ -2,7 +2,7 @@ package vender import ( "os" - "path" + "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -13,6 +13,7 @@ import ( ) func TestVendorComponentPullCommand(t *testing.T) { + // Initialize the CLI configuration atmosConfig, err := cfg.InitCliConfig(schema.ConfigAndStacksInfo{}, true) assert.Nil(t, err) @@ -29,12 +30,12 @@ func TestVendorComponentPullCommand(t *testing.T) { assert.Nil(t, err) // Check if the correct files were pulled and written to the correct folder - assert.FileExists(t, path.Join(componentPath, "context.tf")) - assert.FileExists(t, path.Join(componentPath, "main.tf")) - assert.FileExists(t, path.Join(componentPath, "outputs.tf")) - assert.FileExists(t, path.Join(componentPath, "providers.tf")) - assert.FileExists(t, path.Join(componentPath, "variables.tf")) - assert.FileExists(t, path.Join(componentPath, "versions.tf")) + assert.FileExists(t, filepath.Join(componentPath, "context.tf")) + assert.FileExists(t, filepath.Join(componentPath, "main.tf")) + assert.FileExists(t, filepath.Join(componentPath, "outputs.tf")) + assert.FileExists(t, filepath.Join(componentPath, "providers.tf")) + assert.FileExists(t, filepath.Join(componentPath, "variables.tf")) + assert.FileExists(t, filepath.Join(componentPath, "versions.tf")) // Test 'infra/account-map' component component = "infra/account-map" @@ -45,43 +46,33 @@ func TestVendorComponentPullCommand(t *testing.T) { assert.Nil(t, err) // Check if the correct files were pulled and written to the correct folder - assert.FileExists(t, path.Join(componentPath, "context.tf")) - assert.FileExists(t, path.Join(componentPath, "dynamic-roles.tf")) - assert.FileExists(t, path.Join(componentPath, "main.tf")) - assert.FileExists(t, path.Join(componentPath, "outputs.tf")) - assert.FileExists(t, path.Join(componentPath, "providers.tf")) - assert.FileExists(t, path.Join(componentPath, "README.md")) - assert.FileExists(t, path.Join(componentPath, "remote-state.tf")) - assert.FileExists(t, path.Join(componentPath, "variables.tf")) - assert.FileExists(t, path.Join(componentPath, "versions.tf")) - assert.FileExists(t, path.Join(componentPath, "modules", "iam-roles", "context.tf")) - assert.FileExists(t, path.Join(componentPath, "modules", "iam-roles", "main.tf")) - assert.FileExists(t, path.Join(componentPath, "modules", "iam-roles", "outputs.tf")) - assert.FileExists(t, path.Join(componentPath, "modules", "iam-roles", "variables.tf")) - assert.FileExists(t, path.Join(componentPath, "modules", "roles-to-principals", "context.tf")) - assert.FileExists(t, path.Join(componentPath, "modules", "roles-to-principals", "main.tf")) - assert.FileExists(t, path.Join(componentPath, "modules", "roles-to-principals", "outputs.tf")) - assert.FileExists(t, path.Join(componentPath, "modules", "roles-to-principals", "variables.tf")) + assert.FileExists(t, filepath.Join(componentPath, "context.tf")) + assert.FileExists(t, filepath.Join(componentPath, "dynamic-roles.tf")) + assert.FileExists(t, filepath.Join(componentPath, "main.tf")) + assert.FileExists(t, filepath.Join(componentPath, "outputs.tf")) + assert.FileExists(t, filepath.Join(componentPath, "providers.tf")) + assert.FileExists(t, filepath.Join(componentPath, "README.md")) + assert.FileExists(t, filepath.Join(componentPath, "remote-state.tf")) + assert.FileExists(t, filepath.Join(componentPath, "variables.tf")) + assert.FileExists(t, filepath.Join(componentPath, "versions.tf")) + assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "context.tf")) + assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "main.tf")) + assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "outputs.tf")) + assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "variables.tf")) + assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "context.tf")) + assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "main.tf")) + assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "outputs.tf")) + assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "variables.tf")) // Delete the files and folders - err = os.Remove(path.Join(componentPath, "context.tf")) - assert.Nil(t, err) - err = os.Remove(path.Join(componentPath, "dynamic-roles.tf")) - assert.Nil(t, err) - err = os.Remove(path.Join(componentPath, "main.tf")) - assert.Nil(t, err) - err = os.Remove(path.Join(componentPath, "outputs.tf")) - assert.Nil(t, err) - err = os.Remove(path.Join(componentPath, "providers.tf")) - assert.Nil(t, err) - err = os.Remove(path.Join(componentPath, "README.md")) - assert.Nil(t, err) - err = os.Remove(path.Join(componentPath, "remote-state.tf")) - assert.Nil(t, err) - err = os.Remove(path.Join(componentPath, "variables.tf")) - assert.Nil(t, err) - err = os.Remove(path.Join(componentPath, "versions.tf")) - assert.Nil(t, err) - err = os.RemoveAll(path.Join(componentPath, "modules")) - assert.Nil(t, err) + assert.Nil(t, os.Remove(filepath.Join(componentPath, "context.tf"))) + assert.Nil(t, os.Remove(filepath.Join(componentPath, "dynamic-roles.tf"))) + assert.Nil(t, os.Remove(filepath.Join(componentPath, "main.tf"))) + assert.Nil(t, os.Remove(filepath.Join(componentPath, "outputs.tf"))) + assert.Nil(t, os.Remove(filepath.Join(componentPath, "providers.tf"))) + assert.Nil(t, os.Remove(filepath.Join(componentPath, "README.md"))) + assert.Nil(t, os.Remove(filepath.Join(componentPath, "remote-state.tf"))) + assert.Nil(t, os.Remove(filepath.Join(componentPath, "variables.tf"))) + assert.Nil(t, os.Remove(filepath.Join(componentPath, "versions.tf"))) + assert.Nil(t, os.RemoveAll(filepath.Join(componentPath, "modules"))) } From 1bceaa9e4013e0fbb8bea9273ebd432d317ba36c Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 16:33:40 -0600 Subject: [PATCH 05/13] revert to makefile as output is too large for summary --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 081b105b0..04bad3a7d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -142,7 +142,7 @@ jobs: - name: Acceptance tests timeout-minutes: 10 - uses: robherley/go-test-action@v0 + run: make testacc docker: name: "Docker Lint" From ac1a50404998ae541368e056aceeefd7bc18a10d Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 16:49:53 -0600 Subject: [PATCH 06/13] try to fix vendor test for windows --- pkg/vender/component_vendor_test.go | 74 ++++++++++++++++------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/pkg/vender/component_vendor_test.go b/pkg/vender/component_vendor_test.go index 1fec94ec6..f35718e7b 100644 --- a/pkg/vender/component_vendor_test.go +++ b/pkg/vender/component_vendor_test.go @@ -21,58 +21,64 @@ func TestVendorComponentPullCommand(t *testing.T) { componentType := "terraform" + // Helper function to ensure all paths are absolute + ensureAbsPath := func(path string) string { + absPath, err := filepath.Abs(path) + assert.Nil(t, err) + return absPath + } + // Test 'infra/vpc-flow-logs-bucket' component component := "infra/vpc-flow-logs-bucket" componentConfig, componentPath, err := e.ReadAndProcessComponentVendorConfigFile(atmosConfig, component, componentType) assert.Nil(t, err) + componentPath = ensureAbsPath(componentPath) + err = e.ExecuteComponentVendorInternal(atmosConfig, componentConfig.Spec, component, componentPath, false) assert.Nil(t, err) // Check if the correct files were pulled and written to the correct folder - assert.FileExists(t, filepath.Join(componentPath, "context.tf")) - assert.FileExists(t, filepath.Join(componentPath, "main.tf")) - assert.FileExists(t, filepath.Join(componentPath, "outputs.tf")) - assert.FileExists(t, filepath.Join(componentPath, "providers.tf")) - assert.FileExists(t, filepath.Join(componentPath, "variables.tf")) - assert.FileExists(t, filepath.Join(componentPath, "versions.tf")) + filesToCheck := []string{ + "context.tf", "main.tf", "outputs.tf", + "providers.tf", "variables.tf", "versions.tf", + } + + for _, file := range filesToCheck { + assert.FileExists(t, filepath.Join(componentPath, file)) + } // Test 'infra/account-map' component component = "infra/account-map" componentConfig, componentPath, err = e.ReadAndProcessComponentVendorConfigFile(atmosConfig, component, componentType) assert.Nil(t, err) + componentPath = ensureAbsPath(componentPath) + err = e.ExecuteComponentVendorInternal(atmosConfig, componentConfig.Spec, component, componentPath, false) assert.Nil(t, err) - // Check if the correct files were pulled and written to the correct folder - assert.FileExists(t, filepath.Join(componentPath, "context.tf")) - assert.FileExists(t, filepath.Join(componentPath, "dynamic-roles.tf")) - assert.FileExists(t, filepath.Join(componentPath, "main.tf")) - assert.FileExists(t, filepath.Join(componentPath, "outputs.tf")) - assert.FileExists(t, filepath.Join(componentPath, "providers.tf")) - assert.FileExists(t, filepath.Join(componentPath, "README.md")) - assert.FileExists(t, filepath.Join(componentPath, "remote-state.tf")) - assert.FileExists(t, filepath.Join(componentPath, "variables.tf")) - assert.FileExists(t, filepath.Join(componentPath, "versions.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "context.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "main.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "outputs.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "iam-roles", "variables.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "context.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "main.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "outputs.tf")) - assert.FileExists(t, filepath.Join(componentPath, "modules", "roles-to-principals", "variables.tf")) + // Additional files to check + filesToCheck = append(filesToCheck, + "dynamic-roles.tf", "README.md", "remote-state.tf", + "modules/iam-roles/context.tf", "modules/iam-roles/main.tf", + "modules/iam-roles/outputs.tf", "modules/iam-roles/variables.tf", + "modules/roles-to-principals/context.tf", "modules/roles-to-principals/main.tf", + "modules/roles-to-principals/outputs.tf", "modules/roles-to-principals/variables.tf", + ) + + for _, file := range filesToCheck { + assert.FileExists(t, filepath.Join(componentPath, file)) + } // Delete the files and folders - assert.Nil(t, os.Remove(filepath.Join(componentPath, "context.tf"))) - assert.Nil(t, os.Remove(filepath.Join(componentPath, "dynamic-roles.tf"))) - assert.Nil(t, os.Remove(filepath.Join(componentPath, "main.tf"))) - assert.Nil(t, os.Remove(filepath.Join(componentPath, "outputs.tf"))) - assert.Nil(t, os.Remove(filepath.Join(componentPath, "providers.tf"))) - assert.Nil(t, os.Remove(filepath.Join(componentPath, "README.md"))) - assert.Nil(t, os.Remove(filepath.Join(componentPath, "remote-state.tf"))) - assert.Nil(t, os.Remove(filepath.Join(componentPath, "variables.tf"))) - assert.Nil(t, os.Remove(filepath.Join(componentPath, "versions.tf"))) - assert.Nil(t, os.RemoveAll(filepath.Join(componentPath, "modules"))) + for _, file := range filesToCheck { + err := os.Remove(filepath.Join(componentPath, file)) + if err != nil && !os.IsNotExist(err) { + assert.Failf(t, "Failed to delete file", "Error: %v", err) + } + } + + err = os.RemoveAll(filepath.Join(componentPath, "modules")) + assert.Nil(t, err) } From 0ba32eab9626f9ec659b04e330551dacb7a0f99e Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 20:51:40 -0600 Subject: [PATCH 07/13] Try to sanitize filename on windows --- internal/exec/vendor_utils.go | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/internal/exec/vendor_utils.go b/internal/exec/vendor_utils.go index 5ddda6d9f..2e580cc33 100644 --- a/internal/exec/vendor_utils.go +++ b/internal/exec/vendor_utils.go @@ -5,6 +5,7 @@ import ( "os" "path" "path/filepath" + "runtime" "sort" "strings" @@ -514,6 +515,34 @@ func determineSourceType(uri *string, vendorConfigFilePath string) (bool, bool, return useOciScheme, useLocalFileSystem, sourceIsLocalFile } +// sanitizeFileName replaces invalid characters and query strings with underscores for Windows. +func sanitizeFileName(uri string) string { + // This logic applies only to Windows + if runtime.GOOS != "windows" { + return filepath.Base(uri) + } + + // Extract the path part (ignoring query strings) + if idx := strings.Index(uri, "?"); idx != -1 { + uri = strings.ReplaceAll(uri, "?", "_") + } + + // Extract the base name (last segment of the path) + base := filepath.Base(uri) + + // Replace invalid characters for Windows + base = strings.Map(func(r rune) rune { + switch r { + case '\\', '/', ':', '*', '?', '"', '<', '>', '|': + return '_' + default: + return r + } + }, base) + + return base +} + func copyToTarget(atmosConfig schema.AtmosConfiguration, tempDir, targetPath string, s *schema.AtmosVendorSource, sourceIsLocalFile bool, uri string) error { copyOptions := cp.Options{ Skip: generateSkipFunction(atmosConfig, tempDir, s), @@ -524,7 +553,9 @@ func copyToTarget(atmosConfig schema.AtmosConfiguration, tempDir, targetPath str // Adjust the target path if it's a local file with no extension if sourceIsLocalFile && filepath.Ext(targetPath) == "" { - targetPath = filepath.Join(targetPath, filepath.Base(uri)) + // Sanitize the URI for safe filenames, especially on Windows + sanitizedBase := sanitizeFileName(uri) + targetPath = filepath.Join(targetPath, sanitizedBase) } return cp.Copy(tempDir, targetPath, copyOptions) From bec23def1f7a0a85da1c23ba25adb257d542e1eb Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 21:12:59 -0600 Subject: [PATCH 08/13] sanitize filenames everywhere a URI is used to derive the filename --- internal/exec/vendor_component_utils.go | 2 +- internal/exec/vendor_model.go | 2 +- internal/exec/vendor_model_component.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/exec/vendor_component_utils.go b/internal/exec/vendor_component_utils.go index 419617e59..ad2f18e08 100644 --- a/internal/exec/vendor_component_utils.go +++ b/internal/exec/vendor_component_utils.go @@ -180,7 +180,7 @@ func copyComponentToDestination(atmosConfig schema.AtmosConfiguration, tempDir, componentPath2 := componentPath if sourceIsLocalFile { if filepath.Ext(componentPath) == "" { - componentPath2 = filepath.Join(componentPath, filepath.Base(uri)) + componentPath2 = filepath.Join(componentPath, sanitizeFileName(uri)) } } diff --git a/internal/exec/vendor_model.go b/internal/exec/vendor_model.go index 7171f73ec..1209e6805 100644 --- a/internal/exec/vendor_model.go +++ b/internal/exec/vendor_model.go @@ -298,7 +298,7 @@ func downloadAndInstall(p *pkgAtmosVendor, dryRun bool, atmosConfig schema.Atmos OnSymlink: func(src string) cp.SymlinkAction { return cp.Deep }, } if p.sourceIsLocalFile { - tempDir = filepath.Join(tempDir, filepath.Base(p.uri)) + tempDir = filepath.Join(tempDir, sanitizeFileName(p.uri)) } if err := cp.Copy(p.uri, tempDir, copyOptions); err != nil { return installedPkgMsg{ diff --git a/internal/exec/vendor_model_component.go b/internal/exec/vendor_model_component.go index 213140a64..38671b190 100644 --- a/internal/exec/vendor_model_component.go +++ b/internal/exec/vendor_model_component.go @@ -124,7 +124,7 @@ func installComponent(p *pkgComponentVendor, atmosConfig schema.AtmosConfigurati switch p.pkgType { case pkgTypeRemote: - tempDir = filepath.Join(tempDir, filepath.Base(p.uri)) + tempDir = filepath.Join(tempDir, sanitizeFileName(p.uri)) client := &getter.Client{ Ctx: context.Background(), @@ -159,7 +159,7 @@ func installComponent(p *pkgComponentVendor, atmosConfig schema.AtmosConfigurati tempDir2 := tempDir if p.sourceIsLocalFile { - tempDir2 = filepath.Join(tempDir, filepath.Base(p.uri)) + tempDir2 = filepath.Join(tempDir, sanitizeFileName(p.uri)) } if err = cp.Copy(p.uri, tempDir2, copyOptions); err != nil { From 157fe129dc4384fd76cab4d52167b21c4ecb4c83 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 21:28:29 -0600 Subject: [PATCH 09/13] drop query string --- internal/exec/vendor_utils.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/internal/exec/vendor_utils.go b/internal/exec/vendor_utils.go index 2e580cc33..95f7dcb0e 100644 --- a/internal/exec/vendor_utils.go +++ b/internal/exec/vendor_utils.go @@ -2,6 +2,7 @@ package exec import ( "fmt" + "net/url" "os" "path" "path/filepath" @@ -517,18 +518,21 @@ func determineSourceType(uri *string, vendorConfigFilePath string) (bool, bool, // sanitizeFileName replaces invalid characters and query strings with underscores for Windows. func sanitizeFileName(uri string) string { - // This logic applies only to Windows - if runtime.GOOS != "windows" { + + // Parse the URI to handle paths and query strings properly + parsed, err := url.Parse(uri) + if err != nil { + // Fallback to basic filepath.Base if URI parsing fails return filepath.Base(uri) } - // Extract the path part (ignoring query strings) - if idx := strings.Index(uri, "?"); idx != -1 { - uri = strings.ReplaceAll(uri, "?", "_") - } + // Extract the path component of the URI + base := filepath.Base(parsed.Path) - // Extract the base name (last segment of the path) - base := filepath.Base(uri) + // This logic applies only to Windows + if runtime.GOOS != "windows" { + return base + } // Replace invalid characters for Windows base = strings.Map(func(r rune) rune { From 235a2fdaf6e09dfb499ef3b233a3c4072ff108d4 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 21:42:21 -0600 Subject: [PATCH 10/13] try to fix globs --- pkg/utils/glob_utils.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/utils/glob_utils.go b/pkg/utils/glob_utils.go index 335dfad92..970b99129 100644 --- a/pkg/utils/glob_utils.go +++ b/pkg/utils/glob_utils.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path" + "path/filepath" "strings" "sync" @@ -22,7 +23,11 @@ func GetGlobMatches(pattern string) ([]string, error) { return strings.Split(existingMatches.(string), ","), nil } - base, cleanPattern := doublestar.SplitPattern(pattern) + // Convert the pattern to use / as the separator regardless of platform + allOsSafePattern := filepath.ToSlash(pattern) + + base, cleanPattern := doublestar.SplitPattern(allOsSafePattern) + f := os.DirFS(base) matches, err := doublestar.Glob(f, cleanPattern) From 1abd94744dd373c332b1ffcb1680f9bc979f62d3 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Mon, 23 Dec 2024 21:57:46 -0600 Subject: [PATCH 11/13] revert doublestar fix --- pkg/utils/glob_utils.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/utils/glob_utils.go b/pkg/utils/glob_utils.go index 970b99129..335dfad92 100644 --- a/pkg/utils/glob_utils.go +++ b/pkg/utils/glob_utils.go @@ -4,7 +4,6 @@ import ( "fmt" "os" "path" - "path/filepath" "strings" "sync" @@ -23,11 +22,7 @@ func GetGlobMatches(pattern string) ([]string, error) { return strings.Split(existingMatches.(string), ","), nil } - // Convert the pattern to use / as the separator regardless of platform - allOsSafePattern := filepath.ToSlash(pattern) - - base, cleanPattern := doublestar.SplitPattern(allOsSafePattern) - + base, cleanPattern := doublestar.SplitPattern(pattern) f := os.DirFS(base) matches, err := doublestar.Glob(f, cleanPattern) From adecd1005ea6ab11981c82d3eb5724933ce2da3a Mon Sep 17 00:00:00 2001 From: Haitham Rageh Date: Tue, 24 Dec 2024 21:03:00 +0200 Subject: [PATCH 12/13] fix vendor on windows --- internal/exec/vendor_component_utils.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/exec/vendor_component_utils.go b/internal/exec/vendor_component_utils.go index ad2f18e08..493bea958 100644 --- a/internal/exec/vendor_component_utils.go +++ b/internal/exec/vendor_component_utils.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "os" - "path" "path/filepath" "strings" "text/template" @@ -26,7 +25,7 @@ func findComponentConfigFile(basePath, fileName string) (string, error) { componentConfigExtensions := []string{"yaml", "yml"} for _, ext := range componentConfigExtensions { - configFilePath := path.Join(basePath, fmt.Sprintf("%s.%s", fileName, ext)) + configFilePath := filepath.Join(basePath, fmt.Sprintf("%s.%s", fileName, ext)) if u.FileExists(configFilePath) { return configFilePath, nil } @@ -51,7 +50,7 @@ func ReadAndProcessComponentVendorConfigFile( return componentConfig, "", fmt.Errorf("type '%s' is not supported. Valid types are 'terraform' and 'helmfile'", componentType) } - componentPath := path.Join(atmosConfig.BasePath, componentBasePath, component) + componentPath := filepath.Join(atmosConfig.BasePath, componentBasePath, component) dirExists, err := u.IsDirectory(componentPath) if err != nil { @@ -119,6 +118,7 @@ func copyComponentToDestination(atmosConfig schema.AtmosConfiguration, tempDir, // https://en.wikipedia.org/wiki/Glob_(programming) // https://github.com/bmatcuk/doublestar#patterns for _, excludePath := range vendorComponentSpec.Source.ExcludedPaths { + excludePath := filepath.Clean(excludePath) excludeMatch, err := u.PathMatch(excludePath, src) if err != nil { return true, err @@ -136,6 +136,7 @@ func copyComponentToDestination(atmosConfig schema.AtmosConfiguration, tempDir, if len(vendorComponentSpec.Source.IncludedPaths) > 0 { anyMatches := false for _, includePath := range vendorComponentSpec.Source.IncludedPaths { + includePath := filepath.Clean(includePath) includeMatch, err := u.PathMatch(includePath, src) if err != nil { return true, err From d3b699d5a845a0d790f2721d789d4e7577072e6a Mon Sep 17 00:00:00 2001 From: Haitham Rageh Date: Tue, 24 Dec 2024 21:29:59 +0200 Subject: [PATCH 13/13] fix unit test replace path with filepath --- pkg/vender/vendor_config_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/vender/vendor_config_test.go b/pkg/vender/vendor_config_test.go index 84af2ad6f..3c3005c10 100644 --- a/pkg/vender/vendor_config_test.go +++ b/pkg/vender/vendor_config_test.go @@ -4,7 +4,8 @@ package vender import ( "os" - "path" + + "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -28,7 +29,7 @@ func TestVendorConfigScenarios(t *testing.T) { atmosConfig.Logs.Level = "Trace" // Setup test component directory - componentPath := path.Join(testDir, "components", "terraform", "myapp") + componentPath := filepath.Join(testDir, "components", "terraform", "myapp") err := os.MkdirAll(componentPath, 0755) assert.Nil(t, err) @@ -47,7 +48,7 @@ spec: included_paths: - "**/*.tf" ` - vendorYamlPath := path.Join(testDir, "vendor.yaml") + vendorYamlPath := filepath.Join(testDir, "vendor.yaml") err := os.WriteFile(vendorYamlPath, []byte(vendorYaml), 0644) assert.Nil(t, err) @@ -84,7 +85,7 @@ spec: uri: github.com/cloudposse/terraform-null-label.git//exports?ref={{.Version}} version: 0.25.0 ` - componentYamlPath := path.Join(componentPath, "component.yaml") + componentYamlPath := filepath.Join(componentPath, "component.yaml") err := os.WriteFile(componentYamlPath, []byte(componentYaml), 0644) assert.Nil(t, err) @@ -102,7 +103,7 @@ spec: // Test Case 3: Neither vendor.yaml nor component.yaml exists t.Run("no vendor.yaml or component.yaml", func(t *testing.T) { // Test vendoring with component flag - vendorYamlPath := path.Join(testDir, "vendor.yaml") + vendorYamlPath := filepath.Join(testDir, "vendor.yaml") _, exists, _, err := e.ReadAndProcessVendorConfigFile(atmosConfig, vendorYamlPath, true) assert.Nil(t, err) assert.False(t, exists) @@ -126,7 +127,7 @@ spec: source: github.com/cloudposse/terraform-null-label.git//exports?ref={{.Version}} version: 0.25.0 ` - vendorYamlPath := path.Join(testDir, "vendor.yaml") + vendorYamlPath := filepath.Join(testDir, "vendor.yaml") err := os.WriteFile(vendorYamlPath, []byte(vendorYaml), 0644) assert.Nil(t, err)