use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.ProfileFactory 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.profile.ProfileFactory 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.profile.ProfileFactory in project halyard by spinnaker.
the class SpinnakerMonitoringDaemonService method getProfiles.
@Override
public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
List<Profile> results = new ArrayList<>();
for (Map.Entry<Type, ServiceSettings> entry : endpoints.getAllServiceSettings().entrySet()) {
ServiceSettings settings = entry.getValue();
if (settings.getMonitored() && settings.getEnabled()) {
String serviceName = entry.getKey().getCanonicalName();
String profileName = serviceRegistryProfileName(serviceName);
String profilePath = Paths.get(REGISTRY_OUTPUT_PATH, serviceName + ".yml").toString();
ProfileFactory factory = metricRegistryProfileFactoryBuilder.build(settings);
results.add(factory.getProfile(profileName, profilePath, deploymentConfiguration, endpoints));
}
}
String profileName = monitoringProfileName();
String profilePath = Paths.get(CONFIG_OUTPUT_PATH, profileName).toString();
results.add(spinnakerMonitoringDaemonProfileFactory.getProfile(profileName, profilePath, deploymentConfiguration, endpoints));
return results;
}
use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.ProfileFactory in project halyard by spinnaker.
the class ConsulClientService method getProfiles.
@Override
public List<Profile> getProfiles(DeploymentConfiguration deploymentConfiguration, SpinnakerRuntimeSettings endpoints) {
List<Profile> result = new ArrayList<>();
for (Map.Entry<Type, ServiceSettings> entry : endpoints.getAllServiceSettings().entrySet()) {
ServiceSettings settings = entry.getValue();
Type type = entry.getKey();
if (!settings.getSidecar() && settings.getEnabled()) {
String serviceName = type.getCanonicalName();
String profileName = consulClientService(serviceName);
String profilePath = Paths.get(CLIENT_OUTPUT_PATH, serviceName + ".json").toString();
ProfileFactory factory = consulServiceProfileFactoryBuilder.build(type, settings);
result.add(factory.getProfile(profileName, profilePath, deploymentConfiguration, endpoints));
}
}
String profileName = clientProfileName;
String profilePath = Paths.get(CLIENT_OUTPUT_PATH, profileName.split("/")[1]).toString();
result.add(consulClientProfileFactory.getProfile(profileName, profilePath, deploymentConfiguration, endpoints));
return result;
}
use of com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.ProfileFactory 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