-
Notifications
You must be signed in to change notification settings - Fork 5
fix: allow empty env var for moduleVersion as can be set in the moduleSource #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -105,3 +105,36 @@ var _ = Describe("From TF module to Promise Stage", func() { | |||||
| Expect(string(output)).To(MatchJSON(expectedOutputNoSpec)) | ||||||
| }) | ||||||
| }) | ||||||
|
|
||||||
| var _ = Describe("Different variable inputs", func() { | ||||||
| var ( | ||||||
| envVars map[string]string | ||||||
| tmpDir string | ||||||
| ) | ||||||
|
|
||||||
| BeforeEach(func() { | ||||||
| var err error | ||||||
| tmpDir, err = os.MkdirTemp("", "kratix") | ||||||
| Expect(err).NotTo(HaveOccurred()) | ||||||
| }) | ||||||
|
|
||||||
| AfterEach(func() { | ||||||
| os.RemoveAll(tmpDir) | ||||||
| }) | ||||||
|
|
||||||
| It("No version provided", func() { | ||||||
|
||||||
| It("No version provided", func() { | |
| It("No MODULE_VERSION env var provided", func() { |
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test only covers the scenario where MODULE_SOURCE contains the ref parameter and MODULE_VERSION is not set. However, there are other important scenarios that should be tested to ensure the change works correctly:
- MODULE_PATH is set but MODULE_VERSION is empty (to ensure the double-slash doesn't cause issues)
- Both MODULE_VERSION is set AND MODULE_SOURCE contains ?ref= (to verify this edge case is handled or at least documented)
- MODULE_VERSION is set with MODULE_PATH (the original happy path with path but no version in source)
These additional test cases would help ensure the implementation handles all expected combinations of input variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current implementation can create invalid URLs if both MODULE_SOURCE already contains query parameters (e.g., "?ref=1.0.0") and MODULE_VERSION is also set. This would result in duplicate query parameters like "git::example.com?ref=1.0.0?ref=2.0.0".
Consider validating that MODULE_SOURCE doesn't already contain a ref parameter when MODULE_VERSION is provided, or document that MODULE_VERSION should not be used when MODULE_SOURCE already includes version information. Alternatively, you could parse the URL and detect existing query parameters to prevent conflicts.