Skip to content

Commit

Permalink
Expand relative paths passed to CLI (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwander committed Mar 1, 2017
1 parent 0e68888 commit 8d86543
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.NestableCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.converter.PathExpandingConverter;
import com.netflix.spinnaker.halyard.cli.services.v1.Daemon;
import com.netflix.spinnaker.halyard.cli.ui.v1.AnsiUi;
import lombok.AccessLevel;
Expand All @@ -38,6 +39,7 @@ public class PublishBomCommand extends NestableCommand {

@Parameter(
names = "--bom-path",
converter = PathExpandingConverter.class,
required = true,
description = "The path to the BOM owning the artifact to publish."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.NestableCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.converter.PathExpandingConverter;
import com.netflix.spinnaker.halyard.cli.services.v1.Daemon;
import com.netflix.spinnaker.halyard.cli.ui.v1.AnsiUi;
import lombok.AccessLevel;
Expand All @@ -38,13 +39,15 @@ public class PublishProfileCommand extends NestableCommand {

@Parameter(
names = "--bom-path",
converter = PathExpandingConverter.class,
required = true,
description = "The path to the BOM owning the artifact to publish."
)
private String bomPath;

@Parameter(
names = "--profile-path",
converter = PathExpandingConverter.class,
required = true,
description = "The path to the artifact profile to publish."
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.account.AbstractAddAccountCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.google.CommonGoogleCommandProperties;
import com.netflix.spinnaker.halyard.cli.command.v1.converter.PathExpandingConverter;
import com.netflix.spinnaker.halyard.config.model.v1.node.Account;
import com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineAccount;

Expand All @@ -38,6 +39,7 @@ protected String getProviderName() {

@Parameter(
names = "--json-path",
converter = PathExpandingConverter.class,
description = CommonGoogleCommandProperties.JSON_PATH_DESCRIPTION
)
private String jsonPath;
Expand Down Expand Up @@ -70,6 +72,7 @@ protected String getProviderName() {

@Parameter(
names = "--ssh-private-key-file-path",
converter = PathExpandingConverter.class,
description = AppengineCommandProperties.SSH_PRIVATE_KEY_FILE_PATH
)
private String sshPrivateKeyFilePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.beust.jcommander.Parameter;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.account.AbstractEditAccountCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.google.CommonGoogleCommandProperties;
import com.netflix.spinnaker.halyard.cli.command.v1.converter.PathExpandingConverter;
import com.netflix.spinnaker.halyard.config.model.v1.node.Account;
import com.netflix.spinnaker.halyard.config.model.v1.providers.appengine.AppengineAccount;

Expand All @@ -36,6 +37,7 @@ protected String getProviderName() {

@Parameter(
names = "--json-path",
converter = PathExpandingConverter.class,
description = CommonGoogleCommandProperties.JSON_PATH_DESCRIPTION
)
private String jsonPath;
Expand Down Expand Up @@ -68,6 +70,7 @@ protected String getProviderName() {

@Parameter(
names = "--ssh-private-key-file-path",
converter = PathExpandingConverter.class,
description = AppengineCommandProperties.SSH_PRIVATE_KEY_FILE_PATH
)
private String sshPrivateKeyFilePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.account.AbstractAddAccountCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.converter.PathExpandingConverter;
import com.netflix.spinnaker.halyard.config.model.v1.node.Account;
import com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount;
import java.util.ArrayList;
Expand Down Expand Up @@ -53,6 +54,7 @@ protected String getProviderName() {

@Parameter(
names = "--password-file",
converter = PathExpandingConverter.class,
description = DockerRegistryCommandProperties.PASSWORD_FILE_DESCRIPTION
)
private String passwordFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.beust.jcommander.Parameter;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.account.AbstractEditAccountCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.converter.PathExpandingConverter;
import com.netflix.spinnaker.halyard.config.model.v1.node.Account;
import com.netflix.spinnaker.halyard.config.model.v1.providers.dockerRegistry.DockerRegistryAccount;
import java.util.ArrayList;
Expand Down Expand Up @@ -62,6 +63,7 @@ protected String getProviderName() {

@Parameter(
names = "--password-file",
converter = PathExpandingConverter.class,
description = DockerRegistryCommandProperties.PASSWORD_FILE_DESCRIPTION
)
private String passwordFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.account.AbstractAddAccountCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.converter.PathExpandingConverter;
import com.netflix.spinnaker.halyard.config.model.v1.node.Account;
import com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleAccount;
import java.util.ArrayList;
Expand All @@ -39,6 +40,7 @@ protected String getProviderName() {

@Parameter(
names = "--json-path",
converter = PathExpandingConverter.class,
description = CommonGoogleCommandProperties.JSON_PATH_DESCRIPTION
)
private String jsonPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.beust.jcommander.Parameter;
import com.netflix.spinnaker.halyard.cli.command.v1.config.providers.account.AbstractEditAccountCommand;
import com.netflix.spinnaker.halyard.cli.command.v1.converter.PathExpandingConverter;
import com.netflix.spinnaker.halyard.config.model.v1.node.Account;
import com.netflix.spinnaker.halyard.config.model.v1.providers.google.GoogleAccount;
import java.util.ArrayList;
Expand All @@ -37,6 +38,7 @@ protected String getProviderName() {

@Parameter(
names = "--json-path",
converter = PathExpandingConverter.class,
description = CommonGoogleCommandProperties.JSON_PATH_DESCRIPTION
)
private String jsonPath;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 2017 Google, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.netflix.spinnaker.halyard.cli.command.v1.converter;

import com.beust.jcommander.IStringConverter;

import java.io.File;

public class PathExpandingConverter implements IStringConverter<String> {
@Override
public String convert(String value) {
return new File(value).getAbsolutePath();
}
}

0 comments on commit 8d86543

Please sign in to comment.