use of com.mercedesbenz.sechub.docgen.spring.SpringValueExtractor.SpringValue in project sechub by mercedes-benz.
the class KubernetesTemplateFilesGenerator method generateDeploymentCode.
private void generateDeploymentCode(KubernetesFiles result, DocAnnotationData data) {
StringBuilder code = result.getDeployment(data);
String inspect = findKey(data);
if (inspect == null || inspect.isEmpty()) {
return;
}
String springENV = inspect.replace('.', '_').toUpperCase();
String description = data.description;
if (description == null || description.isEmpty()) {
description = "No description available";
}
String[] lines = description.split("\n");
for (String line : lines) {
newLine(code, " # " + line);
}
newLine(code, " - name: " + springENV);
if (data.isSecret) {
String secretName = createSecretName(data);
String secretKey = springENV.toLowerCase();
result.getSecretKeys(secretName).add(secretKey);
newLine(code, " valueFrom:");
newLine(code, " secretKeyRef:");
newLine(code, " name: " + secretName);
newLine(code, " key: " + secretKey);
/* handle custom secret file names */
result.secretFileNameMapping.put(secretKey, data.options.get(OPTION_SECRET_FILE_NAME));
} else {
String springValue = data.springValue;
if (springValue != null && !springValue.isEmpty()) {
SpringValue extract = springValueExtractor.extract(springValue);
newLine(code, " value: \"" + extract.getDefaultValue() + "\"");
} else if (data.springScheduled != null) {
newLine(code, " value: \"" + springScheduledExtractor.extract(data.springScheduled).getScheduleDefaultValue() + "\"");
}
}
}
use of com.mercedesbenz.sechub.docgen.spring.SpringValueExtractor.SpringValue in project sechub by mercedes-benz.
the class MockPropertiesDescriptionGenerator method generate.
public String generate(ClasspathDataCollector collector) {
if (collector == null) {
return "";
}
List<DocAnnotationData> list = collector.fetchMustBeDocumentParts();
if (list == null || list.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
Map<String, SortedSet<TableRow>> rowMap = new TreeMap<>();
for (DocAnnotationData data : list) {
if (SimpleStringUtils.isEmpty(data.springValue)) {
continue;
}
SpringValue extracted = springValueExtractor.extract(data.springValue);
TableRow row = new TableRow();
row.defaultValue = extracted.getDefaultValue();
row.propertyKey = extracted.getKey();
row.description = data.description;
SortedSet<TableRow> rows = rowMap.get(data.scope);
if (rows == null) {
rows = new TreeSet<>();
rowMap.put(data.scope, rows);
}
rows.add(row);
}
if (rowMap.isEmpty()) {
return "";
}
for (Map.Entry<String, SortedSet<TableRow>> entries : rowMap.entrySet()) {
SortedSet<TableRow> table = entries.getValue();
sb.append("[options=\"header\",cols=\"1,1,1\"]\n");
sb.append(".").append(buildTitle(entries.getKey()));
sb.append("\n|===\n");
sb.append("|Key |Default |Description \n");
sb.append("//----------------------\n");
for (TableRow row : table) {
sb.append("|").append(row.propertyKey);
sb.append("|").append(row.defaultValue);
sb.append("|").append(row.description);
sb.append("\n");
}
sb.append("\n|===\n\n");
}
return sb.toString();
}
use of com.mercedesbenz.sechub.docgen.spring.SpringValueExtractor.SpringValue in project sechub by mercedes-benz.
the class SpringScheduleExtractor method extract.
public SpringSchedule extract(Scheduled springScheduled) {
SpringSchedule data = extractSimpleString(springScheduled);
if (getValueExtractor().isSpringValue(data.scheduleDefinition)) {
SpringValue extracted = getValueExtractor().extract(data.scheduleDefinition);
data.scheduleDefinition = extracted.toDescription();
data.scheduleKey = extracted.getKey();
data.scheduleDefaultValue = extracted.getDefaultValue();
}
return data;
}
use of com.mercedesbenz.sechub.docgen.spring.SpringValueExtractor.SpringValue in project sechub by mercedes-benz.
the class SystemPropertiesDescriptionGenerator method generate.
public String generate(List<DocAnnotationData> list, SpringValueFilter filter) {
if (list == null || list.isEmpty()) {
return "";
}
StringBuilder sb = new StringBuilder();
Map<String, SortedSet<TableRow>> rowMap = new TreeMap<>();
for (DocAnnotationData data : list) {
if (SimpleStringUtils.isEmpty(data.springValue)) {
continue;
}
SpringValue extracted = springValueExtractor.extract(data.springValue);
if (filter.isFiltered(extracted)) {
continue;
}
TableRow row = new TableRow();
row.defaultValue = extracted.getDefaultValue();
row.hasDefaultValue = extracted.hasDefaultValue();
row.propertyKey = extracted.getKey();
row.description = data.description;
SortedSet<TableRow> rows = rowMap.get(data.scope);
if (rows == null) {
rows = new TreeSet<>();
rowMap.put(data.scope, rows);
}
rows.add(row);
}
if (rowMap.isEmpty()) {
return "";
}
appendStringContent(sb, rowMap);
return sb.toString();
}
Aggregations