Search in sources :

Example 31 with OperationHandler

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();
}
Also used : Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) Date(java.util.Date) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 32 with OperationHandler

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();
}
Also used : DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 33 with OperationHandler

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();
}
Also used : DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 34 with OperationHandler

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();
}
Also used : ArtifactAccount(com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 35 with OperationHandler

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();
}
Also used : GoogleCanaryServiceIntegration(com.netflix.spinnaker.halyard.config.model.v1.canary.google.GoogleCanaryServiceIntegration) Canary(com.netflix.spinnaker.halyard.config.model.v1.canary.Canary) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Aggregations

OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)38 Canary (com.netflix.spinnaker.halyard.config.model.v1.canary.Canary)6 AbstractCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)2 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)2 ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)2 BaseImage (com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage)2 Master (com.netflix.spinnaker.halyard.config.model.v1.node.Master)2 Subscription (com.netflix.spinnaker.halyard.config.model.v1.node.Subscription)2 DCOSCluster (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSCluster)2 Versions (com.netflix.spinnaker.halyard.core.registry.v1.Versions)2 AbstractCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration)1 AwsCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.aws.AwsCanaryServiceIntegration)1 GoogleCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.google.GoogleCanaryServiceIntegration)1 PrometheusCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.prometheus.PrometheusCanaryServiceIntegration)1 BakeryDefaults (com.netflix.spinnaker.halyard.config.model.v1.node.BakeryDefaults)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1 DeploymentEnvironment (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment)1 Features (com.netflix.spinnaker.halyard.config.model.v1.node.Features)1 MetricStore (com.netflix.spinnaker.halyard.config.model.v1.node.MetricStore)1 MetricStores (com.netflix.spinnaker.halyard.config.model.v1.node.MetricStores)1