Search in sources :

Example 1 with BillOfMaterials

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

the class DeployService method getDeploymentDetails.

private DeploymentDetails getDeploymentDetails(DeploymentConfiguration deploymentConfiguration) {
    String deploymentName = deploymentConfiguration.getName();
    BillOfMaterials billOfMaterials = artifactService.getBillOfMaterials(deploymentName);
    DeploymentEnvironment.DeploymentType type = deploymentConfiguration.getDeploymentEnvironment().getType();
    switch(type) {
        case BakeDebian:
        case LocalDebian:
        case LocalGit:
            return new DeploymentDetails().setDeploymentConfiguration(deploymentConfiguration).setDeploymentName(deploymentName).setBillOfMaterials(billOfMaterials);
        case Distributed:
            DeploymentEnvironment deploymentEnvironment = deploymentConfiguration.getDeploymentEnvironment();
            String accountName = deploymentEnvironment.getAccountName();
            if (accountName == null || accountName.isEmpty()) {
                throw new HalException(FATAL, "An account name must be " + "specified as the desired place to deploy your simple clustered deployment.");
            }
            Account account = accountService.getAnyProviderAccount(deploymentConfiguration.getName(), accountName);
            return new AccountDeploymentDetails().setAccount(account).setDeploymentConfiguration(deploymentConfiguration).setDeploymentName(deploymentName).setBillOfMaterials(billOfMaterials);
        default:
            throw new IllegalArgumentException("Unrecognized deployment type " + type);
    }
}
Also used : AccountDeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.AccountDeploymentDetails) DeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails) Account(com.netflix.spinnaker.halyard.config.model.v1.node.Account) AccountDeploymentDetails(com.netflix.spinnaker.halyard.deploy.deployment.v1.AccountDeploymentDetails) DeploymentEnvironment(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) BillOfMaterials(com.netflix.spinnaker.halyard.core.registry.v1.BillOfMaterials)

Example 2 with BillOfMaterials

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

the class BomVersionCommand method executeThis.

@Override
protected void executeThis() {
    BillOfMaterials bom = new OperationHandler<BillOfMaterials>().setOperation(Daemon.getBillOfMaterials(getVersion())).setFailureMesssage("Failed to get Bill of Materials for version " + getVersion()).get();
    String result;
    if (artifactName == null) {
        AnsiFormatUtils.Format format = GlobalOptions.getGlobalOptions().getOutput();
        if (format == null) {
            format = AnsiFormatUtils.Format.YAML;
        }
        result = AnsiFormatUtils.format(format, bom);
    } else {
        result = bom.getArtifactVersion(artifactName);
    }
    AnsiPrinter.out.println(result);
}
Also used : BillOfMaterials(com.netflix.spinnaker.halyard.core.registry.v1.BillOfMaterials) AnsiFormatUtils(com.netflix.spinnaker.halyard.cli.ui.v1.AnsiFormatUtils)

Example 3 with BillOfMaterials

use of com.netflix.spinnaker.halyard.core.registry.v1.BillOfMaterials 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 4 with BillOfMaterials

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

the class ArtifactService method writeArtifactConfig.

public void writeArtifactConfig(String bomPath, String artifactName, String profilePath) {
    if (googleWriteableProfileRegistry == null) {
        throw new HalException(new ConfigProblemBuilder(FATAL, "You need to set the \"spinnaker.config.input.writerEnabled\" property to \"true\" to modify base-profiles.").build());
    }
    BillOfMaterials bom;
    File profileFile = Paths.get(profilePath).toFile();
    String profileContents;
    try {
        bom = relaxedObjectMapper.convertValue(yamlParser.load(IOUtils.toString(new FileInputStream(bomPath))), BillOfMaterials.class);
    } catch (IOException e) {
        throw new HalException(new ConfigProblemBuilder(FATAL, "Unable to load Bill of Materials: " + e.getMessage()).build());
    }
    try {
        profileContents = IOUtils.toString(new FileInputStream(profileFile));
    } catch (IOException e) {
        throw new HalException(new ConfigProblemBuilder(FATAL, "Unable to load profile : " + e.getMessage()).build());
    }
    googleWriteableProfileRegistry.writeArtifactConfig(bom, artifactName, profileFile.getName(), profileContents);
}
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) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

BillOfMaterials (com.netflix.spinnaker.halyard.core.registry.v1.BillOfMaterials)4 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)3 ConfigProblemBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemBuilder)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 AnsiFormatUtils (com.netflix.spinnaker.halyard.cli.ui.v1.AnsiFormatUtils)1 Account (com.netflix.spinnaker.halyard.config.model.v1.node.Account)1 DeploymentEnvironment (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentEnvironment)1 AccountDeploymentDetails (com.netflix.spinnaker.halyard.deploy.deployment.v1.AccountDeploymentDetails)1 DeploymentDetails (com.netflix.spinnaker.halyard.deploy.deployment.v1.DeploymentDetails)1 File (java.io.File)1