Search in sources :

Example 1 with AbstractCanaryServiceIntegration

use of com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration in project halyard by spinnaker.

the class CanaryAccountService method deleteAccount.

public void deleteAccount(String deploymentName, String serviceIntegrationName, String accountName) {
    AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName);
    boolean removed = serviceIntegration.getAccounts().removeIf(account -> ((AbstractCanaryAccount) account).getName().equals(accountName));
    if (!removed) {
        throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Canary account \"" + accountName + "\" wasn't found").build());
    }
}
Also used : AbstractCanaryServiceIntegration(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) AbstractCanaryAccount(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)

Example 2 with AbstractCanaryServiceIntegration

use of com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration in project halyard by spinnaker.

the class CanaryAccountService method getCanaryAccount.

public AbstractCanaryAccount getCanaryAccount(String deploymentName, String serviceIntegrationName, String accountName) {
    AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName);
    List<AbstractCanaryAccount> matchingAccounts = (List<AbstractCanaryAccount>) serviceIntegration.getAccounts().stream().filter(a -> (((AbstractCanaryAccount) a).getName().equals(accountName))).collect(Collectors.toList());
    switch(matchingAccounts.size()) {
        case 0:
            throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No account with name \"" + accountName + "\" was found").setRemediation("Check if this account was defined in another service integration, or create a new one").build());
        case 1:
            return matchingAccounts.get(0);
        default:
            throw new IllegalConfigException(new ConfigProblemBuilder(Severity.FATAL, "More than one account named \"" + accountName + "\" was found").setRemediation("Manually delete/rename duplicate canary accounts with name \"" + accountName + "\" in your halconfig file").build());
    }
}
Also used : AbstractCanaryServiceIntegration(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) List(java.util.List) AbstractCanaryAccount(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount) IllegalConfigException(com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)

Example 3 with AbstractCanaryServiceIntegration

use of com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration in project halyard by spinnaker.

the class ListCanaryAccountsCommand method executeThis.

@Override
protected void executeThis() {
    AbstractCanaryServiceIntegration serviceIntegration = CanaryUtils.getServiceIntegrationByName(null, getCurrentDeployment(), getServiceIntegration(), noValidate);
    List<AbstractCanaryAccount> accounts = serviceIntegration.getAccounts();
    if (accounts.isEmpty()) {
        AnsiUi.success("No configured accounts for " + getServiceIntegration() + ".");
    } else {
        AnsiUi.success("Accounts for " + getServiceIntegration() + ":");
        accounts.forEach(account -> AnsiUi.listItem(account.getName()));
    }
}
Also used : AbstractCanaryServiceIntegration(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration) AbstractCanaryAccount(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)

Example 4 with AbstractCanaryServiceIntegration

use of com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration in project halyard by spinnaker.

the class AbstractEnableDisableCanaryServiceIntegrationCommand 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();
    AbstractCanaryServiceIntegration canaryServiceIntegration = CanaryUtils.getServiceIntegrationByName(canary, currentDeployment, getName(), true);
    canaryServiceIntegration.setEnabled(isEnable());
    if (originalHash == canary.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setSuccessMessage("Successfully " + indicativePastPerfectAction() + " canary analysis " + getName() + " service integration.").setFailureMesssage("Failed to " + getCommandName() + " canary analysis " + getName() + " service integration.").setOperation(Daemon.setCanary(currentDeployment, !noValidate, canary)).get();
}
Also used : AbstractCanaryServiceIntegration(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration) Canary(com.netflix.spinnaker.halyard.config.model.v1.canary.Canary) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 5 with AbstractCanaryServiceIntegration

use of com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration in project halyard by spinnaker.

the class CanaryAccountService method addAccount.

public void addAccount(String deploymentName, String serviceIntegrationName, AbstractCanaryAccount newCanaryAccount) {
    AbstractCanaryServiceIntegration serviceIntegration = getServiceIntegration(deploymentName, serviceIntegrationName);
    serviceIntegration.getAccounts().add(newCanaryAccount);
}
Also used : AbstractCanaryServiceIntegration(com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration)

Aggregations

AbstractCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryServiceIntegration)5 AbstractCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.AbstractCanaryAccount)3 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)2 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)1 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)1 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)1 Canary (com.netflix.spinnaker.halyard.config.model.v1.canary.Canary)1 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)1 List (java.util.List)1