public String getArtifactVersion(String artifactName) { String version = billOfMaterials.getArtifactVersion(artifactName); return Versions.isLocal(version) ? Versions.fromLocal(version) : version; } }
public String getArtifactCommit(String deploymentName, SpinnakerArtifact artifact) { return getBillOfMaterials(deploymentName).getArtifactCommit(artifact.getName()); }
/** * Should use {@link #getArtifactSources(String, SpinnakerArtifact)} when it supports all types of * deployments. * * To future devs: In order to remove this method for good, the remaining callers of this method * need to be able to incorporate different repository sources. As of this writing (May 2018) the * {@link com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.debian.LocalDebianServiceProvider} * and the * {@link com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.bake.debian.BakeDebianServiceProvider} * are the two hold outs. */ @Deprecated public BillOfMaterials.ArtifactSources getArtifactSources(String deploymentName) { BillOfMaterials bom = getBillOfMaterials(deploymentName); return bom.getArtifactSources(); }
@Override public BillOfMaterials readBom(String version) throws IOException { if (!Versions.isBranch(version)) { throw new IllegalArgumentException("Version must be a branch in the git profile reader"); } String branch = Versions.fromBranch(version); BillOfMaterials.Artifact artifact = new BillOfMaterials.Artifact(); artifact.setCommit(branch); artifact.setVersion(version); BillOfMaterials.Services services = new BillOfMaterials.Services(); services.setDefaultArtifact(artifact); BillOfMaterials.Dependencies dependencies = new BillOfMaterials.Dependencies(); dependencies.setDefaultArtifact(artifact); BillOfMaterials bom = new BillOfMaterials(); bom.setDependencies(dependencies); bom.setVersion(version); bom.setServices(services); return bom; }
public void writeBom(String bomPath) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } 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); }
static private <T> Artifact getFieldArtifact(Class<T> clazz, T obj, String artifactName) { Optional<Field> field = Arrays.stream(clazz.getDeclaredFields()) .filter(f -> { boolean nameMatches = f.getName().equals(artifactName); boolean propertyMatches = false; JsonProperty property = f.getDeclaredAnnotation(JsonProperty.class); if (property != null) { propertyMatches = property.value().equals(artifactName); } return nameMatches || propertyMatches; }) .findFirst(); try { Artifact result = (Artifact) field .orElseThrow(() -> new NoKnownArtifact(artifactName)) .get(obj); if (result == null && !artifactName.equals("defaultArtifact")) { result = getFieldArtifact(clazz, obj, "defaultArtifact"); } if (result == null) { result = new Artifact(); } return result; } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (NullPointerException e) { throw new RuntimeException("Versioned artifact " + artifactName + " is not listed in the BOM"); } }
public void writeBom(String bomPath) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } 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); }
public void writeArtifactConfig(BillOfMaterials bom, String artifactName, String profileName, String contents) { String version = bom.getArtifactVersion(artifactName); String name = googleProfileReader.profilePath(artifactName, version, profileName); writeTextObject(name, contents); }
/** * Should use {@link #getArtifactSources(String, SpinnakerArtifact)} when it supports all types of * deployments. * * To future devs: In order to remove this method for good, the remaining callers of this method * need to be able to incorporate different repository sources. As of this writing (May 2018) the * {@link com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.local.debian.LocalDebianServiceProvider} * and the * {@link com.netflix.spinnaker.halyard.deploy.spinnaker.v1.service.bake.debian.BakeDebianServiceProvider} * are the two hold outs. */ @Deprecated public BillOfMaterials.ArtifactSources getArtifactSources(String deploymentName) { BillOfMaterials bom = getBillOfMaterials(deploymentName); return bom.getArtifactSources(); }
public String getArtifactCommit(String deploymentName, SpinnakerArtifact artifact) { return getBillOfMaterials(deploymentName).getArtifactCommit(artifact.getName()); }
public String getArtifactVersion(String artifactName) { String version = billOfMaterials.getArtifactVersion(artifactName); return Versions.isLocal(version) ? Versions.fromLocal(version) : version; } }
public BillOfMaterials.ArtifactSources getArtifactSources(String deploymentName, SpinnakerArtifact artifact) { BillOfMaterials bom = getBillOfMaterials(deploymentName); BillOfMaterials.ArtifactSources baseline = bom.getArtifactSources(); BillOfMaterials.ArtifactSources overrides = bom.getArtifactSources(artifact.getName()); return mergeArtifactSources(baseline, overrides); }
public String getArtifactVersion(String deploymentName, SpinnakerArtifact artifact) { return getBillOfMaterials(deploymentName).getArtifactVersion(artifact.getName()); }
public BillOfMaterials.ArtifactSources getArtifactSources(String deploymentName, SpinnakerArtifact artifact) { BillOfMaterials bom = getBillOfMaterials(deploymentName); BillOfMaterials.ArtifactSources baseline = bom.getArtifactSources(); BillOfMaterials.ArtifactSources overrides = bom.getArtifactSources(artifact.getName()); return mergeArtifactSources(baseline, overrides); }
public String getArtifactVersion(String deploymentName, SpinnakerArtifact artifact) { return getBillOfMaterials(deploymentName).getArtifactVersion(artifact.getName()); }
@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); } }
@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); } }