use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerArtifact in project halyard by spinnaker.
the class RegistryBackedArchiveProfileBuilder method build.
public List<Profile> build(DeploymentConfiguration deploymentConfiguration, String baseOutputPath, SpinnakerArtifact artifact, String archiveName) {
String version = artifactService.getArtifactVersion(deploymentConfiguration.getName(), artifact);
InputStream is;
try {
is = profileRegistry.readArchiveProfile(artifact.getName(), version, archiveName);
} catch (IOException e) {
throw new HalException(Problem.Severity.FATAL, "Error retrieving contents of archive " + archiveName + ".tar.gz", e);
}
TarArchiveInputStream tis;
try {
tis = (TarArchiveInputStream) new ArchiveStreamFactory().createArchiveInputStream("tar", is);
} catch (ArchiveException e) {
throw new HalException(Problem.Severity.FATAL, "Failed to unpack tar archive", e);
}
try {
List<Profile> result = new ArrayList<>();
ArchiveEntry profileEntry = tis.getNextEntry();
while (profileEntry != null) {
if (profileEntry.isDirectory()) {
profileEntry = tis.getNextEntry();
continue;
}
String entryName = profileEntry.getName();
String profileName = String.join("/", artifact.getName(), archiveName, entryName);
String outputPath = Paths.get(baseOutputPath, archiveName, entryName).toString();
String contents = IOUtils.toString(tis);
result.add((new ProfileFactory() {
@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
profile.setContents(profile.getBaseContents());
}
@Override
protected Profile getBaseProfile(String name, String version, String outputFile) {
return new Profile(name, version, outputFile, contents);
}
@Override
protected boolean showEditWarning() {
return false;
}
@Override
protected ArtifactService getArtifactService() {
return artifactService;
}
@Override
public SpinnakerArtifact getArtifact() {
return artifact;
}
@Override
protected String commentPrefix() {
return null;
}
}).getProfile(profileName, outputPath, deploymentConfiguration, null));
profileEntry = tis.getNextEntry();
}
return result;
} catch (IOException e) {
throw new HalException(Problem.Severity.FATAL, "Failed to read profile entry", e);
}
}
use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerArtifact in project halyard by spinnaker.
the class SpinnakerService method customProfile.
public Optional<Profile> customProfile(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings runtimeSettings, Path profilePath, String profileName) {
return customProfileOutputPath(profileName).flatMap(outputPath -> {
SpinnakerArtifact artifact = getArtifact();
ProfileFactory factory = new CustomProfileFactory() {
@Override
public SpinnakerArtifact getArtifact() {
return artifact;
}
protected ArtifactService getArtifactService() {
return artifactService;
}
@Override
protected Path getUserProfilePath() {
return profilePath;
}
};
return Optional.of(factory.getProfile(profileName, outputPath, deploymentConfiguration, runtimeSettings));
});
}
use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerArtifact in project halyard by spinnaker.
the class LocalDebianService method getArtifactId.
default String getArtifactId(String deploymentName) {
SpinnakerArtifact artifact = getArtifact();
String version = getArtifactService().getArtifactVersion(deploymentName, artifact);
return String.format("spinnaker-%s=%s", artifact.getName(), version);
}
use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerArtifact in project halyard by spinnaker.
the class BakeDebianService method getArtifactId.
default String getArtifactId(String deploymentName) {
SpinnakerArtifact artifact = getArtifact();
String version = getArtifactService().getArtifactVersion(deploymentName, artifact);
return String.format("spinnaker-%s=%s", artifact.getName(), version);
}
use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerArtifact in project halyard by spinnaker.
the class MetricRegistryProfileFactoryBuilder method build.
public ProfileFactory build(ServiceSettings settings) {
return new ProfileFactory() {
@Override
protected ArtifactService getArtifactService() {
return artifactService;
}
@Override
protected void setProfile(Profile profile, DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
URI uri;
try {
String baseUrl;
if (settings.getBasicAuthEnabled() != null && settings.getBasicAuthEnabled()) {
baseUrl = settings.getAuthBaseUrl();
} else {
baseUrl = settings.getBaseUrl();
}
uri = new URIBuilder(baseUrl).setHost("localhost").setPath("/spectator/metrics").build();
} catch (URISyntaxException e) {
throw new HalException(Problem.Severity.FATAL, "Unable to build service URL: " + e.getMessage());
}
profile.appendContents("metrics_url: " + uri.toString());
}
@Override
protected Profile getBaseProfile(String name, String version, String outputFile) {
return new Profile(name, version, outputFile, "");
}
@Override
public SpinnakerArtifact getArtifact() {
return SpinnakerArtifact.SPINNAKER_MONITORING_DAEMON;
}
@Override
protected String commentPrefix() {
return "## ";
}
};
}
Aggregations