You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sentry.apache.org by ak...@apache.org on 2017/01/24 23:03:24 UTC
[02/12] sentry git commit: Added command documentation
Added command documentation
Project: http://git-wip-us.apache.org/repos/asf/sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/sentry/commit/25fbdb9d
Tree: http://git-wip-us.apache.org/repos/asf/sentry/tree/25fbdb9d
Diff: http://git-wip-us.apache.org/repos/asf/sentry/diff/25fbdb9d
Branch: refs/heads/akolb-ha-cli
Commit: 25fbdb9de5e5823291bf63f856c36c2f5d27a276
Parents: 250cf9f
Author: Alexander Kolbasov <ak...@cloudera.com>
Authored: Wed Dec 14 12:50:36 2016 -0800
Committer: Alexander Kolbasov <ak...@cloudera.com>
Committed: Sun Jan 22 17:09:07 2017 -0800
----------------------------------------------------------------------
.../org/apache/sentry/shell/PrivsShell.java | 19 +++++++++++---
.../java/org/apache/sentry/shell/ShellUtil.java | 3 +++
.../org/apache/sentry/shell/TopLevelShell.java | 27 ++++++++++++++++----
3 files changed, 41 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sentry/blob/25fbdb9d/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java b/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
index 82369cd..9d8b9d9 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/PrivsShell.java
@@ -19,6 +19,7 @@
package org.apache.sentry.shell;
import com.budhash.cliche.Command;
+import com.budhash.cliche.Param;
import com.budhash.cliche.Shell;
import com.budhash.cliche.ShellDependent;
import org.apache.sentry.provider.db.service.thrift.SentryPolicyServiceClient;
@@ -30,7 +31,12 @@ public class PrivsShell implements ShellDependent {
Shell shell;
@Command(description = "Grant privilege to role")
- public void grant(String roleName, String privilege) {
+ public void grant(
+ @Param(name = "roleName")
+ String roleName,
+ @Param(name = "privilege",
+ description = "privilege string, e.g. server=s1->db=foo")
+ String privilege) {
tools.grantPrivilegeToRole(roleName, privilege);
}
@@ -40,12 +46,19 @@ public class PrivsShell implements ShellDependent {
}
@Command
- public List<String> list(String roleName) {
+ public List<String> list(
+ @Param(name = "roleName")
+ String roleName) {
return tools.listPrivileges(roleName);
}
@Command
- public void revoke(String roleName, String privilege) {
+ public void revoke(
+ @Param(name = "roleName")
+ String roleName,
+ @Param(name = "privilege",
+ description = "privilege string, e.g. server=s1->db=foo")
+ String privilege) {
tools.revokePrivilegeFromRole(roleName, privilege);
}
http://git-wip-us.apache.org/repos/asf/sentry/blob/25fbdb9d/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java b/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
index 4decf28..007975c 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/ShellUtil.java
@@ -236,6 +236,9 @@ class ShellUtil {
List<String> result = new LinkedList<>();
for (TSentryPrivilege privilege : privileges) {
String privilegeStr = convertTSentryPrivilegeToStr(privilege);
+ if (privilegeStr.isEmpty()) {
+ continue;
+ }
result.add(privilegeStr);
}
return result;
http://git-wip-us.apache.org/repos/asf/sentry/blob/25fbdb9d/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
----------------------------------------------------------------------
diff --git a/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java b/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
index d5d74b4..ef5313a 100644
--- a/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
+++ b/sentry-tools/src/main/java/org/apache/sentry/shell/TopLevelShell.java
@@ -84,13 +84,20 @@ public class TopLevelShell implements ShellDependent, Runnable {
}
@Command(description = "Grant role to groups")
- public void grantRole(String roleName, String ...groups) {
+ public void grantRole(
+ @Param(name = "roleName")
+ String roleName,
+ @Param(name = "group...") String ...groups) {
tools.grantGroupsToRole(roleName, groups);
}
@Command(abbrev = "grm",
description = "Revoke role from groups")
- public void revokeRole(String roleName, String ...groups) {
+ public void revokeRole(
+ @Param(name = "roleName")
+ String roleName,
+ @Param(name = "group...")
+ String ...groups) {
tools.revokeGroupsFromRole(roleName, groups);
}
@@ -114,17 +121,27 @@ public class TopLevelShell implements ShellDependent, Runnable {
}
@Command(description = "list Sentry privileges")
- public List<String> listPrivileges(String roleName) {
+ public List<String> listPrivileges(
+ @Param(name = "roleName")
+ String roleName) {
return tools.listPrivileges(roleName);
}
@Command(description = "Grant privilege to role")
- public void grantPrivilege(String roleName, String privilege) {
+ public void grantPrivilege(
+ @Param(name = "roleName")
+ String roleName,
+ @Param(name = "privilege", description = "privilege string, e.g. server=s1->db=foo")
+ String privilege) {
tools.grantPrivilegeToRole(roleName, privilege);
}
@Command
- public void revokePrivilege(String roleName, String privilege) {
+ public void revokePrivilege(
+ @Param(name = "roleName")
+ String roleName,
+ @Param(name = "privilege", description = "privilege string, e.g. server=s1->db=foo")
+ String privilege) {
tools.revokePrivilegeFromRole(roleName, privilege);
}