mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-26 00:04:52 +00:00
Looker - Update GitHub creds for UI form (#11019)
* Update GitHub creds for UI form * Add filters
This commit is contained in:
parent
08ecf69978
commit
dcbb77f46c
@ -61,6 +61,9 @@ from metadata.generated.schema.entity.services.dashboardService import (
|
|||||||
from metadata.generated.schema.metadataIngestion.workflow import (
|
from metadata.generated.schema.metadataIngestion.workflow import (
|
||||||
Source as WorkflowSource,
|
Source as WorkflowSource,
|
||||||
)
|
)
|
||||||
|
from metadata.generated.schema.security.credentials.githubCredentials import (
|
||||||
|
GitHubCredentials,
|
||||||
|
)
|
||||||
from metadata.generated.schema.type.entityLineage import EntitiesEdge
|
from metadata.generated.schema.type.entityLineage import EntitiesEdge
|
||||||
from metadata.generated.schema.type.entityReference import EntityReference
|
from metadata.generated.schema.type.entityReference import EntityReference
|
||||||
from metadata.generated.schema.type.usageRequest import UsageRequest
|
from metadata.generated.schema.type.usageRequest import UsageRequest
|
||||||
@ -151,17 +154,29 @@ class LookerSource(DashboardServiceSource):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def parser(self) -> Optional[LkmlParser]:
|
def parser(self) -> Optional[LkmlParser]:
|
||||||
if not self._parser and self.service_connection.githubCredentials:
|
if not self._parser and self.github_credentials:
|
||||||
self._parser = LkmlParser(
|
self._parser = LkmlParser(reader=GitHubReader(self.github_credentials))
|
||||||
reader=GitHubReader(self.service_connection.githubCredentials)
|
|
||||||
)
|
|
||||||
|
|
||||||
return self._parser
|
return self._parser
|
||||||
|
|
||||||
|
@property
|
||||||
|
def github_credentials(self) -> Optional[GitHubCredentials]:
|
||||||
|
"""
|
||||||
|
Check if the credentials are informed and return them.
|
||||||
|
|
||||||
|
We either get GitHubCredentials or `NoGitHubCredentials`
|
||||||
|
"""
|
||||||
|
if self.service_connection.githubCredentials and isinstance(
|
||||||
|
self.service_connection.githubCredentials, GitHubCredentials
|
||||||
|
):
|
||||||
|
return self.service_connection.githubCredentials
|
||||||
|
return None
|
||||||
|
|
||||||
def list_datamodels(self) -> Iterable[LookmlModelExplore]:
|
def list_datamodels(self) -> Iterable[LookmlModelExplore]:
|
||||||
"""
|
"""
|
||||||
Fetch explores with the SDK
|
Fetch explores with the SDK
|
||||||
"""
|
"""
|
||||||
|
if self.source_config.includeDataModels:
|
||||||
# First, pick up all the LookML Models
|
# First, pick up all the LookML Models
|
||||||
all_lookml_models: Sequence[LookmlModel] = self.client.all_lookml_models()
|
all_lookml_models: Sequence[LookmlModel] = self.client.all_lookml_models()
|
||||||
|
|
||||||
@ -171,8 +186,17 @@ class LookerSource(DashboardServiceSource):
|
|||||||
for explore_nav in (
|
for explore_nav in (
|
||||||
cast(Sequence[LookmlModelNavExplore], lookml_model.explores) or []
|
cast(Sequence[LookmlModelNavExplore], lookml_model.explores) or []
|
||||||
):
|
):
|
||||||
|
if filter_by_datamodel(
|
||||||
|
self.source_config.dataModelFilterPattern, lookml_model.name
|
||||||
|
):
|
||||||
|
self.status.filter(
|
||||||
|
lookml_model.name, "Data model (Explore) filtered out."
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
explore = self.client.lookml_model_explore(
|
explore = self.client.lookml_model_explore(
|
||||||
lookml_model_name=lookml_model.name, explore_name=explore_nav.name
|
lookml_model_name=lookml_model.name,
|
||||||
|
explore_name=explore_nav.name,
|
||||||
)
|
)
|
||||||
yield explore
|
yield explore
|
||||||
|
|
||||||
@ -183,7 +207,6 @@ class LookerSource(DashboardServiceSource):
|
|||||||
Get the Explore and View information and prepare
|
Get the Explore and View information and prepare
|
||||||
the model creation request
|
the model creation request
|
||||||
"""
|
"""
|
||||||
if self.source_config.includeDataModels:
|
|
||||||
try:
|
try:
|
||||||
datamodel_name = build_datamodel_name(model.model_name, model.name)
|
datamodel_name = build_datamodel_name(model.model_name, model.name)
|
||||||
if filter_by_datamodel(
|
if filter_by_datamodel(
|
||||||
@ -212,8 +235,17 @@ class LookerSource(DashboardServiceSource):
|
|||||||
|
|
||||||
# We can get VIEWs from the JOINs to know the dependencies
|
# We can get VIEWs from the JOINs to know the dependencies
|
||||||
# We will only try and fetch if we have the credentials
|
# We will only try and fetch if we have the credentials
|
||||||
if self.service_connection.githubCredentials:
|
if self.github_credentials:
|
||||||
for view in model.joins:
|
for view in model.joins:
|
||||||
|
|
||||||
|
if filter_by_datamodel(
|
||||||
|
self.source_config.dataModelFilterPattern, view.name
|
||||||
|
):
|
||||||
|
self.status.filter(
|
||||||
|
view.name, "Data model (View) filtered out."
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
yield from self._process_view(
|
yield from self._process_view(
|
||||||
view_name=ViewName(view.name), explore=model
|
view_name=ViewName(view.name), explore=model
|
||||||
)
|
)
|
||||||
@ -239,7 +271,7 @@ class LookerSource(DashboardServiceSource):
|
|||||||
file definition and add it here
|
file definition and add it here
|
||||||
"""
|
"""
|
||||||
# Only look to parse if creds are in
|
# Only look to parse if creds are in
|
||||||
if self.service_connection.githubCredentials:
|
if self.github_credentials:
|
||||||
try:
|
try:
|
||||||
# This will only parse if the file has not been parsed yet
|
# This will only parse if the file has not been parsed yet
|
||||||
self.parser.parse_file(Includes(explore.source_file))
|
self.parser.parse_file(Includes(explore.source_file))
|
||||||
@ -379,7 +411,6 @@ class LookerSource(DashboardServiceSource):
|
|||||||
"""
|
"""
|
||||||
Method to Get Dashboard Entity
|
Method to Get Dashboard Entity
|
||||||
"""
|
"""
|
||||||
|
|
||||||
dashboard_request = CreateDashboardRequest(
|
dashboard_request = CreateDashboardRequest(
|
||||||
name=clean_dashboard_name(dashboard_details.id),
|
name=clean_dashboard_name(dashboard_details.id),
|
||||||
displayName=dashboard_details.title,
|
displayName=dashboard_details.title,
|
||||||
|
|||||||
@ -229,7 +229,7 @@ def filter_by_datamodel(
|
|||||||
datamodel_filter_pattern: Optional[FilterPattern], datamodel_name: str
|
datamodel_filter_pattern: Optional[FilterPattern], datamodel_name: str
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""
|
"""
|
||||||
Return True if the chart needs to be filtered, False otherwise
|
Return True if the models needs to be filtered, False otherwise
|
||||||
|
|
||||||
Include takes precedence over exclude
|
Include takes precedence over exclude
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,12 @@
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["Looker"],
|
"enum": ["Looker"],
|
||||||
"default": "Looker"
|
"default": "Looker"
|
||||||
|
},
|
||||||
|
"noGitHubCredentials": {
|
||||||
|
"title": "No GitHub Credentials",
|
||||||
|
"description": "Do not set any credentials. Note that credentials are required to extract .lkml views and their lineage.",
|
||||||
|
"type": "object",
|
||||||
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -41,7 +47,14 @@
|
|||||||
"githubCredentials": {
|
"githubCredentials": {
|
||||||
"title": "GitHub Credentials",
|
"title": "GitHub Credentials",
|
||||||
"description": "Credentials to extract the .lkml files from a repository. This is required to get all the lineage and definitions.",
|
"description": "Credentials to extract the .lkml files from a repository. This is required to get all the lineage and definitions.",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/noGitHubCredentials"
|
||||||
|
},
|
||||||
|
{
|
||||||
"$ref": "../../../../security/credentials/githubCredentials.json"
|
"$ref": "../../../../security/credentials/githubCredentials.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"supportsMetadataExtraction": {
|
"supportsMetadataExtraction": {
|
||||||
"title": "Supports Metadata Extraction",
|
"title": "Supports Metadata Extraction",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user