From e07e0191eac311deacbb833fd3c6e0e826e87f75 Mon Sep 17 00:00:00 2001 From: Matt Calhoun Date: Fri, 20 Dec 2024 12:58:30 -0500 Subject: [PATCH 1/7] fix windows paths --- pkg/utils/glob_utils.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/utils/glob_utils.go b/pkg/utils/glob_utils.go index 268473c53..9454bb664 100644 --- a/pkg/utils/glob_utils.go +++ b/pkg/utils/glob_utils.go @@ -22,7 +22,10 @@ func GetGlobMatches(pattern string) ([]string, error) { return strings.Split(existingMatches.(string), ","), nil } - base, cleanPattern := doublestar.SplitPattern(pattern) + // Conver the pattern to use / as the separatoratorator regardless of platform + allOsSafePattern := filepath.ToSlash(pattern) + + base, cleanPattern := doublestar.SplitPattern(allOsSafePattern) f := os.DirFS(base) matches, err := doublestar.Glob(f, cleanPattern) From fad5e5dde8ba8a2673ff145c7a107bf667c926b3 Mon Sep 17 00:00:00 2001 From: Matt Calhoun Date: Sun, 22 Dec 2024 21:11:00 -0500 Subject: [PATCH 2/7] fix TestLogger_FileLogging --- pkg/logger/logger_test.go | 5 ++++- pkg/utils/glob_utils.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/logger/logger_test.go b/pkg/logger/logger_test.go index f6dccd5b0..6f9dad331 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,7 +148,9 @@ func TestLogger_Error(t *testing.T) { } func TestLogger_FileLogging(t *testing.T) { - tempFile := "/tmp/test.log" + tempDir := t.TempDir() + tempFile := filepath.Join(tempDir, "test.log") + defer os.Remove(tempFile) logger, _ := NewLogger(LogLevelInfo, tempFile) diff --git a/pkg/utils/glob_utils.go b/pkg/utils/glob_utils.go index 9454bb664..dbc30855b 100644 --- a/pkg/utils/glob_utils.go +++ b/pkg/utils/glob_utils.go @@ -22,7 +22,7 @@ func GetGlobMatches(pattern string) ([]string, error) { return strings.Split(existingMatches.(string), ","), nil } - // Conver the pattern to use / as the separatoratorator regardless of platform + // Convert the pattern to use / as the separatoratorator regardless of platform allOsSafePattern := filepath.ToSlash(pattern) base, cleanPattern := doublestar.SplitPattern(allOsSafePattern) From 0be2e8fb913cd21663513f16c2db09129afdd8a0 Mon Sep 17 00:00:00 2001 From: Matt Calhoun Date: Sun, 22 Dec 2024 21:20:22 -0500 Subject: [PATCH 3/7] fix assertions to be cross-platform --- pkg/component/component_processor_test.go | 103 +++++++++++----------- 1 file changed, 52 insertions(+), 51 deletions(-) diff --git a/pkg/component/component_processor_test.go b/pkg/component/component_processor_test.go index bf23036a5..112be00c5 100644 --- a/pkg/component/component_processor_test.go +++ b/pkg/component/component_processor_test.go @@ -1,6 +1,7 @@ package component import ( + "path/filepath" "testing" "github.com/stretchr/testify/assert" @@ -28,21 +29,21 @@ func TestComponentProcessor(t *testing.T) { tenant1Ue2DevTestTestComponentBackendWorkspaceKeyPrefix := tenant1Ue2DevTestTestComponentBackend["workspace_key_prefix"].(string) tenant1Ue2DevTestTestComponentRemoteStateBackendWorkspaceKeyPrefix := tenant1Ue2DevTestTestComponentRemoteStateBackend["workspace_key_prefix"].(string) tenant1Ue2DevTestTestComponentDeps := tenant1Ue2DevTestTestComponent["deps"].([]any) - assert.Equal(t, "test-test-component", tenant1Ue2DevTestTestComponentBackendWorkspaceKeyPrefix) - assert.Equal(t, "test-test-component", tenant1Ue2DevTestTestComponentRemoteStateBackendWorkspaceKeyPrefix) - assert.Equal(t, "test/test-component", tenant1Ue2DevTestTestComponentBaseComponent) - assert.Equal(t, "tenant1-ue2-dev", tenant1Ue2DevTestTestComponentWorkspace) + assert.Equal(t, filepath.FromSlash("test-test-component"), tenant1Ue2DevTestTestComponentBackendWorkspaceKeyPrefix) + assert.Equal(t, filepath.FromSlash("test-test-component"), tenant1Ue2DevTestTestComponentRemoteStateBackendWorkspaceKeyPrefix) + assert.Equal(t, filepath.FromSlash("test/test-component"), tenant1Ue2DevTestTestComponentBaseComponent) + assert.Equal(t, filepath.FromSlash("tenant1-ue2-dev"), tenant1Ue2DevTestTestComponentWorkspace) assert.Equal(t, 9, len(tenant1Ue2DevTestTestComponentDeps)) - assert.Equal(t, "catalog/terraform/services/service-1", tenant1Ue2DevTestTestComponentDeps[0]) - assert.Equal(t, "catalog/terraform/services/service-2", tenant1Ue2DevTestTestComponentDeps[1]) - assert.Equal(t, "catalog/terraform/spacelift-and-backend-override-1", tenant1Ue2DevTestTestComponentDeps[2]) - assert.Equal(t, "catalog/terraform/test-component", tenant1Ue2DevTestTestComponentDeps[3]) - assert.Equal(t, "mixins/region/us-east-2", tenant1Ue2DevTestTestComponentDeps[4]) - assert.Equal(t, "mixins/stage/dev", tenant1Ue2DevTestTestComponentDeps[5]) - assert.Equal(t, "orgs/cp/_defaults", tenant1Ue2DevTestTestComponentDeps[6]) - assert.Equal(t, "orgs/cp/tenant1/_defaults", tenant1Ue2DevTestTestComponentDeps[7]) - assert.Equal(t, "orgs/cp/tenant1/dev/us-east-2", tenant1Ue2DevTestTestComponentDeps[8]) - assert.Equal(t, "tenant1-ue2-dev", tenant1Ue2DevTestTestComponentTerraformWorkspace) + assert.Equal(t, filepath.FromSlash("catalog/terraform/services/service-1"), tenant1Ue2DevTestTestComponentDeps[0]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/services/service-2"), tenant1Ue2DevTestTestComponentDeps[1]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/spacelift-and-backend-override-1"), tenant1Ue2DevTestTestComponentDeps[2]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/test-component"), tenant1Ue2DevTestTestComponentDeps[3]) + assert.Equal(t, filepath.FromSlash("mixins/region/us-east-2"), tenant1Ue2DevTestTestComponentDeps[4]) + assert.Equal(t, filepath.FromSlash("mixins/stage/dev"), tenant1Ue2DevTestTestComponentDeps[5]) + assert.Equal(t, filepath.FromSlash("orgs/cp/_defaults"), tenant1Ue2DevTestTestComponentDeps[6]) + assert.Equal(t, filepath.FromSlash("orgs/cp/tenant1/_defaults"), tenant1Ue2DevTestTestComponentDeps[7]) + assert.Equal(t, filepath.FromSlash("orgs/cp/tenant1/dev/us-east-2"), tenant1Ue2DevTestTestComponentDeps[8]) + assert.Equal(t, filepath.FromSlash("tenant1-ue2-dev"), tenant1Ue2DevTestTestComponentTerraformWorkspace) var tenant1Ue2DevTestTestComponent2 map[string]any component = "test/test-component" @@ -59,21 +60,21 @@ func TestComponentProcessor(t *testing.T) { tenant1Ue2DevTestTestComponentBackendWorkspaceKeyPrefix2 := tenant1Ue2DevTestTestComponentBackend2["workspace_key_prefix"].(string) tenant1Ue2DevTestTestComponentRemoteStateBackendWorkspaceKeyPrefix2 := tenant1Ue2DevTestTestComponentRemoteStateBackend2["workspace_key_prefix"].(string) tenant1Ue2DevTestTestComponentDeps2 := tenant1Ue2DevTestTestComponent2["deps"].([]any) - assert.Equal(t, "test-test-component", tenant1Ue2DevTestTestComponentBackendWorkspaceKeyPrefix2) - assert.Equal(t, "test-test-component", tenant1Ue2DevTestTestComponentRemoteStateBackendWorkspaceKeyPrefix2) - assert.Equal(t, "test/test-component", tenant1Ue2DevTestTestComponentBaseComponent2) - assert.Equal(t, "tenant1-ue2-dev", tenant1Ue2DevTestTestComponentWorkspace2) + assert.Equal(t, filepath.FromSlash("test-test-component"), tenant1Ue2DevTestTestComponentBackendWorkspaceKeyPrefix2) + assert.Equal(t, filepath.FromSlash("test-test-component"), tenant1Ue2DevTestTestComponentRemoteStateBackendWorkspaceKeyPrefix2) + assert.Equal(t, filepath.FromSlash("test/test-component"), tenant1Ue2DevTestTestComponentBaseComponent2) + assert.Equal(t, filepath.FromSlash("tenant1-ue2-dev"), tenant1Ue2DevTestTestComponentWorkspace2) assert.Equal(t, 9, len(tenant1Ue2DevTestTestComponentDeps2)) - assert.Equal(t, "catalog/terraform/services/service-1", tenant1Ue2DevTestTestComponentDeps2[0]) - assert.Equal(t, "catalog/terraform/services/service-2", tenant1Ue2DevTestTestComponentDeps2[1]) - assert.Equal(t, "catalog/terraform/spacelift-and-backend-override-1", tenant1Ue2DevTestTestComponentDeps2[2]) - assert.Equal(t, "catalog/terraform/test-component", tenant1Ue2DevTestTestComponentDeps2[3]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/services/service-1"), tenant1Ue2DevTestTestComponentDeps2[0]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/services/service-2"), tenant1Ue2DevTestTestComponentDeps2[1]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/spacelift-and-backend-override-1"), tenant1Ue2DevTestTestComponentDeps2[2]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/test-component"), tenant1Ue2DevTestTestComponentDeps2[3]) assert.Equal(t, "mixins/region/us-east-2", tenant1Ue2DevTestTestComponentDeps2[4]) - assert.Equal(t, "mixins/stage/dev", tenant1Ue2DevTestTestComponentDeps2[5]) - assert.Equal(t, "orgs/cp/_defaults", tenant1Ue2DevTestTestComponentDeps2[6]) - assert.Equal(t, "orgs/cp/tenant1/_defaults", tenant1Ue2DevTestTestComponentDeps2[7]) - assert.Equal(t, "orgs/cp/tenant1/dev/us-east-2", tenant1Ue2DevTestTestComponentDeps2[8]) - assert.Equal(t, "tenant1-ue2-dev", tenant1Ue2DevTestTestComponentTerraformWorkspace2) + assert.Equal(t, filepath.FromSlash("mixins/stage/dev"), tenant1Ue2DevTestTestComponentDeps2[5]) + assert.Equal(t, filepath.FromSlash("orgs/cp/_defaults"), tenant1Ue2DevTestTestComponentDeps2[6]) + assert.Equal(t, filepath.FromSlash("orgs/cp/tenant1/_defaults"), tenant1Ue2DevTestTestComponentDeps2[7]) + assert.Equal(t, filepath.FromSlash("orgs/cp/tenant1/dev/us-east-2"), tenant1Ue2DevTestTestComponentDeps2[8]) + assert.Equal(t, filepath.FromSlash("tenant1-ue2-dev"), tenant1Ue2DevTestTestComponentTerraformWorkspace2) yamlConfig, err = u.ConvertToYAML(tenant1Ue2DevTestTestComponent) assert.Nil(t, err) @@ -91,21 +92,21 @@ func TestComponentProcessor(t *testing.T) { tenant1Ue2DevTestTestComponentOverrideComponentDeps := tenant1Ue2DevTestTestComponentOverrideComponent["deps"].([]any) tenant1Ue2DevTestTestComponentOverrideComponentRemoteStateBackend := tenant1Ue2DevTestTestComponentOverrideComponent["remote_state_backend"].(map[string]any) tenant1Ue2DevTestTestComponentOverrideComponentRemoteStateBackendVal2 := tenant1Ue2DevTestTestComponentOverrideComponentRemoteStateBackend["val2"].(string) - assert.Equal(t, "test-test-component", tenant1Ue2DevTestTestComponentOverrideComponentBackendWorkspaceKeyPrefix) - assert.Equal(t, "test/test-component", tenant1Ue2DevTestTestComponentOverrideComponentBaseComponent) - assert.Equal(t, "test-component-override-workspace-override", tenant1Ue2DevTestTestComponentOverrideComponentWorkspace) + assert.Equal(t, filepath.FromSlash("test-test-component"), tenant1Ue2DevTestTestComponentOverrideComponentBackendWorkspaceKeyPrefix) + assert.Equal(t, filepath.FromSlash("test/test-component"), tenant1Ue2DevTestTestComponentOverrideComponentBaseComponent) + assert.Equal(t, filepath.FromSlash("test-component-override-workspace-override"), tenant1Ue2DevTestTestComponentOverrideComponentWorkspace) assert.Equal(t, 10, len(tenant1Ue2DevTestTestComponentOverrideComponentDeps)) - assert.Equal(t, "catalog/terraform/services/service-1-override", tenant1Ue2DevTestTestComponentOverrideComponentDeps[0]) - assert.Equal(t, "catalog/terraform/services/service-2-override", tenant1Ue2DevTestTestComponentOverrideComponentDeps[1]) - assert.Equal(t, "catalog/terraform/spacelift-and-backend-override-1", tenant1Ue2DevTestTestComponentOverrideComponentDeps[2]) - assert.Equal(t, "catalog/terraform/test-component", tenant1Ue2DevTestTestComponentOverrideComponentDeps[3]) - assert.Equal(t, "catalog/terraform/test-component-override", tenant1Ue2DevTestTestComponentOverrideComponentDeps[4]) - assert.Equal(t, "mixins/region/us-east-2", tenant1Ue2DevTestTestComponentOverrideComponentDeps[5]) - assert.Equal(t, "mixins/stage/dev", tenant1Ue2DevTestTestComponentOverrideComponentDeps[6]) - assert.Equal(t, "orgs/cp/_defaults", tenant1Ue2DevTestTestComponentOverrideComponentDeps[7]) - assert.Equal(t, "orgs/cp/tenant1/_defaults", tenant1Ue2DevTestTestComponentOverrideComponentDeps[8]) - assert.Equal(t, "orgs/cp/tenant1/dev/us-east-2", tenant1Ue2DevTestTestComponentOverrideComponentDeps[9]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/services/service-1-override"), tenant1Ue2DevTestTestComponentOverrideComponentDeps[0]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/services/service-2-override"), tenant1Ue2DevTestTestComponentOverrideComponentDeps[1]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/spacelift-and-backend-override-1"), tenant1Ue2DevTestTestComponentOverrideComponentDeps[2]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/test-component"), tenant1Ue2DevTestTestComponentOverrideComponentDeps[3]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/test-component-override"), tenant1Ue2DevTestTestComponentOverrideComponentDeps[4]) + assert.Equal(t, filepath.FromSlash("mixins/region/us-east-2"), tenant1Ue2DevTestTestComponentOverrideComponentDeps[5]) + assert.Equal(t, filepath.FromSlash("mixins/stage/dev"), tenant1Ue2DevTestTestComponentOverrideComponentDeps[6]) + assert.Equal(t, filepath.FromSlash("orgs/cp/_defaults"), tenant1Ue2DevTestTestComponentOverrideComponentDeps[7]) + assert.Equal(t, filepath.FromSlash("orgs/cp/tenant1/_defaults"), tenant1Ue2DevTestTestComponentOverrideComponentDeps[8]) + assert.Equal(t, filepath.FromSlash("orgs/cp/tenant1/dev/us-east-2"), tenant1Ue2DevTestTestComponentOverrideComponentDeps[9]) assert.Equal(t, "2", tenant1Ue2DevTestTestComponentOverrideComponentRemoteStateBackendVal2) @@ -149,17 +150,17 @@ func TestComponentProcessor(t *testing.T) { tenant1Ue2DevTestTestComponentOverrideComponent3Deps := tenant1Ue2DevTestTestComponentOverrideComponent3["deps"].([]any) assert.Equal(t, 11, len(tenant1Ue2DevTestTestComponentOverrideComponent3Deps)) - assert.Equal(t, "catalog/terraform/mixins/test-2", tenant1Ue2DevTestTestComponentOverrideComponent3Deps[0]) - assert.Equal(t, "catalog/terraform/services/service-1-override-2", tenant1Ue2DevTestTestComponentOverrideComponent3Deps[1]) - assert.Equal(t, "catalog/terraform/services/service-2-override-2", tenant1Ue2DevTestTestComponentOverrideComponent3Deps[2]) - assert.Equal(t, "catalog/terraform/spacelift-and-backend-override-1", tenant1Ue2DevTestTestComponentOverrideComponent3Deps[3]) - assert.Equal(t, "catalog/terraform/test-component", tenant1Ue2DevTestTestComponentOverrideComponent3Deps[4]) - assert.Equal(t, "catalog/terraform/test-component-override-3", tenant1Ue2DevTestTestComponentOverrideComponent3Deps[5]) - assert.Equal(t, "mixins/region/us-east-2", tenant1Ue2DevTestTestComponentOverrideComponent3Deps[6]) - assert.Equal(t, "mixins/stage/dev", tenant1Ue2DevTestTestComponentOverrideComponent3Deps[7]) - assert.Equal(t, "orgs/cp/_defaults", tenant1Ue2DevTestTestComponentOverrideComponent3Deps[8]) - assert.Equal(t, "orgs/cp/tenant1/_defaults", tenant1Ue2DevTestTestComponentOverrideComponent3Deps[9]) - assert.Equal(t, "orgs/cp/tenant1/dev/us-east-2", tenant1Ue2DevTestTestComponentOverrideComponent3Deps[10]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/mixins/test-2"), tenant1Ue2DevTestTestComponentOverrideComponent3Deps[0]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/services/service-1-override-2"), tenant1Ue2DevTestTestComponentOverrideComponent3Deps[1]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/services/service-2-override-2"), tenant1Ue2DevTestTestComponentOverrideComponent3Deps[2]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/spacelift-and-backend-override-1"), tenant1Ue2DevTestTestComponentOverrideComponent3Deps[3]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/test-component"), tenant1Ue2DevTestTestComponentOverrideComponent3Deps[4]) + assert.Equal(t, filepath.FromSlash("catalog/terraform/test-component-override-3"), tenant1Ue2DevTestTestComponentOverrideComponent3Deps[5]) + assert.Equal(t, filepath.FromSlash("mixins/region/us-east-2"), tenant1Ue2DevTestTestComponentOverrideComponent3Deps[6]) + assert.Equal(t, filepath.FromSlash("mixins/stage/dev"), tenant1Ue2DevTestTestComponentOverrideComponent3Deps[7]) + assert.Equal(t, filepath.FromSlash("orgs/cp/_defaults"), tenant1Ue2DevTestTestComponentOverrideComponent3Deps[8]) + assert.Equal(t, filepath.FromSlash("orgs/cp/tenant1/_defaults"), tenant1Ue2DevTestTestComponentOverrideComponent3Deps[9]) + assert.Equal(t, filepath.FromSlash("orgs/cp/tenant1/dev/us-east-2"), tenant1Ue2DevTestTestComponentOverrideComponent3Deps[10]) } func TestComponentProcessorHierarchicalInheritance(t *testing.T) { From 65c415a0cf6716c1a21bb6cec64e59d07b04b30d Mon Sep 17 00:00:00 2001 From: Matt Calhoun Date: Mon, 23 Dec 2024 08:19:44 -0500 Subject: [PATCH 4/7] fix rel path on windows --- pkg/component/component_processor.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/component/component_processor.go b/pkg/component/component_processor.go index b2c6db215..974170088 100644 --- a/pkg/component/component_processor.go +++ b/pkg/component/component_processor.go @@ -2,6 +2,8 @@ package component import ( "github.com/pkg/errors" + "path/filepath" + "strings" e "github.com/cloudposse/atmos/internal/exec" cfg "github.com/cloudposse/atmos/pkg/config" @@ -40,6 +42,22 @@ func ProcessComponentInStack( } } + // Convert any absolute paths in deps to relative paths + if deps, ok := configAndStacksInfo.ComponentSection["deps"].([]any); ok { + for i, dep := range deps { + if depStr, ok := dep.(string); ok { + // Convert absolute path to relative path if it starts with the base path + if atmosBasePath != "" && strings.HasPrefix(depStr, atmosBasePath) { + relPath, err := filepath.Rel(atmosBasePath, depStr) + if err == nil { + deps[i] = relPath + } + } + } + } + configAndStacksInfo.ComponentSection["deps"] = deps + } + return configAndStacksInfo.ComponentSection, nil } From 635da708bd19f76143b9d3ce7ed04a981d2b45c8 Mon Sep 17 00:00:00 2001 From: Matt Calhoun Date: Mon, 23 Dec 2024 08:36:15 -0500 Subject: [PATCH 5/7] fix relative paths on windows --- pkg/component/component_processor.go | 45 ++++++++++++++++++---------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/pkg/component/component_processor.go b/pkg/component/component_processor.go index 974170088..337affe91 100644 --- a/pkg/component/component_processor.go +++ b/pkg/component/component_processor.go @@ -11,6 +11,33 @@ import ( u "github.com/cloudposse/atmos/pkg/utils" ) +func convertPathsToRelative(v any, atmosBasePath string) any { + switch val := v.(type) { + case string: + if atmosBasePath != "" && strings.HasPrefix(val, atmosBasePath) { + relPath, err := filepath.Rel(atmosBasePath, val) + if err == nil { + return relPath + } + } + return val + case []any: + result := make([]any, len(val)) + for i, item := range val { + result[i] = convertPathsToRelative(item, atmosBasePath) + } + return result + case map[string]any: + result := make(map[string]any) + for k, v := range val { + result[k] = convertPathsToRelative(v, atmosBasePath) + } + return result + default: + return v + } +} + // ProcessComponentInStack accepts a component and a stack name and returns the component configuration in the stack func ProcessComponentInStack( component string, @@ -18,7 +45,6 @@ func ProcessComponentInStack( atmosCliConfigPath string, atmosBasePath string, ) (map[string]any, error) { - var configAndStacksInfo schema.ConfigAndStacksInfo configAndStacksInfo.ComponentFromArg = component configAndStacksInfo.Stack = stack @@ -42,21 +68,8 @@ func ProcessComponentInStack( } } - // Convert any absolute paths in deps to relative paths - if deps, ok := configAndStacksInfo.ComponentSection["deps"].([]any); ok { - for i, dep := range deps { - if depStr, ok := dep.(string); ok { - // Convert absolute path to relative path if it starts with the base path - if atmosBasePath != "" && strings.HasPrefix(depStr, atmosBasePath) { - relPath, err := filepath.Rel(atmosBasePath, depStr) - if err == nil { - deps[i] = relPath - } - } - } - } - configAndStacksInfo.ComponentSection["deps"] = deps - } + // Convert paths in the entire component section + configAndStacksInfo.ComponentSection = convertPathsToRelative(configAndStacksInfo.ComponentSection, atmosBasePath).(map[string]any) return configAndStacksInfo.ComponentSection, nil } From 80c9ec1c026e251559a8f771b22e0941b002252f Mon Sep 17 00:00:00 2001 From: Matt Calhoun Date: Mon, 23 Dec 2024 08:52:41 -0500 Subject: [PATCH 6/7] rever to main --- pkg/component/component_processor.go | 33 +--------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/pkg/component/component_processor.go b/pkg/component/component_processor.go index 337affe91..b2c6db215 100644 --- a/pkg/component/component_processor.go +++ b/pkg/component/component_processor.go @@ -2,8 +2,6 @@ package component import ( "github.com/pkg/errors" - "path/filepath" - "strings" e "github.com/cloudposse/atmos/internal/exec" cfg "github.com/cloudposse/atmos/pkg/config" @@ -11,33 +9,6 @@ import ( u "github.com/cloudposse/atmos/pkg/utils" ) -func convertPathsToRelative(v any, atmosBasePath string) any { - switch val := v.(type) { - case string: - if atmosBasePath != "" && strings.HasPrefix(val, atmosBasePath) { - relPath, err := filepath.Rel(atmosBasePath, val) - if err == nil { - return relPath - } - } - return val - case []any: - result := make([]any, len(val)) - for i, item := range val { - result[i] = convertPathsToRelative(item, atmosBasePath) - } - return result - case map[string]any: - result := make(map[string]any) - for k, v := range val { - result[k] = convertPathsToRelative(v, atmosBasePath) - } - return result - default: - return v - } -} - // ProcessComponentInStack accepts a component and a stack name and returns the component configuration in the stack func ProcessComponentInStack( component string, @@ -45,6 +16,7 @@ func ProcessComponentInStack( atmosCliConfigPath string, atmosBasePath string, ) (map[string]any, error) { + var configAndStacksInfo schema.ConfigAndStacksInfo configAndStacksInfo.ComponentFromArg = component configAndStacksInfo.Stack = stack @@ -68,9 +40,6 @@ func ProcessComponentInStack( } } - // Convert paths in the entire component section - configAndStacksInfo.ComponentSection = convertPathsToRelative(configAndStacksInfo.ComponentSection, atmosBasePath).(map[string]any) - return configAndStacksInfo.ComponentSection, nil } From 281dc343ee1474349d5b3bf4d1da3f14c9be60b0 Mon Sep 17 00:00:00 2001 From: "Erik Osterman (CEO @ Cloud Posse)" Date: Mon, 23 Dec 2024 09:56:20 -0600 Subject: [PATCH 7/7] Update pkg/utils/glob_utils.go --- pkg/utils/glob_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/utils/glob_utils.go b/pkg/utils/glob_utils.go index dbc30855b..b5f6b0b3b 100644 --- a/pkg/utils/glob_utils.go +++ b/pkg/utils/glob_utils.go @@ -22,7 +22,7 @@ func GetGlobMatches(pattern string) ([]string, error) { return strings.Split(existingMatches.(string), ","), nil } - // Convert the pattern to use / as the separatoratorator regardless of platform + // Convert the pattern to use / as the separator regardless of platform allOsSafePattern := filepath.ToSlash(pattern) base, cleanPattern := doublestar.SplitPattern(allOsSafePattern)