use of com.netflix.spinnaker.halyard.core.error.v1.HalException in project halyard by spinnaker.
the class LocalServiceProvider method getLocalService.
public <S> LocalService<S> getLocalService(SpinnakerService.Type type, Class<S> clazz) {
Field serviceField = getField(type.getCanonicalName() + "service");
if (serviceField == null) {
return null;
}
serviceField.setAccessible(true);
try {
return (LocalService<S>) serviceField.get(this);
} catch (IllegalAccessException e) {
throw new HalException(Problem.Severity.FATAL, "Can't access service field for " + type + ": " + e.getMessage());
} finally {
serviceField.setAccessible(false);
}
}
use of com.netflix.spinnaker.halyard.core.error.v1.HalException 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.core.error.v1.HalException 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.core.error.v1.HalException 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.core.error.v1.HalException 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