Search in sources :

Example 21 with ConfigProblemBuilder

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;
    }
}
Also used : Master(com.netflix.spinnaker.halyard.config.model.v1.node.Master) ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) ConfigNotFoundException(com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException) NodeFilter(com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)

Example 22 with ConfigProblemBuilder

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)));
}
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 23 with ConfigProblemBuilder

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)));
}
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 24 with ConfigProblemBuilder

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);
}
Also used : ConfigProblemBuilder(com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) IOException(java.io.IOException) BillOfMaterials(com.netflix.spinnaker.halyard.core.registry.v1.BillOfMaterials) FileInputStream(java.io.FileInputStream)

Example 25 with ConfigProblemBuilder

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)));
}
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

ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)39 ConfigNotFoundException (com.netflix.spinnaker.halyard.config.error.v1.ConfigNotFoundException)18 NodeFilter (com.netflix.spinnaker.halyard.config.model.v1.node.NodeFilter)17 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)16 IllegalConfigException (com.netflix.spinnaker.halyard.config.error.v1.IllegalConfigException)10 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)4 Versions (com.netflix.spinnaker.halyard.core.registry.v1.Versions)4 IOException (java.io.IOException)4 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)3 ArtifactProvider (com.netflix.spinnaker.halyard.config.model.v1.node.ArtifactProvider)3 Ci (com.netflix.spinnaker.halyard.config.model.v1.node.Ci)3 Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)3 Pubsub (com.netflix.spinnaker.halyard.config.model.v1.node.Pubsub)3 AppengineProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineProvider)3 AwsProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.aws.AwsProvider)3 AzureProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.azure.AzureProvider)3 DCOSProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSProvider)3 DockerRegistryProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryProvider)3 GoogleProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleProvider)3 KubernetesProvider (com.netflix.spinnaker.halyard.config.model.v1.providers.kubernetes.KubernetesProvider)3