Skip to content

Commit

Permalink
Renames a method
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
  • Loading branch information
DarshitChanpura committed Dec 12, 2023
1 parent a1cfa75 commit b0870a4
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Map<String, Object> buildSecurityConfigMap() {
static boolean isNetworkHostAlreadyPresent(String filePath) {
try {
String searchString = "network.host";
return isStringAlreadyPresentInYMLFile(filePath, searchString);
return isKeyPresentInYMLFile(filePath, searchString);
} catch (IOException e) {
return false;
}
Expand All @@ -305,28 +305,28 @@ static boolean isNetworkHostAlreadyPresent(String filePath) {
static boolean isNodeMaxLocalStorageNodesAlreadyPresent(String filePath) {
try {
String searchString = "node.max_local_storage_nodes";
return isStringAlreadyPresentInYMLFile(filePath, searchString);
return isKeyPresentInYMLFile(filePath, searchString);
} catch (IOException e) {
return false;
}
}

/**
* Checks if given string is already present in the yml file
* @param filePath path to yml file in which given string should be searched
* @param fieldName the field name to be searched for
* @return true if string is present, false otherwise
* Checks if the given key is present in the yml file
* @param filePath path to yml file in which given key should be searched
* @param key the key to be searched for
* @return true if the key is present, false otherwise
* @throws IOException if there was exception reading the file
*/
static boolean isStringAlreadyPresentInYMLFile(String filePath, String fieldName) throws IOException {
static boolean isKeyPresentInYMLFile(String filePath, String key) throws IOException {
JsonNode node;
try {
node = DefaultObjectMapper.YAML_MAPPER.readTree(new File(filePath));
} catch (IOException e) {
throw new RuntimeException(e);
}

return node.has(fieldName);
return node.has(key);
}

/**
Expand Down

0 comments on commit b0870a4

Please sign in to comment.