Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Feature/user overridable help page for dashboard (#14)
Browse files Browse the repository at this point in the history
* Add param to publish dashboard to allow a org specific help page or possible i18n or externalized string data file replacements.
  • Loading branch information
fieldju authored Dec 14, 2016
1 parent 139d51c commit 9cbb6e6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

group=com.nike
artifactId=cerberus-lifecycle-cli
version=0.12.0
version=0.13.0
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 =
Expand All @@ -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 {
Expand Down Expand Up @@ -136,8 +147,6 @@ private File extractArtifact(final URL artifactUrl) {
} finally {
IOUtils.closeQuietly(tarArchiveInputStream);
}

return extractionDirectory;
}

private void initClient(final String dashboardBucketName) {
Expand Down

0 comments on commit 9cbb6e6

Please sign in to comment.