diff --git a/openmetadata-service/src/main/java/org/openmetadata/service/secrets/converter/DbtPipelineClassConverter.java b/openmetadata-service/src/main/java/org/openmetadata/service/secrets/converter/DbtPipelineClassConverter.java index ccb52ecc0db..c49abbfc6b4 100644 --- a/openmetadata-service/src/main/java/org/openmetadata/service/secrets/converter/DbtPipelineClassConverter.java +++ b/openmetadata-service/src/main/java/org/openmetadata/service/secrets/converter/DbtPipelineClassConverter.java @@ -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> 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); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTAzureConfig.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTAzureConfig.component.tsx new file mode 100644 index 00000000000..1a1698eb22a --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTAzureConfig.component.tsx @@ -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 ( + + {generateFormFields(azureConfigFields)} + + + ); +}; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTAzureConfig.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTAzureConfig.test.tsx new file mode 100644 index 00000000000..4ee28d49ef9 --- /dev/null +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTAzureConfig.test.tsx @@ -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(() =>
DBT Common Fields
) +); + +describe('Test DBT S3 Config Form', () => { + it('Fields should render', async () => { + render(); + 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(); + }); +}); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTConfigForm.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTConfigForm.interface.ts index 6d6cb3e3400..89829aed07c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTConfigForm.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTConfigForm.interface.ts @@ -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' diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTConfigFormBuilder.tsx b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTConfigFormBuilder.tsx index bbd82872171..3539f1b3dc5 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTConfigFormBuilder.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTConfigFormBuilder.tsx @@ -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 = ({ /> ); } + case DBT_SOURCES.azure: { + return ( + + ); + } + default: { return ( @@ -357,6 +371,32 @@ const DBTConfigFormBuilder: FunctionComponent = ({ 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: { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTFormConstants.ts b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTFormConstants.ts index c64b3e02d76..59ccd09fb4c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTFormConstants.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTFormConstants.ts @@ -44,6 +44,10 @@ export const DBTSources: Array = [ 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 = [ diff --git a/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTFormEnum.ts b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTFormEnum.ts index 0577c28b67f..b7931529f4b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTFormEnum.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/common/DBTConfigFormBuilder/DBTFormEnum.ts @@ -17,6 +17,7 @@ export enum DBT_SOURCES { http = 'http', s3 = 's3', gcs = 'gcs', + azure = 'azure', } export enum GCS_CONFIG { diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json index 47deea93d29..b58159ff88a 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/en-us.json @@ -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", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json index b7e07b4d680..84f56a41da4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/es-es.json @@ -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", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json index ba50e967798..d234210638f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/fr-fr.json @@ -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", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json index 3dfd12d07ac..b48acbed0fc 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/ja-jp.json @@ -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", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json index c50a2f1a50c..5d6d39f6918 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/pt-br.json @@ -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", diff --git a/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json b/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json index a6e6b79b14c..f29b6391e47 100644 --- a/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json +++ b/openmetadata-ui/src/main/resources/ui/src/locale/languages/zh-cn.json @@ -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": "术语", diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/DBTConfigFormUtil.ts b/openmetadata-ui/src/main/resources/ui/src/utils/DBTConfigFormUtil.ts index 8371550068b..c8d120c7fb6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/DBTConfigFormUtil.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/DBTConfigFormUtil.ts @@ -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; }