Search in sources :

Example 1 with GcsStorageService

use of com.netflix.spinnaker.front50.model.GcsStorageService in project front50 by spinnaker.

the class GcsConfig method applicationPermissionDAO.

@Bean
public ApplicationPermissionDAO applicationPermissionDAO(Storage storage, StorageServiceConfigurationProperties storageServiceConfigurationProperties, Registry registry, CircuitBreakerRegistry circuitBreakerRegistry, GcsProperties gcsProperties) {
    GcsStorageService service = googleCloudStorageService(storage, APPLICATION_PERMISSION_DATA_FILENAME, gcsProperties);
    ObjectKeyLoader keyLoader = new DefaultObjectKeyLoader(service);
    return new DefaultApplicationPermissionDAO(service, Schedulers.from(Executors.newFixedThreadPool(storageServiceConfigurationProperties.getApplicationPermission().getThreadPool())), keyLoader, storageServiceConfigurationProperties.getApplicationPermission().getRefreshMs(), storageServiceConfigurationProperties.getApplicationPermission().getShouldWarmCache(), registry, circuitBreakerRegistry);
}
Also used : DefaultObjectKeyLoader(com.netflix.spinnaker.front50.model.DefaultObjectKeyLoader) DefaultObjectKeyLoader(com.netflix.spinnaker.front50.model.DefaultObjectKeyLoader) ObjectKeyLoader(com.netflix.spinnaker.front50.model.ObjectKeyLoader) DefaultApplicationPermissionDAO(com.netflix.spinnaker.front50.model.application.DefaultApplicationPermissionDAO) GcsStorageService(com.netflix.spinnaker.front50.model.GcsStorageService) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with GcsStorageService

use of com.netflix.spinnaker.front50.model.GcsStorageService in project front50 by spinnaker.

the class GcsConfig method googleCloudStorageService.

private GcsStorageService googleCloudStorageService(Storage storage, String dataFilename, GcsProperties gcsProperties) {
    var executor = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat(GcsStorageService.class.getName() + "-%s").build());
    GcsStorageService service = new GcsStorageService(storage, gcsProperties.getBucket(), gcsProperties.getBucketLocation(), gcsProperties.getRootFolder(), dataFilename, new ObjectMapper().addMixIn(Timestamped.class, TimestampedMixins.class).addMixIn(Pipeline.class, PipelineMixins.class), executor);
    log.info("Using Google Cloud Storage bucket={} in project={}", value("bucket", gcsProperties.getBucket()), value("project", gcsProperties.getProject()));
    return service;
}
Also used : ThreadFactoryBuilder(com.google.common.util.concurrent.ThreadFactoryBuilder) GcsStorageService(com.netflix.spinnaker.front50.model.GcsStorageService) PipelineMixins(com.netflix.spinnaker.front50.jackson.mixins.PipelineMixins) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Pipeline(com.netflix.spinnaker.front50.api.model.pipeline.Pipeline)

Example 3 with GcsStorageService

use of com.netflix.spinnaker.front50.model.GcsStorageService 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 4 with GcsStorageService

use of com.netflix.spinnaker.front50.model.GcsStorageService 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 5 with GcsStorageService

use of com.netflix.spinnaker.front50.model.GcsStorageService 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)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)3 Credentials (com.google.auth.Credentials)2 Storage (com.google.cloud.storage.Storage)2 GcsProperties (com.netflix.spinnaker.front50.config.GcsProperties)2 ExecutorService (java.util.concurrent.ExecutorService)2 GoogleNamedAccountCredentials (com.netflix.spinnaker.clouddriver.google.security.GoogleNamedAccountCredentials)1 Pipeline (com.netflix.spinnaker.front50.api.model.pipeline.Pipeline)1 PipelineMixins (com.netflix.spinnaker.front50.jackson.mixins.PipelineMixins)1 DefaultObjectKeyLoader (com.netflix.spinnaker.front50.model.DefaultObjectKeyLoader)1 ObjectKeyLoader (com.netflix.spinnaker.front50.model.ObjectKeyLoader)1 StorageService (com.netflix.spinnaker.front50.model.StorageService)1 DefaultApplicationPermissionDAO (com.netflix.spinnaker.front50.model.application.DefaultApplicationPermissionDAO)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1 Bean (org.springframework.context.annotation.Bean)1