@Bean public GoogleWriteableProfileRegistry defaultWriteableProfileRegistry(WriteableProfileRegistryProperties properties) { return new GoogleWriteableProfileRegistry(properties); } }
public void writeVersions(String versions) { writeTextObject("versions.yml", versions); }
public void publishLatestHalyard(String latestHalyard) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } Versions versionsCollection = versionsService.getVersions(); if (versionsCollection == null) { throw new HalException(FATAL, NO_GCS_ENABLED); } versionsCollection.setLatestHalyard(latestHalyard); googleWriteableProfileRegistry.writeVersions(yamlParser.dump(relaxedObjectMapper.convertValue(versionsCollection, Map.class))); }
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(String bomPath, String artifactName, String profilePath) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } 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); } }
GoogleWriteableProfileRegistry(WriteableProfileRegistryProperties properties) { HttpTransport httpTransport = GoogleCredentials.buildHttpTransport(); JsonFactory jsonFactory = JacksonFactory.getDefaultInstance(); GoogleCredential credential; try { credential = loadCredential(httpTransport, jsonFactory, properties.getJsonPath()); } catch (IOException e) { throw new RuntimeException("Failed to load json credential", e); } this.storage = new Storage.Builder(httpTransport, jsonFactory, GoogleCredentials.setHttpTimeout(credential)) .setApplicationName("halyard") .build(); this.properties = properties; }
public void publishVersion(Version version) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } Versions versionsCollection = versionsService.getVersions(); if (versionsCollection == null) { throw new HalException(FATAL, NO_GCS_ENABLED); } deleteVersion(versionsCollection, version.getVersion()); versionsCollection.getVersions().add(version); googleWriteableProfileRegistry.writeVersions(yamlParser.dump(relaxedObjectMapper.convertValue(versionsCollection, Map.class))); }
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(String bomPath, String artifactName, String profilePath) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } 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); } }
public void publishLatestHalyard(String latestHalyard) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } Versions versionsCollection = versionsService.getVersions(); if (versionsCollection == null) { throw new HalException(FATAL, NO_GCS_ENABLED); } versionsCollection.setLatestHalyard(latestHalyard); googleWriteableProfileRegistry.writeVersions(yamlParser.dump(relaxedObjectMapper.convertValue(versionsCollection, Map.class))); }
public void writeBom(String version, String contents) { String name = googleProfileReader.bomPath(version); writeTextObject(name, contents); }
public void publishLatestSpinnaker(String latestSpinnaker) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } Versions versionsCollection = versionsService.getVersions(); if (versionsCollection == null) { throw new HalException(FATAL, NO_GCS_ENABLED); } 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))); }
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); }
public void publishLatestSpinnaker(String latestSpinnaker) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } Versions versionsCollection = versionsService.getVersions(); if (versionsCollection == null) { throw new HalException(FATAL, NO_GCS_ENABLED); } 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))); }
public void publishVersion(Version version) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } Versions versionsCollection = versionsService.getVersions(); if (versionsCollection == null) { throw new HalException(FATAL, NO_GCS_ENABLED); } deleteVersion(versionsCollection, version.getVersion()); versionsCollection.getVersions().add(version); googleWriteableProfileRegistry.writeVersions(yamlParser.dump(relaxedObjectMapper.convertValue(versionsCollection, Map.class))); }
public void deprecateVersion(Version version, String illegalReason) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } Versions versionsCollection = versionsService.getVersions(); if (versionsCollection == null) { throw new HalException(FATAL, NO_GCS_ENABLED); } 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))); }
public void deprecateVersion(Version version, String illegalReason) { if (googleWriteableProfileRegistry == null) { throw new HalException(FATAL, NO_WRITER_ENABLED); } Versions versionsCollection = versionsService.getVersions(); if (versionsCollection == null) { throw new HalException(FATAL, NO_GCS_ENABLED); } 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))); }