Search in sources :

Example 11 with EDITED

use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff.ChangeType.EDITED in project halyard by spinnaker.

the class AbstractEditAuthnMethodCommand method executeThis.

@Override
protected void executeThis() {
    String currentDeployment = getCurrentDeployment();
    String authnMethodName = getMethod().id;
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    AuthnMethod authnMethod = new OperationHandler<AuthnMethod>().setOperation(Daemon.getAuthnMethod(currentDeployment, authnMethodName, false)).setFailureMesssage("Failed to get " + authnMethodName + " method.").get();
    new OperationHandler<Void>().setOperation(Daemon.setAuthnMethod(currentDeployment, authnMethodName, !noValidate, editAuthnMethod((T) authnMethod))).setFailureMesssage("Failed to edit " + authnMethodName + " method.").setSuccessMessage("Successfully edited " + authnMethodName + " method.").get();
}
Also used : AuthnMethod(com.netflix.spinnaker.halyard.config.model.v1.security.AuthnMethod) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 12 with EDITED

use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff.ChangeType.EDITED in project halyard by spinnaker.

the class AbstractEditAccountCommand method executeThis.

@Override
protected void executeThis() {
    String accountName = getAccountName();
    String providerName = getProviderName();
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    Account account = new OperationHandler<Account>().setFailureMesssage("Failed to get account " + accountName + " for provider " + providerName + ".").setOperation(Daemon.getAccount(currentDeployment, providerName, accountName, false)).get();
    int originaHash = account.hashCode();
    account = editAccount((T) account);
    account.setRequiredGroupMembership(updateStringList(account.getRequiredGroupMembership(), requiredGroupMembership, addRequiredGroupMembership, removeRequiredGroupMembership));
    account.setProviderVersion(isSet(providerVersion) ? providerVersion : account.getProviderVersion());
    if (originaHash == account.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setFailureMesssage("Failed to edit account " + accountName + " for provider " + providerName + ".").setSuccessMessage("Successfully edited account " + accountName + " for provider " + providerName + ".").setOperation(Daemon.setAccount(currentDeployment, providerName, accountName, !noValidate, account)).get();
}
Also used : Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 13 with EDITED

use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff.ChangeType.EDITED in project halyard by spinnaker.

the class AbstractEditBaseImageCommand method executeThis.

@Override
protected void executeThis() {
    String baseImageId = getBaseImageId();
    String providerName = getProviderName();
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    BaseImage baseImage = new OperationHandler<BaseImage>().setFailureMesssage("Failed to get base image " + baseImageId + " in" + providerName + "'s bakery.").setOperation(Daemon.getBaseImage(currentDeployment, providerName, baseImageId, false)).get();
    int originalHash = baseImage.hashCode();
    BaseImage.ImageSettings imageSettings = baseImage.getBaseImage();
    if (imageSettings == null) {
        throw new RuntimeException("Image settings cannot be deleted during an edit. This is a bug in the " + getProviderName() + " provider's implementation of halyard.");
    }
    imageSettings.setId(isSet(id) ? id : imageSettings.getId());
    imageSettings.setShortDescription(isSet(shortDescription) ? shortDescription : imageSettings.getShortDescription());
    imageSettings.setDetailedDescription(isSet(detailedDescription) ? detailedDescription : imageSettings.getDetailedDescription());
    imageSettings.setPackageType(isSet(packageType) ? packageType : imageSettings.getPackageType());
    imageSettings.setTemplateFile(isSet(templateFile) ? templateFile : imageSettings.getTemplateFile());
    baseImage = editBaseImage((T) baseImage);
    if (originalHash == baseImage.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setFailureMesssage("Failed to edit base image " + baseImageId + " in" + providerName + "'s bakery.").setSuccessMessage("Successfully edited base image " + baseImageId + " in" + providerName + "'s bakery.").setOperation(Daemon.setBaseImage(currentDeployment, providerName, baseImageId, !noValidate, baseImage)).get();
}
Also used : BaseImage(com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 14 with EDITED

use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff.ChangeType.EDITED in project halyard by spinnaker.

the class AbstractPersistentStoreEditCommand method executeThis.

@Override
protected void executeThis() {
    String persistentStoreType = getPersistentStoreType();
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    PersistentStore persistentStore = new OperationHandler<PersistentStore>().setFailureMesssage("Failed to get persistent store \"" + persistentStoreType + "\".").setOperation(Daemon.getPersistentStore(currentDeployment, persistentStoreType, false)).get();
    int originalHash = persistentStore.hashCode();
    persistentStore = editPersistentStore((T) persistentStore);
    if (originalHash == persistentStore.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setFailureMesssage("Failed to edit persistent store \"" + persistentStoreType + "\".").setSuccessMessage("Successfully edited persistent store \"" + persistentStoreType + "\".").setOperation(Daemon.setPersistentStore(currentDeployment, persistentStoreType, !noValidate, persistentStore)).get();
}
Also used : PersistentStore(com.netflix.spinnaker.halyard.config.model.v1.node.PersistentStore) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 15 with EDITED

use of com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff.ChangeType.EDITED in project halyard by spinnaker.

the class DCOSEditClusterCommand method executeThis.

@Override
protected void executeThis() {
    String clusterName = getClusterName();
    String providerName = getProviderName();
    String currentDeployment = getCurrentDeployment();
    // Disable validation here, since we don't want an illegal config to prevent us from fixing it.
    DCOSCluster cluster = (DCOSCluster) new OperationHandler<Cluster>().setFailureMesssage("Failed to get cluster " + clusterName + " for provider " + providerName + ".").setOperation(Daemon.getCluster(currentDeployment, providerName, clusterName, false)).get();
    int originalHash = cluster.hashCode();
    if (!isStringEmpty(dcosUrl)) {
        cluster.setDcosUrl(dcosUrl);
    }
    if (!isStringEmpty(caCertFile)) {
        cluster.setCaCertFile(caCertFile);
    }
    if (removeCaCertFile) {
        cluster.setCaCertFile(null);
    }
    if (Objects.nonNull(insecureSkipTlsVerify)) {
        cluster.setInsecureSkipTlsVerify(insecureSkipTlsVerify);
    }
    if (!isStringEmpty(loadBalancerImage)) {
        DCOSCluster.LoadBalancer loadBalancer = cluster.getLoadBalancer();
        if (loadBalancer == null) {
            loadBalancer = new DCOSCluster.LoadBalancer();
            cluster.setLoadBalancer(loadBalancer);
        }
        loadBalancer.setImage(loadBalancerImage);
    }
    if (!isStringEmpty(loadBalancerServiceAccountSecret)) {
        DCOSCluster.LoadBalancer loadBalancer = cluster.getLoadBalancer();
        if (loadBalancer == null) {
            loadBalancer = new DCOSCluster.LoadBalancer();
            cluster.setLoadBalancer(loadBalancer);
        }
        loadBalancer.setServiceAccountSecret(loadBalancerServiceAccountSecret);
    }
    if (removeLoadBalancer) {
        cluster.setLoadBalancer(null);
    }
    if (originalHash == cluster.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setFailureMesssage("Failed to edit cluster " + clusterName + " for provider " + providerName + ".").setSuccessMessage("Successfully edited cluster " + clusterName + " for provider " + providerName + ".").setOperation(Daemon.setCluster(currentDeployment, providerName, clusterName, !noValidate, cluster)).get();
}
Also used : DCOSCluster(com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSCluster) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Aggregations

OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)20 Canary (com.netflix.spinnaker.halyard.config.model.v1.canary.Canary)4 AbstractCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)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 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)1 ArtifactAccount (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactAccount)1 BakeryDefaults (com.netflix.spinnaker.halyard.config.model.v1.node.BakeryDefaults)1 BaseImage (com.netflix.spinnaker.halyard.config.model.v1.node.BaseImage)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1 Master (com.netflix.spinnaker.halyard.config.model.v1.node.Master)1 MetricStore (com.netflix.spinnaker.halyard.config.model.v1.node.MetricStore)1 NodeDiff (com.netflix.spinnaker.halyard.config.model.v1.node.NodeDiff)1 Notification (com.netflix.spinnaker.halyard.config.model.v1.node.Notification)1 PersistentStorage (com.netflix.spinnaker.halyard.config.model.v1.node.PersistentStorage)1 PersistentStore (com.netflix.spinnaker.halyard.config.model.v1.node.PersistentStore)1 Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)1 Subscription (com.netflix.spinnaker.halyard.config.model.v1.node.Subscription)1 DCOSCluster (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSCluster)1