-
Notifications
You must be signed in to change notification settings - Fork 304
Stable Config file: target system properties in process_arguments and support template variables in YamlParser #8690
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
d112dc7
migrate CLIHelper to use a Map, parse system properties in key-vals
mtoffl01 3ba99af
Fix processTemplateVar logic to remove superfluous ':'
mtoffl01 9caeb5d
nits: javadocs
mtoffl01 d0f194b
Move writeFileRaw helper to testutils
mtoffl01 457c288
Add YamlParser tests
mtoffl01 06ae9ac
Revert CLIHelper to use List<String>; lazily load a Map cache for que…
mtoffl01 06712dc
reuse logic for adding to the vm args cache
mtoffl01 0a1da8f
apply github suggestions
mtoffl01 e106416
Move processTemplate yaml helper fns into StableConfigParser, along w…
mtoffl01 48adeaa
Remove changes to CLIHelper; rely on System.getProperty instead
mtoffl01 24b8615
optimize: return from processTemplate early if no {{ found
mtoffl01 cc76954
Add more test coverage to StableConfigParserTest
mtoffl01 afddf95
Merge branch 'master' into mtoff/scfg_fix
mtoffl01 fc4652c
Optimize template processing to reduce use of substrings
mcculls e633f26
Introduce constants for repeated strings
mcculls 3c8b646
Remove FileUtils and all its references
mtoffl01 96d2d2c
Merge branch 'master' into mtoff/scfg_fix
amarziali File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
package datadog.yaml; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import org.yaml.snakeyaml.Yaml; | ||
|
||
public class YamlParser { | ||
// Supports clazz == null for default yaml parsing | ||
public static <T> T parse(String filePath, Class<T> clazz) throws IOException { | ||
public static <T> T parse(String content, Class<T> clazz) { | ||
Yaml yaml = new Yaml(); | ||
try (FileInputStream fis = new FileInputStream(filePath)) { | ||
if (clazz == null) { | ||
return yaml.load(fis); | ||
} else { | ||
return yaml.loadAs(fis, clazz); | ||
} | ||
if (clazz == null) { | ||
return yaml.load(content); | ||
} else { | ||
return yaml.loadAs(content, clazz); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
One question - will users ever want to substitute a variable with an empty string?
Currently we don't support this, because the variable will be replaced with
UNDEFINED
- but a user might want to have some kind of optional variable that may have a value or optionally be the empty string...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.
Addressing in a separate PR: #8759