Skip to content

Commit

Permalink
Fix #66 don't prompt when token or user+pass set
Browse files Browse the repository at this point in the history
  • Loading branch information
gschueler committed Feb 2, 2017
1 parent 386960d commit 45c9a53
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main/java/org/rundeck/client/tool/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,13 @@ private static void setupColor(final ToolBelt belt, AppConfig config) {
public static Client<RundeckApi> createClient(AppConfig config) throws InputError {
Auth auth = new Auth() {
};
String baseUrl = null;
auth = auth.chain(new ConfigAuth(config));
String baseUrl = config.require(
ENV_URL,
"Please specify the Rundeck base URL, e.g. http://host:port or http://host:port/api/14"
);

if (null == baseUrl) {
baseUrl = config.require(
ENV_URL,
"Please specify the Rundeck base URL, e.g. http://host:port or http://host:port/api/14"
);
}

if (config.getBool(ENV_AUTH_PROMPT, true) && null != System.console()) {
if (!auth.isConfigured() && config.getBool(ENV_AUTH_PROMPT, true) && null != System.console()) {
auth = auth.chain(new ConsoleAuth(String.format("Credentials for URL: %s", baseUrl)).memoize());
}

Expand Down Expand Up @@ -217,6 +213,12 @@ public static Client<RundeckApi> createClient(AppConfig config) throws InputErro
}

static interface Auth {
default boolean isConfigured() {
return null != getToken() || (
null != getUsername() && null != getPassword()
);
}

default String getUsername() {
return null;
}
Expand Down

0 comments on commit 45c9a53

Please sign in to comment.