use of io.stackgres.common.crd.storages.AzureBlobStorageCredentials in project stackgres by ongres.
the class BackupConfigSourceValidatorTest method setAzureBlobCredentials.
private void setAzureBlobCredentials(final BackupConfigReview review, String accountName, String accountKey, String accessKeyName, String accessKeyKey) {
BackupStorage storage = review.getRequest().getObject().getSpec().getStorage();
storage.setType("azureblob");
storage.setAzureBlob(new AzureBlobStorage());
storage.getAzureBlob().setAzureCredentials(new AzureBlobStorageCredentials());
storage.getAzureBlob().getAzureCredentials().setSecretKeySelectors(new AzureBlobSecretKeySelector());
AzureBlobSecretKeySelector azureBlobSecretKeySelector = storage.getAzureBlob().getAzureCredentials().getSecretKeySelectors();
azureBlobSecretKeySelector.setAccount(new SecretKeySelector(accountKey, accountName));
azureBlobSecretKeySelector.setAccessKey(new SecretKeySelector(accessKeyKey, accessKeyName));
}
use of io.stackgres.common.crd.storages.AzureBlobStorageCredentials 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());
}
}
}
Aggregations