use of com.microsoft.azure.serverless.functions.annotation.StorageAccount in project azure-gradle-plugins by lenala.
the class AnnotationHandlerImpl method patchStorageBinding.
private void patchStorageBinding(final Method method, final List<BaseBinding> bindings) {
final Optional<Annotation> storageAccount = Arrays.stream(method.getAnnotations()).filter(a -> a instanceof StorageAccount).findFirst();
if (storageAccount.isPresent()) {
logger.quiet("StorageAccount annotation found.");
final String connectionString = ((StorageAccount) storageAccount.get()).value();
bindings.stream().forEach(b -> {
if (b instanceof StorageBaseBinding) {
final StorageBaseBinding sb = (StorageBaseBinding) b;
// Override storage bindings with empty connection
if (StringUtils.isEmpty(sb.getConnection())) {
sb.setConnection(connectionString);
}
}
});
} else {
logger.quiet("No StorageAccount annotation found.");
}
}
Aggregations