Search in sources :

Example 1 with StorageService

use of com.netflix.spinnaker.front50.model.StorageService in project halyard by spinnaker.

the class GoogleCanaryAccountValidator method validate.

@Override
public void validate(ConfigProblemSetBuilder p, GoogleCanaryAccount n) {
    super.validate(p, n);
    DaemonTaskHandler.message("Validating " + n.getNodeName() + " with " + GoogleCanaryAccountValidator.class.getSimpleName());
    GoogleNamedAccountCredentials credentials = getNamedAccountCredentials(p, n);
    if (credentials == null) {
        return;
    }
    GcsProperties gcsProperties = getGoogleCloudStorageProperties(n);
    try {
        Credentials gcsCredentials = GCSConfig.getGcsCredentials(gcsProperties);
        Storage googleCloudStorage = GCSConfig.getGoogleCloudStorage(gcsCredentials, gcsProperties);
        ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat(GcsStorageService.class.getName() + "-%s").build());
        GcsStorageService storageService = new GcsStorageService(googleCloudStorage, n.getBucket(), n.getBucketLocation(), n.getRootFolder(), n.getProject(), new ObjectMapper(), executor);
        storageService.ensureBucketExists();
    } catch (Exception e) {
        p.addProblem(Severity.ERROR, "Failed to ensure the required bucket \"" + n.getBucket() + "\" exists: " + e.getMessage());
    }
}
Also used : Storage(com.google.cloud.storage.Storage) ExecutorService(java.util.concurrent.ExecutorService) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) GcsStorageService(com.netflix.spinnaker.front50.model.GcsStorageService) GoogleNamedAccountCredentials(com.netflix.spinnaker.clouddriver.google.security.GoogleNamedAccountCredentials) GoogleNamedAccountCredentials(com.netflix.spinnaker.clouddriver.google.security.GoogleNamedAccountCredentials) Credentials(com.google.auth.Credentials) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GcsProperties(com.netflix.spinnaker.front50.config.GcsProperties)

Example 2 with StorageService

use of com.netflix.spinnaker.front50.model.StorageService in project halyard by spinnaker.

the class CanaryGCSValidator method validate.

@Override
public void validate(ConfigProblemSetBuilder ps, GoogleCanaryAccount n) {
    String jsonPath = n.getJsonPath();
    try {
        StorageService storageService = new GcsStorageService(n.getBucket(), n.getBucketLocation(), n.getRootFolder(), n.getProject(), jsonPath != null ? jsonPath : "", "halyard", registry);
        storageService.ensureBucketExists();
    } catch (Exception e) {
        e.printStackTrace();
        ps.addProblem(Severity.ERROR, "Failed to ensure the required canary bucket \"" + n.getBucket() + "\" exists: " + e.getMessage());
    }
}
Also used : GcsStorageService(com.netflix.spinnaker.front50.model.GcsStorageService) GcsStorageService(com.netflix.spinnaker.front50.model.GcsStorageService) StorageService(com.netflix.spinnaker.front50.model.StorageService)

Example 3 with StorageService

use of com.netflix.spinnaker.front50.model.StorageService in project halyard by spinnaker.

the class GCSValidator method validate.

@Override
public void validate(ConfigProblemSetBuilder ps, GcsPersistentStore n) {
    GcsProperties gcsProperties = getGoogleCloudStorageProperties(n);
    try {
        Credentials credentials = GCSConfig.getGcsCredentials(gcsProperties);
        Storage googleCloudStorage = GCSConfig.getGoogleCloudStorage(credentials, gcsProperties);
        ExecutorService executor = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat(GcsStorageService.class.getName() + "-%s").build());
        GcsStorageService storageService = new GcsStorageService(googleCloudStorage, n.getBucket(), n.getBucketLocation(), n.getRootFolder(), n.getProject(), new ObjectMapper(), executor);
        storageService.ensureBucketExists();
    } catch (Exception e) {
        ps.addProblem(Severity.ERROR, "Failed to ensure the required bucket \"" + n.getBucket() + "\" exists: " + e.getMessage());
    }
}
Also used : Storage(com.google.cloud.storage.Storage) ExecutorService(java.util.concurrent.ExecutorService) ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) GcsStorageService(com.netflix.spinnaker.front50.model.GcsStorageService) Credentials(com.google.auth.Credentials) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) GcsProperties(com.netflix.spinnaker.front50.config.GcsProperties)

Aggregations

GcsStorageService (com.netflix.spinnaker.front50.model.GcsStorageService)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 Credentials (com.google.auth.Credentials)2 Storage (com.google.cloud.storage.Storage)2 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)2 GcsProperties (com.netflix.spinnaker.front50.config.GcsProperties)2 ExecutorService (java.util.concurrent.ExecutorService)2 GoogleNamedAccountCredentials (com.netflix.spinnaker.clouddriver.google.security.GoogleNamedAccountCredentials)1 StorageService (com.netflix.spinnaker.front50.model.StorageService)1