Skip to content

Commit 13bab11

Browse files
Yavor16karrgov
authored andcommitted
Fix the problem with the start of deploy-service (cloudfoundry#1806)
* Fix the problem with the start of deploy-service
1 parent 9fa8324 commit 13bab11

2 files changed

Lines changed: 8 additions & 26 deletions

File tree

multiapps-controller-web/src/main/java/org/cloudfoundry/multiapps/controller/web/Messages.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public final class Messages {
5858

5959
// WARN log messages
6060

61-
public static final String NO_OBJECTSTORE_PROVIDER_FOUND = "No ObjectStore provider found!";
61+
public static final String NO_OBJECTSTORE_PROVIDER_FOUND_FOR_0 = "No ObjectStore provider found for {0}!";
6262

6363
// INFO log messages
6464
public static final String ALM_SERVICE_ENV_INITIALIZED = "Deploy service environment initialized";

multiapps-controller-web/src/main/java/org/cloudfoundry/multiapps/controller/web/configuration/bean/factory/ObjectStoreFileStorageFactoryBean.java

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.cloudfoundry.multiapps.controller.persistence.util.EnvironmentServicesFinder;
2424
import org.cloudfoundry.multiapps.controller.web.Constants;
2525
import org.cloudfoundry.multiapps.controller.web.Messages;
26-
import org.cloudfoundry.multiapps.controller.web.configuration.service.ImmutableObjectStoreServiceInfo;
2726
import org.cloudfoundry.multiapps.controller.web.configuration.service.ObjectStoreServiceInfo;
2827
import org.cloudfoundry.multiapps.controller.web.configuration.service.ObjectStoreServiceInfoCreator;
2928
import org.jclouds.ContextBuilder;
@@ -92,11 +91,13 @@ public FileStorage createObjectStoreFromFirstReachableProvider(Map<String, Excep
9291
private Optional<FileStorage> createObjectStoreBasedOnProvider(String objectStoreProviderName,
9392
List<ObjectStoreServiceInfo> providersServiceInfo,
9493
Map<String, Exception> exceptions) {
95-
return switch (objectStoreProviderName) {
96-
case Constants.AZURE -> tryToCreateSdkObjectStore(exceptions, Constants.AZUREBLOB);
97-
case Constants.GCP -> tryToCreateSdkObjectStore(exceptions, Constants.GOOGLE_CLOUD_STORAGE);
98-
default -> tryToCreateJCloudsObjectStore(objectStoreProviderName, providersServiceInfo, exceptions);
99-
};
94+
Optional<ObjectStoreServiceInfo> objectStoreServiceInfoOptional = getAppropriateProvider(objectStoreProviderName,
95+
providersServiceInfo);
96+
if (objectStoreServiceInfoOptional.isEmpty()) {
97+
LOGGER.warn(MessageFormat.format(Messages.NO_OBJECTSTORE_PROVIDER_FOUND_FOR_0, objectStoreProviderName));
98+
return Optional.empty();
99+
}
100+
return tryToCreateObjectStore(objectStoreServiceInfoOptional.get(), exceptions);
100101
}
101102

102103
private Optional<ObjectStoreServiceInfo> getAppropriateProvider(String objectStoreProviderName,
@@ -107,25 +108,6 @@ private Optional<ObjectStoreServiceInfo> getAppropriateProvider(String objectSto
107108
.findFirst();
108109
}
109110

110-
private Optional<FileStorage> tryToCreateJCloudsObjectStore(String objectStoreProviderName,
111-
List<ObjectStoreServiceInfo> providersServiceInfo,
112-
Map<String, Exception> exceptions) {
113-
Optional<ObjectStoreServiceInfo> objectStoreServiceInfoOptional = getAppropriateProvider(objectStoreProviderName,
114-
providersServiceInfo);
115-
if (objectStoreServiceInfoOptional.isPresent()) {
116-
ObjectStoreServiceInfo objectStoreServiceInfo = objectStoreServiceInfoOptional.get();
117-
return tryToCreateObjectStore(objectStoreServiceInfo, exceptions);
118-
}
119-
LOGGER.warn(Messages.NO_OBJECTSTORE_PROVIDER_FOUND);
120-
return Optional.empty();
121-
}
122-
123-
private Optional<FileStorage> tryToCreateSdkObjectStore(Map<String, Exception> exceptions, String providerName) {
124-
return tryToCreateObjectStore(ImmutableObjectStoreServiceInfo.builder()
125-
.provider(providerName)
126-
.build(), exceptions);
127-
}
128-
129111
private Optional<FileStorage> tryToCreateObjectStore(ObjectStoreServiceInfo objectStoreServiceInfo,
130112
Map<String, Exception> exceptions) {
131113
try {

0 commit comments

Comments
 (0)