Skip to content

Commit a5872d9

Browse files
Maven site: wcm-io-devops/conga
1 parent 38414ab commit a5872d9

File tree

169 files changed

+6119
-6066
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+6119
-6066
lines changed
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

conga/generator/dependencies.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ <h1 id="dependency_file_details">Dependency File Details</h1>
15031503
</tr>
15041504
<tr class="a">
15051505
<td style="text-align: left;">io.wcm.devops.conga.model-1.17.5-SNAPSHOT.jar</td>
1506-
<td style="text-align: right;">32.2 kB</td>
1506+
<td style="text-align: right;">32.3 kB</td>
15071507
<td style="text-align: right;">48</td>
15081508
<td style="text-align: right;">31</td>
15091509
<td style="text-align: right;">5</td>
@@ -1512,7 +1512,7 @@ <h1 id="dependency_file_details">Dependency File Details</h1>
15121512
</tr>
15131513
<tr class="b">
15141514
<td style="text-align: left;">io.wcm.devops.conga.resource-1.17.5-SNAPSHOT.jar</td>
1515-
<td style="text-align: right;">18.2 kB</td>
1515+
<td style="text-align: right;">18.3 kB</td>
15161516
<td style="text-align: right;">25</td>
15171517
<td style="text-align: right;">13</td>
15181518
<td style="text-align: right;">1</td>

conga/generator/jacoco-unit/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

conga/generator/jacoco-unit/io.wcm.devops.conga.generator.plugins.export/YamlNodeModelExport.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

conga/generator/jacoco-unit/io.wcm.devops.conga.generator.plugins.export/YamlNodeModelExport.java.html

Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.util.stream.Collectors;
3333

3434
import org.apache.commons.lang3.StringUtils;
35+
import org.apache.commons.lang3.Strings;
3536
import org.yaml.snakeyaml.DumperOptions;
3637
import org.yaml.snakeyaml.Yaml;
3738

