use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff in project halyard by spinnaker.
the class AnsiFormatUtils method format.
static void format(NodeDiff diff, AnsiStoryBuilder resultBuilder) {
AnsiSnippet snippet = null;
AnsiParagraphBuilder paragraph = null;
boolean printLocation = true;
switch(diff.getChangeType()) {
case EDITED:
if (!diff.getFieldDiffs().isEmpty()) {
snippet = new AnsiSnippet("~ EDITED\n").setForegroundColor(AnsiForegroundColor.MAGENTA);
} else {
printLocation = false;
}
break;
case REMOVED:
snippet = new AnsiSnippet("- REMOVED\n").setForegroundColor(AnsiForegroundColor.RED);
break;
case ADDED:
snippet = new AnsiSnippet("+ ADDED\n").setForegroundColor(AnsiForegroundColor.GREEN);
break;
default:
throw new RuntimeException("Unknown changetype " + diff.getChangeType());
}
if (printLocation) {
paragraph = resultBuilder.addParagraph();
paragraph.addSnippet(snippet.addStyle(AnsiStyle.BOLD).toString());
paragraph.addSnippet(diff.getLocation()).addStyle(AnsiStyle.BOLD);
}
for (NodeDiff.FieldDiff fieldDiff : diff.getFieldDiffs()) {
paragraph = resultBuilder.addParagraph();
paragraph.addSnippet(" - ");
paragraph.addSnippet(fieldDiff.getFieldName()).addStyle(AnsiStyle.UNDERLINE);
paragraph.addSnippet(" " + fieldDiff.getOldValue() + " -> " + fieldDiff.getNewValue());
}
if (printLocation) {
resultBuilder.addNewline();
}
for (NodeDiff nodeDiff : diff.getNodeDiffs()) {
format(nodeDiff, resultBuilder);
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff in project halyard by spinnaker.
the class DiffDeployCommand method executeThis.
@Override
protected void executeThis() {
String deploymentName = getCurrentDeployment();
NodeDiff result = new OperationHandler<NodeDiff>().setFailureMesssage("Failed to generate config diff.").setOperation(Daemon.configDiff(deploymentName, !noValidate)).get();
if (result == null) {
AnsiUi.raw("No changes have been made to your configuration.");
} else {
AnsiUi.raw(AnsiFormatUtils.format(result));
}
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff in project halyard by spinnaker.
the class DeployService method configDiff.
public NodeDiff configDiff(String deploymentName) {
try {
DeploymentConfiguration deploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
halconfigParser.switchToBackupConfig();
DeploymentConfiguration oldDeploymentConfiguration = deploymentService.getDeploymentConfiguration(deploymentName);
return deploymentConfiguration.diff(oldDeploymentConfiguration);
} finally {
halconfigParser.switchToPrimaryConfig();
}
}
Aggregations