From 9cbb6e6fb510d43196f7a60438ac7ab6cb12b1e2 Mon Sep 17 00:00:00 2001 From: Justin Field Date: Wed, 14 Dec 2016 15:49:57 -0800 Subject: [PATCH] Feature/user overridable help page for dashboard (#14) * Add param to publish dashboard to allow a org specific help page or possible i18n or externalized string data file replacements. --- gradle.properties | 2 +- .../dashboard/PublishDashboardCommand.java | 7 +++++++ .../consul/CreateConsulClusterOperation.java | 1 + .../dashboard/PublishDashboardOperation.java | 19 ++++++++++++++----- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 1eeb389a..a8227cb5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,4 +16,4 @@ group=com.nike artifactId=cerberus-lifecycle-cli -version=0.12.0 +version=0.13.0 diff --git a/src/main/java/com/nike/cerberus/command/dashboard/PublishDashboardCommand.java b/src/main/java/com/nike/cerberus/command/dashboard/PublishDashboardCommand.java index eb8d8396..957e9214 100644 --- a/src/main/java/com/nike/cerberus/command/dashboard/PublishDashboardCommand.java +++ b/src/main/java/com/nike/cerberus/command/dashboard/PublishDashboardCommand.java @@ -37,10 +37,17 @@ public class PublishDashboardCommand implements Command { @Parameter(names = "--artifact-url", description = "URL to the dashboard artifact.", required = true) private URL artifactUrl; + @Parameter(names = "--override-artifact-url", description = "URL to an artifact that will be extracted and merged into the main artifact before upload to s3.") + private URL overrideArtifactUrl; + public URL getArtifactUrl() { return artifactUrl; } + public URL getOverrideArtifactUrl() { + return overrideArtifactUrl; + } + @Override public String getCommandName() { return COMMAND_NAME; diff --git a/src/main/java/com/nike/cerberus/operation/consul/CreateConsulClusterOperation.java b/src/main/java/com/nike/cerberus/operation/consul/CreateConsulClusterOperation.java index 093cfa52..9b52fb1b 100644 --- a/src/main/java/com/nike/cerberus/operation/consul/CreateConsulClusterOperation.java +++ b/src/main/java/com/nike/cerberus/operation/consul/CreateConsulClusterOperation.java @@ -94,6 +94,7 @@ public void run(final CreateConsulClusterCommand command) { consulParameters.getLaunchConfigParameters().setAmiId(command.getStackDelegate().getAmiId()); consulParameters.getLaunchConfigParameters().setInstanceSize(command.getStackDelegate().getInstanceSize()); consulParameters.getLaunchConfigParameters().setKeyPairName(command.getStackDelegate().getKeyPairName()); + consulParameters.getLaunchConfigParameters().setKeyPairName(command.getStackDelegate().getKeyPairName()); consulParameters.getLaunchConfigParameters().setUserData( ec2UserDataService.getUserData(StackName.CONSUL, command.getStackDelegate().getOwnerGroup())); diff --git a/src/main/java/com/nike/cerberus/operation/dashboard/PublishDashboardOperation.java b/src/main/java/com/nike/cerberus/operation/dashboard/PublishDashboardOperation.java index 1dc5e0c2..91d1f556 100644 --- a/src/main/java/com/nike/cerberus/operation/dashboard/PublishDashboardOperation.java +++ b/src/main/java/com/nike/cerberus/operation/dashboard/PublishDashboardOperation.java @@ -63,6 +63,7 @@ public PublishDashboardOperation(final ConfigStore configStore, final AmazonS3 a @Override public void run(final PublishDashboardCommand command) { final URL artifactUrl = command.getArtifactUrl(); + final URL overrideArtifactUrl = command.getOverrideArtifactUrl(); final BaseOutputs outputParameters = configStore.getBaseStackOutputs(); final String dashboardBucketName = outputParameters.getDashboardBucketName(); @@ -75,7 +76,7 @@ public void run(final PublishDashboardCommand command) { initClient(dashboardBucketName); - final File extractedDirectory = extractArtifact(artifactUrl); + final File extractedDirectory = extractArtifact(artifactUrl, overrideArtifactUrl); try { final MultipleFileUpload multipleFileUpload = @@ -101,10 +102,20 @@ public boolean isRunnable(final PublishDashboardCommand command) { } } - private File extractArtifact(final URL artifactUrl) { + private File extractArtifact(final URL artifactUrl, final URL helpArtifactUrl) { final File extractionDirectory = Files.createTempDir(); - logger.debug("Extracting artifact contents to {}", extractionDirectory.getAbsolutePath()); + logger.info("Extracting artifact contents to {}", extractionDirectory.getAbsolutePath()); + downloadAndExtract(artifactUrl, extractionDirectory); + + if (helpArtifactUrl != null) { + downloadAndExtract(helpArtifactUrl, extractionDirectory); + } + + return extractionDirectory; + } + + private void downloadAndExtract(URL artifactUrl, File extractionDirectory) { ArchiveEntry entry; TarArchiveInputStream tarArchiveInputStream = null; try { @@ -136,8 +147,6 @@ private File extractArtifact(final URL artifactUrl) { } finally { IOUtils.closeQuietly(tarArchiveInputStream); } - - return extractionDirectory; } private void initClient(final String dashboardBucketName) {