Github user mmiklavc commented on a diff in the pull request:
https://github.com/apache/metron/pull/760#discussion_r139532867
--- Diff:
metron-platform/metron-common/src/main/java/org/apache/metron/common/cli/ConfigurationManager.java
---
@@ -130,29 +201,39 @@ public void pull(CuratorFramework client, String
outFileStr, final boolean force
public void visit(ConfigurationType configurationType, String name,
String data) {
File out = getFile(outputDir, configurationType, name);
if (!out.exists() || force) {
- if(!out.exists()) {
+ if (!out.exists()) {
out.getParentFile().mkdirs();
}
try {
Files.write(data, out, Charset.defaultCharset());
} catch (IOException e) {
throw new RuntimeException("Sorry, something bad happened
writing the config to " + out.getAbsolutePath() + ": " + e.getMessage(), e);
}
- }
- else if(out.exists() && !force) {
+ } else if (out.exists() && !force) {
throw new IllegalStateException("Unable to overwrite existing
file (" + out.getAbsolutePath() + ") without the force flag (-f or --force)
being set.");
}
}
});
}
public void push(String inputDirStr, CuratorFramework client) throws
Exception {
- final File inputDir = new File(inputDirStr);
+ final File inputDir = new File(inputDirStr);
--- End diff --
That was actually me missing the "-i" parameter in the test script. I've
modified the test accordingly. In general we should be better guarding user
inputs, e.g. some may have noticed that help never actually worked without
throwing an exception. I could add a check there also. I'm inclined to rewrite
our configuration classes altogether as I think they can be greatly simplified.
---