Search in sources :

Example 1 with AwsCredentials

use of io.stackgres.common.crd.storages.AwsCredentials in project stackgres by ongres.

the class BackupConfigSourceValidatorTest method setS3Credentials.

private void setS3Credentials(final BackupConfigReview review, String accessKeyIdName, String accessKeyIdKey, String secretAccessKeyName, String secretAccessKeyKey) {
    BackupStorage storage = review.getRequest().getObject().getSpec().getStorage();
    storage.setType("s3");
    storage.setS3(new AwsS3Storage());
    storage.getS3().setAwsCredentials(new AwsCredentials());
    storage.getS3().getAwsCredentials().setSecretKeySelectors(new AwsSecretKeySelector());
    AwsSecretKeySelector awsSecretKeySelector = storage.getS3().getAwsCredentials().getSecretKeySelectors();
    awsSecretKeySelector.setAccessKeyId(new SecretKeySelector(accessKeyIdKey, accessKeyIdName));
    awsSecretKeySelector.setSecretAccessKey(new SecretKeySelector(secretAccessKeyKey, secretAccessKeyName));
}
Also used : AwsS3Storage(io.stackgres.common.crd.storages.AwsS3Storage) BackupStorage(io.stackgres.common.crd.storages.BackupStorage) AwsSecretKeySelector(io.stackgres.common.crd.storages.AwsSecretKeySelector) AwsCredentials(io.stackgres.common.crd.storages.AwsCredentials) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) AzureBlobSecretKeySelector(io.stackgres.common.crd.storages.AzureBlobSecretKeySelector) AwsSecretKeySelector(io.stackgres.common.crd.storages.AwsSecretKeySelector) GoogleCloudSecretKeySelector(io.stackgres.common.crd.storages.GoogleCloudSecretKeySelector)

Example 2 with AwsCredentials

use of io.stackgres.common.crd.storages.AwsCredentials in project stackgres by ongres.

the class BackupConfigSourceValidatorTest method setS3CompatibleCredentials.

private void setS3CompatibleCredentials(final BackupConfigReview review, String accessKeyIdName, String accessKeyIdKey, String secretAccessKeyName, String secretAccessKeyKey) {
    BackupStorage storage = review.getRequest().getObject().getSpec().getStorage();
    storage.setType("s3compatible");
    storage.setS3Compatible(new AwsS3CompatibleStorage());
    storage.getS3Compatible().setAwsCredentials(new AwsCredentials());
    storage.getS3Compatible().getAwsCredentials().setSecretKeySelectors(new AwsSecretKeySelector());
    AwsSecretKeySelector awsSecretKeySelector = storage.getS3Compatible().getAwsCredentials().getSecretKeySelectors();
    awsSecretKeySelector.setAccessKeyId(new SecretKeySelector(accessKeyIdKey, accessKeyIdName));
    awsSecretKeySelector.setSecretAccessKey(new SecretKeySelector(secretAccessKeyKey, secretAccessKeyName));
}
Also used : BackupStorage(io.stackgres.common.crd.storages.BackupStorage) AwsSecretKeySelector(io.stackgres.common.crd.storages.AwsSecretKeySelector) AwsCredentials(io.stackgres.common.crd.storages.AwsCredentials) SecretKeySelector(io.stackgres.common.crd.SecretKeySelector) AzureBlobSecretKeySelector(io.stackgres.common.crd.storages.AzureBlobSecretKeySelector) AwsSecretKeySelector(io.stackgres.common.crd.storages.AwsSecretKeySelector) GoogleCloudSecretKeySelector(io.stackgres.common.crd.storages.GoogleCloudSecretKeySelector) AwsS3CompatibleStorage(io.stackgres.common.crd.storages.AwsS3CompatibleStorage)

Example 3 with AwsCredentials

use of io.stackgres.common.crd.storages.AwsCredentials in project stackgres by ongres.

the class BackupConfigStorageValidator method validate.

@Override
public void validate(BackupConfigReview review) throws ValidationFailed {
    Operation operation = review.getRequest().getOperation();
    if (operation == Operation.CREATE || operation == Operation.UPDATE) {
        String namespace = review.getRequest().getObject().getMetadata().getNamespace();
        String storageType = review.getRequest().getObject().getSpec().getStorage().getType();
        if (storageType.equals("s3") && review.getRequest().getObject().getSpec().getStorage().getS3() != null) {
            AwsCredentials credentials = review.getRequest().getObject().getSpec().getStorage().getS3().getAwsCredentials();
            checkSecret(namespace, storageType, "accessKeyId", credentials.getSecretKeySelectors().getAccessKeyId());
            checkSecret(namespace, storageType, "secretAccessKey", credentials.getSecretKeySelectors().getSecretAccessKey());
        }
        if (storageType.equals("s3compatible") && review.getRequest().getObject().getSpec().getStorage().getS3Compatible() != null) {
            AwsCredentials credentials = review.getRequest().getObject().getSpec().getStorage().getS3Compatible().getAwsCredentials();
            checkSecret(namespace, storageType, "accessKeyId", credentials.getSecretKeySelectors().getAccessKeyId());
            checkSecret(namespace, storageType, "secretAccessKey", credentials.getSecretKeySelectors().getSecretAccessKey());
        }
        if (storageType.equals("azureblob") && review.getRequest().getObject().getSpec().getStorage().getAzureBlob() != null) {
            AzureBlobStorageCredentials credentials = review.getRequest().getObject().getSpec().getStorage().getAzureBlob().getAzureCredentials();
            checkSecret(namespace, storageType, "account", credentials.getSecretKeySelectors().getAccount());
            checkSecret(namespace, storageType, "accessKey", credentials.getSecretKeySelectors().getAccessKey());
        }
        if (storageType.equals("gcs") && review.getRequest().getObject().getSpec().getStorage().getGcs() != null && review.getRequest().getObject().getSpec().getStorage().getGcs().getCredentials().getSecretKeySelectors() != null) {
            GoogleCloudCredentials credentials = review.getRequest().getObject().getSpec().getStorage().getGcs().getCredentials();
            checkSecret(namespace, storageType, "serviceAccountJsonKey", credentials.getSecretKeySelectors().getServiceAccountJsonKey());
        }
    }
}
Also used : GoogleCloudCredentials(io.stackgres.common.crd.storages.GoogleCloudCredentials) AwsCredentials(io.stackgres.common.crd.storages.AwsCredentials) AzureBlobStorageCredentials(io.stackgres.common.crd.storages.AzureBlobStorageCredentials) Operation(io.stackgres.operatorframework.admissionwebhook.Operation)

Aggregations

AwsCredentials (io.stackgres.common.crd.storages.AwsCredentials)3 SecretKeySelector (io.stackgres.common.crd.SecretKeySelector)2 AwsSecretKeySelector (io.stackgres.common.crd.storages.AwsSecretKeySelector)2 AzureBlobSecretKeySelector (io.stackgres.common.crd.storages.AzureBlobSecretKeySelector)2 BackupStorage (io.stackgres.common.crd.storages.BackupStorage)2 GoogleCloudSecretKeySelector (io.stackgres.common.crd.storages.GoogleCloudSecretKeySelector)2 AwsS3CompatibleStorage (io.stackgres.common.crd.storages.AwsS3CompatibleStorage)1 AwsS3Storage (io.stackgres.common.crd.storages.AwsS3Storage)1 AzureBlobStorageCredentials (io.stackgres.common.crd.storages.AzureBlobStorageCredentials)1 GoogleCloudCredentials (io.stackgres.common.crd.storages.GoogleCloudCredentials)1 Operation (io.stackgres.operatorframework.admissionwebhook.Operation)1