use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.
the class HalconfigParser method saveConfigTo.
private void saveConfigTo(Path path) {
Halconfig local = (Halconfig) DaemonTaskHandler.getContext();
if (local == null) {
throw new HalException(new ConfigProblemBuilder(Severity.WARNING, "No halconfig changes have been made, nothing to write").build());
}
AtomicFileWriter writer = null;
try {
writer = new AtomicFileWriter(path);
writer.write(yamlParser.dump(objectMapper.convertValue(local, Map.class)));
writer.commit();
} catch (IOException e) {
throw new HalException(Severity.FATAL, "Failure writing your halconfig to path \"" + halconfigPath + "\": " + e.getMessage(), e);
} finally {
DaemonTaskHandler.setContext(null);
if (writer != null) {
writer.close();
}
}
}
use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.
the class PubsubService method getAllPubsubs.
public List<Pubsub> getAllPubsubs(String deploymentName) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).withAnyPubsub();
List<Pubsub> matching = lookupService.getMatchingNodesOfType(filter, Pubsub.class);
if (matching.size() == 0) {
throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No pubsubs could be found").build());
} else {
return matching;
}
}
use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.
the class SubscriptionService method deleteSubscription.
public void deleteSubscription(String deploymentName, String pubsubName, String subscriptionName) {
Pubsub pubsub = pubsubService.getPubsub(deploymentName, pubsubName);
boolean removed = pubsub.getSubscriptions().removeIf(subscription -> ((Subscription) subscription).getName().equals(subscriptionName));
if (!removed) {
throw new HalException(new ConfigProblemBuilder(Severity.FATAL, "Subscription \"" + subscriptionName + "\" wasn't found").build());
}
}
use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.
the class HalconfigValidator method validate.
@Override
public void validate(ConfigProblemSetBuilder p, Halconfig n) {
try {
String runningVersion = versionsService.getRunningHalyardVersion();
String latestVersion = versionsService.getLatestHalyardVersion();
if (StringUtils.isEmpty(latestVersion)) {
log.warn("No latest version of halyard published.");
return;
}
if (runningVersion.contains("SNAPSHOT")) {
return;
}
if (Versions.lessThan(runningVersion, latestVersion)) {
ConfigProblemBuilder problemBuilder = p.addProblem(Problem.Severity.WARNING, "There is a newer version of Halyard available (" + latestVersion + "), please update when possible");
File updateScript = new File("/usr/local/bin/update-halyard");
if (updateScript.exists() && !updateScript.isDirectory()) {
problemBuilder.setRemediation("Run 'sudo update-halyard' to upgrade");
} else {
problemBuilder.setRemediation("Run 'sudo apt-get update && sudo apt-get install spinnaker-halyard -y' to upgrade");
}
}
} catch (Exception e) {
log.warn("Unexpected error comparing versions: " + e);
}
}
Aggregations