Fix #5822 - Remove looker env and rename props (#5700)

Fix #5822 - Remove looker env and rename props (#5700)
This commit is contained in:
Pere Miquel Brull 2022-07-24 16:02:26 +02:00 committed by GitHub
parent 539da30ca0
commit 810e6c7dfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 58 additions and 24 deletions

View File

@ -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';

View File

@ -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';

View File

@ -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"]
}

View File

@ -250,8 +250,8 @@ public class DashboardServiceResourceTest extends EntityResourceTest<DashboardSe
.withConfig(
new LookerConnection()
.withHostPort(new URI("http://localhost:8080"))
.withUsername("test")
.withPassword("test"));
.withClientId("test")
.withClientSecret("test"));
lookerDashboardService.withConnection(lookerConnection);
dashboardService = new DashboardServiceResourceTest().createEntity(lookerDashboardService, ADMIN_AUTH_HEADERS);
LOOKER_REFERENCE = dashboardService.getEntityReference();

View File

@ -680,9 +680,11 @@ def _(connection: LookerConnection, verbose: bool = False):
import looker_sdk
if not os.environ.get("LOOKERSDK_CLIENT_ID"):
os.environ["LOOKERSDK_CLIENT_ID"] = connection.username
os.environ["LOOKERSDK_CLIENT_ID"] = connection.clientId
if not os.environ.get("LOOKERSDK_CLIENT_SECRET"):
os.environ["LOOKERSDK_CLIENT_SECRET"] = connection.password.get_secret_value()
os.environ[
"LOOKERSDK_CLIENT_SECRET"
] = connection.clientSecret.get_secret_value()
if not os.environ.get("LOOKERSDK_BASE_URL"):
os.environ["LOOKERSDK_BASE_URL"] = connection.hostPort
client = looker_sdk.init40()

View File

@ -58,7 +58,9 @@ class OMetaChartTest(TestCase):
name="test-service-chart",
serviceType=DashboardServiceType.Looker,
connection=DashboardConnection(
config=LookerConnection(hostPort="http://hostPort", username="username")
config=LookerConnection(
hostPort="http://hostPort", clientId="id", clientSecret="secret"
)
),
)
service_type = "dashboardService"

View File

@ -58,7 +58,9 @@ class OMetaDashboardTest(TestCase):
name="test-service-dashboard",
serviceType=DashboardServiceType.Looker,
connection=DashboardConnection(
config=LookerConnection(hostPort="http://hostPort", username="username")
config=LookerConnection(
hostPort="http://hostPort", clientId="id", clientSecret="secret"
)
),
)
service_type = "dashboardService"

View File

@ -179,8 +179,8 @@ class OMetaServiceTest(TestCase):
"serviceConnection": {
"config": {
"type": "Looker",
"username": "looker_user",
"password": "looker_pwd",
"clientId": "id",
"clientSecret": "secret",
"hostPort": "http://random:1234",
}
},
@ -195,7 +195,7 @@ class OMetaServiceTest(TestCase):
)
assert service
assert service.serviceType == DashboardServiceType.Looker
assert service.connection.config.password.get_secret_value() == "looker_pwd"
assert service.connection.config.clientSecret.get_secret_value() == "secret"
# Check get
assert service == self.metadata.get_service_or_create(

View File

@ -372,10 +372,9 @@ def test_looker():
"serviceConnection": {
"config": {
"type": "Looker",
"username": "username",
"password": "password",
"clientId": "username",
"clientSecret": "password",
"hostPort": "http://hostPort",
"env": "env",
}
},
"sourceConfig": {"config": {}},