Search in sources :

Example 1 with SpinnakerArtifact

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);
    }
}
Also used : SpinnakerArtifact(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerArtifact) TarArchiveInputStream(org.apache.commons.compress.archivers.tar.TarArchiveInputStream) InputStream(java.io.InputStream) HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) ArtifactService(com.netflix.spinnaker.halyard.deploy.services.v1.ArtifactService) ArrayList(java.util.ArrayList) ArchiveEntry(org.apache.commons.compress.archivers.ArchiveEntry) IOException(java.io.IOException) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) ArchiveException(org.apache.commons.compress.archivers.ArchiveException) TarArchiveInputStream(org.apache.commons.compress.archivers.tar.TarArchiveInputStream) ArchiveStreamFactory(org.apache.commons.compress.archivers.ArchiveStreamFactory) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)

Example 2 with SpinnakerArtifact

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));
    });
}
Also used : SpinnakerArtifact(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerArtifact) CustomProfileFactory(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.CustomProfileFactory) ProfileFactory(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.ProfileFactory) CustomProfileFactory(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.CustomProfileFactory)

Example 3 with SpinnakerArtifact

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);
}
Also used : SpinnakerArtifact(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerArtifact)

Example 4 with SpinnakerArtifact

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);
}
Also used : SpinnakerArtifact(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerArtifact)

Example 5 with SpinnakerArtifact

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 "## ";
        }
    };
}
Also used : HalException(com.netflix.spinnaker.halyard.core.error.v1.HalException) SpinnakerRuntimeSettings(com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) DeploymentConfiguration(com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration) URIBuilder(org.apache.http.client.utils.URIBuilder)

Aggregations

SpinnakerArtifact (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerArtifact)4 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)2 HalException (com.netflix.spinnaker.halyard.core.error.v1.HalException)2 SpinnakerRuntimeSettings (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.SpinnakerRuntimeSettings)2 ArtifactService (com.netflix.spinnaker.halyard.deploy.services.v1.ArtifactService)1 CustomProfileFactory (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.CustomProfileFactory)1 ProfileFactory (com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.ProfileFactory)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 ArchiveEntry (org.apache.commons.compress.archivers.ArchiveEntry)1 ArchiveException (org.apache.commons.compress.archivers.ArchiveException)1 ArchiveStreamFactory (org.apache.commons.compress.archivers.ArchiveStreamFactory)1 TarArchiveInputStream (org.apache.commons.compress.archivers.tar.TarArchiveInputStream)1 URIBuilder (org.apache.http.client.utils.URIBuilder)1