use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.
the class MasterService method getAllMasters.
public List<Master> getAllMasters(String deploymentName, String ciName) {
NodeFilter filter = new NodeFilter().setDeployment(deploymentName).setCi(ciName).withAnyMaster();
List<Master> matchingMasters = lookupService.getMatchingNodesOfType(filter, Master.class);
if (matchingMasters.size() == 0) {
throw new ConfigNotFoundException(new ConfigProblemBuilder(Severity.FATAL, "No masters could be found").build());
} else {
return matchingMasters;
}
}
use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.
the class ArtifactService method publishLatestSpinnaker.
public void publishLatestSpinnaker(String latestSpinnaker) {
if (googleWriteableProfileRegistry == null) {
throw new HalException(new ConfigProblemBuilder(FATAL, "You need to set the \"spinnaker.config.input.writerEnabled\" property to \"true\" to modify BOM contents.").build());
}
Versions versionsCollection = versionsService.getVersions();
boolean hasLatest = versionsCollection.getVersions().stream().anyMatch(v -> v.getVersion().equals(latestSpinnaker));
if (!hasLatest) {
throw new HalException(FATAL, "Version " + latestSpinnaker + " does not exist in the list of published versions");
}
versionsCollection.setLatestSpinnaker(latestSpinnaker);
googleWriteableProfileRegistry.writeVersions(yamlParser.dump(relaxedObjectMapper.convertValue(versionsCollection, Map.class)));
}
use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.
the class ArtifactService method publishLatestHalyard.
public void publishLatestHalyard(String latestHalyard) {
if (googleWriteableProfileRegistry == null) {
throw new HalException(new ConfigProblemBuilder(FATAL, "You need to set the \"spinnaker.config.input.writerEnabled\" property to \"true\" to modify BOM contents.").build());
}
Versions versionsCollection = versionsService.getVersions();
versionsCollection.setLatestHalyard(latestHalyard);
googleWriteableProfileRegistry.writeVersions(yamlParser.dump(relaxedObjectMapper.convertValue(versionsCollection, Map.class)));
}
use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.
the class ArtifactService method writeBom.
public void writeBom(String bomPath) {
if (googleWriteableProfileRegistry == null) {
throw new HalException(new ConfigProblemBuilder(FATAL, "You need to set the \"spinnaker.config.input.writerEnabled\" property to \"true\" to modify BOM contents.").build());
}
BillOfMaterials bom;
String bomContents;
String version;
try {
bomContents = IOUtils.toString(new FileInputStream(bomPath));
bom = relaxedObjectMapper.convertValue(yamlParser.load(bomContents), BillOfMaterials.class);
version = bom.getVersion();
} catch (IOException e) {
throw new HalException(new ConfigProblemBuilder(FATAL, "Unable to load Bill of Materials: " + e.getMessage()).build());
}
if (version == null) {
throw new HalException(new ConfigProblemBuilder(FATAL, "No version was supplied in this BOM.").build());
}
googleWriteableProfileRegistry.writeBom(bom.getVersion(), bomContents);
}
use of com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder in project halyard by spinnaker.
the class ArtifactService method deprecateVersion.
public void deprecateVersion(Version version, String illegalReason) {
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());
if (!StringUtils.isEmpty(illegalReason)) {
List<Versions.IllegalVersion> illegalVersions = versionsCollection.getIllegalVersions();
if (illegalVersions == null) {
illegalVersions = new ArrayList<>();
}
illegalVersions.add(new Versions.IllegalVersion().setVersion(version.getVersion()).setReason(illegalReason));
versionsCollection.setIllegalVersions(illegalVersions);
}
googleWriteableProfileRegistry.writeVersions(yamlParser.dump(relaxedObjectMapper.convertValue(versionsCollection, Map.class)));
}
Aggregations