From 2d5854152a31caa1dbe2a9eacbb037e55f293527 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Tue, 14 Jan 2025 22:05:03 +0100 Subject: [PATCH 1/3] fix vendor pull error message --- internal/exec/vendor_utils.go | 2 +- tests/test-cases/vendor-test.yaml | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 tests/test-cases/vendor-test.yaml diff --git a/internal/exec/vendor_utils.go b/internal/exec/vendor_utils.go index d116f62ac..a8d226bd1 100644 --- a/internal/exec/vendor_utils.go +++ b/internal/exec/vendor_utils.go @@ -181,7 +181,7 @@ func ReadAndProcessVendorConfigFile( // Check if it's a directory fileInfo, err := os.Stat(foundVendorConfigFile) if err != nil { - return vendorConfig, false, "", err + return vendorConfig, false, "", fmt.Errorf("Vendoring is not configured. To set up vendoring please see https://atmos.tools/core-concepts/vendor/") } var configFiles []string diff --git a/tests/test-cases/vendor-test.yaml b/tests/test-cases/vendor-test.yaml new file mode 100644 index 000000000..07b738712 --- /dev/null +++ b/tests/test-cases/vendor-test.yaml @@ -0,0 +1,13 @@ +tests: + - name: atmos vendor pull + enabled: true + description: "" + workdir: "../" + command: "atmos" + args: + - "vendor" + - "pull" + expect: + stderr: + - "Vendoring is not configured. To set up vendoring please see https://atmos.tools/core-concepts/vendor/" + exit_code: 1 From c49448d42f20841e82b553e109a41383ef867ddd Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 15 Jan 2025 20:07:41 +0100 Subject: [PATCH 2/3] Added more error handling messages --- internal/exec/vendor_utils.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/internal/exec/vendor_utils.go b/internal/exec/vendor_utils.go index a8d226bd1..a9e0fd3aa 100644 --- a/internal/exec/vendor_utils.go +++ b/internal/exec/vendor_utils.go @@ -181,7 +181,16 @@ func ReadAndProcessVendorConfigFile( // Check if it's a directory fileInfo, err := os.Stat(foundVendorConfigFile) if err != nil { - return vendorConfig, false, "", fmt.Errorf("Vendoring is not configured. To set up vendoring please see https://atmos.tools/core-concepts/vendor/") + if os.IsNotExist(err) { + // File does not exist + return vendorConfig, false, "", fmt.Errorf("Vendoring is not configured. To set up vendoring, please see https://atmos.tools/core-concepts/vendor/") + } + if os.IsPermission(err) { + // Permission error + return vendorConfig, false, "", fmt.Errorf("Permission denied when accessing '%s'. Please check the file permissions.", foundVendorConfigFile) + } + // Other errors + return vendorConfig, false, "", fmt.Errorf("An error occurred while accessing the vendoring configuration: %w", err) } var configFiles []string From 719dee3d5e1a04767735faa5b1b5c15794f8bd26 Mon Sep 17 00:00:00 2001 From: Sam Tholiya Date: Wed, 15 Jan 2025 20:27:09 +0100 Subject: [PATCH 3/3] fix test case --- tests/test-cases/vendor-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-cases/vendor-test.yaml b/tests/test-cases/vendor-test.yaml index 07b738712..a1061e398 100644 --- a/tests/test-cases/vendor-test.yaml +++ b/tests/test-cases/vendor-test.yaml @@ -9,5 +9,5 @@ tests: - "pull" expect: stderr: - - "Vendoring is not configured. To set up vendoring please see https://atmos.tools/core-concepts/vendor/" + - "Vendoring is not configured. To set up vendoring, please see https://atmos.tools/core-concepts/vendor/" exit_code: 1