Browse Source

HUE-8298 [kafka] Add a proper is_enabled config flag

Romain Rigaux 7 years ago
parent
commit
95425937c2

+ 2 - 2
desktop/libs/indexer/src/indexer/api3.py

@@ -237,8 +237,8 @@ def guess_field_types(request):
     if file_format['streamSelection'] == 'kafka':
       data = """%(kafkaFieldNames)s
 %(data)s""" % {
-        'kafkaFieldNames': file_format['kafkaFieldNames'],
-        'data': '\n'.join([','.join(['...'] * len(file_format['kafkaFieldTypes'].split(',')))] * 5)
+        'kafkaFieldNames': file_format.get('kafkaFieldNames', ''),
+        'data': '\n'.join([','.join(['...'] * len(file_format.get('kafkaFieldTypes', '').split(',')))] * 5)
       }
     elif file_format['streamSelection'] == 'sfdc':
       data = """AccountId,Amount,CampaignId,CloseDate,CreatedById,CreatedDate,CurrentGenerators__c,DeliveryInstallationStatus__c,Description,ExpectedRevenue,Fiscal,FiscalQuarter,FiscalYear,ForecastCategory,ForecastCategoryName,HasOpenActivity,HasOpportunityLineItem,HasOverdueTask,Id,IsClosed,IsDeleted,IsPrivate,IsWon,LastActivityDate,LastModifiedById,LastModifiedDate,LastReferencedDate,LastViewedDate,LeadSource,MainCompetitors__c,Name,NextStep,OrderNumber__c,OwnerId,Pricebook2Id,Probability,StageName,SystemModstamp,TotalOpportunityQuantity,TrackingNumber__c,Type

+ 1 - 1
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -231,7 +231,7 @@ ${ assist.assistPanel() }
               <input type="text" class="form-control path filechooser-input input-xxlarge" data-bind="value: createWizard.source.path, filechooser: createWizard.source.path, filechooserOptions: { linkMarkup: true, skipInitialPathIfEmpty: true, openOnFocus: true, selectFolder: false }" placeholder="${ _('Click or drag from the assist') }">
             </label>
             <!-- ko if: createWizard.source.path().length > 0 -->
-              <a data-bind="hueLink: '/filebrowser/view=' + createWizard.source.path()" title="${ _('Open') }" style="font-size: 14px" class="margin-left-10">
+              <a data-bind="storageContextPopover: { path: createWizard.source.path(), offset: { right: 5 } }" title="${ _('Open') }" style="font-size: 14px" class="margin-left-10">
                 <i class="fa fa-external-link-square"></i>
               </a>
             <!-- /ko -->

+ 11 - 2
desktop/libs/metadata/src/metadata/conf.py

@@ -66,6 +66,9 @@ def has_navigator(user):
 
 
 def has_kafka():
+  return KAFKA.IS_ENABLED.get()
+
+def has_kafka_api():
   return bool(KAFKA.API_URL.get())
 
 
@@ -398,11 +401,17 @@ MANAGER = ConfigSection(
 
 KAFKA = ConfigSection(
   key='kafka',
-  help=_t("""Configuration options for Kafka API"""),
+  help=_t("""Configuration options for Kafka management"""),
   members=dict(
+    IS_ENABLED = Config(
+      key="is_enabled",
+      help=_t("Enable the Kafka integration."),
+      type=coerce_bool,
+      default=False
+    ),
     API_URL=Config(
       key='api_url',
-      help=_t('Base URL to API.'),
+      help=_t('Base URL of Kafka REST API.'),
       default=None),
   )
 )

+ 4 - 4
desktop/libs/metadata/src/metadata/kafka_api.py

@@ -35,7 +35,7 @@ from django.views.decorators.http import require_POST
 from desktop.lib.django_util import JsonResponse
 from desktop.lib.i18n import force_unicode
 
-from metadata.conf import has_navigator, has_kafka
+from metadata.conf import has_navigator, has_kafka_api
 from metadata.navigator_client import NavigatorApiException
 
 
@@ -91,16 +91,16 @@ def list_topic(request):
 
 
 def get_topics():
-  if has_kafka():
+  if has_kafka_api():
     return KafkaApi().topics()
   else:
     manager = ManagerApi()
     broker_host = manager.get_kafka_brokers().split(',')[0].split(':')[0]
-    return manager.get_kafka_topics(broker_host).keys()
+    return [name for name in manager.get_kafka_topics(broker_host).keys() if not name.startswith('__')]
 
 
 def get_topic(name):
-  if has_kafka() and False:
+  if has_kafka_api():
     pass
   else:
     manager = ManagerApi()

File diff suppressed because it is too large
+ 3 - 4
desktop/libs/metadata/src/metadata/manager_client.py


Some files were not shown because too many files changed in this diff