use of com.netflix.spinnaker.halyard.core.error.v1.HalException in project halyard by spinnaker.
the class ArtifactService method writeArtifactConfig.
public void writeArtifactConfig(String bomPath, String artifactName, String profilePath) {
if (googleWriteableProfileRegistry == null) {
throw new HalException(new ConfigProblemBuilder(FATAL, "You need to set the \"spinnaker.config.input.writerEnabled\" property to \"true\" to modify base-profiles.").build());
}
BillOfMaterials bom;
File profileFile = Paths.get(profilePath).toFile();
String profileContents;
try {
bom = relaxedObjectMapper.convertValue(yamlParser.load(IOUtils.toString(new FileInputStream(bomPath))), BillOfMaterials.class);
} catch (IOException e) {
throw new HalException(new ConfigProblemBuilder(FATAL, "Unable to load Bill of Materials: " + e.getMessage()).build());
}
try {
profileContents = IOUtils.toString(new FileInputStream(profileFile));
} catch (IOException e) {
throw new HalException(new ConfigProblemBuilder(FATAL, "Unable to load profile : " + e.getMessage()).build());
}
googleWriteableProfileRegistry.writeArtifactConfig(bom, artifactName, profileFile.getName(), profileContents);
}
use of com.netflix.spinnaker.halyard.core.error.v1.HalException in project halyard by spinnaker.
the class ArtifactService method publishVersion.
public void publishVersion(Version version) {
if (googleWriteableProfileRegistry == null) {
throw new HalException(new ConfigProblemBuilder(FATAL, "You need to set the \"spinnaker.config.input.writerEnabled\" property to \"true\" to modify your halconfig bucket contents.").build());
}
Versions versionsCollection = versionsService.getVersions();
deleteVersion(versionsCollection, version.getVersion());
versionsCollection.getVersions().add(version);
googleWriteableProfileRegistry.writeVersions(yamlParser.dump(relaxedObjectMapper.convertValue(versionsCollection, Map.class)));
}
use of com.netflix.spinnaker.halyard.core.error.v1.HalException 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);
}
use of com.netflix.spinnaker.halyard.core.error.v1.HalException in project halyard by spinnaker.
the class SpinnakerRuntimeSettings method getServiceSettings.
private ServiceSettings getServiceSettings(String name) {
Field serviceField = getServiceField(name);
serviceField.setAccessible(true);
try {
return (ServiceSettings) serviceField.get(services);
} catch (IllegalAccessException e) {
throw new HalException(Problem.Severity.FATAL, "Can't access service field for " + name + ": " + e.getMessage());
} finally {
serviceField.setAccessible(false);
}
}
use of com.netflix.spinnaker.halyard.core.error.v1.HalException in project halyard by spinnaker.
the class MetricRegistryProfileFactoryBuilder method build.
public ProfileFactory build(ServiceSettings settings) {
return new ProfileFactory() {
@Override
protected ArtifactService getArtifactService() {
return artifactService;
}
@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
URI uri;
try {
String baseUrl;
if (settings.getBasicAuthEnabled() != null && settings.getBasicAuthEnabled()) {
baseUrl = settings.getAuthBaseUrl();
} else {
baseUrl = settings.getBaseUrl();
}
uri = new URIBuilder(baseUrl).setHost("localhost").setPath("/spectator/metrics").build();
} catch (URISyntaxException e) {
throw new HalException(Problem.Severity.FATAL, "Unable to build service URL: " + e.getMessage());
}
profile.appendContents("metrics_url: " + uri.toString());
}
@Override
protected Profile getBaseProfile(String name, String version, String outputFile) {
return new Profile(name, version, outputFile, "");
}
@Override
public SpinnakerArtifact getArtifact() {
return SpinnakerArtifact.SPINNAKER_MONITORING_DAEMON;
}
@Override
protected String commentPrefix() {
return "## ";
}
};
}
Aggregations