fixed: ui: add support of azure config in dbt form #12589 (#12594)

* fixed: ui: add support of azure config in dbt form #12589

* translation-sync

* fixed azure option selection in edit mode
This commit is contained in:
Shailesh Parmar 2023-07-26 14:32:22 +05:30 committed by GitHub
parent 307dcbf629
commit f36ed5f204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 253 additions and 3 deletions

View File

@ -15,6 +15,7 @@ package org.openmetadata.service.secrets.converter;
import java.util.List;
import org.openmetadata.schema.metadataIngestion.DbtPipeline;
import org.openmetadata.schema.metadataIngestion.dbtconfig.DbtAzureConfig;
import org.openmetadata.schema.metadataIngestion.dbtconfig.DbtCloudConfig;
import org.openmetadata.schema.metadataIngestion.dbtconfig.DbtGCSConfig;
import org.openmetadata.schema.metadataIngestion.dbtconfig.DbtHttpConfig;
@ -26,7 +27,13 @@ import org.openmetadata.service.util.JsonUtils;
public class DbtPipelineClassConverter extends ClassConverter {
private static final List<Class<?>> DBT_CONFIG_CLASSES =
List.of(DbtCloudConfig.class, DbtGCSConfig.class, DbtHttpConfig.class, DbtLocalConfig.class, DbtS3Config.class);
List.of(
DbtCloudConfig.class,
DbtGCSConfig.class,
DbtHttpConfig.class,
DbtLocalConfig.class,
DbtS3Config.class,
DbtAzureConfig.class);
public DbtPipelineClassConverter() {
super(DbtPipeline.class);

View File

@ -0,0 +1,126 @@
/*
* Copyright 2023 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/
import { FieldProp, FieldTypes } from 'interface/FormUtils.interface';
import React, { Fragment } from 'react';
import { useTranslation } from 'react-i18next';
import { generateFormFields } from 'utils/formUtils';
import DBTCommonFields from './DBTCommonFields.component';
import { DbtConfigAzure } from './DBTConfigForm.interface';
interface Props extends DbtConfigAzure {
enableDebugLog: boolean;
}
export const DBTAzureConfig = ({
dbtSecurityConfig,
dbtPrefixConfig,
dbtClassificationName,
dbtUpdateDescriptions = false,
enableDebugLog,
includeTags = true,
}: Props) => {
const { t } = useTranslation();
const azureConfigFields: FieldProp[] = [
{
name: 'clientId',
label: t('label.client-id'),
type: FieldTypes.TEXT,
required: true,
props: {
'data-testid': 'azure-client-id',
},
id: 'root/azureClientId',
formItemProps: {
initialValue: dbtSecurityConfig?.clientId,
},
},
{
name: 'clientSecret',
label: t('label.client-secret'),
type: FieldTypes.PASSWORD,
required: true,
props: {
'data-testid': 'azure-client-secret',
},
id: 'root/azureClientSecret',
formItemProps: {
initialValue: dbtSecurityConfig?.clientSecret,
},
},
{
name: 'tenantId',
label: t('label.tenant-id'),
type: FieldTypes.TEXT,
required: true,
props: {
'data-testid': 'azure-tenant-id',
},
id: 'root/azureTenantId',
formItemProps: {
initialValue: dbtSecurityConfig?.tenantId,
},
},
{
name: 'accountName',
label: t('label.account-name'),
type: FieldTypes.TEXT,
required: true,
props: {
'data-testid': 'azure-account-name',
},
id: 'root/azureAccountName',
formItemProps: {
initialValue: dbtSecurityConfig?.accountName,
},
},
{
name: 'dbtBucketName',
label: t('label.dbt-bucket-name'),
type: FieldTypes.TEXT,
required: false,
props: {
'data-testid': 'dbt-bucket-name',
},
id: 'root/dbtBucketName',
formItemProps: {
initialValue: dbtPrefixConfig?.dbtBucketName,
},
},
{
name: 'dbtObjectPrefix',
label: t('label.dbt-object-prefix'),
type: FieldTypes.TEXT,
required: false,
props: {
'data-testid': 'dbt-object-prefix',
},
id: 'root/dbtObjectPrefix',
formItemProps: {
initialValue: dbtPrefixConfig?.dbtObjectPrefix,
},
},
];
return (
<Fragment key="dbt-azure-config">
{generateFormFields(azureConfigFields)}
<DBTCommonFields
dbtClassificationName={dbtClassificationName}
dbtUpdateDescriptions={dbtUpdateDescriptions}
descriptionId="azure-update-description"
enableDebugLog={enableDebugLog}
includeTags={includeTags}
/>
</Fragment>
);
};

View File

@ -0,0 +1,39 @@
/*
* Copyright 2022 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/
import { render, screen } from '@testing-library/react';
import React from 'react';
import { DBTAzureConfig } from './DBTAzureConfig.component';
const mockProps = {
enableDebugLog: false,
};
jest.mock('./DBTCommonFields.component', () =>
jest.fn().mockImplementation(() => <div>DBT Common Fields</div>)
);
describe('Test DBT S3 Config Form', () => {
it('Fields should render', async () => {
render(<DBTAzureConfig {...mockProps} />);
const clientID = screen.getByTestId('azure-client-id');
const clientSecretKey = screen.getByTestId('azure-client-secret');
const azureTenantId = screen.getByTestId('azure-tenant-id');
const azureAccountName = screen.getByTestId('azure-account-name');
expect(clientID).toBeInTheDocument();
expect(clientSecretKey).toBeInTheDocument();
expect(azureTenantId).toBeInTheDocument();
expect(azureAccountName).toBeInTheDocument();
});
});

View File

@ -82,6 +82,15 @@ export type DbtConfigS3GCS = Pick<
| 'includeTags'
>;
export type DbtConfigAzure = Pick<
ModifiedDbtConfig,
| 'dbtSecurityConfig'
| 'dbtPrefixConfig'
| 'dbtUpdateDescriptions'
| 'dbtClassificationName'
| 'includeTags'
>;
export type DbtS3Creds = Pick<
Credentials,
| 'awsAccessKeyId'

View File

@ -20,6 +20,7 @@ import React, { FunctionComponent, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { generateFormFields } from 'utils/formUtils';
import { FormSubmitType } from '../../../enums/form.enum';
import { DBTAzureConfig } from './DBTAzureConfig.component';
import { DBTCloudConfig } from './DBTCloudConfig';
import { DBTConfigFormProps } from './DBTConfigForm.interface';
import { DBTSources } from './DBTFormConstants';
@ -160,6 +161,19 @@ const DBTConfigFormBuilder: FunctionComponent<DBTConfigFormProps> = ({
/>
);
}
case DBT_SOURCES.azure: {
return (
<DBTAzureConfig
dbtClassificationName={dbtConfigSource?.dbtClassificationName}
dbtPrefixConfig={dbtConfigSource?.dbtPrefixConfig}
dbtSecurityConfig={dbtConfigSource?.dbtSecurityConfig}
dbtUpdateDescriptions={dbtConfigSource?.dbtUpdateDescriptions}
enableDebugLog={data.enableDebugLog}
includeTags={dbtConfigSource?.includeTags}
/>
);
}
default: {
return (
<span data-testid="dbt-source-none">
@ -357,6 +371,32 @@ const DBTConfigFormBuilder: FunctionComponent<DBTConfigFormProps> = ({
onSubmit();
}
break;
case DBT_SOURCES.azure:
{
onChange({
dbtConfigSourceType: currentDbtConfigSourceType,
dbtConfigSource: {
dbtSecurityConfig: {
clientId: value?.clientId,
clientSecret: value?.clientSecret,
tenantId: value?.tenantId,
accountName: value?.accountName,
},
dbtPrefixConfig: {
dbtBucketName: value?.dbtBucketName,
dbtObjectPrefix: value?.dbtObjectPrefix,
},
dbtUpdateDescriptions: value?.dbtUpdateDescriptions,
dbtClassificationName: value?.dbtClassificationName,
includeTags: value?.includeTags,
},
ingestionName: value?.name,
enableDebugLog: value?.loggerLevel,
});
onSubmit();
}
break;
case DBT_SOURCES.gcs:
{

View File

@ -44,6 +44,10 @@ export const DBTSources: Array<DropDownListItem> = [
label: i18n.t('label.gcs-config-source'),
value: DBT_SOURCES.gcs,
},
{
label: i18n.t('label.azure-config-source'),
value: DBT_SOURCES.azure,
},
];
export const GCSCreds: Array<DropDownListItem> = [

View File

@ -17,6 +17,7 @@ export enum DBT_SOURCES {
http = 'http',
s3 = 's3',
gcs = 'gcs',
azure = 'azure',
}
export enum GCS_CONFIG {

View File

@ -6,6 +6,7 @@
"access": "Access",
"account": "Account",
"account-email": "Account email",
"account-name": "Account Name",
"action-plural": "Actions",
"active": "Active",
"active-user": "Active User",
@ -89,6 +90,7 @@
"aws-secret-access-key": "AWS Secret Access Key",
"aws-session-token": "AWS Session Token",
"azure": "Azure",
"azure-config-source": "Azure Config Source",
"back": "Back",
"back-to-login-lowercase": "back to login",
"basic-configuration": "Basic Configuration",
@ -122,8 +124,8 @@
"clear-entity": "Clear {{entity}}",
"click-here": "Click here",
"client-email": "Client Email",
"client-id": "ClientId",
"client-secret": "ClientSecret",
"client-id": "Client Id",
"client-secret": "Client Secret",
"client-x509-certificate-url": "Client x509 Certificate URL",
"close": "Close",
"close-with-comment": "Close with Comment",
@ -913,6 +915,7 @@
"team-plural": "Teams",
"team-plural-lowercase": "teams",
"team-type": "Team Type",
"tenant-id": "Tenant Id",
"term": "Term",
"term-lowercase": "term",
"term-plural": "Terms",

View File

@ -6,6 +6,7 @@
"access": "Acceso",
"account": "Cuenta",
"account-email": "Correo electrónico de la cuenta",
"account-name": "Account Name",
"action-plural": "Acciones",
"active": "Activo",
"active-user": "Usuario activo",
@ -89,6 +90,7 @@
"aws-secret-access-key": "Clave de acceso secreta de AWS",
"aws-session-token": "Token de sesión de AWS",
"azure": "Azure",
"azure-config-source": "Azure Config Source",
"back": "Volver",
"back-to-login-lowercase": "volver a iniciar sesión",
"basic-configuration": "Configuración básica",
@ -913,6 +915,7 @@
"team-plural": "Equipos",
"team-plural-lowercase": "equipos",
"team-type": "Tipo de Equipo",
"tenant-id": "Tenant Id",
"term": "Término",
"term-lowercase": "término",
"term-plural": "Términos",

View File

@ -6,6 +6,7 @@
"access": "Accès",
"account": "Compte",
"account-email": "Compte email",
"account-name": "Account Name",
"action-plural": "Actions",
"active": "Actif",
"active-user": "Utilisateur Actif",
@ -89,6 +90,7 @@
"aws-secret-access-key": "Clef Secrète d'Accès AWS",
"aws-session-token": "Jeton de Session AWS",
"azure": "Azure",
"azure-config-source": "Azure Config Source",
"back": "Précédent",
"back-to-login-lowercase": "retour à la page de connexion",
"basic-configuration": "Configuration de Base",
@ -913,6 +915,7 @@
"team-plural": "Equipes",
"team-plural-lowercase": "equipes",
"team-type": "Type d'équipe",
"tenant-id": "Tenant Id",
"term": "Terme",
"term-lowercase": "terme",
"term-plural": "Termes",

View File

@ -6,6 +6,7 @@
"access": "アクセス",
"account": "アカウント",
"account-email": "アカウントのEmail",
"account-name": "Account Name",
"action-plural": "アクション",
"active": "アクティブ",
"active-user": "アクティブなユーザ",
@ -89,6 +90,7 @@
"aws-secret-access-key": "AWSシークレットアクセスキー",
"aws-session-token": "AWSセッショントークン",
"azure": "Azure",
"azure-config-source": "Azure Config Source",
"back": "戻る",
"back-to-login-lowercase": "ログインに戻る",
"basic-configuration": "Basic Configuration",
@ -913,6 +915,7 @@
"team-plural": "チーム",
"team-plural-lowercase": "チーム",
"team-type": "チームタイプ",
"tenant-id": "Tenant Id",
"term": "Term",
"term-lowercase": "term",
"term-plural": "Terms",

View File

@ -6,6 +6,7 @@
"access": "Acesso",
"account": "Conta",
"account-email": "E-mail da conta",
"account-name": "Account Name",
"action-plural": "Ações",
"active": "Ativo",
"active-user": "Usuário ativo",
@ -89,6 +90,7 @@
"aws-secret-access-key": "AWS secret access key",
"aws-session-token": "AWS session token",
"azure": "Azure",
"azure-config-source": "Azure Config Source",
"back": "Voltar",
"back-to-login-lowercase": "voltar para login",
"basic-configuration": "Configuração básica",
@ -913,6 +915,7 @@
"team-plural": "Equipes",
"team-plural-lowercase": "equipes",
"team-type": "Tipo de Equipe",
"tenant-id": "Tenant Id",
"term": "Termo",
"term-lowercase": "termo",
"term-plural": "Termos",

View File

@ -6,6 +6,7 @@
"access": "访问",
"account": "帐号",
"account-email": "帐号邮箱",
"account-name": "Account Name",
"action-plural": "操作",
"active": "活跃的",
"active-user": "活跃用户",
@ -89,6 +90,7 @@
"aws-secret-access-key": "AWS Secret Access Key",
"aws-session-token": "AWS Session Token",
"azure": "Azure",
"azure-config-source": "Azure Config Source",
"back": "返回",
"back-to-login-lowercase": "返回登录",
"basic-configuration": "基本配置",
@ -913,6 +915,7 @@
"team-plural": "团队",
"team-plural-lowercase": "团队",
"team-type": "团队类型",
"tenant-id": "Tenant Id",
"term": "术语",
"term-lowercase": "术语",
"term-plural": "术语",

View File

@ -42,6 +42,12 @@ export const getSourceTypeFromConfig = (
gcsType = isString(data.dbtSecurityConfig.gcpConfig)
? GCS_CONFIG.GCSCredentialsPath
: GCS_CONFIG.GCSValues;
}
if (
!isNil(data.dbtSecurityConfig.clientId) ||
!isNil(data.dbtSecurityConfig.tenantId)
) {
sourceType = DBT_SOURCES.azure;
} else {
sourceType = DBT_SOURCES.s3;
}