Search in sources :

Example 1 with GoogleCanaryServiceIntegration

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

the class GoogleAddCanaryAccountCommand method buildAccount.

@Override
protected AbstractCanaryAccount buildAccount(Canary canary, String accountName) {
    GoogleCanaryAccount account = (GoogleCanaryAccount) new GoogleCanaryAccount().setName(accountName);
    account.setProject(project).setJsonPath(jsonPath);
    account.setBucket(bucket).setBucketLocation(bucketLocation);
    account.setRootFolder(isSet(rootFolder) ? rootFolder : account.getRootFolder());
    if (account.getBucket() == null) {
        String bucketName = "spin-kayenta-" + UUID.randomUUID().toString();
        AnsiUi.raw("Generated canary bucket name: " + bucketName);
        account.setBucket(bucketName);
    }
    GoogleCanaryServiceIntegration googleCanaryServiceIntegration = (GoogleCanaryServiceIntegration) CanaryUtils.getServiceIntegrationByClass(canary, GoogleCanaryServiceIntegration.class);
    if (googleCanaryServiceIntegration.isStackdriverEnabled()) {
        account.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.METRICS_STORE);
    }
    if (googleCanaryServiceIntegration.isGcsEnabled()) {
        account.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.CONFIGURATION_STORE);
        account.getSupportedTypes().add(AbstractCanaryServiceIntegration.SupportedTypes.OBJECT_STORE);
    }
    return account;
}
Also used : GoogleCanaryServiceIntegration(com.netflix.spinnaker.halyard.config.model.v1.canary.google.GoogleCanaryServiceIntegration) GoogleCanaryAccount(com.netflix.spinnaker.halyard.config.model.v1.canary.google.GoogleCanaryAccount)

Example 2 with GoogleCanaryServiceIntegration

use of com.netflix.spinnaker.halyard.config.model.v1.canary.google.GoogleCanaryServiceIntegration 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

GoogleCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.google.GoogleCanaryServiceIntegration)2 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)1 Canary (com.netflix.spinnaker.halyard.config.model.v1.canary.Canary)1 GoogleCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.google.GoogleCanaryAccount)1