use of com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler in project halyard by spinnaker.
the class PublishVersionCommand method executeThis.
@Override
protected void executeThis() {
Versions.Version publishedVersion = new Versions.Version().setVersion(version).setAlias(alias).setChangelog(changelog).setMinimumHalyardVersion(minimumHalyardVersion).setLastUpdate(new Date());
new OperationHandler<Void>().setFailureMesssage("Failed to publish your version.").setSuccessMessage("Successfully published your version.").setOperation(Daemon.publishVersion(publishedVersion)).get();
}
use of com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler in project halyard by spinnaker.
the class EditConfigCommand method executeThis.
@Override
protected void executeThis() {
String currentDeployment = getCurrentDeployment();
DeploymentConfiguration deploymentConfiguration = new OperationHandler<DeploymentConfiguration>().setOperation(Daemon.getDeploymentConfiguration(currentDeployment, false)).setFailureMesssage("Failed to get your deployment configuration for edits.").get();
int hash = deploymentConfiguration.hashCode();
deploymentConfiguration.setTimezone(isSet(timezone) ? timezone : deploymentConfiguration.getTimezone());
if (deploymentConfiguration.hashCode() == hash) {
AnsiUi.error("No changes supplied.");
return;
}
new OperationHandler<Void>().setOperation(Daemon.setDeploymentConfiguration(currentDeployment, !noValidate, deploymentConfiguration)).setFailureMesssage("Failed to apply edits to your deployment configuration").setSuccessMessage("Successfully edited your deployment configuration").get();
}
use of com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler in project halyard by spinnaker.
the class EditDeploymentEnvironmentCommand method executeThis.
@Override
protected void executeThis() {
String currentDeployment = getCurrentDeployment();
DeploymentEnvironment deploymentEnvironment = new OperationHandler<DeploymentEnvironment>().setFailureMesssage("Failed to get your deployment environment.").setOperation(Daemon.getDeploymentEnvironment(currentDeployment, false)).get();
int originalHash = deploymentEnvironment.hashCode();
DeploymentEnvironment.GitConfig gitConfig = deploymentEnvironment.getGitConfig();
if (gitConfig == null) {
gitConfig = new DeploymentEnvironment.GitConfig();
}
gitConfig.setOriginUser(isSet(gitOriginUser) ? gitOriginUser : gitConfig.getOriginUser());
gitConfig.setUpstreamUser(isSet(gitUpstreamUser) ? gitUpstreamUser : gitConfig.getUpstreamUser());
deploymentEnvironment.setGitConfig(gitConfig);
DeploymentEnvironment.Consul consul = deploymentEnvironment.getConsul();
if (consul == null) {
consul = new DeploymentEnvironment.Consul();
}
DeploymentEnvironment.Vault vault = deploymentEnvironment.getVault();
if (vault == null) {
vault = new DeploymentEnvironment.Vault();
}
deploymentEnvironment.setAccountName(isSet(accountName) ? accountName : deploymentEnvironment.getAccountName());
deploymentEnvironment.setBootstrapOnly(isSet(bootstrapOnly) ? bootstrapOnly : deploymentEnvironment.getBootstrapOnly());
deploymentEnvironment.setUpdateVersions(isSet(updateVersions) ? updateVersions : deploymentEnvironment.getUpdateVersions());
deploymentEnvironment.setType(type != null ? type : deploymentEnvironment.getType());
consul.setAddress(isSet(consulAddress) ? consulAddress : consul.getAddress());
consul.setEnabled(isSet(consulEnabled) ? consulEnabled : consul.isEnabled());
deploymentEnvironment.setConsul(consul);
vault.setAddress(isSet(vaultAddress) ? vaultAddress : vault.getAddress());
vault.setEnabled(isSet(vaultEnabled) ? vaultEnabled : vault.isEnabled());
deploymentEnvironment.setVault(vault);
deploymentEnvironment.setLocation(isSet(location) ? location : deploymentEnvironment.getLocation());
if (originalHash == deploymentEnvironment.hashCode()) {
AnsiUi.failure("No changes supplied.");
return;
}
new OperationHandler<Void>().setFailureMesssage("Failed to update your deployment environment.").setSuccessMessage("Successfully updated your deployment environment.").setOperation(Daemon.setDeploymentEnvironment(currentDeployment, !noValidate, deploymentEnvironment)).get();
}
use of com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler in project halyard by spinnaker.
the class AbstractArtifactEditAccountCommand method executeThis.
@Override
protected void executeThis() {
String accountName = getArtifactAccountName();
String providerName = getArtifactProviderName();
String currentDeployment = getCurrentDeployment();
// Disable validation here, since we don't want an illegal config to prevent us from fixing it.
ArtifactAccount account = new OperationHandler<ArtifactAccount>().setFailureMesssage("Failed to get account " + accountName + " for provider " + providerName + ".").setOperation(Daemon.getArtifactAccount(currentDeployment, providerName, accountName, false)).get();
int originaHash = account.hashCode();
account = editArtifactAccount((T) account);
if (originaHash == account.hashCode()) {
AnsiUi.failure("No changes supplied.");
return;
}
new OperationHandler<Void>().setFailureMesssage("Failed to edit artifact account " + accountName + " for artifact provider " + providerName + ".").setSuccessMessage("Successfully edited artifact account " + accountName + " for artifact provider " + providerName + ".").setOperation(Daemon.setArtifactAccount(currentDeployment, providerName, accountName, !noValidate, account)).get();
}
use of com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler in project halyard by spinnaker.
the class EditCanaryGoogleCommand method executeThis.
@Override
protected void executeThis() {
String currentDeployment = getCurrentDeployment();
// Disable validation here, since we don't want an illegal config to prevent us from fixing it.
Canary canary = new OperationHandler<Canary>().setFailureMesssage("Failed to get canary.").setOperation(Daemon.getCanary(currentDeployment, false)).get();
int originalHash = canary.hashCode();
GoogleCanaryServiceIntegration googleCanaryServiceIntegration = (GoogleCanaryServiceIntegration) CanaryUtils.getServiceIntegrationByClass(canary, GoogleCanaryServiceIntegration.class);
googleCanaryServiceIntegration.setGcsEnabled(isSet(gcsEnabled) ? gcsEnabled : googleCanaryServiceIntegration.isGcsEnabled());
googleCanaryServiceIntegration.setStackdriverEnabled(isSet(stackdriverEnabled) ? stackdriverEnabled : googleCanaryServiceIntegration.isStackdriverEnabled());
googleCanaryServiceIntegration.setMetadataCachingIntervalMS(isSet(metadataCachingIntervalMS) ? metadataCachingIntervalMS : googleCanaryServiceIntegration.getMetadataCachingIntervalMS());
if (googleCanaryServiceIntegration.isStackdriverEnabled()) {
googleCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.METRICS_STORE));
} else {
googleCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().remove(AbstractCanaryServiceIntegration.SupportedTypes.METRICS_STORE));
}
if (googleCanaryServiceIntegration.isGcsEnabled()) {
googleCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.CONFIGURATION_STORE));
googleCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.OBJECT_STORE));
} else {
googleCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().remove(AbstractCanaryServiceIntegration.SupportedTypes.CONFIGURATION_STORE));
googleCanaryServiceIntegration.getAccounts().forEach(a -> a.getSupportedTypes().remove(AbstractCanaryServiceIntegration.SupportedTypes.OBJECT_STORE));
}
if (originalHash == canary.hashCode()) {
AnsiUi.failure("No changes supplied.");
return;
}
new OperationHandler<Void>().setOperation(Daemon.setCanary(currentDeployment, !noValidate, canary)).setFailureMesssage("Failed to edit canary analysis Google service integration settings.").setSuccessMessage("Successfully edited canary analysis Google service integration settings.").get();
}
Aggregations