use of org.bf2.operator.resources.v1alpha1.Versions in project halyard by spinnaker.
the class DeploymentConfiguration method versionOptions.
protected List<String> versionOptions(ConfigProblemSetBuilder psBuilder) {
VersionsService service = psBuilder.getContext().getBean(VersionsService.class);
Versions versions = service.getVersions();
if (versions == null) {
return Collections.emptyList();
} else {
return versions.getVersions().stream().map(Version::getVersion).collect(Collectors.toList());
}
}
use of org.bf2.operator.resources.v1alpha1.Versions in project halyard by spinnaker.
the class DeploymentConfigurationValidator method validate.
@Override
public void validate(ConfigProblemSetBuilder p, DeploymentConfiguration n) {
String timezone = n.getTimezone();
if (Arrays.stream(TimeZone.getAvailableIDs()).noneMatch(t -> t.equals(timezone))) {
p.addProblem(Problem.Severity.ERROR, "Timezone " + timezone + " does not match any known canonical timezone ID").setRemediation("Pick a timezone from those listed here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones");
}
String version = n.getVersion();
Versions versions = versionsService.getVersions();
boolean localGit = n.getDeploymentEnvironment().getType() == DeploymentType.LocalGit;
if (StringUtils.isEmpty(version)) {
p.addProblem(Problem.Severity.WARNING, "You have not yet selected a version of Spinnaker to deploy.", "version");
return;
}
Optional<Versions.IllegalVersion> illegalVersion = versions.getIllegalVersions().stream().filter(v -> v.getVersion().equals(version)).findAny();
if (illegalVersion.isPresent()) {
p.addProblem(Problem.Severity.ERROR, "Version \"" + version + "\" may no longer be deployed with Halyard: " + illegalVersion.get().getReason());
return;
}
if (Versions.isBranch(version) && !localGit) {
p.addProblem(Problem.Severity.FATAL, "You can't run Spinnaker from a branch when your deployment type isn't \"LocalGit\".").setRemediation("Either pick a version (hal version list) or set a different deployment type (hal config deploy edit --type <t>).");
return;
}
try {
if (!Versions.isBranch(version)) {
versionsService.getBillOfMaterials(version);
}
} catch (HalException e) {
if (localGit) {
p.addProblem(Problem.Severity.FATAL, "Could not fetch your desired version.").setRemediation("Is it possible that you're trying to checkout a branch? Prefix the version with \"" + Versions.BRANCH_PREFIX + "\".");
return;
}
p.extend(e);
return;
} catch (Exception e) {
p.addProblem(Problem.Severity.FATAL, "Unexpected error trying to validate version \"" + version + "\": " + e.getMessage(), "version");
return;
}
Optional<Versions.Version> releasedVersion = versions.getVersions().stream().filter(v -> Objects.equals(v.getVersion(), version)).findFirst();
boolean isReleased = releasedVersion.isPresent();
String runningVersion = versionsService.getRunningHalyardVersion();
boolean halyardSnapshotRelease = runningVersion.endsWith("SNAPSHOT");
if (isReleased && !localGit) {
String minimumHalyardVersion = releasedVersion.get().getMinimumHalyardVersion();
if (!halyardSnapshotRelease && !StringUtils.isEmpty(minimumHalyardVersion) && Versions.lessThan(runningVersion, minimumHalyardVersion)) {
p.addProblem(Problem.Severity.ERROR, "Halyard version \"" + runningVersion + "\" is less than Halyard version \"" + minimumHalyardVersion + "\" required for Spinnaker \"" + version + "\"");
}
} else {
// Checks if version is of the form X.Y.Z
if (version.matches("\\d+\\.\\d+\\.\\d+")) {
String majorMinor = Versions.toMajorMinor(version);
Optional<Versions.Version> patchVersion = versions.getVersions().stream().map(v -> new ImmutablePair<>(v, Versions.toMajorMinor(v.getVersion()))).filter(v -> v.getRight() != null).filter(v -> v.getRight().equals(majorMinor)).map(ImmutablePair::getLeft).findFirst();
if (patchVersion.isPresent()) {
p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" was patched by \"" + patchVersion.get().getVersion() + "\". Please upgrade when possible.").setRemediation("https://spinnaker.io/setup/install/upgrades/");
} else {
p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" is no longer supported by the Spinnaker team. Please upgrade when possible.").setRemediation("https://spinnaker.io/setup/install/upgrades/");
}
} else {
p.addProblem(Problem.Severity.WARNING, "Version \"" + version + "\" is not a released (validated) version of Spinnaker.", "version");
}
}
}
use of org.bf2.operator.resources.v1alpha1.Versions in project halyard by spinnaker.
the class ArtifactService method publishLatestSpinnaker.
public void publishLatestSpinnaker(String latestSpinnaker) {
if (googleWriteableProfileRegistry == null) {
throw new HalException(FATAL, NO_WRITER_ENABLED);
}
Versions versionsCollection = versionsService.getVersions();
if (versionsCollection == null) {
throw new HalException(FATAL, NO_GCS_ENABLED);
}
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 org.bf2.operator.resources.v1alpha1.Versions in project halyard by spinnaker.
the class ArtifactService method publishVersion.
public void publishVersion(Version version) {
if (googleWriteableProfileRegistry == null) {
throw new HalException(FATAL, NO_WRITER_ENABLED);
}
Versions versionsCollection = versionsService.getVersions();
if (versionsCollection == null) {
throw new HalException(FATAL, NO_GCS_ENABLED);
}
deleteVersion(versionsCollection, version.getVersion());
versionsCollection.getVersions().add(version);
googleWriteableProfileRegistry.writeVersions(yamlParser.dump(relaxedObjectMapper.convertValue(versionsCollection, Map.class)));
}
use of org.bf2.operator.resources.v1alpha1.Versions in project halyard by spinnaker.
the class ArtifactService method deprecateVersion.
public void deprecateVersion(Version version, String illegalReason) {
if (googleWriteableProfileRegistry == null) {
throw new HalException(FATAL, NO_WRITER_ENABLED);
}
Versions versionsCollection = versionsService.getVersions();
if (versionsCollection == null) {
throw new HalException(FATAL, NO_GCS_ENABLED);
}
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