-
Notifications
You must be signed in to change notification settings - Fork 26
fix: Handle numbers in env variables #651
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
Conversation
| content := envRegex.FindSubmatch(match)[1] | ||
| return []byte(openPlaceholder + string(content) + closePlaceholder) | ||
| k := fmt.Sprintf("%d", r.Int()) | ||
| for bytes.Contains(content, []byte(k)) { |
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.
Missed opportunity to use goto
erezrokah
left a comment
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.
🙈
⏱️ Benchmark resultsComparing with beda411
|
Codecov ReportBase: 47.15% // Head: 47.19% // Increases project coverage by
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## main #651 +/- ##
==========================================
+ Coverage 47.15% 47.19% +0.04%
==========================================
Files 70 70
Lines 6721 6727 +6
==========================================
+ Hits 3169 3175 +6
Misses 3106 3106
Partials 446 446
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
|
we might want to change the approach instead of yaml->json->yaml just do a small regex removing comments from the yaml . I've a feeling yaml->json->yaml is a place for a lot of such edge cases. but we can do that in the next edge case. |
🤖 I have created a release *beep* *boop* --- ## [1.33.1](v1.33.0...v1.33.1) (2023-02-01) ### Bug Fixes * Handle numbers in env variables ([#651](#651)) ([0aa8f68](0aa8f68)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This fixes an edge case in the yaml comment removal code, where environment variables containing only the numbers lost any quotes around them during the yaml -> json -> yaml conversion process. We can force quotes being maintained by making sure the placeholders are replaced by numbers. If they were quoted before, the yaml conversion process will then ensure the quotes remain. In this implementation we use random numbers with a constant seed, so it's spread out but predictable. We also check if the number already occurs in the config (which is incredibly unlikely, but anyway) and choose a different one if so.
Fixes #652