@@ -46,7 +47,7 @@
4647
* Exports model information for each node in YAML format.
4748
* This is useful e.g. for integration with Ansible.
4849
*/
49-
<span class="fc" id="L49">public class YamlNodeModelExport implements NodeModelExportPlugin {</span>
50+
<span class="fc" id="L50">public class YamlNodeModelExport implements NodeModelExportPlugin {</span>
5051

5152
/**
5253
* Plugin name
@@ -57,113 +58,113 @@
5758

5859
@Override
5960
public String getName() {
60-
<span class="fc" id="L60"> return NAME;</span>
61+
<span class="fc" id="L61"> return NAME;</span>
6162
}
6263

6364
@Override
6465
public void export(NodeModelExportContext context) {
6566

6667
// generate YAML data
67-
<span class="fc" id="L67"> List&lt;Map&lt;String, Object&gt;&gt; roles = new ArrayList&lt;&gt;();</span>
68-
<span class="fc bfc" id="L68" title="All 2 branches covered."> for (ExportNodeRoleData roleData : context.getRoleData()) {</span>
69-
<span class="fc" id="L69"> addRole(roles, roleData, context);</span>
70-
<span class="fc" id="L70"> }</span>
68+
<span class="fc" id="L68"> List&lt;Map&lt;String, Object&gt;&gt; roles = new ArrayList&lt;&gt;();</span>
69+
<span class="fc bfc" id="L69" title="All 2 branches covered."> for (ExportNodeRoleData roleData : context.getRoleData()) {</span>
70+
<span class="fc" id="L70"> addRole(roles, roleData, context);</span>
71+
<span class="fc" id="L71"> }</span>
7172

72-
<span class="fc" id="L72"> Map&lt;String, Object&gt; modelMap = new LinkedHashMap&lt;&gt;();</span>
73-
<span class="fc" id="L73"> modelMap.put(&quot;roles&quot;, roles);</span>
73+
<span class="fc" id="L73"> Map&lt;String, Object&gt; modelMap = new LinkedHashMap&lt;&gt;();</span>
74+
<span class="fc" id="L74"> modelMap.put(&quot;roles&quot;, roles);</span>
7475

75-
<span class="fc" id="L75"> Map&lt;String, String&gt; versionInfo = context.getContainerVersionInfo();</span>
76-
<span class="pc bpc" id="L76" title="1 of 2 branches missed."> if (versionInfo != null) {</span>
77-
<span class="nc" id="L77"> modelMap.put(&quot;versionInfo&quot;, Collections.unmodifiableSortedMap(new TreeMap&lt;&gt;(versionInfo)));</span>
76+
<span class="fc" id="L76"> Map&lt;String, String&gt; versionInfo = context.getContainerVersionInfo();</span>
77+
<span class="pc bpc" id="L77" title="1 of 2 branches missed."> if (versionInfo != null) {</span>
78+
<span class="nc" id="L78"> modelMap.put(&quot;versionInfo&quot;, Collections.unmodifiableSortedMap(new TreeMap&lt;&gt;(versionInfo)));</span>
7879
}
7980

8081
// save YAML file
81-
<span class="fc" id="L81"> save(modelMap, context);</span>
82-
<span class="fc" id="L82"> }</span>
82+
<span class="fc" id="L82"> save(modelMap, context);</span>
83+
<span class="fc" id="L83"> }</span>
8384

8485
private void addRole(List&lt;Map&lt;String, Object&gt;&gt; modelList, ExportNodeRoleData roleData, NodeModelExportContext context) {
85-
<span class="fc" id="L85"> String nodeDirPath = FileUtil.getCanonicalPath(context.getNodeDir());</span>
86+
<span class="fc" id="L86"> String nodeDirPath = FileUtil.getCanonicalPath(context.getNodeDir());</span>
8687

87-
<span class="fc" id="L87"> Map&lt;String, Object&gt; roleMap = new LinkedHashMap&lt;&gt;();</span>
88-
<span class="fc" id="L88"> roleMap.put(&quot;role&quot;, roleData.getRole());</span>
88+
<span class="fc" id="L88"> Map&lt;String, Object&gt; roleMap = new LinkedHashMap&lt;&gt;();</span>
89+
<span class="fc" id="L89"> roleMap.put(&quot;role&quot;, roleData.getRole());</span>
8990

90-
<span class="fc" id="L90"> List&lt;String&gt; variants = roleData.getRoleVariants();</span>
91-
<span class="fc bfc" id="L91" title="All 2 branches covered."> if (variants.size() == 1) {</span>
92-
<span class="fc" id="L92"> roleMap.put(&quot;variant&quot;, variants.get(0));</span>
91+
<span class="fc" id="L91"> List&lt;String&gt; variants = roleData.getRoleVariants();</span>
92+
<span class="fc bfc" id="L92" title="All 2 branches covered."> if (variants.size() == 1) {</span>
93+
<span class="fc" id="L93"> roleMap.put(&quot;variant&quot;, variants.get(0));</span>
9394
}
94-
<span class="fc bfc" id="L94" title="All 2 branches covered."> if (!variants.isEmpty()) {</span>
95-
<span class="fc" id="L95"> roleMap.put(&quot;variants&quot;, variants);</span>
95+
<span class="fc bfc" id="L95" title="All 2 branches covered."> if (!variants.isEmpty()) {</span>
96+
<span class="fc" id="L96"> roleMap.put(&quot;variants&quot;, variants);</span>
9697
}
9798

98-
<span class="fc" id="L98"> roleMap.put(&quot;files&quot;, roleData.getFiles().stream()</span>
99-
<span class="fc" id="L99"> .filter(item -&gt; item.getFileContext().getFile().exists())</span>
100-
<span class="fc" id="L100"> .map(item -&gt; {</span>
101-
<span class="fc" id="L101"> Map&lt;String, Object&gt; itemMap = new LinkedHashMap&lt;&gt;();</span>
102-
<span class="fc" id="L102"> itemMap.put(&quot;path&quot;, cleanupFileName(item.getFileContext().getCanonicalPath(), nodeDirPath));</span>
103-
<span class="pc bpc" id="L103" title="1 of 2 branches missed."> if (!item.getPostProcessors().isEmpty()) {</span>
104-
<span class="nc" id="L104"> itemMap.put(&quot;postProcessors&quot;, List.copyOf(item.getPostProcessors()));</span>
99+
<span class="fc" id="L99"> roleMap.put(&quot;files&quot;, roleData.getFiles().stream()</span>
100+
<span class="fc" id="L100"> .filter(item -&gt; item.getFileContext().getFile().exists())</span>
101+
<span class="fc" id="L101"> .map(item -&gt; {</span>
102+
<span class="fc" id="L102"> Map&lt;String, Object&gt; itemMap = new LinkedHashMap&lt;&gt;();</span>
103+
<span class="fc" id="L103"> itemMap.put(&quot;path&quot;, cleanupFileName(item.getFileContext().getCanonicalPath(), nodeDirPath));</span>
104+
<span class="pc bpc" id="L104" title="1 of 2 branches missed."> if (!item.getPostProcessors().isEmpty()) {</span>
105+
<span class="nc" id="L105"> itemMap.put(&quot;postProcessors&quot;, List.copyOf(item.getPostProcessors()));</span>
105106
}
106-
<span class="fc" id="L106"> Map&lt;String, Object&gt; modelOptions = item.getFileContext().getModelOptions();</span>
107-
<span class="pc bpc" id="L107" title="1 of 2 branches missed."> if (modelOptions != null) {</span>
108-
<span class="fc bfc" id="L108" title="All 2 branches covered."> for (Map.Entry&lt;String, Object&gt; entry : modelOptions.entrySet()) {</span>
109-
<span class="pc bpc" id="L109" title="1 of 2 branches missed."> if (!itemMap.containsKey(entry.getKey())) {</span>
110-
<span class="fc" id="L110"> itemMap.put(entry.getKey(), entry.getValue());</span>
107+
<span class="fc" id="L107"> Map&lt;String, Object&gt; modelOptions = item.getFileContext().getModelOptions();</span>
108+
<span class="pc bpc" id="L108" title="1 of 2 branches missed."> if (modelOptions != null) {</span>
109+
<span class="fc bfc" id="L109" title="All 2 branches covered."> for (Map.Entry&lt;String, Object&gt; entry : modelOptions.entrySet()) {</span>
110+
<span class="pc bpc" id="L110" title="1 of 2 branches missed."> if (!itemMap.containsKey(entry.getKey())) {</span>
111+
<span class="fc" id="L111"> itemMap.put(entry.getKey(), entry.getValue());</span>
111112
}
112-
<span class="fc" id="L112"> }</span>
113+
<span class="fc" id="L113"> }</span>
113114
}
114-
<span class="fc" id="L114"> return itemMap;</span>
115+
<span class="fc" id="L115"> return itemMap;</span>
115116
})
116-
<span class="fc" id="L116"> .collect(Collectors.toList()));</span>
117+
<span class="fc" id="L117"> .collect(Collectors.toList()));</span>
117118

118-
<span class="fc" id="L118"> roleMap.put(&quot;config&quot;, context.getModelExportConfigProcessor().apply(roleData.getConfig()));</span>
119+
<span class="fc" id="L119"> roleMap.put(&quot;config&quot;, context.getModelExportConfigProcessor().apply(roleData.getConfig()));</span>
119120

120-
<span class="fc" id="L120"> addTenants(roleMap, roleData, context);</span>
121+
<span class="fc" id="L121"> addTenants(roleMap, roleData, context);</span>
121122

122-
<span class="fc" id="L122"> modelList.add(roleMap);</span>
123-
<span class="fc" id="L123"> }</span>
123+
<span class="fc" id="L123"> modelList.add(roleMap);</span>
124+
<span class="fc" id="L124"> }</span>
124125

125126
private void addTenants(Map&lt;String, Object&gt; roleMap, ExportNodeRoleData roleData, NodeModelExportContext context) {
126-
<span class="fc" id="L126"> List&lt;Map&lt;String, Object&gt;&gt; tenants = new ArrayList&lt;&gt;();</span>
127+
<span class="fc" id="L127"> List&lt;Map&lt;String, Object&gt;&gt; tenants = new ArrayList&lt;&gt;();</span>
127128

128-
<span class="pc bpc" id="L128" title="1 of 2 branches missed."> if (roleData.getTenantData() != null) {</span>
129-
<span class="fc bfc" id="L129" title="All 2 branches covered."> for (ExportNodeRoleTenantData tenantData : roleData.getTenantData()) {</span>
130-
<span class="fc" id="L130"> addTenant(tenants, tenantData, context);</span>
131-
<span class="fc" id="L131"> }</span>
129+
<span class="pc bpc" id="L129" title="1 of 2 branches missed."> if (roleData.getTenantData() != null) {</span>
130+
<span class="fc bfc" id="L130" title="All 2 branches covered."> for (ExportNodeRoleTenantData tenantData : roleData.getTenantData()) {</span>
131+
<span class="fc" id="L131"> addTenant(tenants, tenantData, context);</span>
132+
<span class="fc" id="L132"> }</span>
132133
}
133134

134-
<span class="pc bpc" id="L134" title="1 of 2 branches missed."> if (!tenants.isEmpty()) {</span>
135-
<span class="fc" id="L135"> roleMap.put(&quot;tenants&quot;, tenants);</span>
135+
<span class="pc bpc" id="L135" title="1 of 2 branches missed."> if (!tenants.isEmpty()) {</span>
136+
<span class="fc" id="L136"> roleMap.put(&quot;tenants&quot;, tenants);</span>
136137
}
137-
<span class="fc" id="L137"> }</span>
138+
<span class="fc" id="L138"> }</span>
138139

139140
private void addTenant(List&lt;Map&lt;String, Object&gt;&gt; tenants, ExportNodeRoleTenantData tenantData, NodeModelExportContext context) {
140-
<span class="fc" id="L140"> Map&lt;String, Object&gt; tenantMap = new LinkedHashMap&lt;&gt;();</span>
141+
<span class="fc" id="L141"> Map&lt;String, Object&gt; tenantMap = new LinkedHashMap&lt;&gt;();</span>
141142

142-
<span class="fc" id="L142"> tenantMap.put(&quot;tenant&quot;, context.getVariableStringResolver().resolve(tenantData.getTenant(), tenantData.getConfig()));</span>
143-
<span class="fc bfc" id="L143" title="All 2 branches covered."> if (!tenantData.getRoles().isEmpty()) {</span>
143+
<span class="fc" id="L143"> tenantMap.put(&quot;tenant&quot;, context.getVariableStringResolver().resolve(tenantData.getTenant(), tenantData.getConfig()));</span>
144+
<span class="fc bfc" id="L144" title="All 2 branches covered."> if (!tenantData.getRoles().isEmpty()) {</span>
144145
// copy role list for each tenant to avoid alias in YAML export
145-
<span class="fc" id="L145"> tenantMap.put(&quot;roles&quot;, new ArrayList&lt;&gt;(tenantData.getRoles()));</span>
146+
<span class="fc" id="L146"> tenantMap.put(&quot;roles&quot;, new ArrayList&lt;&gt;(tenantData.getRoles()));</span>
146147
}
147-
<span class="fc" id="L147"> tenantMap.put(&quot;config&quot;, context.getModelExportConfigProcessor().apply(tenantData.getConfig()));</span>
148+
<span class="fc" id="L148"> tenantMap.put(&quot;config&quot;, context.getModelExportConfigProcessor().apply(tenantData.getConfig()));</span>
148149

149-
<span class="fc" id="L149"> tenants.add(tenantMap);</span>
150-
<span class="fc" id="L150"> }</span>
150+
<span class="fc" id="L150"> tenants.add(tenantMap);</span>
151+
<span class="fc" id="L151"> }</span>
151152

152153
private void save(Map&lt;String, Object&gt; modelMap, NodeModelExportContext context) {
153-
<span class="fc" id="L153"> File file = new File(context.getNodeDir(), MODEL_FILE);</span>
154-
<span class="fc" id="L154"> try (FileOutputStream os = new FileOutputStream(file);</span>
155-
<span class="fc" id="L155"> OutputStreamWriter writer = new OutputStreamWriter(os, StandardCharsets.UTF_8)) {</span>
156-
<span class="fc" id="L156"> Yaml yaml = new Yaml(context.getYamlRepresenter(), new DumperOptions());</span>
157-
<span class="fc" id="L157"> yaml.dump(modelMap, writer);</span>
154+
<span class="fc" id="L154"> File file = new File(context.getNodeDir(), MODEL_FILE);</span>
155+
<span class="fc" id="L155"> try (FileOutputStream os = new FileOutputStream(file);</span>
156+
<span class="fc" id="L156"> OutputStreamWriter writer = new OutputStreamWriter(os, StandardCharsets.UTF_8)) {</span>
157+
<span class="fc" id="L157"> Yaml yaml = new Yaml(context.getYamlRepresenter(), new DumperOptions());</span>
158+
<span class="fc" id="L158"> yaml.dump(modelMap, writer);</span>
158159
}
159-
<span class="nc" id="L159"> /*CHECKSTYLE:OFF*/ catch (Exception ex) { /*CHECKSTYLE:ON*/</span>
160-
<span class="nc" id="L160"> throw new GeneratorException(&quot;Unable to write model file: &quot; + FileUtil.getCanonicalPath(file), ex);</span>
161-
<span class="fc" id="L161"> }</span>
162-
<span class="fc" id="L162"> }</span>
160+
<span class="nc" id="L160"> /*CHECKSTYLE:OFF*/ catch (Exception ex) { /*CHECKSTYLE:ON*/</span>
161+
<span class="nc" id="L161"> throw new GeneratorException(&quot;Unable to write model file: &quot; + FileUtil.getCanonicalPath(file), ex);</span>
162+
<span class="fc" id="L162"> }</span>
163+
<span class="fc" id="L163"> }</span>
163164

164165
private String cleanupFileName(String fileName, String basePath) {
165-
<span class="fc" id="L165"> String relativePath = StringUtils.substring(fileName, basePath.length() + 1);</span>
166-
<span class="fc" id="L166"> return StringUtils.replace(relativePath, File.separator, &quot;/&quot;);</span>
166+
<span class="fc" id="L166"> String relativePath = StringUtils.substring(fileName, basePath.length() + 1);</span>
167+
<span class="fc" id="L167"> return Strings.CS.replace(relativePath, File.separator, &quot;/&quot;);</span>
167168
}
168169

169170
}

0 commit comments

Comments
 (0)