Bläddra i källkod

[sentry] Add a flag to turn on the new API

On/off is fine as the Sentry API has the same version number as the old one.
Romain Rigaux 10 år sedan
förälder
incheckning
c385027

+ 11 - 0
apps/security/src/security/conf.py

@@ -14,3 +14,14 @@
 # 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.
+
+from django.utils.translation import ugettext_lazy as _
+
+from desktop.lib.conf import Config, coerce_bool
+
+
+LATEST = Config(
+  key="latest",
+  help=_("Use Sentry generic API V2 for Hive and Solr."),
+  default=False,
+  type=coerce_bool)

+ 3 - 1
apps/security/src/security/templates/layout.mako

@@ -16,7 +16,7 @@
 
 <%!
 from django.utils.translation import ugettext as _
-
+from security.conf import LATEST
 
 def is_selected(section, matcher):
   if section == matcher:
@@ -64,8 +64,10 @@ def is_selected(section, matcher):
                 </a>
               </li>
               <li class="${is_selected(section, 'hive')}"><a href="${ url('security:hive') }">${_('Sentry Tables')}</a></li>
+              % if LATEST.get():
               <li class="${is_selected(section, 'hive2')}"><a href="${ url('security:hive2') }">${_('Sentry Tables v2')}</a></li>
               <li class="${is_selected(section, 'solr')}"><a href="${ url('security:hive') }">${_('Solr Collections')}</a></li>
+              % endif
               <li class="${is_selected(section, 'hdfs')}"><a href="${ url('security:hdfs') }">${_('File ACLs')}</a></li>
             </ul>
           </div>

+ 10 - 0
desktop/conf.dist/hue.ini

@@ -1027,6 +1027,16 @@
   ## disable_killing_jobs=false
 
 
+###########################################################################
+# Settings to configure Sentry / Security App.
+###########################################################################
+
+[security]
+
+  # Use Sentry generic API V2 for Hive and Solr.
+  ## latest=false
+
+
 ###########################################################################
 # Settings to configure the Zookeeper application.
 ###########################################################################

+ 10 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1029,6 +1029,16 @@
   ## disable_killing_jobs=false
 
 
+###########################################################################
+# Settings to configure Sentry / Security App.
+###########################################################################
+
+[security]
+
+  # Use Sentry generic API V2 for Hive and Solr.
+  ## latest=false
+
+
 ###########################################################################
 # Settings to configure the Zookeeper application.
 ###########################################################################

+ 3 - 0
desktop/core/src/desktop/templates/common_header.mako

@@ -561,12 +561,15 @@ from django.utils.translation import ugettext as _
          % endif
        % endif
        % if 'security' in apps:
+         <% from security.conf import LATEST %>
          <li class="dropdown">
            <a title="${_('Hadoop Security')}" rel="navigator-tooltip" href="#" data-toggle="dropdown" class="dropdown-toggle">Security <b class="caret"></b></a>
            <ul role="menu" class="dropdown-menu">
              <li><a href="${ url('security:hive') }">&nbsp;<img src="/static/metastore/art/icon_metastore_48.png" class="app-icon"></img>&nbsp;&nbsp;${_('Sentry Tables')}</a></li>
+             % if LATEST.get():
              <li><a href="${ url('security:hive2') }">&nbsp;<img src="/static/metastore/art/icon_metastore_48.png" class="app-icon"></img>&nbsp;&nbsp;${_('Sentry Tables v2')}</a></li>
              <li><a href="${ url('security:solr') }">&nbsp;<i class="fa fa-database"></i>&nbsp;&nbsp;${_('Solr Collections')}</a></li>
+             % endif
              <li><a href="${ url('security:hdfs') }">&nbsp;<i class="fa fa-file"></i>&nbsp;&nbsp;${_('File ACLs')}</a></li>
            </ul>
          </li>