Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #66 don't prompt when token or user+pass set #67

Merged
merged 1 commit into from
Feb 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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