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