HADOOP-10900. CredentialShell args should use single-dash style. (wang)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1615178 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1b4f028385
commit
f3db1ad3cc
|
@ -52,6 +52,11 @@ Release 2.6.0 - UNRELEASED
|
||||||
HADOOP-8069. Enable TCP_NODELAY by default for IPC. (Todd Lipcon via
|
HADOOP-8069. Enable TCP_NODELAY by default for IPC. (Todd Lipcon via
|
||||||
Arpit Agarwal)
|
Arpit Agarwal)
|
||||||
|
|
||||||
|
HADOOP-10902. Deletion of directories with snapshots will not output
|
||||||
|
reason for trash move failure. (Stephen Chu via wang)
|
||||||
|
|
||||||
|
HADOOP-10900. CredentialShell args should use single-dash style. (wang)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -118,7 +118,11 @@ class Delete {
|
||||||
} catch(FileNotFoundException fnfe) {
|
} catch(FileNotFoundException fnfe) {
|
||||||
throw fnfe;
|
throw fnfe;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new IOException(ioe.getMessage() + ". Consider using -skipTrash option", ioe);
|
String msg = ioe.getMessage();
|
||||||
|
if (ioe.getCause() != null) {
|
||||||
|
msg += ": " + ioe.getCause().getMessage();
|
||||||
|
}
|
||||||
|
throw new IOException(msg + ". Consider using -skipTrash option", ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
|
|
|
@ -79,9 +79,9 @@ public class CredentialShell extends Configured implements Tool {
|
||||||
/**
|
/**
|
||||||
* Parse the command line arguments and initialize the data
|
* Parse the command line arguments and initialize the data
|
||||||
* <pre>
|
* <pre>
|
||||||
* % hadoop alias create alias [--provider providerPath]
|
* % hadoop alias create alias [-provider providerPath]
|
||||||
* % hadoop alias list [-provider providerPath]
|
* % hadoop alias list [-provider providerPath]
|
||||||
* % hadoop alias delete alias [--provider providerPath] [-i]
|
* % hadoop alias delete alias [-provider providerPath] [-i]
|
||||||
* </pre>
|
* </pre>
|
||||||
* @param args
|
* @param args
|
||||||
* @return
|
* @return
|
||||||
|
@ -92,28 +92,28 @@ public class CredentialShell extends Configured implements Tool {
|
||||||
if (args[i].equals("create")) {
|
if (args[i].equals("create")) {
|
||||||
String alias = args[++i];
|
String alias = args[++i];
|
||||||
command = new CreateCommand(alias);
|
command = new CreateCommand(alias);
|
||||||
if (alias.equals("--help")) {
|
if (alias.equals("-help")) {
|
||||||
printCredShellUsage();
|
printCredShellUsage();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (args[i].equals("delete")) {
|
} else if (args[i].equals("delete")) {
|
||||||
String alias = args[++i];
|
String alias = args[++i];
|
||||||
command = new DeleteCommand(alias);
|
command = new DeleteCommand(alias);
|
||||||
if (alias.equals("--help")) {
|
if (alias.equals("-help")) {
|
||||||
printCredShellUsage();
|
printCredShellUsage();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else if (args[i].equals("list")) {
|
} else if (args[i].equals("list")) {
|
||||||
command = new ListCommand();
|
command = new ListCommand();
|
||||||
} else if (args[i].equals("--provider")) {
|
} else if (args[i].equals("-provider")) {
|
||||||
userSuppliedProvider = true;
|
userSuppliedProvider = true;
|
||||||
getConf().set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
|
getConf().set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
|
||||||
args[++i]);
|
args[++i]);
|
||||||
} else if (args[i].equals("-i") || (args[i].equals("--interactive"))) {
|
} else if (args[i].equals("-i") || (args[i].equals("-interactive"))) {
|
||||||
interactive = true;
|
interactive = true;
|
||||||
} else if (args[i].equals("-v") || (args[i].equals("--value"))) {
|
} else if (args[i].equals("-v") || (args[i].equals("-value"))) {
|
||||||
value = args[++i];
|
value = args[++i];
|
||||||
} else if (args[i].equals("--help")) {
|
} else if (args[i].equals("-help")) {
|
||||||
printCredShellUsage();
|
printCredShellUsage();
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,20 +188,20 @@ public class CredentialShell extends Configured implements Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ListCommand extends Command {
|
private class ListCommand extends Command {
|
||||||
public static final String USAGE = "list <alias> [--provider] [--help]";
|
public static final String USAGE = "list <alias> [-provider] [-help]";
|
||||||
public static final String DESC =
|
public static final String DESC =
|
||||||
"The list subcommand displays the aliases contained within \n" +
|
"The list subcommand displays the aliases contained within \n" +
|
||||||
"a particular provider - as configured in core-site.xml or " +
|
"a particular provider - as configured in core-site.xml or " +
|
||||||
"indicated\nthrough the --provider argument.";
|
"indicated\nthrough the -provider argument.";
|
||||||
|
|
||||||
public boolean validate() {
|
public boolean validate() {
|
||||||
boolean rc = true;
|
boolean rc = true;
|
||||||
provider = getCredentialProvider();
|
provider = getCredentialProvider();
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
out.println("There are no non-transient CredentialProviders configured.\n"
|
out.println("There are no non-transient CredentialProviders configured.\n"
|
||||||
+ "Consider using the --provider option to indicate the provider\n"
|
+ "Consider using the -provider option to indicate the provider\n"
|
||||||
+ "to use. If you want to list a transient provider then you\n"
|
+ "to use. If you want to list a transient provider then you\n"
|
||||||
+ "you MUST use the --provider argument.");
|
+ "you MUST use the -provider argument.");
|
||||||
rc = false;
|
rc = false;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
@ -229,11 +229,11 @@ public class CredentialShell extends Configured implements Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DeleteCommand extends Command {
|
private class DeleteCommand extends Command {
|
||||||
public static final String USAGE = "delete <alias> [--provider] [--help]";
|
public static final String USAGE = "delete <alias> [-provider] [-help]";
|
||||||
public static final String DESC =
|
public static final String DESC =
|
||||||
"The delete subcommand deletes the credenital\n" +
|
"The delete subcommand deletes the credenital\n" +
|
||||||
"specified as the <alias> argument from within the provider\n" +
|
"specified as the <alias> argument from within the provider\n" +
|
||||||
"indicated through the --provider argument";
|
"indicated through the -provider argument";
|
||||||
|
|
||||||
String alias = null;
|
String alias = null;
|
||||||
boolean cont = true;
|
boolean cont = true;
|
||||||
|
@ -248,13 +248,13 @@ public class CredentialShell extends Configured implements Tool {
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
out.println("There are no valid CredentialProviders configured.\n"
|
out.println("There are no valid CredentialProviders configured.\n"
|
||||||
+ "Nothing will be deleted.\n"
|
+ "Nothing will be deleted.\n"
|
||||||
+ "Consider using the --provider option to indicate the provider"
|
+ "Consider using the -provider option to indicate the provider"
|
||||||
+ " to use.");
|
+ " to use.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (alias == null) {
|
if (alias == null) {
|
||||||
out.println("There is no alias specified. Please provide the" +
|
out.println("There is no alias specified. Please provide the" +
|
||||||
"mandatory <alias>. See the usage description with --help.");
|
"mandatory <alias>. See the usage description with -help.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (interactive) {
|
if (interactive) {
|
||||||
|
@ -299,11 +299,11 @@ public class CredentialShell extends Configured implements Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CreateCommand extends Command {
|
private class CreateCommand extends Command {
|
||||||
public static final String USAGE = "create <alias> [--provider] [--help]";
|
public static final String USAGE = "create <alias> [-provider] [-help]";
|
||||||
public static final String DESC =
|
public static final String DESC =
|
||||||
"The create subcommand creates a new credential for the name specified\n" +
|
"The create subcommand creates a new credential for the name specified\n" +
|
||||||
"as the <alias> argument within the provider indicated through\n" +
|
"as the <alias> argument within the provider indicated through\n" +
|
||||||
"the --provider argument.";
|
"the -provider argument.";
|
||||||
|
|
||||||
String alias = null;
|
String alias = null;
|
||||||
|
|
||||||
|
@ -317,13 +317,13 @@ public class CredentialShell extends Configured implements Tool {
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
out.println("There are no valid CredentialProviders configured." +
|
out.println("There are no valid CredentialProviders configured." +
|
||||||
"\nCredential will not be created.\n"
|
"\nCredential will not be created.\n"
|
||||||
+ "Consider using the --provider option to indicate the provider" +
|
+ "Consider using the -provider option to indicate the provider" +
|
||||||
" to use.");
|
" to use.");
|
||||||
rc = false;
|
rc = false;
|
||||||
}
|
}
|
||||||
if (alias == null) {
|
if (alias == null) {
|
||||||
out.println("There is no alias specified. Please provide the" +
|
out.println("There is no alias specified. Please provide the" +
|
||||||
"mandatory <alias>. See the usage description with --help.");
|
"mandatory <alias>. See the usage description with -help.");
|
||||||
rc = false;
|
rc = false;
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class TestCredShell {
|
||||||
@Test
|
@Test
|
||||||
public void testCredentialSuccessfulLifecycle() throws Exception {
|
public void testCredentialSuccessfulLifecycle() throws Exception {
|
||||||
outContent.reset();
|
outContent.reset();
|
||||||
String[] args1 = {"create", "credential1", "--value", "p@ssw0rd", "--provider",
|
String[] args1 = {"create", "credential1", "-value", "p@ssw0rd", "-provider",
|
||||||
"jceks://file" + tmpDir + "/credstore.jceks"};
|
"jceks://file" + tmpDir + "/credstore.jceks"};
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
CredentialShell cs = new CredentialShell();
|
CredentialShell cs = new CredentialShell();
|
||||||
|
@ -56,14 +56,14 @@ public class TestCredShell {
|
||||||
"created."));
|
"created."));
|
||||||
|
|
||||||
outContent.reset();
|
outContent.reset();
|
||||||
String[] args2 = {"list", "--provider",
|
String[] args2 = {"list", "-provider",
|
||||||
"jceks://file" + tmpDir + "/credstore.jceks"};
|
"jceks://file" + tmpDir + "/credstore.jceks"};
|
||||||
rc = cs.run(args2);
|
rc = cs.run(args2);
|
||||||
assertEquals(0, rc);
|
assertEquals(0, rc);
|
||||||
assertTrue(outContent.toString().contains("credential1"));
|
assertTrue(outContent.toString().contains("credential1"));
|
||||||
|
|
||||||
outContent.reset();
|
outContent.reset();
|
||||||
String[] args4 = {"delete", "credential1", "--provider",
|
String[] args4 = {"delete", "credential1", "-provider",
|
||||||
"jceks://file" + tmpDir + "/credstore.jceks"};
|
"jceks://file" + tmpDir + "/credstore.jceks"};
|
||||||
rc = cs.run(args4);
|
rc = cs.run(args4);
|
||||||
assertEquals(0, rc);
|
assertEquals(0, rc);
|
||||||
|
@ -71,7 +71,7 @@ public class TestCredShell {
|
||||||
"deleted."));
|
"deleted."));
|
||||||
|
|
||||||
outContent.reset();
|
outContent.reset();
|
||||||
String[] args5 = {"list", "--provider",
|
String[] args5 = {"list", "-provider",
|
||||||
"jceks://file" + tmpDir + "/credstore.jceks"};
|
"jceks://file" + tmpDir + "/credstore.jceks"};
|
||||||
rc = cs.run(args5);
|
rc = cs.run(args5);
|
||||||
assertEquals(0, rc);
|
assertEquals(0, rc);
|
||||||
|
@ -80,7 +80,7 @@ public class TestCredShell {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInvalidProvider() throws Exception {
|
public void testInvalidProvider() throws Exception {
|
||||||
String[] args1 = {"create", "credential1", "--value", "p@ssw0rd", "--provider",
|
String[] args1 = {"create", "credential1", "-value", "p@ssw0rd", "-provider",
|
||||||
"sdff://file/tmp/credstore.jceks"};
|
"sdff://file/tmp/credstore.jceks"};
|
||||||
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
@ -94,7 +94,7 @@ public class TestCredShell {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTransientProviderWarning() throws Exception {
|
public void testTransientProviderWarning() throws Exception {
|
||||||
String[] args1 = {"create", "credential1", "--value", "p@ssw0rd", "--provider",
|
String[] args1 = {"create", "credential1", "-value", "p@ssw0rd", "-provider",
|
||||||
"user:///"};
|
"user:///"};
|
||||||
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
@ -105,7 +105,7 @@ public class TestCredShell {
|
||||||
assertTrue(outContent.toString().contains("WARNING: you are modifying a " +
|
assertTrue(outContent.toString().contains("WARNING: you are modifying a " +
|
||||||
"transient provider."));
|
"transient provider."));
|
||||||
|
|
||||||
String[] args2 = {"delete", "credential1", "--provider", "user:///"};
|
String[] args2 = {"delete", "credential1", "-provider", "user:///"};
|
||||||
rc = cs.run(args2);
|
rc = cs.run(args2);
|
||||||
assertEquals(outContent.toString(), 0, rc);
|
assertEquals(outContent.toString(), 0, rc);
|
||||||
assertTrue(outContent.toString().contains("credential1 has been successfully " +
|
assertTrue(outContent.toString().contains("credential1 has been successfully " +
|
||||||
|
@ -129,7 +129,7 @@ public class TestCredShell {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPromptForCredentialWithEmptyPasswd() throws Exception {
|
public void testPromptForCredentialWithEmptyPasswd() throws Exception {
|
||||||
String[] args1 = {"create", "credential1", "--provider",
|
String[] args1 = {"create", "credential1", "-provider",
|
||||||
"jceks://file" + tmpDir + "/credstore.jceks"};
|
"jceks://file" + tmpDir + "/credstore.jceks"};
|
||||||
ArrayList<String> passwords = new ArrayList<String>();
|
ArrayList<String> passwords = new ArrayList<String>();
|
||||||
passwords.add(null);
|
passwords.add(null);
|
||||||
|
@ -145,7 +145,7 @@ public class TestCredShell {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPromptForCredential() throws Exception {
|
public void testPromptForCredential() throws Exception {
|
||||||
String[] args1 = {"create", "credential1", "--provider",
|
String[] args1 = {"create", "credential1", "-provider",
|
||||||
"jceks://file" + tmpDir + "/credstore.jceks"};
|
"jceks://file" + tmpDir + "/credstore.jceks"};
|
||||||
ArrayList<String> passwords = new ArrayList<String>();
|
ArrayList<String> passwords = new ArrayList<String>();
|
||||||
passwords.add("p@ssw0rd");
|
passwords.add("p@ssw0rd");
|
||||||
|
@ -159,7 +159,7 @@ public class TestCredShell {
|
||||||
assertTrue(outContent.toString().contains("credential1 has been successfully " +
|
assertTrue(outContent.toString().contains("credential1 has been successfully " +
|
||||||
"created."));
|
"created."));
|
||||||
|
|
||||||
String[] args2 = {"delete", "credential1", "--provider",
|
String[] args2 = {"delete", "credential1", "-provider",
|
||||||
"jceks://file" + tmpDir + "/credstore.jceks"};
|
"jceks://file" + tmpDir + "/credstore.jceks"};
|
||||||
rc = shell.run(args2);
|
rc = shell.run(args2);
|
||||||
assertEquals(0, rc);
|
assertEquals(0, rc);
|
||||||
|
|
Loading…
Reference in New Issue