use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff.ChangeType.EDITED in project halyard by spinnaker.
the class AbstractEditCanaryAccountCommand method executeThis.
@Override
protected void executeThis() {
String accountName = getAccountName();
String serviceIntegration = getServiceIntegration();
String currentDeployment = getCurrentDeployment();
// Disable validation here, since we don't want an illegal config to prevent us from fixing it.
AbstractCanaryAccount account = new OperationHandler<AbstractCanaryAccount>().setFailureMesssage("Failed to get canary account " + accountName + " for service integration " + serviceIntegration + ".").setOperation(Daemon.getCanaryAccount(currentDeployment, serviceIntegration.toLowerCase(), accountName, false)).get();
int originaHash = account.hashCode();
account = editAccount((T) account);
if (originaHash == account.hashCode()) {
AnsiUi.failure("No changes supplied.");
return;
}
new OperationHandler<Void>().setFailureMesssage("Failed to edit canary account " + accountName + " for service integration " + serviceIntegration + ".").setSuccessMessage("Successfully edited canary account " + accountName + " for service integration " + serviceIntegration + ".").setOperation(Daemon.setCanaryAccount(currentDeployment, serviceIntegration.toLowerCase(), accountName, !noValidate, account)).get();
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff.ChangeType.EDITED in project halyard by spinnaker.
the class AbstractEditProviderCommand method executeThis.
@Override
protected void executeThis() {
String providerName = getProviderName();
String currentDeployment = getCurrentDeployment();
Provider provider = new OperationHandler<Provider>().setFailureMesssage("Failed to get provider " + providerName + ".").setOperation(Daemon.getProvider(currentDeployment, providerName, false)).get();
int originalHash = provider.hashCode();
provider = editProvider((P) provider);
if (originalHash == provider.hashCode()) {
AnsiUi.failure("No changes supplied.");
return;
}
new OperationHandler<Void>().setFailureMesssage("Failed to edit provider " + providerName + ".").setSuccessMessage("Successfully edited provider " + providerName + ".").setOperation(Daemon.setProvider(currentDeployment, providerName, !noValidate, provider)).get();
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff.ChangeType.EDITED 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.ChangeType.EDITED in project halyard by spinnaker.
the class AbstractEditRoleProviderCommand method executeThis.
@Override
protected void executeThis() {
String currentDeployment = getCurrentDeployment();
String roleProviderName = getRoleProviderType() + "";
// Disable validation here, since we don't want an illegal config to prevent us from fixing it.
RoleProvider roleProvider = new OperationHandler<RoleProvider>().setOperation(Daemon.getRoleProvider(currentDeployment, roleProviderName, false)).setFailureMesssage("Failed to get " + roleProviderName + " method.").get();
new OperationHandler<Void>().setOperation(Daemon.setRoleProvider(currentDeployment, roleProviderName, !noValidate, editRoleProvider((T) roleProvider))).setFailureMesssage("Failed to edit " + roleProviderName + " method.").setSuccessMessage("Successfully edited " + roleProviderName + " method.").get();
}
use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff.ChangeType.EDITED in project halyard by spinnaker.
the class AbstractEditSubscriptionCommand method executeThis.
@Override
protected void executeThis() {
String subscriptionName = getSubscriptionName();
String pubsubName = getPubsubName();
String currentDeployment = getCurrentDeployment();
// Disable validation here, since we don't want an illegal config to prevent us from fixing it.
Subscription subscription = new OperationHandler<Subscription>().setFailureMesssage("Failed to get subscription " + subscriptionName + " for pubsub " + pubsubName + ".").setOperation(Daemon.getSubscription(currentDeployment, pubsubName, subscriptionName, false)).get();
int originaHash = subscription.hashCode();
subscription = editSubscription((T) subscription);
if (originaHash == subscription.hashCode()) {
AnsiUi.failure("No changes supplied.");
return;
}
new OperationHandler<Void>().setFailureMesssage("Failed to edit subscription " + subscriptionName + " for pubsub " + pubsubName + ".").setSuccessMessage("Successfully edited subscription " + subscriptionName + " for pubsub " + pubsubName + ".").setOperation(Daemon.setSubscription(currentDeployment, pubsubName, subscriptionName, !noValidate, subscription)).get();
}
Aggregations