diff --git a/conga/plugins/ansible/conga-ansible-plugin/jacoco/index.html b/conga/plugins/ansible/conga-ansible-plugin/jacoco/index.html
index 625c63ffb..1cc268b47 100644
--- a/conga/plugins/ansible/conga-ansible-plugin/jacoco/index.html
+++ b/conga/plugins/ansible/conga-ansible-plugin/jacoco/index.html
@@ -1 +1 @@
-CONGA Ansible Plugin CONGA Ansible Plugin
\ No newline at end of file
+CONGA Ansible Plugin CONGA Ansible Plugin
\ No newline at end of file
diff --git a/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin$InventoryContent.html b/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin$InventoryContent.html
index 05a3e3f09..3be527169 100644
--- a/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin$InventoryContent.html
+++ b/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin$InventoryContent.html
@@ -1 +1 @@
-AnsibleInventoryValueProviderPlugin.InventoryContent AnsibleInventoryValueProviderPlugin.InventoryContent
\ No newline at end of file
+AnsibleInventoryValueProviderPlugin.InventoryContent AnsibleInventoryValueProviderPlugin.InventoryContent
\ No newline at end of file
diff --git a/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin.html b/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin.html
index 028d37c4f..e9ffab476 100644
--- a/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin.html
+++ b/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin.html
@@ -1 +1 @@
-AnsibleInventoryValueProviderPlugin AnsibleInventoryValueProviderPlugin
\ No newline at end of file
+AnsibleInventoryValueProviderPlugin AnsibleInventoryValueProviderPlugin
\ No newline at end of file
diff --git a/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin.java.html b/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin.java.html
index 78ee222d9..f6659828e 100644
--- a/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin.java.html
+++ b/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/AnsibleInventoryValueProviderPlugin.java.html
@@ -118,66 +118,62 @@
content = tryReadInitStyle(inventoryContent);
}
- // fallback to empty map
- if (content == null) {
- content = new InventoryContent(Map.of());
- }
-
// put to cache
- context.setValueProviderCache(content);
- return content;
+ context.setValueProviderCache(content);
+ return content;
}
- catch (IOException ex) {
- throw new GeneratorException("Error reading Ansible Inventory file: " + FileUtil.getCanonicalPath(file), ex);
+ catch (IOException ex) {
+ throw new GeneratorException("Error reading Ansible Inventory file: " + FileUtil.getCanonicalPath(file), ex);
}
}
private InventoryContent tryReadJsonStyle(String inventoryContent, File file, ValueProviderContext context) {
try {
- JsonElement root = JsonParser.parseString(inventoryContent);
- if (root instanceof JsonObject) {
- ReadContext jsonpathReadContext = JsonPath.parse(inventoryContent);
- return new InventoryContent(jsonToConfig((JsonObject)root), jsonpathReadContext);
+ JsonElement root = JsonParser.parseString(inventoryContent);
+ if (root instanceof JsonObject) {
+ ReadContext jsonpathReadContext = JsonPath.parse(inventoryContent);
+ return new InventoryContent(jsonToConfig((JsonObject)root), jsonpathReadContext);
}
}
- catch (JsonSyntaxException ex) {
- context.getLogger().debug("Failed to parse Ansible inventory " + FileUtil.getCanonicalPath(file) + " as JSON string "
+ catch (JsonSyntaxException ex) {
+ context.getLogger().debug("Failed to parse Ansible inventory " + FileUtil.getCanonicalPath(file) + " as JSON string "
+ "- assuming not JSON style.", ex);
- }
- return null;
+ }
+ return null;
}
+ @SuppressWarnings("java:S3776") // ignore complexity
private Map<String, List<String>> jsonToConfig(JsonObject root) {
- Map<String, List<String>> content = new HashMap<>();
- for (Map.Entry<String, JsonElement> entry : root.entrySet()) {
- if (!StringUtils.equals(entry.getKey(), "_meta")) {
- JsonArray hostNamesArray = null;
- if (entry.getValue() instanceof JsonArray) {
- hostNamesArray = (JsonArray)entry.getValue();
+ Map<String, List<String>> content = new HashMap<>();
+ for (Map.Entry<String, JsonElement> entry : root.entrySet()) {
+ if (!StringUtils.equals(entry.getKey(), "_meta")) {
+ JsonArray hostNamesArray = null;
+ if (entry.getValue() instanceof JsonArray) {
+ hostNamesArray = (JsonArray)entry.getValue();
}
- else if (entry.getValue() instanceof JsonObject) {
- JsonObject entryObject = (JsonObject)entry.getValue();
- JsonElement hostsElement = entryObject.get("hosts");
- if (hostsElement instanceof JsonArray) {
- hostNamesArray = (JsonArray)hostsElement;
+ else if (entry.getValue() instanceof JsonObject) {
+ JsonObject entryObject = (JsonObject)entry.getValue();
+ JsonElement hostsElement = entryObject.get("hosts");
+ if (hostsElement instanceof JsonArray) {
+ hostNamesArray = (JsonArray)hostsElement;
}
}
- if (hostNamesArray != null) {
- List<String> hostNames = new ArrayList<>();
- for (JsonElement item : hostNamesArray) {
- hostNames.add(item.getAsString());
- }
- content.put(entry.getKey(), hostNames);
+ if (hostNamesArray != null) {
+ List<String> hostNames = new ArrayList<>();
+ for (JsonElement item : hostNamesArray) {
+ hostNames.add(item.getAsString());
+ }
+ content.put(entry.getKey(), hostNames);
}
}
- }
- return content;
+ }
+ return content;
}
private InventoryContent tryReadInitStyle(String inventoryContent) {
- AnsibleInventory inventory = AnsibleInventoryReader.read(inventoryContent);
- return new InventoryContent(inventoryToConfig(inventory));
+ AnsibleInventory inventory = AnsibleInventoryReader.read(inventoryContent);
+ return new InventoryContent(inventoryToConfig(inventory));
}
/**
@@ -186,13 +182,13 @@
* @return Group/hostname map
*/
private Map<String, List<String>> inventoryToConfig(AnsibleInventory inventory) {
- Map<String, List<String>> config = new HashMap<>();
- for (AnsibleGroup group : inventory.getGroups()) {
- config.put(group.getName(), group.getHosts().stream()
- .map(AnsibleHost::getName)
- .collect(Collectors.toList()));
- }
- return config;
+ Map<String, List<String>> config = new HashMap<>();
+ for (AnsibleGroup group : inventory.getGroups()) {
+ config.put(group.getName(), group.getHosts().stream()
+ .map(AnsibleHost::getName)
+ .collect(Collectors.toList()));
+ }
+ return config;
}
private static class InventoryContent {
@@ -201,20 +197,20 @@
private final ReadContext jsonpathReadContext;
InventoryContent(Map<String, List<String>> content) {
- this(content, null);
- }
+ this(content, null);
+ }
- InventoryContent(Map<String, List<String>> content, ReadContext jsonpathReadContext) {
- this.map = content;
- this.jsonpathReadContext = jsonpathReadContext;
- }
+ InventoryContent(Map<String, List<String>> content, ReadContext jsonpathReadContext) {
+ this.map = content;
+ this.jsonpathReadContext = jsonpathReadContext;
+ }
public Map<String, List<String>> getMap() {
- return this.map;
+ return this.map;
}
public ReadContext getJsonpathReadContext() {
- return this.jsonpathReadContext;
+ return this.jsonpathReadContext;
}
}
diff --git a/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/index.html b/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/index.html
index 595508ed3..826556249 100644
--- a/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/index.html
+++ b/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/index.html
@@ -1 +1 @@
-io.wcm.devops.conga.plugins.ansible.valueprovider io.wcm.devops.conga.plugins.ansible.valueprovider
\ No newline at end of file
+io.wcm.devops.conga.plugins.ansible.valueprovider io.wcm.devops.conga.plugins.ansible.valueprovider
\ No newline at end of file
diff --git a/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/index.source.html b/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/index.source.html
index beb48a76d..b38d5cd5d 100644
--- a/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/index.source.html
+++ b/conga/plugins/ansible/conga-ansible-plugin/jacoco/io.wcm.devops.conga.plugins.ansible.valueprovider/index.source.html
@@ -1 +1 @@
-io.wcm.devops.conga.plugins.ansible.valueprovider io.wcm.devops.conga.plugins.ansible.valueprovider
\ No newline at end of file
+io.wcm.devops.conga.plugins.ansible.valueprovider io.wcm.devops.conga.plugins.ansible.valueprovider
\ No newline at end of file
diff --git a/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryReader.html b/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryReader.html
index ed2f1b63c..e97d98df7 100644
--- a/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryReader.html
+++ b/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryReader.html
@@ -1 +1 @@
-AnsibleInventoryReader AnsibleInventoryReader Element Missed Instructions Cov. Missed Branches Cov. Missed Cxty Missed Lines Missed Methods Total 9 of 249 96% 8 of 46 82% 8 24 3 65 0 1 read(String) 96% 82% 8 24 3 65 0 1
\ No newline at end of file
+AnsibleInventoryReader AnsibleInventoryReader Element Missed Instructions Cov. Missed Branches Cov. Missed Cxty Missed Lines Missed Methods Total 9 of 249 96% 8 of 46 82% 8 24 3 65 0 1 read(String) 96% 82% 8 24 3 65 0 1
\ No newline at end of file
diff --git a/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryReader.java.html b/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryReader.java.html
index 745da2713..b751b42b2 100644
--- a/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryReader.java.html
+++ b/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryReader.java.html
@@ -33,101 +33,102 @@
private AnsibleInventoryReader() {
}
+ @SuppressWarnings({ "java:S3776", "java:S135", "java:S6541" }) // ignore complexity
public static AnsibleInventory read(String text) {
- final AnsibleInventory inventory = new AnsibleInventory();
+ final AnsibleInventory inventory = new AnsibleInventory();
- final StringTokenizer tokenizer = new StringTokenizer(text, " \t\n\r\f", true);
+ final StringTokenizer tokenizer = new StringTokenizer(text, " \t\n\r\f", true);
- AnsibleGroup group = null;
- AnsibleHost host = null;
- boolean skipComment = false;
- boolean isVarsBlock = false;
- boolean isChildrenBlock = false;
- while (tokenizer.hasMoreTokens()) {
- final String token = tokenizer.nextToken();
+ AnsibleGroup group = null;
+ AnsibleHost host = null;
+ boolean skipComment = false;
+ boolean isVarsBlock = false;
+ boolean isChildrenBlock = false;
+ while (tokenizer.hasMoreTokens()) {
+ final String token = tokenizer.nextToken();
// New line, reset the comment flag
- if ("\n".equals(token)) {
- skipComment = false;
- continue;
+ if ("\n".equals(token)) {
+ skipComment = false;
+ continue;
}
// We are still reading a comment line
- if (skipComment) {
- continue;
+ if (skipComment) {
+ continue;
}
// Ignore separators
- if (" ".equals(token) || "\t".equals(token) || "\r".equals(token) || "\f".equals(token)) {
- continue;
+ if (" ".equals(token) || "\t".equals(token) || "\r".equals(token) || "\f".equals(token)) {
+ continue;
}
// We are reading a comment
- if (token.startsWith(";") || token.startsWith("#")) {
- skipComment = true;
- continue;
+ if (token.startsWith(";") || token.startsWith("#")) {
+ skipComment = true;
+ continue;
}
- if (token.startsWith("[")) {
- host = null;
- isChildrenBlock = false;
- isVarsBlock = false;
+ if (token.startsWith("[")) {
+ host = null;
+ isChildrenBlock = false;
+ isVarsBlock = false;
- String groupName = token.replaceAll("^\\[", "").replaceAll("]$", "");
+ String groupName = token.replaceAll("^\\[", "").replaceAll("]$", "");
- if (groupName.contains(":")) {
- final String[] g = groupName.split(":");
+ if (groupName.contains(":")) {
+ final String[] g = groupName.split(":");
- groupName = g[0];
+ groupName = g[0];
- if ("vars".equals(g[1])) {
- isVarsBlock = true;
- group = inventory.getGroup(groupName);
- } else if ("children".equals(g[1])) {
- isChildrenBlock = true;
- group = new AnsibleGroup(groupName);
- inventory.addGroup(group);
+ if ("vars".equals(g[1])) {
+ isVarsBlock = true;
+ group = inventory.getGroup(groupName);
+ } else if ("children".equals(g[1])) {
+ isChildrenBlock = true;
+ group = new AnsibleGroup(groupName);
+ inventory.addGroup(group);
}
- } else {
- group = new AnsibleGroup(groupName);
- inventory.addGroup(group);
+ } else {
+ group = new AnsibleGroup(groupName);
+ inventory.addGroup(group);
}
- } else if (token.contains("=")) {
- final String[] v = token.split("=");
+ } else if (token.contains("=")) {
+ final String[] v = token.split("=");
// Replace YAML backslashes escapes
- final AnsibleVariable variable = new AnsibleVariable(v[0], v[1].replace("\\\\", "\\"));
-
- if (host != null) {
- host.addVariable(variable);
- } else if (isVarsBlock && group != null) {
- for (AnsibleGroup s : group.getSubgroups()) {
- for (AnsibleHost h : s.getHosts()) {
- h.addVariable(variable);
- }
- }
- for (AnsibleHost h : group.getHosts()) {
- h.addVariable(variable);
- }
+ final AnsibleVariable variable = new AnsibleVariable(v[0], v[1].replace("\\\\", "\\"));
+
+ if (host != null) {
+ host.addVariable(variable);
+ } else if (isVarsBlock && group != null) {
+ for (AnsibleGroup s : group.getSubgroups()) {
+ for (AnsibleHost h : s.getHosts()) {
+ h.addVariable(variable);
+ }
+ }
+ for (AnsibleHost h : group.getHosts()) {
+ h.addVariable(variable);
+ }
}
- } else {
- if (group == null) {
- host = new AnsibleHost(token);
- inventory.addHost(host);
- } else if (isChildrenBlock) {
- final AnsibleGroup g = inventory.getGroup(token);
- if (g != null) {
- group.addSubgroup(g);
+ } else {
+ if (group == null) {
+ host = new AnsibleHost(token);
+ inventory.addHost(host);
+ } else if (isChildrenBlock) {
+ final AnsibleGroup g = inventory.getGroup(token);
+ if (g != null) {
+ group.addSubgroup(g);
} else {
- group.addSubgroup(new AnsibleGroup(token));
+ group.addSubgroup(new AnsibleGroup(token));
}
- } else {
- host = new AnsibleHost(token);
- group.addHost(host);
+ } else {
+ host = new AnsibleHost(token);
+ group.addHost(host);
}
}
- }
+ }
- return inventory;
+ return inventory;
}
}
diff --git a/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryWriter.html b/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryWriter.html
index 865cf16dd..ba0968b02 100644
--- a/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryWriter.html
+++ b/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryWriter.html
@@ -1 +1 @@
-AnsibleInventoryWriter AnsibleInventoryWriter
\ No newline at end of file
+AnsibleInventoryWriter AnsibleInventoryWriter
\ No newline at end of file
diff --git a/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryWriter.java.html b/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryWriter.java.html
index a725d9501..2a54e60f8 100644
--- a/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryWriter.java.html
+++ b/conga/plugins/ansible/conga-ansible-plugin/jacoco/it.andreascarpino.ansible.inventory.util/AnsibleInventoryWriter.java.html
@@ -76,90 +76,92 @@
stream.write("\n".getBytes());
}
+ @SuppressWarnings("java:S3776") // ignore complexity
public static String write(AnsibleInventory inventory) {
- final StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
- for (AnsibleHost host : inventory.getHosts()) {
- builder.append(printHost(host));
- }
+ for (AnsibleHost host : inventory.getHosts()) {
+ builder.append(printHost(host));
+ }
- for (AnsibleGroup group : inventory.getGroups()) {
- if (!group.getSubgroups().isEmpty()) {
- builder.append(groupOfGroupHeader(group.getName()));
+ for (AnsibleGroup group : inventory.getGroups()) {
+ if (!group.getSubgroups().isEmpty()) {
+ builder.append(groupOfGroupHeader(group.getName()));
- if (!group.getSubgroups().isEmpty()) {
- for (AnsibleGroup g : group.getSubgroups()) {
- builder.append(g.getName()).append('\n');
- }
+ if (!group.getSubgroups().isEmpty()) {
+ for (AnsibleGroup g : group.getSubgroups()) {
+ builder.append(g.getName()).append('\n');
+ }
} else {
- builder.append("\n");
+ builder.append("\n");
}
}
- if (!group.getHosts().isEmpty()) {
- builder.append(groupHeader(group.getName()));
+ if (!group.getHosts().isEmpty()) {
+ builder.append(groupHeader(group.getName()));
- for (AnsibleHost host : group.getHosts()) {
- builder.append(printHost(host));
- }
+ for (AnsibleHost host : group.getHosts()) {
+ builder.append(printHost(host));
+ }
}
- if (!group.getVariables().isEmpty()) {
- builder.append(groupVarsHeader(group.getName()));
+ if (!group.getVariables().isEmpty()) {
+ builder.append(groupVarsHeader(group.getName()));
- if (!group.getVariables().isEmpty()) {
- for (AnsibleVariable variable : group.getVariables()) {
- builder.append(variableBlock(variable)).append('\n');
- }
+ if (!group.getVariables().isEmpty()) {
+ for (AnsibleVariable variable : group.getVariables()) {
+ builder.append(variableBlock(variable)).append('\n');
+ }
} else {
- builder.append("\n");
+ builder.append("\n");
}
}
- }
+ }
- return builder.toString();
+ return builder.toString();
}
+ @SuppressWarnings("java:S3776") // ignore complexity
public static void write(AnsibleInventory inventory, OutputStream stream) throws IOException {
- for (AnsibleHost host : inventory.getHosts()) {
- printHost(host, stream);
- }
-
- for (AnsibleGroup group : inventory.getGroups()) {
- if (!group.getSubgroups().isEmpty()) {
- stream.write(groupOfGroupHeader(group.getName()).getBytes());
-
- if (!group.getSubgroups().isEmpty()) {
- for (AnsibleGroup g : group.getSubgroups()) {
- stream.write((g.getName() + "\n").getBytes());
- }
+ for (AnsibleHost host : inventory.getHosts()) {
+ printHost(host, stream);
+ }
+
+ for (AnsibleGroup group : inventory.getGroups()) {
+ if (!group.getSubgroups().isEmpty()) {
+ stream.write(groupOfGroupHeader(group.getName()).getBytes());
+
+ if (!group.getSubgroups().isEmpty()) {
+ for (AnsibleGroup g : group.getSubgroups()) {
+ stream.write((g.getName() + "\n").getBytes());
+ }
} else {
- stream.write("\n".getBytes());
+ stream.write("\n".getBytes());
}
}
- if (!group.getHosts().isEmpty()) {
- stream.write(groupHeader(group.getName()).getBytes());
+ if (!group.getHosts().isEmpty()) {
+ stream.write(groupHeader(group.getName()).getBytes());
- for (AnsibleHost host : group.getHosts()) {
- printHost(host, stream);
- }
+ for (AnsibleHost host : group.getHosts()) {
+ printHost(host, stream);
+ }
}
- if (!group.getVariables().isEmpty()) {
- stream.write("\n".getBytes());
- stream.write(groupVarsHeader(group.getName()).getBytes());
+ if (!group.getVariables().isEmpty()) {
+ stream.write("\n".getBytes());
+ stream.write(groupVarsHeader(group.getName()).getBytes());
- if (!group.getVariables().isEmpty()) {
- for (AnsibleVariable variable : group.getVariables()) {
- stream.write((variableBlock(variable) + "\n").getBytes());
- }
+ if (!group.getVariables().isEmpty()) {
+ for (AnsibleVariable variable : group.getVariables()) {
+ stream.write((variableBlock(variable) + "\n").getBytes());
+ }
} else {
- stream.write("\n".getBytes());
+ stream.write("\n".getBytes());
}
}
- }
- }
+ }
+ }
}