env: add bash-style default value operator :-#11787
env: add bash-style default value operator :-#11787benjaminmueggenburg-serato wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds bash-style default substitution ChangesEnvironment Variable Default Substitution
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Super useful and makes things a lot more consistent with the usage of the |
Signed-off-by: benjaminmueggenburg-serato <benjamin.mueggenburg@serato.com>
Signed-off-by: benjaminmueggenburg-serato <benjamin.mueggenburg@serato.com>
50870ce to
93acbd7
Compare
cosmo0920
left a comment
There was a problem hiding this comment.
The direction of implementation is quite useful for saving undefined variable error and also it prevent possible errors without defined environment variables.
I found a nitpick point of view to handle default "nested" variable.
Just leaving as-is is reasonable for us for now.
| else if (def_val) { | ||
| if (def_len > 0) { | ||
| s = buf_append(buf, def_val, def_len); | ||
| if (!s) { | ||
| flb_sds_destroy(buf); | ||
| return NULL; | ||
| } | ||
| buf = s; | ||
| } | ||
| } |
There was a problem hiding this comment.
This is just a nitpick comment but bash shell also supports nested style of expanding variable like:
result=${A:-${B:-default}}.
Do we need to plan for this style of nested variable for default variable?
Just leaving as-is is also better to keep simplicity of implementation.
Adds the familiar bash-style default value operator
:-.Now inside configuration files
${VALUE:-default}will resolve todefaultif VALUE variable is not set (os or locally) or is empty ''.Addresses #5517
Configuration example
Expand
Checklist (maintainers)
Debug / stdout
Unset
TEST_ZONESet
TEST_ZONE=eu-west-1:Unit tests
Valgrind summary / log tail
Command:
Valgrind tail:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
fluent/fluent-bit-docs#2568
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit
New Features
${VAR:-fallback}now expands to the fallback when the variable is unset or empty.Tests