Search in sources :

Example 1 with GoogleCanaryAccount

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

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

the class GoogleCanaryAccountValidator method validate.

@Override
public void validate(ConfigProblemSetBuilder p, AbstractCanaryAccount n) {
    super.validate(p, n);
    GoogleCanaryAccount canaryAccount = (GoogleCanaryAccount) n;
    DaemonTaskHandler.message("Validating " + n.getNodeName() + " with " + GoogleCanaryAccountValidator.class.getSimpleName());
    GoogleNamedAccountCredentials credentials = canaryAccount.getNamedAccountCredentials(halyardVersion, p);
    if (credentials == null) {
        return;
    }
    try {
        Compute compute = credentials.getCompute();
        compute.projects().get(canaryAccount.getProject()).execute();
    } catch (IOException e) {
        p.addProblem(Severity.ERROR, "Failed to load project \"" + canaryAccount.getProject() + "\": " + e.getMessage() + ".");
    }
}
Also used : Compute(com.google.api.services.compute.Compute) IOException(java.io.IOException) GoogleCanaryAccount(com.netflix.spinnaker.halyard.config.model.v1.canary.google.GoogleCanaryAccount) GoogleNamedAccountCredentials(com.netflix.spinnaker.clouddriver.google.security.GoogleNamedAccountCredentials)

Aggregations

GoogleCanaryAccount (com.netflix.spinnaker.halyard.config.model.v1.canary.google.GoogleCanaryAccount)2 Compute (com.google.api.services.compute.Compute)1 GoogleNamedAccountCredentials (com.netflix.spinnaker.clouddriver.google.security.GoogleNamedAccountCredentials)1 GoogleCanaryServiceIntegration (com.netflix.spinnaker.halyard.config.model.v1.canary.google.GoogleCanaryServiceIntegration)1 IOException (java.io.IOException)1