From fbb6f2ad753f1cfc3df1f3504164b36ab1e9d6b2 Mon Sep 17 00:00:00 2001 From: haitham911 Date: Sun, 17 Nov 2024 12:42:42 +0200 Subject: [PATCH 1/3] fix: handle empty stack YAML configuration and adjust file content retrieval --- examples/demo-localstack/stacks/deploy/footbar.yaml | 0 internal/exec/stack_processor_utils.go | 6 +++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 examples/demo-localstack/stacks/deploy/footbar.yaml diff --git a/examples/demo-localstack/stacks/deploy/footbar.yaml b/examples/demo-localstack/stacks/deploy/footbar.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/internal/exec/stack_processor_utils.go b/internal/exec/stack_processor_utils.go index b6c6f4d0e..6b22b0ad5 100644 --- a/internal/exec/stack_processor_utils.go +++ b/internal/exec/stack_processor_utils.go @@ -199,6 +199,10 @@ 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 := "" @@ -1874,7 +1878,7 @@ func CreateComponentStackMap( func GetFileContent(filePath string) (string, error) { existingContent, found := getFileContentSyncMap.Load(filePath) if found && existingContent != nil { - return fmt.Sprintf("%s", existingContent), nil + return "", nil } content, err := os.ReadFile(filePath) From 600a22962b6411bd5bbb4e1944268479463a189a Mon Sep 17 00:00:00 2001 From: haitham911 Date: Sun, 17 Nov 2024 14:01:59 +0200 Subject: [PATCH 2/3] fix: return existing content from GetFileContent instead of an empty string --- internal/exec/stack_processor_utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/exec/stack_processor_utils.go b/internal/exec/stack_processor_utils.go index 6b22b0ad5..3fb35695a 100644 --- a/internal/exec/stack_processor_utils.go +++ b/internal/exec/stack_processor_utils.go @@ -1878,7 +1878,8 @@ func CreateComponentStackMap( func GetFileContent(filePath string) (string, error) { existingContent, found := getFileContentSyncMap.Load(filePath) if found && existingContent != nil { - return "", nil + return fmt.Sprintf("%s", existingContent), nil + } content, err := os.ReadFile(filePath) From 8811dec8f1cab0cac4977ce889889a863cb7ccd2 Mon Sep 17 00:00:00 2001 From: haitham911 Date: Sun, 17 Nov 2024 14:06:51 +0200 Subject: [PATCH 3/3] fix: remove unnecessary blank lines in ProcessYAMLConfigFile and GetFileContent functions --- internal/exec/stack_processor_utils.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/exec/stack_processor_utils.go b/internal/exec/stack_processor_utils.go index 3fb35695a..b616e2348 100644 --- a/internal/exec/stack_processor_utils.go +++ b/internal/exec/stack_processor_utils.go @@ -201,7 +201,6 @@ func ProcessYAMLConfigFile( } if stackYamlConfig == "" { return map[string]any{}, map[string]map[string]any{}, map[string]any{}, nil - } stackManifestTemplatesProcessed := stackYamlConfig @@ -1879,7 +1878,6 @@ func GetFileContent(filePath string) (string, error) { existingContent, found := getFileContentSyncMap.Load(filePath) if found && existingContent != nil { return fmt.Sprintf("%s", existingContent), nil - } content, err := os.ReadFile(filePath)