use of com.netflix.spinnaker.halyard.config.model.v1.persistentStorage.RedisPersistentStore in project halyard by spinnaker.
the class Front50ProfileFactory method setProfile.
@Override
public void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
PersistentStorage persistentStorage = deploymentConfiguration.getPersistentStorage();
if (persistentStorage.getPersistentStoreType() == null) {
throw new HalException(Problem.Severity.FATAL, "No persistent storage type was configured.");
}
List<String> files = backupRequiredFiles(persistentStorage, deploymentConfiguration.getName());
Map<String, Map<String, Object>> persistentStorageMap = new HashMap<>();
NodeIterator children = persistentStorage.getChildren();
Node child = children.getNext();
while (child != null) {
if (child instanceof PersistentStore) {
PersistentStore persistentStore = (PersistentStore) child;
URI connectionUri = null;
if (persistentStore instanceof RedisPersistentStore) {
try {
connectionUri = new URI(endpoints.getServices().getRedis().getBaseUrl());
} catch (URISyntaxException e) {
throw new RuntimeException("Malformed redis URL, this is a bug.");
}
}
persistentStore.setConnectionInfo(connectionUri);
PersistentStore.PersistentStoreType persistentStoreType = persistentStore.persistentStoreType();
Map persistentStoreMap = objectMapper.convertValue(persistentStore, Map.class);
persistentStoreMap.put("enabled", persistentStoreType.equals(persistentStorage.getPersistentStoreType()));
persistentStorageMap.put(persistentStoreType.getId(), persistentStoreMap);
}
child = children.getNext();
}
Map<String, Object> spinnakerObjectMap = new HashMap<>();
spinnakerObjectMap.put("spinnaker", persistentStorageMap);
super.setProfile(profile, deploymentConfiguration, endpoints);
profile.appendContents(yamlToString(spinnakerObjectMap)).appendContents(profile.getBaseContents()).setRequiredFiles(files);
}
Aggregations