Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public class MinIoHostInfo {
private String host;
private String user;
private String password;
private Map<String, String> bucketAliases;
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,13 @@ public String getType() {

@Override
public Storage createStorage(Data data) {
Storage storage = new MinIoStorage();
MinIoStorage storage = new MinIoStorage();
if (!properties.getMinIo().isEnabled()) {
throw new StorageNotEnabledException("Storage of type [" + MINIO_TYPE + "] is not enabled.");
}
if (data.getStorage().getHost() != null) {
storage.setHost(data.getStorage().getHost());
}
if (data.getStorage().getBucket() != null) {
((MinIoStorage) storage).setBucket(getBucketOrDefault(data.getStorage().getBucket()));
storage.setBucket(getBucketOrDefault(storage.getHost(), data.getStorage().getBucket()));
}
return storage;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Expand Down Expand Up @@ -149,8 +147,8 @@ public String getPath(String caseId, String fieldId, String name) {
return caseId + "/" + fieldId + "-" + name;
}

public static String getBucketOrDefault(String bucket) {
return bucket != null ? bucket : StorageConfigurationProperties.MinIoStorageProperties.DEFAULT_BUCKET;
public String getBucketOrDefault(String host, String bucket) {
return bucket != null ? getMappedBucketIfExists(host, bucket) : StorageConfigurationProperties.MinIoStorageProperties.DEFAULT_BUCKET;
}

protected MinioClient client(String host) {
Expand All @@ -159,4 +157,14 @@ protected MinioClient client(String host) {
.credentials(properties.getMinIo().getHosts(host).getUser(), properties.getMinIo().getHosts(host).getPassword())
.build();
}

protected String getMappedBucketIfExists(String host, String aliasKey) {
MinIoHostInfo hostInfo = properties.getMinIo().getHosts(host);
if (hostInfo != null
&& hostInfo.getBucketAliases() != null
&& hostInfo.getBucketAliases().containsKey(aliasKey)) {
return hostInfo.getBucketAliases().get(aliasKey);
}
return aliasKey;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.netgrif.application.engine.startup.annotation.RunnerOrder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
Expand Down
2 changes: 2 additions & 0 deletions application-engine/src/main/resources/application-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ netgrif:
host: http://127.0.0.1:9000
user: root
password: password
bucket-aliases:
pistucket: uat-pistucket
swagger:
enabled: true
security:
Expand Down
Loading