Search in sources :

Example 1 with Versions

use of com.netflix.spinnaker.halyard.core.registry.v1.Versions in project halyard by spinnaker.

the class ListVersionCommand method executeThis.

@Override
protected void executeThis() {
    String version = new OperationHandler<String>().setOperation(Daemon.getVersion(getCurrentDeployment(), false)).setFailureMesssage("Failed to load your version of Spinnaker.").get();
    Versions versions = new OperationHandler<Versions>().setOperation(Daemon.getVersions()).setFailureMesssage("Failed to load available Spinnaker versions.").setSuccessMessage("You are on version \"" + version + "\", and the following are available:").setFormat(AnsiFormatUtils.Format.STRING).setUserFormatted(true).get();
}
Also used : Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 2 with Versions

use of com.netflix.spinnaker.halyard.core.registry.v1.Versions 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)));
}
Also used : Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException)

Example 3 with Versions

use of com.netflix.spinnaker.halyard.core.registry.v1.Versions 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)));
}
Also used : Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException)

Example 4 with Versions

use of com.netflix.spinnaker.halyard.core.registry.v1.Versions 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)));
}
Also used : Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException)

Example 5 with Versions

use of com.netflix.spinnaker.halyard.core.registry.v1.Versions 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)));
}
Also used : Versions(com.netflix.spinnaker.halyard.core.registry.v1.Versions) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException)

Aggregations

Versions (com.netflix.spinnaker.halyard.core.registry.v1.Versions)6 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)5 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)4 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)1 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)1 DeploymentEnvironment (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment)1 DeploymentType (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment.DeploymentType)1 Validator (com.netflix.spinnaker.halyard.config.model.v1.node.Validator)1 ConfigProblemSetBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemSetBuilder)1 VersionsService (com.netflix.spinnaker.halyard.config.services.v1.VersionsService)1 Problem (com.netflix.spinnaker.halyard.core.problem.v1.Problem)1 Arrays (java.util.Arrays)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 TimeZone (java.util.TimeZone)1 StringUtils (org.apache.commons.lang3.StringUtils)1 ImmutablePair (org.apache.commons.lang3.tuple.ImmutablePair)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Component (org.springframework.stereotype.Component)1