From 810e6c7dfc81bd8502198f4b1f546f81812f7d77 Mon Sep 17 00:00:00 2001 From: Pere Miquel Brull Date: Sun, 24 Jul 2022 16:02:26 +0200 Subject: [PATCH] Fix #5822 - Remove looker env and rename props (#5700) Fix #5822 - Remove looker env and rename props (#5700) --- .../v004__create_db_connection_info.sql | 20 +++++++++++++++++++ .../v004__create_db_connection_info.sql | 14 +++++++++++++ .../dashboard/lookerConnection.json | 19 +++++++----------- .../DashboardServiceResourceTest.java | 4 ++-- ingestion/src/metadata/utils/connections.py | 6 ++++-- .../integration/ometa/test_ometa_chart_api.py | 4 +++- .../ometa/test_ometa_dashboard_api.py | 4 +++- .../ometa/test_ometa_service_api.py | 6 +++--- .../tests/unit/source/test_source_parsing.py | 5 ++--- 9 files changed, 58 insertions(+), 24 deletions(-) diff --git a/bootstrap/sql/com.mysql.cj.jdbc.Driver/v004__create_db_connection_info.sql b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v004__create_db_connection_info.sql index ff38603bf6a..c11df18b328 100644 --- a/bootstrap/sql/com.mysql.cj.jdbc.Driver/v004__create_db_connection_info.sql +++ b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v004__create_db_connection_info.sql @@ -7,3 +7,23 @@ ADD teamType VARCHAR(64) GENERATED ALWAYS AS (json ->> '$.teamType') NOT NULL; UPDATE dbservice_entity SET json = JSON_REMOVE(json, '$.connection.config.database') WHERE serviceType = 'DynamoDB'; + +UPDATE dashboard_service_entity +SET json = JSON_INSERT( + JSON_REMOVE(json, '$.connection.config.username'), + '$.connection.config.clientId', + JSON_EXTRACT(json, '$.connection.config.username') + ) +WHERE serviceType = 'Looker'; + +UPDATE dashboard_service_entity +SET json = JSON_INSERT( + JSON_REMOVE(json, '$.connection.config.password'), + '$.connection.config.clientSecret', + JSON_EXTRACT(json, '$.connection.config.password') + ) +WHERE serviceType = 'Looker'; + +UPDATE dashboard_service_entity +SET json = JSON_REMOVE(json, '$.connection.config.env') +WHERE serviceType = 'Looker'; diff --git a/bootstrap/sql/org.postgresql.Driver/v004__create_db_connection_info.sql b/bootstrap/sql/org.postgresql.Driver/v004__create_db_connection_info.sql index 3b34645cb59..6f7d9351449 100644 --- a/bootstrap/sql/org.postgresql.Driver/v004__create_db_connection_info.sql +++ b/bootstrap/sql/org.postgresql.Driver/v004__create_db_connection_info.sql @@ -7,3 +7,17 @@ ADD teamType VARCHAR(64) GENERATED ALWAYS AS (json ->> 'teamType') STORED NOT NU UPDATE dbservice_entity SET json = json::jsonb #- '{connection,config,database}' where serviceType = 'DynamoDB'; + +UPDATE dashboard_service_entity +SET json = jsonb_set(json, '{connection,config,clientId}', json#>'{connection,config,username}') +WHERE serviceType = 'Looker' + and json#>'{connection,config,username}' is not null; + +UPDATE dashboard_service_entity +SET json = jsonb_set(json, '{connection,config,clientSecret}', json#>'{connection,config,password}') +WHERE serviceType = 'Looker' + and json#>'{connection,config,password}' is not null; + +UPDATE dashboard_service_entity +SET json = json::jsonb #- '{connection,config,username}' #- '{connection,config,password}' #- '{connection,config,env}' +WHERE serviceType = 'Looker'; diff --git a/catalog-rest-service/src/main/resources/json/schema/entity/services/connections/dashboard/lookerConnection.json b/catalog-rest-service/src/main/resources/json/schema/entity/services/connections/dashboard/lookerConnection.json index 4b69884ad92..953e14605a7 100644 --- a/catalog-rest-service/src/main/resources/json/schema/entity/services/connections/dashboard/lookerConnection.json +++ b/catalog-rest-service/src/main/resources/json/schema/entity/services/connections/dashboard/lookerConnection.json @@ -20,14 +20,14 @@ "$ref": "#/definitions/lookerType", "default": "Looker" }, - "username": { - "title": "Username", - "description": "Username to connect to Looker. This user should have privileges to read all the metadata in Looker.", + "clientId": { + "title": "Client ID", + "description": "User's Client ID. This user should have privileges to read all the metadata in Looker.", "type": "string" }, - "password": { - "title": "Password", - "description": "Password to connect to Looker.", + "clientSecret": { + "title": "Client Secret", + "description": "User's Client Secret.", "type": "string", "format": "password" }, @@ -37,16 +37,11 @@ "type": "string", "format": "uri" }, - "env": { - "title": "Looker Environment", - "description": "Looker Environment", - "type": "string" - }, "supportsMetadataExtraction": { "title": "Supports Metadata Extraction", "$ref": "../connectionBasicType.json#/definitions/supportsMetadataExtraction" } }, "additionalProperties": false, - "required": ["hostPort", "username"] + "required": ["hostPort", "clientId", "clientSecret"] } diff --git a/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/services/DashboardServiceResourceTest.java b/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/services/DashboardServiceResourceTest.java index baaf4d2a241..bb0a68757c9 100644 --- a/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/services/DashboardServiceResourceTest.java +++ b/catalog-rest-service/src/test/java/org/openmetadata/catalog/resources/services/DashboardServiceResourceTest.java @@ -250,8 +250,8 @@ public class DashboardServiceResourceTest extends EntityResourceTest