Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: update credential for spanner/bigquery (#17349)

ecmadaocd4968964033
diff --git a/backend/migrator/migration/3.10/0000##migrate_instance_metadata.sql b/backend/migrator/migration/3.10/0000##migrate_instance_metadata.sql
new file mode 100644
index 0000000000..edd13d68cb
--- /dev/null
+++ b/backend/migrator/migration/3.10/0000##migrate_instance_metadata.sql
@@ -0,0 +1,34 @@
+-- Migrate instance metadata for Spanner and BigQuery instances with PASSWORD authentication
+-- Change authentication type from PASSWORD to GOOGLE_CLOUD_SQL_IAM
+-- Move obfuscatedPassword to gcpCredential.obfuscatedContent
+
+UPDATE instance
+SET metadata = jsonb_set(
+ metadata,
+ '{dataSources}',
+ (
+ SELECT jsonb_agg(
+ CASE
+ WHEN (ds->>'authenticationType' = 'PASSWORD'
+ AND ds ? 'obfuscatedPassword')
+ THEN
+ -- Remove obfuscatedPassword field
+ (ds - 'obfuscatedPassword') ||
+ -- Set authenticationType to GOOGLE_CLOUD_SQL_IAM
+ jsonb_build_object('authenticationType', 'GOOGLE_CLOUD_SQL_IAM') ||
+ -- Add gcpCredential with obfuscatedContent
+ jsonb_build_object('gcpCredential', jsonb_build_object('obfuscatedContent', ds->>'obfuscatedPassword'))
+ ELSE ds
+ END
+ )
+ FROM jsonb_array_elements(metadata->'dataSources') AS ds
+ )
+)
+WHERE metadata->>'engine' IN ('SPANNER', 'BIGQUERY')
+ AND metadata ? 'dataSources'
+ AND EXISTS (
+ SELECT 1
+ FROM jsonb_array_elements(metadata->'dataSources') AS ds
+ WHERE ds->>'authenticationType' = 'PASSWORD'
+ AND ds ? 'obfuscatedPassword'
+ );
\ No newline at end of file
diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index c7210ae4a6..5614375657 100644
--- a/backend/migrator/migrator_test.go
+++ b/backend/migrator/migrator_test.go
@@ -12,7 +12,7 @@ import (
func TestLatestVersion(t *testing.T) {
files, err := getSortedVersionedFiles()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("3.9.10"), *files[len(files)-1].version)
+ require.Equal(t, semver.MustParse("3.10.0"), *files[len(files)-1].version)
}
func TestVersionUnique(t *testing.T) {
diff --git a/backend/plugin/db/bigquery/bigquery.go b/backend/plugin/db/bigquery/bigquery.go
index 452adeae45..0fa5bc3dcf 100644
--- a/backend/plugin/db/bigquery/bigquery.go
+++ b/backend/plugin/db/bigquery/bigquery.go
@@ -56,8 +56,8 @@ func (d *Driver) Open(ctx context.Context, _ storepb.Engine, config db.Connectio
d.databaseName = config.ConnectionContext.DatabaseName
var o []option.ClientOption
- if config.DataSource.GetAuthenticationType() != storepb.DataSource_GOOGLE_CLOUD_SQL_IAM {
- o = append(o, option.WithCredentialsJSON([]byte(config.Password)))
+ if gcpCredential := config.DataSource.GetGcpCredential(); gcpCredential != nil {
+ o = append(o, option.WithCredentialsJSON([]byte(gcpCredential.Content)))
}
client, err := bigquery.NewClient(ctx, config.DataSource.Host, o...)
if err != nil {
diff --git a/backend/plugin/db/spanner/spanner.go b/backend/plugin/db/spanner/spanner.go
index 41e1855c69..67c81ab751 100644
--- a/backend/plugin/db/spanner/spanner.go
+++ b/backend/plugin/db/spanner/spanner.go
@@ -63,8 +63,8 @@ func (d *Driver) Open(ctx context.Context, _ storepb.Engine, config db.Connectio
d.connCtx = config.ConnectionContext
var o []option.ClientOption
- if config.DataSource.GetAuthenticationType() != storepb.DataSource_GOOGLE_CLOUD_SQL_IAM {
- o = append(o, option.WithCredentialsJSON([]byte(config.Password)))
+ if gcpCredential := config.DataSource.GetGcpCredential(); gcpCredential != nil {
+ o = append(o, option.WithCredentialsJSON([]byte(gcpCredential.Content)))
}
if config.ConnectionContext.DatabaseName != "" {
d.databaseName = config.ConnectionContext.DatabaseName
diff --git a/frontend/src/components/InstanceForm/Buttons.vue b/frontend/src/components/InstanceForm/Buttons.vue
index a35d1e4668..0b173d9d95 100644
--- a/frontend/src/components/InstanceForm/Buttons.vue
+++ b/frontend/src/components/InstanceForm/Buttons.vue
@@ -152,6 +152,18 @@ const allowUpdate = computed((): boolean => {
return false;
}
}
+ return !!basicInfo.value.title.trim();
+ }
+ if (basicInfo.value.engine === Engine.BIGQUERY) {
+ if (!adminDataSource.value.host) {
+ return false;
+ }
+ if (readonlyDataSourceList.value.length > 0) {
+ if (readonlyDataSourceList.value.some((ds) => !ds.host)) {
+ return false;
+ }
+ }
+ return !!basicInfo.value.title.trim();
}
return checkDataSource([
adminDataSource.value,
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vue b/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vue
index d272b7d610..4425859a89 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vue
@@ -4,7 +4,7 @@
class="w-full flex flex-col justify-start"
:class="props.className"
>
- <p class="w-full mt-1 text-sm text-gray-500">
+ <p class="w-full text-sm text-gray-500">
<template v-if="isEngineUsingSQL">
{{
props.dataSourceType === DataSourceType.ADMIN
@@ -28,10 +28,7 @@
</span>
</p>
<!-- Specify the fixed width so the create instance dialog width won't shift when switching engine types-->
- <div
- v-if="state.showCreateUserExample"
- class="mt-2 text-sm text-main w-208"
- >
+ <div v-if="state.showCreateUserExample" class="text-sm text-main w-208">
<template
v-if="
props.engine === Engine.MYSQL ||
@@ -108,7 +105,7 @@
</i18n-t>
</template>
<template v-else-if="props.engine === Engine.POSTGRES">
- <BBAttention class="my-3" type="warning">
+ <BBAttention class="my-2" type="warning">
{{ $t("instance.sentence.create-user-example.postgresql.warn") }}
</BBAttention>
<i18n-t
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/CredentialSourceForm.vue b/frontend/src/components/InstanceForm/DataSourceSection/CredentialSourceForm.vue
new file mode 100644
index 0000000000..a28ac782f2
--- /dev/null
+++ b/frontend/src/components/InstanceForm/DataSourceSection/CredentialSourceForm.vue
@@ -0,0 +1,340 @@
+<template>
+ <!-- eslint-disable vue/no-mutating-props -->
+ <div class="sm:col-span-3 sm:col-start-1">
+ <label for="credential-source" class="textlabel block">
+ {{ $t("instance.iam-extension.credential-source") }}
+ </label>
+ <NRadioGroup
+ v-model:value="credentialSource"
+ class="textlabel mt-2"
+ :disabled="!allowEdit"
+ >
+ <NRadio
+ v-for="option in iamExtensionOptions"
+ :value="option.value"
+ :key="option.value"
+ :label="option.label"
+ />
+ </NRadioGroup>
+ <template v-if="credentialSource === 'specific-credential'">
+ <div
+ v-if="
+ dataSource.authenticationType ===
+ DataSource_AuthenticationType.AZURE_IAM
+ "
+ class="mt-4 sm:col-span-3 sm:col-start-1"
+ >
+ <label for="tenant-id" class="textlabel block mt-2">
+ {{ $t("instance.iam-extension.tenant-id") }}
+ </label>
+ <NInput
+ v-model:value="
+ (dataSource.iamExtension?.case === 'azureCredential'
+ ? dataSource.iamExtension.value
+ : {}
+ ).tenantId
+ "
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ :placeholder="''"
+ @update:value="
+ (val) => {
+ if (dataSource.iamExtension?.case === 'azureCredential') {
+ dataSource.iamExtension.value.tenantId = val;
+ }
+ }
+ "
+ />
+ <label for="client-id" class="textlabel block mt-2">
+ {{ $t("instance.iam-extension.client-id") }}
+ </label>
+ <NInput
+ v-model:value="
+ (dataSource.iamExtension?.case === 'azureCredential'
+ ? dataSource.iamExtension.value
+ : {}
+ ).clientId
+ "
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ :placeholder="''"
+ @update:value="
+ (val) => {
+ if (dataSource.iamExtension?.case === 'azureCredential') {
+ dataSource.iamExtension.value.clientId = val;
+ }
+ }
+ "
+ />
+ <label for="client-secret" class="textlabel block mt-2">
+ {{ $t("instance.iam-extension.client-secret") }}
+ </label>
+ <NInput
+ type="password"
+ show-password-on="click"
+ v-model:value="
+ (dataSource.iamExtension?.case === 'azureCredential'
+ ? dataSource.iamExtension.value
+ : {}
+ ).clientSecret
+ "
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ :placeholder="$t('instance.type-or-paste-credentials-write-only')"
+ @update:value="
+ (val) => {
+ if (dataSource.iamExtension?.case === 'azureCredential') {
+ dataSource.iamExtension.value.clientSecret = val;
+ }
+ }
+ "
+ />
+ </div>
+ <div
+ v-else-if="
+ dataSource.authenticationType ===
+ DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM
+ "
+ class="mt-2 sm:col-span-3 sm:col-start-1"
+ >
+ <GcpCredentialInput
+ v-model:value="
+ (dataSource.iamExtension?.case === 'gcpCredential'
+ ? dataSource.iamExtension.value
+ : {}
+ ).content
+ "
+ />
+ </div>
+ <div
+ v-else-if="
+ dataSource.authenticationType ===
+ DataSource_AuthenticationType.AWS_RDS_IAM
+ "
+ class="mt-4 sm:col-span-3 sm:col-start-1"
+ >
+ <label class="textlabel block mt-2"> Access Key ID </label>
+ <NInput
+ v-model:value="
+ (dataSource.iamExtension?.case === 'awsCredential'
+ ? dataSource.iamExtension.value
+ : {}
+ ).accessKeyId
+ "
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ :placeholder="$t('common.write-only')"
+ @update:value="
+ (val) => {
+ if (dataSource.iamExtension?.case === 'awsCredential') {
+ dataSource.iamExtension.value.accessKeyId = val;
+ }
+ }
+ "
+ />
+ <label class="textlabel block mt-2"> Secret Access Key </label>
+ <NInput
+ v-model:value="
+ (dataSource.iamExtension?.case === 'awsCredential'
+ ? dataSource.iamExtension.value
+ : {}
+ ).secretAccessKey
+ "
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ :placeholder="$t('common.write-only')"
+ @update:value="
+ (val) => {
+ if (dataSource.iamExtension?.case === 'awsCredential') {
+ dataSource.iamExtension.value.secretAccessKey = val;
+ }
+ }
+ "
+ />
+ <label class="textlabel block mt-2"> Session Token </label>
+ <NInput
+ v-model:value="
+ (dataSource.iamExtension?.case === 'awsCredential'
+ ? dataSource.iamExtension.value
+ : {}
+ ).sessionToken
+ "
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ :placeholder="$t('common.write-only')"
+ @update:value="
+ (val) => {
+ if (dataSource.iamExtension?.case === 'awsCredential') {
+ dataSource.iamExtension.value.sessionToken = val;
+ }
+ }
+ "
+ />
+ </div>
+ </template>
+ <div
+ v-else-if="credentialSource === 'default'"
+ class="mt-1 sm:col-span-3 sm:col-start-1 textinfolabel !leading-6 credential"
+ >
+ <span
+ v-if="
+ dataSource.authenticationType ===
+ DataSource_AuthenticationType.AZURE_IAM
+ "
+ >
+ Bytebase will read the credential from environment variables
+ <code class="code">AZURE_CLIENT_ID</code>/
+ <code class="code">AZURE_TENANT_ID</code>/
+ <code class="code">AZURE_CLIENT_SECRET</code>
+ or
+ <code class="code">AZURE_CLIENT_CERTIFICATE_PATH</code>, and fallback to
+ attached users in Azure VM
+ </span>
+ <span
+ v-else-if="
+ dataSource.authenticationType ===
+ DataSource_AuthenticationType.AWS_RDS_IAM
+ "
+ >
+ Bytebase will read the credential from environment variables
+ <code class="code">AWS_ACCESS_KEY_ID</code>/
+ <code class="code">AWS_SECRET_ACCESS_KEY</code>/
+ <code class="code">AWS_SESSION_TOKEN</code>, fallback to shared
+ credentials file <code class="code">~/.aws/credentials</code> or IAM
+ role in AWS ECS
+ </span>
+ <span
+ v-else-if="
+ dataSource.authenticationType ===
+ DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM
+ "
+ >
+ Bytebase will read the credential from environment variable
+ <code class="code">GOOGLE_APPLICATION_CREDENTIALS</code>, fallback to
+ the attached service account in GCP GCE
+ </span>
+ </div>
+ </div>
+</template>
+
+<script lang="tsx" setup>
+/* eslint-disable vue/no-mutating-props */
+import { create } from "@bufbuild/protobuf";
+import { NRadioGroup, NRadio, NInput } from "naive-ui";
+import { computed, watch, ref } from "vue";
+import { useI18n } from "vue-i18n";
+import {
+ DataSource_AuthenticationType,
+ DataSource_AzureCredentialSchema,
+ DataSource_AWSCredentialSchema,
+ DataSource_GCPCredentialSchema,
+} from "@/types/proto-es/v1/instance_service_pb";
+import type { EditDataSource } from "../common";
+import GcpCredentialInput from "./GcpCredentialInput.vue";
+
+type credentialSource = "default" | "specific-credential";
+
+const props = defineProps<{
+ allowEdit: boolean;
+ dataSource: EditDataSource;
+}>();
+
+const credentialSource = ref<credentialSource>("default");
+
+const { t } = useI18n();
+
+const iamExtensionOptions = computed(() => {
+ return [
+ {
+ label: t("common.Default"),
+ value: "default",
+ },
+ {
+ label: t("instance.iam-extension.specific-credential"),
+ value: "specific-credential",
+ },
+ ];
+});
+
+watch(
+ [
+ () => props.dataSource.iamExtension?.case === "azureCredential",
+ () => props.dataSource.iamExtension?.case === "awsCredential",
+ () => props.dataSource.iamExtension?.case === "gcpCredential",
+ ],
+ (credentials) => {
+ if (credentials.some((c) => c === true)) {
+ credentialSource.value = "specific-credential";
+ } else {
+ credentialSource.value = "default";
+ }
+ },
+ { immediate: true, deep: true }
+);
+
+watch(
+ () => props.dataSource.authenticationType,
+ () => {
+ credentialSource.value = "default";
+ }
+);
+
+watch(
+ () => credentialSource.value,
+ (source) => {
+ switch (props.dataSource.authenticationType) {
+ case DataSource_AuthenticationType.AWS_RDS_IAM:
+ if (source === "default") {
+ props.dataSource.iamExtension = { case: undefined };
+ } else {
+ props.dataSource.iamExtension = {
+ case: "awsCredential",
+ value: create(
+ DataSource_AWSCredentialSchema,
+ props.dataSource.iamExtension?.case === "awsCredential"
+ ? props.dataSource.iamExtension.value
+ : {}
+ ),
+ };
+ }
+ break;
+ case DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM:
+ if (source === "default") {
+ props.dataSource.iamExtension = { case: undefined };
+ } else {
+ props.dataSource.iamExtension = {
+ case: "gcpCredential",
+ value: create(
+ DataSource_GCPCredentialSchema,
+ props.dataSource.iamExtension?.case === "gcpCredential"
+ ? props.dataSource.iamExtension.value
+ : {}
+ ),
+ };
+ }
+ break;
+ case DataSource_AuthenticationType.AZURE_IAM:
+ if (source === "default") {
+ props.dataSource.iamExtension = { case: undefined };
+ } else {
+ props.dataSource.iamExtension = {
+ case: "azureCredential",
+ value: create(
+ DataSource_AzureCredentialSchema,
+ props.dataSource.iamExtension?.case === "azureCredential"
+ ? props.dataSource.iamExtension.value
+ : {}
+ ),
+ };
+ }
+ break;
+ }
+ }
+);
+</script>
+
+<style lang="postcss" scoped>
+.credential :deep(.code) {
+ @apply bg-gray-100 p-1 rounded-sm mr-1;
+}
+</style>
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
index 3cb4c81635..5b9e380009 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
@@ -1,1248 +1,962 @@
<template>
<!-- eslint-disable vue/no-mutating-props -->
- <template
- v-if="
- basicInfo.engine !== Engine.SPANNER &&
- basicInfo.engine !== Engine.BIGQUERY &&
- basicInfo.engine !== Engine.DYNAMODB &&
- basicInfo.engine !== Engine.DATABRICKS
- "
- >
- <div
+ <div class="grid grid-cols-1 gap-y-4 gap-x-4 border-none sm:grid-cols-3">
+ <template
v-if="
- basicInfo.engine === Engine.MYSQL ||
- basicInfo.engine === Engine.POSTGRES ||
- basicInfo.engine === Engine.COSMOSDB ||
- basicInfo.engine === Engine.MSSQL ||
- basicInfo.engine === Engine.ELASTICSEARCH
+ basicInfo.engine !== Engine.SPANNER &&
+ basicInfo.engine !== Engine.BIGQUERY &&
+ basicInfo.engine !== Engine.DYNAMODB &&
+ basicInfo.engine !== Engine.DATABRICKS
"
- class="mt-2 sm:col-span-3 sm:col-start-1"
>
- <template v-if="basicInfo.engine === Engine.COSMOSDB">
- <NRadioGroup
- v-model:value="dataSource.authenticationType"
- class="textlabel"
- :disabled="!allowEdit"
- >
- <NRadio :value="DataSource_AuthenticationType.AZURE_IAM">
- {{ $t("instance.password-type.azure-iam") }}
- </NRadio>
- </NRadioGroup>
- </template>
- <template v-else-if="basicInfo.engine === Engine.MSSQL">
- <NRadioGroup
- v-model:value="dataSource.authenticationType"
- class="textlabel"
- :disabled="!allowEdit"
- >
- <NRadio :value="DataSource_AuthenticationType.PASSWORD">
- {{ $t("instance.password-type.password") }}
- </NRadio>
- <NRadio :value="DataSource_AuthenticationType.AZURE_IAM">
- {{ $t("instance.password-type.azure-iam") }}
- </NRadio>
- </NRadioGroup>
- </template>
- <template v-else-if="basicInfo.engine === Engine.ELASTICSEARCH">
- <NRadioGroup
- v-model:value="dataSource.authenticationType"
- class="textlabel"
- :disabled="!allowEdit"
- >
- <NRadio :value="DataSource_AuthenticationType.PASSWORD">
- {{ $t("instance.password-type.password") }}
- </NRadio>
- <NRadio :value="DataSource_AuthenticationType.AWS_RDS_IAM">
- {{ $t("instance.password-type.aws-iam") }}
- </NRadio>
- </NRadioGroup>
- </template>
- <template v-else>
+ <div
+ v-if="
+ basicInfo.engine === Engine.MYSQL ||
+ basicInfo.engine === Engine.POSTGRES ||
+ basicInfo.engine === Engine.COSMOSDB ||
+ basicInfo.engine === Engine.MSSQL ||
+ basicInfo.engine === Engine.ELASTICSEARCH
+ "
+ class="sm:col-span-3 sm:col-start-1"
+ >
<NRadioGroup
v-model:value="dataSource.authenticationType"
class="textlabel"
:disabled="!allowEdit"
>
- <NRadio :value="DataSource_AuthenticationType.PASSWORD">
- {{ $t("instance.password-type.password") }}
- </NRadio>
- <NRadio :value="DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM">
- {{ $t("instance.password-type.google-iam") }}
- </NRadio>
- <NRadio :value="DataSource_AuthenticationType.AWS_RDS_IAM">
- {{ $t("instance.password-type.aws-iam") }}
+ <NRadio
+ v-for="item in supportedAuthenticationTypes"
+ :key="item.value"
+ :value="item.value"
+ >
+ {{ item.label }}
</NRadio>
</NRadioGroup>
- </template>
- </div>
- <div
- v-else-if="basicInfo.engine === Engine.HIVE"
- class="mt-2 sm:col-span-3 sm:col-start-1"
- >
- <NRadioGroup
- :value="hiveAuthentication"
- class="textlabel"
- :disabled="!allowEdit"
- @update:value="onHiveAuthenticationChange"
- >
- <NRadio value="PASSWORD"> Plain password </NRadio>
- <NRadio value="KERBEROS"> Kerberos </NRadio>
- </NRadioGroup>
- </div>
- <CreateDataSourceExample
- class-name="sm:col-span-3 border-none mt-2"
- :create-instance-flag="isCreating"
- :engine="basicInfo.engine"
- :data-source-type="dataSource.type"
- :authentication-type="dataSource.authenticationType"
- />
- <div
- v-if="dataSource.saslConfig?.mechanism?.case === 'krbConfig'"
- class="sm:col-span-3 sm:col-start-1"
- >
- <div class="mt-4 sm:col-span-3 sm:col-start-1">
- <label class="textlabel block">
- Principal
- <span class="text-red-600">*</span>
- </label>
- <div class="flex mt-2 items-center space-x-2">
- <NInput
- :value="
- dataSource.saslConfig?.mechanism?.case === 'krbConfig'
- ? dataSource.saslConfig.mechanism.value.primary
- : ''
- "
- :disabled="!allowEdit"
- placeholder="primary"
- @update:value="
- (val) => {
- if (dataSource.saslConfig?.mechanism?.case === 'krbConfig') {
- dataSource.saslConfig.mechanism.value.primary = val;
- }
- }
- "
- />
- <span>/</span>
- <NInput
- :value="
- dataSource.saslConfig?.mechanism?.case === 'krbConfig'
- ? dataSource.saslConfig.mechanism.value.instance
- : ''
- "
- :disabled="!allowEdit"
- placeholder="instance, optional"
- @update:value="
- (val) => {
- if (dataSource.saslConfig?.mechanism?.case === 'krbConfig') {
- dataSource.saslConfig.mechanism.value.instance = val;
- }
- }
- "
- />
- <span>@</span>
- <NInput
- :value="
- dataSource.saslConfig?.mechanism?.case === 'krbConfig'
- ? dataSource.saslConfig.mechanism.value.realm
- : ''
- "
- :disabled="!allowEdit"
- placeholder="realm"
- @update:value="
- (val) => {
- if (dataSource.saslConfig?.mechanism?.case === 'krbConfig') {
- dataSource.saslConfig.mechanism.value.realm = val;
- }
- }
- "
- />
- </div>
</div>
- <div class="mt-4 sm:col-span-3 sm:col-start-1">
- <label class="textlabel block">
- KDC
- <span class="text-red-600">*</span>
- </label>
- <div class="flex items-center space-x-2">
- <div class="w-fit">
- <NRadioGroup
- :value="
- dataSource.saslConfig?.mechanism?.case === 'krbConfig'
- ? dataSource.saslConfig.mechanism.value.kdcTransportProtocol
- : 'tcp'
- "
- class="textlabel w-32"
- :disabled="!allowEdit"
- @update:value="
- (val) => {
- if (dataSource.saslConfig?.mechanism?.case === 'krbConfig') {
- dataSource.saslConfig.mechanism.value.kdcTransportProtocol =
- val;
- }
- }
- "
- >
- <NRadio value="tcp"> TCP </NRadio>
- <NRadio value="udp"> UDP </NRadio>
- </NRadioGroup>
- </div>
- <NInput
- :value="
- dataSource.saslConfig?.mechanism?.case === 'krbConfig'
- ? dataSource.saslConfig.mechanism.value.kdcHost
- : ''
- "
- :disabled="!allowEdit"
- placeholder="KDC host"
- @update:value="
- (val) => {
- if (dataSource.saslConfig?.mechanism?.case === 'krbConfig') {
- dataSource.saslConfig.mechanism.value.kdcHost = val;
- }
- }
- "
- />
- <span>:</span>
- <NInput
- :value="
- dataSource.saslConfig?.mechanism?.case === 'krbConfig'
- ? dataSource.saslConfig.mechanism.value.kdcPort
- : ''
- "
- :disabled="!allowEdit"
- placeholder="KDC port, optional"
- :allow-input="onlyAllowNumber"
- @update:value="
- (val) => {
- if (dataSource.saslConfig?.mechanism?.case === 'krbConfig') {
- dataSource.saslConfig.mechanism.value.kdcPort = val;
- }
- }
- "
- />
- </div>
- </div>
- <div class="mt-4 sm:col-span-3 sm:col-start-1">
- <label class="textlabel block">
- Keytab File
- <span class="text-red-600">*</span>
- </label>
-
- <NUpload :max="1" @change="handleKeytabUpload">
- <NUploadDragger class="mt-3">
- <span class="text-gray-400"
- >Click or Drag your .keytab file here</span
- >
- </NUploadDragger>
- </NUpload>
- </div>
- </div>
- <div v-else class="sm:col-span-3 sm:col-start-1">
<div
- v-if="
- dataSource.authenticationType !==
- DataSource_AuthenticationType.AZURE_IAM
- "
- class="mt-4 sm:col-span-3 sm:col-start-1"
+ v-else-if="basicInfo.engine === Engine.HIVE"
+ class="sm:col-span-3 sm:col-start-1"
>
- <label for="username" class="textlabel block">
- {{ $t("common.username") }}
- </label>
- <!-- For mysql, username can be empty indicating anonymous user.
- But it's a very bad practice to use anonymous user for admin operation,
- thus we make it REQUIRED here.-->
- <NInput
- v-model:value="dataSource.username"
- class="mt-2 w-full"
- :disabled="!allowEdit"
- :placeholder="
- basicInfo.engine === Engine.CLICKHOUSE ? $t('common.default') : ''
- "
- />
- </div>
- <div
- v-if="
- dataSource.authenticationType ===
- DataSource_AuthenticationType.AZURE_IAM ||
- dataSource.authenticationType ===
- DataSource_AuthenticationType.AWS_RDS_IAM ||
- dataSource.authenticationType ===
- DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM
- "
- class="mt-4 sm:col-span-3 sm:col-start-1"
- >
- <label for="credential-source" class="textlabel block">
- {{ $t("instance.iam-extension.credential-source") }}
- </label>
<NRadioGroup
- v-model:value="state.credentialSource"
+ :value="hiveAuthentication"
class="textlabel"
:disabled="!allowEdit"
+ @update:value="onHiveAuthenticationChange"
>
- <NRadio
- v-for="option in getIAMExtensionOptions(
- DataSource_AuthenticationType.AZURE_IAM
- )"
- :value="option.value"
- :key="option.value"
- :label="option.label"
- />
+ <NRadio value="PASSWORD"> Plain Password </NRadio>
+ <NRadio value="KERBEROS"> Kerberos </NRadio>
</NRadioGroup>
- <template v-if="state.credentialSource === 'specific-credential'">
- <div
- v-if="
- dataSource.authenticationType ===
- DataSource_AuthenticationType.AZURE_IAM
- "
- class="mt-4 sm:col-span-3 sm:col-start-1"
- >
- <label for="tenant-id" class="textlabel block mt-2">
- {{ $t("instance.iam-extension.tenant-id") }}
- </label>
+ </div>
+ <CreateDataSourceExample
+ class-name="sm:col-span-3 border-none"
+ :create-instance-flag="isCreating"
+ :engine="basicInfo.engine"
+ :data-source-type="dataSource.type"
+ :authentication-type="dataSource.authenticationType"
+ />
+ <template v-if="dataSource.saslConfig?.mechanism?.case === 'krbConfig'">
+ <div class="sm:col-span-3 sm:col-start-1">
+ <label class="textlabel block">
+ Principal
+ <span class="text-red-600">*</span>
+ </label>
+ <div class="mt-2 flex items-center space-x-2">
<NInput
- v-model:value="
- (dataSource.iamExtension?.case === 'azureCredential'
- ? dataSource.iamExtension.value
- : {}
- ).tenantId
+ :value="
+ dataSource.saslConfig?.mechanism?.case === 'krbConfig'
+ ? dataSource.saslConfig.mechanism.value.primary
+ : ''
"
- class="mt-2 w-full"
:disabled="!allowEdit"
- :placeholder="''"
+ placeholder="primary"
@update:value="
(val) => {
- if (dataSource.iamExtension?.case === 'azureCredential') {
- dataSource.iamExtension.value.tenantId = val;
+ if (dataSource.saslConfig?.mechanism?.case === 'krbConfig') {
+ dataSource.saslConfig.mechanism.value.primary = val;
}
}
"
/>
- <label for="client-id" class="textlabel block mt-2">
- {{ $t("instance.iam-extension.client-id") }}
- </label>
+ <span>/</span>
<NInput
- v-model:value="
- (dataSource.iamExtension?.case === 'azureCredential'
- ? dataSource.iamExtension.value
- : {}
- ).clientId
+ :value="
+ dataSource.saslConfig?.mechanism?.case === 'krbConfig'
+ ? dataSource.saslConfig.mechanism.value.instance
+ : ''
"
- class="mt-2 w-full"
:disabled="!allowEdit"
- :placeholder="''"
+ placeholder="instance, optional"
@update:value="
(val) => {
- if (dataSource.iamExtension?.case === 'azureCredential') {
- dataSource.iamExtension.value.clientId = val;
+ if (dataSource.saslConfig?.mechanism?.case === 'krbConfig') {
+ dataSource.saslConfig.mechanism.value.instance = val;
}
}
"
/>
- <label for="client-secret" class="textlabel block mt-2">
- {{ $t("instance.iam-extension.client-secret") }}
- </label>
+ <span>@</span>
<NInput
- type="password"
- show-password-on="click"
- v-model:value="
- (dataSource.iamExtension?.case === 'azureCredential'
- ? dataSource.iamExtension.value
- : {}
- ).clientSecret
- "
- class="mt-2 w-full"
- :disabled="!allowEdit"
- :placeholder="$t('instance.type-or-paste-credentials-write-only')"
- @update:value="
- (val) => {
- if (dataSource.iamExtension?.case === 'azureCredential') {
- dataSource.iamExtension.value.clientSecret = val;
- }
- }
- "
- />
- </div>
- <div
- v-else-if="
- dataSource.authenticationType ===
- DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM
- "
- class="mt-4 sm:col-span-3 sm:col-start-1"
- >
- <label class="textlabel block mt-2"> Credential File Content</label>
- <NInput
- v-model:value="
- (dataSource.iamExtension?.case === 'gcpCredential'
- ? dataSource.iamExtension.value
- : {}
- ).content
+ :value="
+ dataSource.saslConfig?.mechanism?.case === 'krbConfig'
+ ? dataSource.saslConfig.mechanism.value.realm
+ : ''
"
- type="textarea"
- class="mt-2 w-full"
:disabled="!allowEdit"
- :placeholder="$t('instance.type-or-paste-credentials-write-only')"
+ placeholder="realm"
@update:value="
(val) => {
- if (dataSource.iamExtension?.case === 'gcpCredential') {
- dataSource.iamExtension.value.content = val;
+ if (dataSource.saslConfig?.mechanism?.case === 'krbConfig') {
+ dataSource.saslConfig.mechanism.value.realm = val;
}
}
"
/>
</div>
- <div
- v-else-if="
- dataSource.authenticationType ===
- DataSource_AuthenticationType.AWS_RDS_IAM
- "
- class="mt-4 sm:col-span-3 sm:col-start-1"
- >
- <label class="textlabel block mt-2"> Access Key ID </label>
- <NInput
- v-model:value="
- (dataSource.iamExtension?.case === 'awsCredential'
- ? dataSource.iamExtension.value
- : {}
- ).accessKeyId
- "
- class="mt-2 w-full"
- :disabled="!allowEdit"
- :placeholder="$t('common.write-only')"
- @update:value="
- (val) => {
- if (dataSource.iamExtension?.case === 'awsCredential') {
- dataSource.iamExtension.value.accessKeyId = val;
+ </div>
+ <div class="sm:col-span-3 sm:col-start-1">
+ <label class="textlabel block">
+ KDC
+ <span class="text-red-600">*</span>
+ </label>
+ <div class="flex items-center space-x-2">
+ <div class="w-fit">
+ <NRadioGroup
+ :value="
+ dataSource.saslConfig?.mechanism?.case === 'krbConfig'
+ ? dataSource.saslConfig.mechanism.value.kdcTransportProtocol
+ : 'tcp'
+ "
+ class="textlabel w-32"
+ :disabled="!allowEdit"
+ @update:value="
+ (val) => {
+ if (
+ dataSource.saslConfig?.mechanism?.case === 'krbConfig'
+ ) {
+ dataSource.saslConfig.mechanism.value.kdcTransportProtocol =
+ val;
+ }
}
- }
- "
- />
- <label class="textlabel block mt-2"> Secret Access Key </label>
+ "
+ >
+ <NRadio value="tcp"> TCP </NRadio>
+ <NRadio value="udp"> UDP </NRadio>
+ </NRadioGroup>
+ </div>
<NInput
- v-model:value="
- (dataSource.iamExtension?.case === 'awsCredential'
- ? dataSource.iamExtension.value
- : {}
- ).secretAccessKey
+ :value="
+ dataSource.saslConfig?.mechanism?.case === 'krbConfig'
+ ? dataSource.saslConfig.mechanism.value.kdcHost
+ : ''
"
- class="mt-2 w-full"
:disabled="!allowEdit"
- :placeholder="$t('common.write-only')"
+ placeholder="KDC host"
@update:value="
(val) => {
- if (dataSource.iamExtension?.case === 'awsCredential') {
- dataSource.iamExtension.value.secretAccessKey = val;
+ if (dataSource.saslConfig?.mechanism?.case === 'krbConfig') {
+ dataSource.saslConfig.mechanism.value.kdcHost = val;
}
}
"
/>
- <label class="textlabel block mt-2"> Session Token </label>
+ <span>:</span>
<NInput
- v-model:value="
- (dataSource.iamExtension?.case === 'awsCredential'
- ? dataSource.iamExtension.value
- : {}
- ).sessionToken
+ :value="
+ dataSource.saslConfig?.mechanism?.case === 'krbConfig'
+ ? dataSource.saslConfig.mechanism.value.kdcPort
+ : ''
"
- class="mt-2 w-full"
:disabled="!allowEdit"
- :placeholder="$t('common.write-only')"
+ placeholder="KDC port, optional"
+ :allow-input="onlyAllowNumber"
@update:value="
(val) => {
- if (dataSource.iamExtension?.case === 'awsCredential') {
- dataSource.iamExtension.value.sessionToken = val;
+ if (dataSource.saslConfig?.mechanism?.case === 'krbConfig') {
+ dataSource.saslConfig.mechanism.value.kdcPort = val;
}
}
"
/>
</div>
- </template>
+ </div>
+ <div class="sm:col-span-3 sm:col-start-1">
+ <label class="textlabel block">
+ Keytab File
+ <span class="text-red-600">*</span>
+ </label>
+ <NUpload :max="1" @change="handleKeytabUpload">
+ <NUploadDragger class="mt-3">
+ <span class="textinfolabel"
+ >Click or Drag your .keytab file here</span
+ >
+ </NUploadDragger>
+ </NUpload>
+ </div>
+ </template>
+ <template v-else>
<div
- v-else-if="state.credentialSource === 'default'"
- class="mt-1 sm:col-span-3 sm:col-start-1 textinfolabel !leading-6 credential"
+ v-if="
+ dataSource.authenticationType !==
+ DataSource_AuthenticationType.AZURE_IAM
+ "
+ class="sm:col-span-3 sm:col-start-1"
>
- <span
- v-if="
- dataSource.authenticationType ===
- DataSource_AuthenticationType.AZURE_IAM
- "
- >
- Bytebase will read the credential from environment variables
- <code class="code">AZURE_CLIENT_ID</code>/
- <code class="code">AZURE_TENANT_ID</code>/
- <code class="code">AZURE_CLIENT_SECRET</code>
- or
- <code class="code">AZURE_CLIENT_CERTIFICATE_PATH</code>, and
- fallback to attached users in Azure VM
- </span>
- <span
- v-else-if="
- dataSource.authenticationType ===
- DataSource_AuthenticationType.AWS_RDS_IAM
- "
- >
- Bytebase will read the credential from environment variables
- <code class="code">AWS_ACCESS_KEY_ID</code>/
- <code class="code">AWS_SECRET_ACCESS_KEY</code>/
- <code class="code">AWS_SESSION_TOKEN</code>, fallback to shared
- credentials file <code class="code">~/.aws/credentials</code> or IAM
- role in AWS ECS
- </span>
- <span
- v-else-if="
- dataSource.authenticationType ===
- DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM
+ <label for="username" class="textlabel block">
+ {{ $t("common.username") }}
+ </label>
+ <!-- For mysql, username can be empty indicating anonymous user.
+ But it's a very bad practice to use anonymous user for admin operation,
+ thus we make it REQUIRED here.-->
+ <NInput
+ v-model:value="dataSource.username"
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ :placeholder="
+ basicInfo.engine === Engine.CLICKHOUSE ? $t('common.default') : ''
"
- >
- Bytebase will read the credential from environment variable
- <code class="code">GOOGLE_APPLICATION_CREDENTIALS</code>, fallback
- to the attached service account in GCP GCE
- </span>
+ />
</div>
- </div>
- <div
- v-if="
- dataSource.authenticationType ===
- DataSource_AuthenticationType.AWS_RDS_IAM
- "
- class="mt-4 sm:col-span-3 sm:col-start-1"
- >
- <label for="username" class="textlabel block">
- {{ $t("instance.database-region") }}
- <span class="text-red-600">*</span>
- </label>
- <NInput
- v-model:value="dataSource.region"
- class="mt-2 w-full"
- :disabled="!allowEdit"
- :placeholder="'database region, for example, us-east-1'"
+ <CredentialSourceForm
+ v-if="
+ dataSource.authenticationType ===
+ DataSource_AuthenticationType.AZURE_IAM ||
+ dataSource.authenticationType ===
+ DataSource_AuthenticationType.AWS_RDS_IAM ||
+ dataSource.authenticationType ===
+ DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM
+ "
+ :data-source="dataSource"
+ :allow-edit="allowEdit"
/>
- </div>
- <div
- v-if="
- dataSource.authenticationType ===
- DataSource_AuthenticationType.PASSWORD
- "
- class="mt-4 sm:col-span-3 sm:col-start-1"
- >
- <div v-if="!hideAdvancedFeatures" class="mb-4">
- <NRadioGroup
- class="textlabel"
- :value="state.passwordType"
+ <div
+ v-if="
+ dataSource.authenticationType ===
+ DataSource_AuthenticationType.AWS_RDS_IAM
+ "
+ class="sm:col-span-3 sm:col-start-1"
+ >
+ <label for="username" class="textlabel block">
+ {{ $t("instance.database-region") }}
+ <span class="text-red-600">*</span>
+ </label>
+ <NInput
+ v-model:value="dataSource.region"
+ class="mt-2 w-full"
:disabled="!allowEdit"
- @update:value="changeSecretType"
- >
- <NRadio
- :value="
- DataSourceExternalSecret_SecretType.SAECRET_TYPE_UNSPECIFIED
- "
- >
- {{ $t("instance.password-type.password") }}
- </NRadio>
- <NRadio :value="DataSourceExternalSecret_SecretType.VAULT_KV_V2">
- <div class="flex items-center gap-x-1">
- {{ $t("instance.password-type.external-secret-vault") }}
- <FeatureBadge
- :feature="PlanFeature.FEATURE_EXTERNAL_SECRET_MANAGER"
- />
- </div>
- </NRadio>
- <NRadio
- :value="DataSourceExternalSecret_SecretType.AWS_SECRETS_MANAGER"
- >
- <div class="flex items-center gap-x-1">
- {{ $t("instance.password-type.external-secret-aws") }}
- <FeatureBadge
- :feature="PlanFeature.FEATURE_EXTERNAL_SECRET_MANAGER"
- />
- </div>
- </NRadio>
- <NRadio
- :value="DataSourceExternalSecret_SecretType.GCP_SECRET_MANAGER"
- >
- <div class="flex items-center gap-x-1">
- {{ $t("instance.password-type.external-secret-gcp") }}
- <FeatureBadge
- :feature="PlanFeature.FEATURE_EXTERNAL_SECRET_MANAGER"
- />
- </div>
- </NRadio>
- </NRadioGroup>
- <LearnMoreLink
- url="https://docs.bytebase.com/get-started/connect/overview#secret-manager-integration"
- class="text-sm"
+ :placeholder="'database region, for example, us-east-1'"
/>
</div>
<div
v-if="
- state.passwordType ===
- DataSourceExternalSecret_SecretType.SAECRET_TYPE_UNSPECIFIED
+ dataSource.authenticationType ===
+ DataSource_AuthenticationType.PASSWORD
"
+ class="sm:col-span-3 sm:col-start-1"
>
- <label class="textlabel block">
- {{ $t("common.password") }}
- </label>
- <div v-if="!hideAdvancedFeatures" class="flex space-x-2 text-sm">
- <div class="text-gray-400">
- {{ $t("instance.password-type.password-tip") }}
- </div>
- <LearnMoreLink
- url="https://docs.bytebase.com/get-started/connect/overview/#use-secret-manager?source=console"
- class="ml-1 text-sm"
- />
- <FeatureBadge
- :feature="PlanFeature.FEATURE_EXTERNAL_SECRET_MANAGER"
- />
- </div>
- <div class="mt-2">
- <NCheckbox
- v-if="!isCreating && allowUsingEmptyPassword"
- :size="'small'"
- :checked="dataSource.useEmptyPassword"
+ <div v-if="!hideAdvancedFeatures" class="mb-4">
+ <NRadioGroup
+ class="textlabel"
+ :value="state.passwordType"
:disabled="!allowEdit"
- @update:checked="toggleUseEmptyPassword"
+ @update:value="changeSecretType"
>
- {{ $t("instance.no-password") }}
- </NCheckbox>
- <NInput
- type="password"
- show-password-on="click"
- class="w-full"
- :input-props="{ autocomplete: 'off' }"
- :placeholder="
- dataSource.useEmptyPassword
- ? $t('instance.no-password')
- : $t('instance.password-write-only')
- "
- :disabled="!allowEdit || dataSource.useEmptyPassword"
- :value="
- dataSource.useEmptyPassword ? '' : dataSource.updatedPassword
- "
- @update:value="dataSource.updatedPassword = $event.trim()"
+ <NRadio
+ :value="
+ DataSourceExternalSecret_SecretType.SAECRET_TYPE_UNSPECIFIED
+ "
+ >
+ {{ $t("instance.password-type.password") }}
+ </NRadio>
+ <NRadio :value="DataSourceExternalSecret_SecretType.VAULT_KV_V2">
+ <div class="flex items-center gap-x-1">
+ {{ $t("instance.password-type.external-secret-vault") }}
+ <FeatureBadge
+ :feature="PlanFeature.FEATURE_EXTERNAL_SECRET_MANAGER"
+ />
+ </div>
+ </NRadio>
+ <NRadio
+ :value="DataSourceExternalSecret_SecretType.AWS_SECRETS_MANAGER"
+ >
+ <div class="flex items-center gap-x-1">
+ {{ $t("instance.password-type.external-secret-aws") }}
+ <FeatureBadge
+ :feature="PlanFeature.FEATURE_EXTERNAL_SECRET_MANAGER"
+ />
+ </div>
+ </NRadio>
+ <NRadio
+ :value="DataSourceExternalSecret_SecretType.GCP_SECRET_MANAGER"
+ >
+ <div class="flex items-center gap-x-1">
+ {{ $t("instance.password-type.external-secret-gcp") }}
+ <FeatureBadge
+ :feature="PlanFeature.FEATURE_EXTERNAL_SECRET_MANAGER"
+ />
+ </div>
+ </NRadio>
+ </NRadioGroup>
+ <LearnMoreLink
+ url="https://docs.bytebase.com/get-started/connect/overview#secret-manager-integration"
+ class="text-sm"
/>
</div>
- </div>
- <div v-else-if="dataSource.externalSecret" class="space-y-4">
<div
v-if="
state.passwordType ===
- DataSourceExternalSecret_SecretType.VAULT_KV_V2
+ DataSourceExternalSecret_SecretType.SAECRET_TYPE_UNSPECIFIED
"
- class="space-y-4"
>
- <div class="sm:col-span-2 sm:col-start-1">
- <label class="textlabel block">
- {{ $t("instance.external-secret-vault.vault-url") }}
- <span class="text-red-600">*</span>
- </label>
- <BBTextField
- v-model:value="dataSource.externalSecret.url"
- :required="true"
- class="mt-2 w-full"
- :disabled="!allowEdit"
- :placeholder="$t('instance.external-secret-vault.vault-url')"
+ <label class="textlabel block">
+ {{ $t("common.password") }}
+ </label>
+ <div v-if="!hideAdvancedFeatures" class="flex space-x-2 text-sm">
+ <div class="textinfolabel">
+ {{ $t("instance.password-type.password-tip") }}
+ </div>
+ <LearnMoreLink
+ url="https://docs.bytebase.com/get-started/connect/overview/#use-secret-manager?source=console"
+ class="ml-1 text-sm"
+ />
+ <FeatureBadge
+ :feature="PlanFeature.FEATURE_EXTERNAL_SECRET_MANAGER"
/>
</div>
- <div class="sm:col-span-2 sm:col-start-1 space-y-2">
- <label class="textlabel block">
- {{ $t("instance.external-secret-vault.vault-auth-type.self") }}
- </label>
- <NRadioGroup
- class="textlabel mb-2"
- :value="dataSource.externalSecret.authType"
- @update:value="changeExternalSecretAuthType"
+ <div class="mt-2">
+ <NCheckbox
+ v-if="!isCreating && allowUsingEmptyPassword"
+ :size="'small'"
+ :checked="dataSource.useEmptyPassword"
+ :disabled="!allowEdit"
+ @update:checked="toggleUseEmptyPassword"
>
- <NRadio :value="DataSourceExternalSecret_AuthType.TOKEN">
- {{
- $t(
- "instance.external-secret-vault.vault-auth-type.token.self"
- )
- }}
- </NRadio>
- <NRadio
- :value="DataSourceExternalSecret_AuthType.VAULT_APP_ROLE"
- >
- {{
- $t(
- "instance.external-secret-vault.vault-auth-type.approle.self"
- )
- }}
- </NRadio>
- </NRadioGroup>
- </div>
- <div
- v-if="
- dataSource.externalSecret.authType ===
- DataSourceExternalSecret_AuthType.TOKEN
- "
- class="sm:col-span-2 sm:col-start-1"
- >
- <label class="textlabel block">
- {{
- $t(
- "instance.external-secret-vault.vault-auth-type.token.self"
- )
- }}
- <span class="text-red-600">*</span>
- </label>
- <div class="flex space-x-2 text-sm">
- <div class="text-gray-400">
- {{
- $t(
- "instance.external-secret-vault.vault-auth-type.token.tips"
- )
- }}
- </div>
- <LearnMoreLink
- url="https://developer.hashicorp.com/vault/tutorials/operations/generate-root"
- class="ml-1 text-sm"
- />
- </div>
- <BBTextField
- :value="
- dataSource.externalSecret?.authOption?.case === 'token'
- ? dataSource.externalSecret.authOption.value
- : ''
+ {{ $t("instance.no-password") }}
+ </NCheckbox>
+ <NInput
+ type="password"
+ show-password-on="click"
+ class="w-full"
+ :input-props="{ autocomplete: 'off' }"
+ :placeholder="
+ dataSource.useEmptyPassword
+ ? $t('instance.no-password')
+ : $t('instance.password-write-only')
"
- class="mt-2 w-full"
- :disabled="!allowEdit"
- :placeholder="secretInputPlaceholder"
- :required="isCreating"
- @update:value="
- (val: string) => {
- const ds = dataSource;
- if (ds.externalSecret) {
- ds.externalSecret.authOption = {
- case: 'token',
- value: val,
- };
- }
- }
+ :disabled="!allowEdit || dataSource.useEmptyPassword"
+ :value="
+ dataSource.useEmptyPassword ? '' : dataSource.updatedPassword
"
+ @update:value="dataSource.updatedPassword = $event.trim()"
/>
</div>
+ </div>
+ <div v-else-if="dataSource.externalSecret" class="space-y-4">
<div
- v-else-if="
- dataSource.externalSecret?.authOption?.case === 'appRole'
+ v-if="
+ state.passwordType ===
+ DataSourceExternalSecret_SecretType.VAULT_KV_V2
"
class="space-y-4"
>
<div class="sm:col-span-2 sm:col-start-1">
<label class="textlabel block">
- {{
- $t(
- "instance.external-secret-vault.vault-auth-type.approle.role-id"
- )
- }}
+ {{ $t("instance.external-secret-vault.vault-url") }}
<span class="text-red-600">*</span>
</label>
<BBTextField
- :value="
- dataSource.externalSecret?.authOption?.case === 'appRole'
- ? dataSource.externalSecret.authOption.value.roleId
- : ''
- "
- :required="isCreating"
+ v-model:value="dataSource.externalSecret.url"
+ :required="true"
class="mt-2 w-full"
:disabled="!allowEdit"
- :placeholder="`${$t(
- 'instance.external-secret-vault.vault-auth-type.approle.role-id'
- )} - ${$t('common.write-only')}`"
- @update:value="
- (val: string) => {
- const ds = dataSource;
- if (ds.externalSecret?.authOption?.case === 'appRole') {
- ds.externalSecret.authOption.value.roleId = val;
- }
- }
- "
+ :placeholder="$t('instance.external-secret-vault.vault-url')"
/>
</div>
- <div class="sm:col-span-2 sm:col-start-1">
+ <div class="sm:col-span-2 sm:col-start-1 space-y-2">
<label class="textlabel block">
{{
- $t(
- "instance.external-secret-vault.vault-auth-type.approle.secret-id"
- )
+ $t("instance.external-secret-vault.vault-auth-type.self")
}}
- <span class="text-red-600">*</span>
</label>
- <i18n-t
- tag="div"
- keypath="instance.external-secret-vault.vault-auth-type.approle.secret-tips"
- class="text-gray-400 text-sm"
- >
- <template #learn_more>
- <LearnMoreLink
- url="https://developer.hashicorp.com/vault/tutorials/auth-methods/approle"
- class="ml-1 text-sm"
- />
- </template>
- </i18n-t>
<NRadioGroup
- :value="
- dataSource.externalSecret?.authOption?.case === 'appRole'
- ? dataSource.externalSecret.authOption.value.type
- : DataSourceExternalSecret_AppRoleAuthOption_SecretType.PLAIN
- "
- class="textlabel my-1"
- :disabled="!allowEdit"
- @update:value="
- (val) => {
- if (
- dataSource.externalSecret?.authOption?.case ===
- 'appRole'
- ) {
- dataSource.externalSecret.authOption.value.type = val;
- }
- }
- "
+ class="textlabel mb-2"
+ :value="dataSource.externalSecret.authType"
+ @update:value="changeExternalSecretAuthType"
>
- <NRadio
- :value="
- DataSourceExternalSecret_AppRoleAuthOption_SecretType.PLAIN
- "
- >
+ <NRadio :value="DataSourceExternalSecret_AuthType.TOKEN">
{{
$t(
- "instance.external-secret-vault.vault-auth-type.approle.secret-plain-text"
+ "instance.external-secret-vault.vault-auth-type.token.self"
)
}}
</NRadio>
<NRadio
- :value="
- DataSourceExternalSecret_AppRoleAuthOption_SecretType.ENVIRONMENT
- "
+ :value="DataSourceExternalSecret_AuthType.VAULT_APP_ROLE"
>
{{
$t(
- "instance.external-secret-vault.vault-auth-type.approle.secret-env-name"
+ "instance.external-secret-vault.vault-auth-type.approle.self"
)
}}
</NRadio>
</NRadioGroup>
+ </div>
+ <div
+ v-if="
+ dataSource.externalSecret.authType ===
+ DataSourceExternalSecret_AuthType.TOKEN
+ "
+ class="sm:col-span-2 sm:col-start-1"
+ >
+ <label class="textlabel block">
+ {{
+ $t(
+ "instance.external-secret-vault.vault-auth-type.token.self"
+ )
+ }}
+ <span class="text-red-600">*</span>
+ </label>
+ <div class="flex space-x-2 text-sm">
+ <div class="textinfolabel">
+ {{
+ $t(
+ "instance.external-secret-vault.vault-auth-type.token.tips"
+ )
+ }}
+ </div>
+ <LearnMoreLink
+ url="https://developer.hashicorp.com/vault/tutorials/operations/generate-root"
+ class="ml-1 text-sm"
+ />
+ </div>
<BBTextField
:value="
- dataSource.externalSecret?.authOption?.case === 'appRole'
- ? dataSource.externalSecret.authOption.value.secretId
+ dataSource.externalSecret?.authOption?.case === 'token'
+ ? dataSource.externalSecret.authOption.value
: ''
"
class="mt-2 w-full"
:disabled="!allowEdit"
:placeholder="secretInputPlaceholder"
+ :required="isCreating"
@update:value="
(val: string) => {
const ds = dataSource;
- if (ds.externalSecret?.authOption?.case === 'appRole') {
- ds.externalSecret.authOption.value.secretId = val;
+ if (ds.externalSecret) {
+ ds.externalSecret.authOption = {
+ case: 'token',
+ value: val,
+ };
}
}
"
/>
</div>
+ <div
+ v-else-if="
+ dataSource.externalSecret?.authOption?.case === 'appRole'
+ "
+ class="space-y-4"
+ >
+ <div class="sm:col-span-2 sm:col-start-1">
+ <label class="textlabel block">
+ {{
+ $t(
+ "instance.external-secret-vault.vault-auth-type.approle.role-id"
+ )
+ }}
+ <span class="text-red-600">*</span>
+ </label>
+ <BBTextField
+ :value="
+ dataSource.externalSecret?.authOption?.case === 'appRole'
+ ? dataSource.externalSecret.authOption.value.roleId
+ : ''
+ "
+ :required="isCreating"
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ :placeholder="`${$t(
+ 'instance.external-secret-vault.vault-auth-type.approle.role-id'
+ )} - ${$t('common.write-only')}`"
+ @update:value="
+ (val: string) => {
+ const ds = dataSource;
+ if (ds.externalSecret?.authOption?.case === 'appRole') {
+ ds.externalSecret.authOption.value.roleId = val;
+ }
+ }
+ "
+ />
+ </div>
+ <div class="sm:col-span-2 sm:col-start-1">
+ <label class="textlabel block">
+ {{
+ $t(
+ "instance.external-secret-vault.vault-auth-type.approle.secret-id"
+ )
+ }}
+ <span class="text-red-600">*</span>
+ </label>
+ <i18n-t
+ tag="div"
+ keypath="instance.external-secret-vault.vault-auth-type.approle.secret-tips"
+ class="textinfolabel text-sm"
+ >
+ <template #learn_more>
+ <LearnMoreLink
+ url="https://developer.hashicorp.com/vault/tutorials/auth-methods/approle"
+ class="ml-1 text-sm"
+ />
+ </template>
+ </i18n-t>
+ <NRadioGroup
+ :value="
+ dataSource.externalSecret?.authOption?.case === 'appRole'
+ ? dataSource.externalSecret.authOption.value.type
+ : DataSourceExternalSecret_AppRoleAuthOption_SecretType.PLAIN
+ "
+ class="textlabel my-1"
+ :disabled="!allowEdit"
+ @update:value="
+ (val) => {
+ if (
+ dataSource.externalSecret?.authOption?.case ===
+ 'appRole'
+ ) {
+ dataSource.externalSecret.authOption.value.type = val;
+ }
+ }
+ "
+ >
+ <NRadio
+ :value="
+ DataSourceExternalSecret_AppRoleAuthOption_SecretType.PLAIN
+ "
+ >
+ {{
+ $t(
+ "instance.external-secret-vault.vault-auth-type.approle.secret-plain-text"
+ )
+ }}
+ </NRadio>
+ <NRadio
+ :value="
+ DataSourceExternalSecret_AppRoleAuthOption_SecretType.ENVIRONMENT
+ "
+ >
+ {{
+ $t(
+ "instance.external-secret-vault.vault-auth-type.approle.secret-env-name"
+ )
+ }}
+ </NRadio>
+ </NRadioGroup>
+ <BBTextField
+ :value="
+ dataSource.externalSecret?.authOption?.case === 'appRole'
+ ? dataSource.externalSecret.authOption.value.secretId
+ : ''
+ "
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ :placeholder="secretInputPlaceholder"
+ @update:value="
+ (val: string) => {
+ const ds = dataSource;
+ if (ds.externalSecret?.authOption?.case === 'appRole') {
+ ds.externalSecret.authOption.value.secretId = val;
+ }
+ }
+ "
+ />
+ </div>
+ </div>
+ <div class="sm:col-span-2 sm:col-start-1">
+ <label class="textlabel block">
+ {{
+ $t(
+ "instance.external-secret-vault.vault-secret-engine-name"
+ )
+ }}
+ <span class="text-red-600">*</span>
+ </label>
+ <div class="flex space-x-2 text-sm textinfolabel">
+ {{
+ $t(
+ "instance.external-secret-vault.vault-secret-engine-tips"
+ )
+ }}
+ </div>
+ <BBTextField
+ v-model:value="dataSource.externalSecret.engineName"
+ :required="true"
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ :placeholder="
+ $t(
+ 'instance.external-secret-vault.vault-secret-engine-name'
+ )
+ "
+ />
+ </div>
</div>
<div class="sm:col-span-2 sm:col-start-1">
<label class="textlabel block">
- {{
- $t("instance.external-secret-vault.vault-secret-engine-name")
- }}
+ {{ secretNameLabel }}
<span class="text-red-600">*</span>
</label>
- <div class="flex space-x-2 text-sm text-gray-400">
- {{
- $t("instance.external-secret-vault.vault-secret-engine-tips")
- }}
+ <div
+ v-if="
+ state.passwordType ===
+ DataSourceExternalSecret_SecretType.GCP_SECRET_MANAGER
+ "
+ class="flex space-x-2 text-sm textinfolabel"
+ >
+ {{ $t("instance.external-secret-gcp.secret-name-tips") }}
</div>
<BBTextField
- v-model:value="dataSource.externalSecret.engineName"
+ v-model:value="dataSource.externalSecret.secretName"
:required="true"
class="mt-2 w-full"
:disabled="!allowEdit"
- :placeholder="
- $t('instance.external-secret-vault.vault-secret-engine-name')
- "
+ :placeholder="secretNameLabel"
/>
</div>
- </div>
- <div class="sm:col-span-2 sm:col-start-1">
- <label class="textlabel block">
- {{ secretNameLabel }}
- <span class="text-red-600">*</span>
- </label>
<div
v-if="
- state.passwordType ===
+ state.passwordType !==
DataSourceExternalSecret_SecretType.GCP_SECRET_MANAGER
"
- class="flex space-x-2 text-sm text-gray-400"
+ class="sm:col-span-2 sm:col-start-1"
>
- {{ $t("instance.external-secret-gcp.secret-name-tips") }}
+ <label class="textlabel block">
+ {{ secretKeyLabel }}
+ <span class="text-red-600">*</span>
+ </label>
+ <BBTextField
+ v-model:value="dataSource.externalSecret.passwordKeyName"
+ :required="true"
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ :placeholder="secretKeyLabel"
+ />
</div>
- <BBTextField
- v-model:value="dataSource.externalSecret.secretName"
- :required="true"
- class="mt-2 w-full"
- :disabled="!allowEdit"
- :placeholder="secretNameLabel"
- />
</div>
- <div
+
+ <template
v-if="
- state.passwordType !==
- DataSourceExternalSecret_SecretType.GCP_SECRET_MANAGER
+ basicInfo.engine === Engine.REDIS &&
+ dataSource.redisType === DataSource_RedisType.SENTINEL
"
- class="sm:col-span-2 sm:col-start-1"
>
- <label class="textlabel block">
- {{ secretKeyLabel }}
- <span class="text-red-600">*</span>
- </label>
- <BBTextField
- v-model:value="dataSource.externalSecret.passwordKeyName"
- :required="true"
- class="mt-2 w-full"
- :disabled="!allowEdit"
- :placeholder="secretKeyLabel"
- />
- </div>
- </div>
-
- <div
- v-if="
- basicInfo.engine === Engine.REDIS &&
- dataSource.redisType === DataSource_RedisType.SENTINEL
- "
- >
- <div class="mt-4">
- <label class="textlabel"> Master Name </label>
- <span class="text-red-600 mr-2">*</span>
- <NInput
- v-model:value="dataSource.masterName"
- class="mt-1 w-full"
- :disabled="!allowEdit"
- :placeholder="''"
- />
- </div>
- <div class="mt-4">
- <label class="textlabel"> Master Username </label>
- <NInput
- v-model:value="dataSource.masterUsername"
- class="mt-1 w-full"
- :disabled="!allowEdit"
- :placeholder="''"
- />
- </div>
- <div class="mt-4">
- <label class="textlabel block"> Master Password </label>
<div class="mt-2">
- <NCheckbox
- v-if="!isCreating && allowUsingEmptyPassword"
- :size="'small'"
- :checked="dataSource.useEmptyMasterPassword"
+ <label class="textlabel"> Master Name </label>
+ <span class="text-red-600 mr-2">*</span>
+ <NInput
+ v-model:value="dataSource.masterName"
+ class="mt-1 w-full"
:disabled="!allowEdit"
- @update:checked="toggleUseEmptyMasterPassword"
- >
- {{ $t("instance.no-password") }}
- </NCheckbox>
+ :placeholder="''"
+ />
+ </div>
+ <div class="mt-2">
+ <label class="textlabel"> Master Username </label>
<NInput
- type="password"
- show-password-on="click"
- class="w-full"
- :input-props="{ autocomplete: 'off' }"
- :placeholder="
- dataSource.useEmptyMasterPassword
- ? $t('instance.no-password')
- : $t('instance.password-write-only')
- "
- :disabled="!allowEdit || dataSource.useEmptyMasterPassword"
- :value="
- dataSource.useEmptyMasterPassword
- ? ''
- : dataSource.updatedMasterPassword
- "
- @update:value="dataSource.updatedMasterPassword = $event.trim()"
+ v-model:value="dataSource.masterUsername"
+ class="mt-1 w-full"
+ :disabled="!allowEdit"
+ :placeholder="''"
/>
</div>
- </div>
+ <div class="mt-2">
+ <label class="textlabel block"> Master Password </label>
+ <div class="mt-2">
+ <NCheckbox
+ v-if="!isCreating && allowUsingEmptyPassword"
+ :size="'small'"
+ :checked="dataSource.useEmptyMasterPassword"
+ :disabled="!allowEdit"
+ @update:checked="toggleUseEmptyMasterPassword"
+ >
+ {{ $t("instance.no-password") }}
+ </NCheckbox>
+ <NInput
+ type="password"
+ show-password-on="click"
+ class="w-full"
+ :input-props="{ autocomplete: 'off' }"
+ :placeholder="
+ dataSource.useEmptyMasterPassword
+ ? $t('instance.no-password')
+ : $t('instance.password-write-only')
+ "
+ :disabled="!allowEdit || dataSource.useEmptyMasterPassword"
+ :value="
+ dataSource.useEmptyMasterPassword
+ ? ''
+ : dataSource.updatedMasterPassword
+ "
+ @update:value="
+ dataSource.updatedMasterPassword = $event.trim()
+ "
+ />
+ </div>
+ </div>
+ </template>
</div>
- </div>
- </div>
- </template>
- <template
- v-if="
- basicInfo.engine === Engine.SPANNER ||
- basicInfo.engine === Engine.BIGQUERY
- "
- >
- <div class="mt-2 sm:col-span-3 sm:col-start-1">
+ </template>
+ </template>
+ <template
+ v-if="
+ basicInfo.engine === Engine.SPANNER ||
+ basicInfo.engine === Engine.BIGQUERY
+ "
+ >
<NRadioGroup
v-model:value="dataSource.authenticationType"
class="textlabel"
:disabled="!allowEdit"
>
- <NRadio :value="DataSource_AuthenticationType.PASSWORD">
- {{ $t("common.credentials") }}
- </NRadio>
- <NRadio :value="DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM">
- {{ $t("instance.password-type.google-iam") }}
+ <NRadio
+ v-for="item in supportedAuthenticationTypes"
+ :key="item.value"
+ :value="item.value"
+ >
+ {{ item.label }}
</NRadio>
</NRadioGroup>
- </div>
+ <CredentialSourceForm :data-source="dataSource" :allow-edit="allowEdit" />
+ </template>
- <GcpCredentialInput
- v-if="
- dataSource.authenticationType === DataSource_AuthenticationType.PASSWORD
- "
- v-model:value="dataSource.updatedPassword"
- :write-only="!isCreating"
- class="mt-4 sm:col-span-3 sm:col-start-1"
- />
- </template>
-
- <template v-if="basicInfo.engine === Engine.ORACLE">
- <OracleSIDAndServiceNameInput
- v-model:sid="dataSource.sid"
- v-model:service-name="dataSource.serviceName"
- :allow-edit="allowEdit"
- />
- </template>
-
- <template v-if="basicInfo.engine === Engine.SNOWFLAKE">
- <div class="mt-4 sm:col-span-3 sm:col-start-1">
- <div class="textlabel block">
- {{ $t("data-source.ssh.private-key") }}
- </div>
- <div class="flex space-x-2 text-sm">
- <div class="text-gray-400">
- {{ $t("data-source.snowflake-keypair-tip") }}
+ <template v-if="basicInfo.engine === Engine.ORACLE">
+ <OracleSIDAndServiceNameInput
+ v-model:sid="dataSource.sid"
+ v-model:service-name="dataSource.serviceName"
+ :allow-edit="allowEdit"
+ />
+ </template>
+
+ <template v-if="basicInfo.engine === Engine.SNOWFLAKE">
+ <div class="sm:col-span-3 sm:col-start-1">
+ <div class="textlabel block">
+ {{ $t("data-source.ssh.private-key") }}
</div>
- <LearnMoreLink
- url="https://docs.snowflake.com/en/user-guide/key-pair-auth"
- class="ml-1 text-sm"
- />
- </div>
- <DroppableTextarea
- v-model:value="dataSource.authenticationPrivateKey"
- :resizable="false"
- :disabled="!allowEdit"
- class="w-full h-32 mt-2 whitespace-pre-wrap"
- placeholder="-----BEGIN PRIVATE KEY-----
+ <div class="flex space-x-2 text-sm">
+ <div class="textinfolabel">
+ {{ $t("data-source.snowflake-keypair-tip") }}
+ </div>
+ <LearnMoreLink
+ url="https://docs.snowflake.com/en/user-guide/key-pair-auth"
+ class="ml-1 text-sm"
+ />
+ </div>
+ <DroppableTextarea
+ v-model:value="dataSource.authenticationPrivateKey"
+ :resizable="false"
+ :disabled="!allowEdit"
+ class="w-full h-32 mt-2 whitespace-pre-wrap"
+ placeholder="-----BEGIN PRIVATE KEY-----
MIIEvQ...
-----END PRIVATE KEY-----"
- :allow-edit="allowEdit"
- />
- </div>
- </template>
+ :allow-edit="allowEdit"
+ />
+ </div>
+ </template>
- <template v-if="basicInfo.engine === Engine.DATABRICKS">
- <div>
- <div class="textlabel black mt-4">
- Warehouse ID
- <span class="text-red-600">*</span>
+ <template v-if="basicInfo.engine === Engine.DATABRICKS">
+ <div>
+ <div class="textlabel black mt-2">
+ Warehouse ID
+ <span class="text-red-600">*</span>
+ </div>
+ <NInput
+ v-model:value="dataSource.warehouseId"
+ class="mt-2"
+ :disabled="!allowEdit"
+ />
</div>
- <NInput
- v-model:value="dataSource.warehouseId"
- class="mt-2"
- :disabled="!allowEdit"
- />
- </div>
- <div>
- <div class="textlabel black mt-4">
- Token
- <span class="text-red-600">*</span>
+ <div>
+ <div class="textlabel black mt-2">
+ Token
+ <span class="text-red-600">*</span>
+ </div>
+ <NInput
+ v-model:value="dataSource.authenticationPrivateKey"
+ class="mt-2 w-full"
+ :disabled="!allowEdit"
+ placeholder="personal access token"
+ />
</div>
- <NInput
- v-model:value="dataSource.authenticationPrivateKey"
- class="mt-2 w-full"
- :disabled="!allowEdit"
- placeholder="personal access token"
- />
- </div>
- </template>
+ </template>
- <template v-if="showAuthenticationDatabase">
- <div class="mt-4 sm:col-span-3 sm:col-start-1">
- <div class="flex flex-row items-center space-x-2">
- <label for="authenticationDatabase" class="textlabel block">
- {{ $t("instance.authentication-database") }}
- </label>
+ <template v-if="showAuthenticationDatabase">
+ <div class="sm:col-span-3 sm:col-start-1">
+ <div class="flex flex-row items-center space-x-2">
+ <label for="authenticationDatabase" class="textlabel block">
+ {{ $t("instance.authentication-database") }}
+ </label>
+ </div>
+ <NInput
+ class="mt-2 w-full"
+ :input-props="{ autocomplete: 'off' }"
+ placeholder="admin"
+ :disabled="!allowEdit"
+ :value="dataSource.authenticationDatabase"
+ @update:value="dataSource.authenticationDatabase = $event.trim()"
+ />
</div>
- <NInput
- class="mt-2 w-full"
- :input-props="{ autocomplete: 'off' }"
- placeholder="admin"
- :disabled="!allowEdit"
- :value="dataSource.authenticationDatabase"
- @update:value="dataSource.authenticationDatabase = $event.trim()"
- />
- </div>
- </template>
+ </template>
- <template
- v-if="
- dataSource.type === DataSourceType.READ_ONLY &&
- (hasReadonlyReplicaHost || hasReadonlyReplicaPort)
- "
- >
- <div
- v-if="hasReadonlyReplicaHost"
- class="mt-4 sm:col-span-3 sm:col-start-1"
+ <template
+ v-if="
+ dataSource.type === DataSourceType.READ_ONLY &&
+ (hasReadonlyReplicaHost || hasReadonlyReplicaPort)
+ "
>
- <div class="flex flex-row items-center space-x-2">
- <label for="host" class="textlabel block">
- {{ $t("data-source.read-replica-host") }}
- </label>
+ <div v-if="hasReadonlyReplicaHost" class="sm:col-span-3 sm:col-start-1">
+ <div class="flex flex-row items-center space-x-2">
+ <label for="host" class="textlabel block">
+ {{ $t("data-source.read-replica-host") }}
+ </label>
+ </div>
+ <NInput
+ class="mt-2 w-full"
+ :input-props="{ autocomplete: 'off' }"
+ :value="dataSource.host"
+ :disabled="!allowEdit"
+ @update:value="handleHostInput"
+ />
+ </div>
+
+ <div v-if="hasReadonlyReplicaPort" class="sm:col-span-3 sm:col-start-1">
+ <div class="flex flex-row items-center space-x-2">
+ <label for="port" class="textlabel block">
+ {{ $t("data-source.read-replica-port") }}
+ </label>
+ </div>
+ <NInput
+ class="mt-2 w-full"
+ :input-props="{ autocomplete: 'off' }"
+ :value="dataSource.port"
+ :allow-input="onlyAllowNumber"
+ :disabled="!allowEdit"
+ @update:value="handlePortInput"
+ />
</div>
+ </template>
+
+ <div v-if="showDatabase" class="sm:col-span-3 sm:col-start-1">
+ <label for="database" class="textlabel block">
+ {{ $t("common.database") }}
+ </label>
<NInput
+ v-model:value="dataSource.database"
class="mt-2 w-full"
- :input-props="{ autocomplete: 'off' }"
- :value="dataSource.host"
:disabled="!allowEdit"
- @update:value="handleHostInput"
+ :placeholder="$t('common.database')"
/>
</div>
- <div
- v-if="hasReadonlyReplicaPort"
- class="mt-4 sm:col-span-3 sm:col-start-1"
- >
- <div class="flex flex-row items-center space-x-2">
- <label for="port" class="textlabel block">
- {{ $t("data-source.read-replica-port") }}
+ <div v-if="hasExtraParameters" class="sm:col-span-3 sm:col-start-1">
+ <div class="flex flex-row items-center justify-between">
+ <label class="textlabel block">
+ {{ $t("data-source.extra-params.self") }}
</label>
</div>
- <NInput
- class="mt-2 w-full"
- :input-props="{ autocomplete: 'off' }"
- :value="dataSource.port"
- :allow-input="onlyAllowNumber"
- :disabled="!allowEdit"
- @update:value="handlePortInput"
- />
- </div>
- </template>
-
- <div v-if="showDatabase" class="mt-4 sm:col-span-3 sm:col-start-1">
- <label for="database" class="textlabel block">
- {{ $t("common.database") }}
- </label>
- <NInput
- v-model:value="dataSource.database"
- class="mt-2 w-full"
- :disabled="!allowEdit"
- :placeholder="$t('common.database')"
- />
- </div>
+ <div class="textinfolabel text-sm mt-1 mb-2">
+ {{ $t("data-source.extra-params.description") }}
+ </div>
- <div v-if="hasExtraParameters" class="mt-4 sm:col-span-3 sm:col-start-1">
- <div class="flex flex-row items-center justify-between">
- <label class="textlabel block">
- {{ $t("data-source.extra-params.self") }}
- </label>
- </div>
- <div class="text-gray-400 text-sm mt-1 mb-2">
- {{ $t("data-source.extra-params.description") }}
- </div>
+ <!-- Add parameter form -->
+ <div
+ v-if="allowEdit"
+ class="flex mt-2 mb-2 space-x-2 bg-gray-50 p-3 rounded-md"
+ >
+ <NInput
+ v-model:value="newParam.key"
+ class="w-full"
+ :placeholder="$t('instance.parameter-name-placeholder')"
+ />
+ <NInput
+ v-model:value="newParam.value"
+ class="w-full"
+ :placeholder="$t('instance.parameter-value-placeholder')"
+ />
+ <NButton
+ type="primary"
+ ghost
+ size="small"
+ :disabled="!newParam.key.trim()"
+ @click="addNewParameter"
+ >
+ Add
+ </NButton>
+ </div>
- <!-- Add parameter form -->
- <div
- v-if="allowEdit"
- class="flex mt-2 mb-4 space-x-2 bg-gray-50 p-3 rounded-md"
- >
- <NInput
- v-model:value="newParam.key"
- class="w-full"
- :placeholder="$t('instance.parameter-name-placeholder')"
- />
- <NInput
- v-model:value="newParam.value"
- class="w-full"
- :placeholder="$t('instance.parameter-value-placeholder')"
- />
- <NButton
- type="primary"
- ghost
- size="small"
- :disabled="!newParam.key.trim()"
- @click="addNewParameter"
+ <!-- Existing parameters -->
+ <div
+ v-for="(param, index) in extraConnectionParamsList"
+ :key="param.key"
+ class="flex mt-2 space-x-2"
>
- Add
- </NButton>
- </div>
+ <NInput
+ class="w-full"
+ :value="param.key"
+ :disabled="!allowEdit"
+ placeholder="Parameter name"
+ @update:value="(v) => updateExtraConnectionParamKey(index, v)"
+ />
+ <NInput
+ class="w-full"
+ :value="param.value"
+ :disabled="!allowEdit"
+ placeholder="Parameter value"
+ @update:value="(v) => updateExtraConnectionParamValue(index, v)"
+ />
+ <NButton
+ v-if="allowEdit"
+ type="error"
+ secondary
+ size="small"
+ @click="removeExtraConnectionParam(index)"
+ title="Remove parameter"
+ >
+ Remove
+ </NButton>
+ </div>
- <!-- Existing parameters -->
- <div
- v-for="(param, index) in extraConnectionParamsList"
- :key="param.key"
- class="flex mt-2 space-x-2"
- >
- <NInput
- class="w-full"
- :value="param.key"
- :disabled="!allowEdit"
- placeholder="Parameter name"
- @update:value="(v) => updateExtraConnectionParamKey(index, v)"
- />
- <NInput
- class="w-full"
- :value="param.value"
- :disabled="!allowEdit"
- placeholder="Parameter value"
- @update:value="(v) => updateExtraConnectionParamValue(index, v)"
- />
- <NButton
- v-if="allowEdit"
- type="error"
- secondary
- size="small"
- @click="removeExtraConnectionParam(index)"
- title="Remove parameter"
+ <!-- Show a message when there are no parameters -->
+ <div
+ v-if="extraConnectionParamsList.length === 0"
+ class="textinfolabel text-sm italic"
>
- Remove
- </NButton>
+ {{
+ allowEdit
+ ? $t("instance.no-params-yet-add-above")
+ : $t("instance.no-extra-params-configured")
+ }}
+ </div>
</div>
- <!-- Show a message when there are no parameters -->
<div
- v-if="extraConnectionParamsList.length === 0"
- class="text-gray-500 text-sm mt-2 italic"
+ v-if="
+ showSSL &&
+ dataSource.authenticationType === DataSource_AuthenticationType.PASSWORD
+ "
+ class="sm:col-span-3 sm:col-start-1"
>
- {{
- allowEdit
- ? $t("instance.no-params-yet-add-above")
- : $t("instance.no-extra-params-configured")
- }}
- </div>
- </div>
-
- <div
- v-if="
- showSSL &&
- dataSource.authenticationType === DataSource_AuthenticationType.PASSWORD
- "
- class="mt-4 sm:col-span-3 sm:col-start-1"
- >
- <div class="flex flex-row items-center gap-2">
- <NSwitch
- :value="dataSource.useSsl"
- size="small"
- @update:value="handleUseSslChanged"
- />
<label for="ssl" class="textlabel block">
{{ $t("data-source.ssl-connection") }}
</label>
- </div>
- <template v-if="dataSource.useSsl">
- <template v-if="dataSource.pendingCreate">
- <SslCertificateFormV1
- :value="dataSource"
- :engine-type="basicInfo.engine"
- :disabled="!allowEdit"
- @change="handleSSLChange"
- />
- </template>
- <template v-else>
- <template v-if="dataSource.updateSsl">
+ <Switch
+ class="mt-2"
+ :text="true"
+ :value="dataSource.useSsl"
+ @update:value="handleUseSslChanged"
+ />
+ <template v-if="dataSource.useSsl">
+ <template v-if="dataSource.pendingCreate">
<SslCertificateFormV1
:value="dataSource"
:engine-type="basicInfo.engine"
@@ -1251,42 +965,51 @@ MIIEvQ...
/>
</template>
<template v-else>
- <NButton
- class="!mt-2"
- :disabled="!allowEdit"
- @click.prevent="handleEditSSL"
- >
- {{ $t("common.edit") }} - {{ $t("common.write-only") }}
- </NButton>
+ <template v-if="dataSource.updateSsl">
+ <SslCertificateFormV1
+ :value="dataSource"
+ :engine-type="basicInfo.engine"
+ :disabled="!allowEdit"
+ @change="handleSSLChange"
+ />
+ </template>
+ <template v-else>
+ <NButton
+ class="!mt-2"
+ :disabled="!allowEdit"
+ @click.prevent="handleEditSSL"
+ >
+ {{ $t("common.edit") }} - {{ $t("common.write-only") }}
+ </NButton>
+ </template>
</template>
</template>
- </template>
- </div>
+ </div>
- <div
- v-if="
- !hideAdvancedFeatures &&
- showSSH &&
- dataSource.authenticationType === DataSource_AuthenticationType.PASSWORD
- "
- class="mt-4 sm:col-span-3 sm:col-start-1"
- >
- <div class="flex flex-row items-center gap-x-1">
- <label for="ssh" class="textlabel block">
- {{ $t("data-source.ssh-connection") }}
- </label>
+ <div
+ v-if="
+ !hideAdvancedFeatures &&
+ showSSH &&
+ dataSource.authenticationType === DataSource_AuthenticationType.PASSWORD
+ "
+ class="sm:col-span-3 sm:col-start-1"
+ >
+ <div class="flex flex-row items-center gap-x-1">
+ <label for="ssh" class="textlabel block">
+ {{ $t("data-source.ssh-connection") }}
+ </label>
+ </div>
+ <SshConnectionForm
+ :value="dataSource"
+ :instance="instance"
+ :disabled="!allowEdit"
+ @change="handleSSHChange"
+ />
</div>
- <SshConnectionForm
- :value="dataSource"
- :instance="instance"
- :disabled="!allowEdit"
- @change="handleSSHChange"
- />
</div>
</template>
<script setup lang="ts">
-/* eslint-disable vue/no-mutating-props */
import { create } from "@bufbuild/protobuf";
import {
NButton,
@@ -1294,7 +1017,6 @@ import {
NInput,
NRadio,
NRadioGroup,
- NSwitch,
NUpload,
NUploadDragger,
type UploadFileInfo,
@@ -1305,6 +1027,7 @@ import { BBTextField } from "@/bbkit";
import { FeatureBadge } from "@/components/FeatureGuard";
import LearnMoreLink from "@/components/LearnMoreLink.vue";
import DroppableTextarea from "@/components/misc/DroppableTextarea.vue";
+import { Switch } from "@/components/v2";
import type { DataSourceOptions } from "@/types/dataSource";
import { Engine } from "@/types/proto-es/v1/common_pb";
import type { DataSource } from "@/types/proto-es/v1/instance_service_pb";
@@ -1317,9 +1040,6 @@ import {
DataSource_RedisType,
DataSourceExternalSecretSchema,
DataSourceExternalSecret_AppRoleAuthOptionSchema,
- DataSource_AzureCredentialSchema,
- DataSource_AWSCredentialSchema,
- DataSource_GCPCredentialSchema,
KerberosConfigSchema,
SASLConfigSchema,
} from "@/types/proto-es/v1/instance_service_pb";
@@ -1328,21 +1048,13 @@ import { onlyAllowNumber } from "@/utils";
import type { EditDataSource } from "../common";
import { useInstanceFormContext } from "../context";
import CreateDataSourceExample from "./CreateDataSourceExample.vue";
-import GcpCredentialInput from "./GcpCredentialInput.vue";
+import CredentialSourceForm from "./CredentialSourceForm.vue";
import OracleSIDAndServiceNameInput from "./OracleSIDAndServiceNameInput.vue";
import SshConnectionForm from "./SshConnectionForm.vue";
import SslCertificateFormV1 from "./SslCertificateFormV1.vue";
-type credentialSource = "default" | "specific-credential";
-
interface LocalState {
passwordType: DataSourceExternalSecret_SecretType;
- credentialSource: credentialSource;
-}
-
-interface IAMExtensionOptions {
- label: string;
- value: credentialSource;
}
interface ExtraConnectionParam {
@@ -1379,7 +1091,6 @@ const {
const state = reactive<LocalState>({
passwordType: DataSourceExternalSecret_SecretType.SAECRET_TYPE_UNSPECIFIED,
- credentialSource: "default",
});
// Use a simpler approach to track new parameters
@@ -1408,82 +1119,6 @@ watch(
{ immediate: true, deep: true }
);
-watch(
- [
- () => props.dataSource.iamExtension?.case === "azureCredential",
- () => props.dataSource.iamExtension?.case === "awsCredential",
- () => props.dataSource.iamExtension?.case === "gcpCredential",
- ],
- (credentials) => {
- if (credentials.some((c) => c === true)) {
- state.credentialSource = "specific-credential";
- } else {
- state.credentialSource = "default";
- }
- },
- { immediate: true, deep: true }
-);
-
-watch(
- () => props.dataSource.authenticationType,
- () => {
- state.credentialSource = "default";
- }
-);
-
-watch(
- () => state.credentialSource,
- (source) => {
- switch (props.dataSource.authenticationType) {
- case DataSource_AuthenticationType.AWS_RDS_IAM:
- if (source === "default") {
- props.dataSource.iamExtension = { case: undefined };
- } else {
- props.dataSource.iamExtension = {
- case: "awsCredential",
- value: create(
- DataSource_AWSCredentialSchema,
- props.dataSource.iamExtension?.case === "awsCredential"
- ? props.dataSource.iamExtension.value
- : {}
- ),
- };
- }
- break;
- case DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM:
- if (source === "default") {
- props.dataSource.iamExtension = { case: undefined };
- } else {
- props.dataSource.iamExtension = {
- case: "gcpCredential",
- value: create(
- DataSource_GCPCredentialSchema,
- props.dataSource.iamExtension?.case === "gcpCredential"
- ? props.dataSource.iamExtension.value
- : {}
- ),
- };
- }
- break;
- case DataSource_AuthenticationType.AZURE_IAM:
- if (source === "default") {
- props.dataSource.iamExtension = { case: undefined };
- } else {
- props.dataSource.iamExtension = {
- case: "azureCredential",
- value: create(
- DataSource_AzureCredentialSchema,
- props.dataSource.iamExtension?.case === "azureCredential"
- ? props.dataSource.iamExtension.value
- : {}
- ),
- };
- }
- break;
- }
- }
-);
-
const hiveAuthentication = computed(() => {
return props.dataSource.saslConfig?.mechanism?.case === "krbConfig"
? "KERBEROS"
@@ -1506,6 +1141,64 @@ const onHiveAuthenticationChange = (val: "KERBEROS" | "PASSWORD") => {
}
};
+const supportedAuthenticationTypes = computed(() => {
+ switch (basicInfo.value.engine) {
+ case Engine.COSMOSDB:
+ return [
+ {
+ value: DataSource_AuthenticationType.AZURE_IAM,
+ label: t("instance.password-type.azure-iam"),
+ },
+ ];
+ case Engine.MSSQL:
+ return [
+ {
+ value: DataSource_AuthenticationType.PASSWORD,
+ label: t("instance.password-type.password"),
+ },
+ {
+ value: DataSource_AuthenticationType.AZURE_IAM,
+ label: t("instance.password-type.azure-iam"),
+ },
+ ];
+ case Engine.ELASTICSEARCH:
+ return [
+ {
+ value: DataSource_AuthenticationType.PASSWORD,
+ label: t("instance.password-type.password"),
+ },
+ {
+ value: DataSource_AuthenticationType.AWS_RDS_IAM,
+ label: t("instance.password-type.aws-iam"),
+ },
+ ];
+ case Engine.SPANNER:
+ case Engine.BIGQUERY: {
+ return [
+ {
+ value: DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM,
+ label: t("instance.password-type.google-iam"),
+ },
+ ];
+ }
+ default:
+ return [
+ {
+ value: DataSource_AuthenticationType.PASSWORD,
+ label: t("instance.password-type.password"),
+ },
+ {
+ value: DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM,
+ label: t("instance.password-type.google-iam"),
+ },
+ {
+ value: DataSource_AuthenticationType.AWS_RDS_IAM,
+ label: t("instance.password-type.aws-iam"),
+ },
+ ];
+ }
+});
+
const secretInputPlaceholder = computed(() => {
switch (state.passwordType) {
case DataSourceExternalSecret_SecretType.SAECRET_TYPE_UNSPECIFIED:
@@ -1719,28 +1412,6 @@ const handleKeytabUpload = (options: { file: UploadFileInfo }) => {
reader.readAsArrayBuffer(options.file.file as Blob);
};
-// IAM Extension Options
-const getIAMExtensionOptions = (
- authenticationType: DataSource_AuthenticationType
-): IAMExtensionOptions[] => {
- switch (authenticationType) {
- case DataSource_AuthenticationType.AWS_RDS_IAM:
- case DataSource_AuthenticationType.AZURE_IAM:
- case DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM:
- return [
- {
- label: t("common.default"),
- value: "default",
- },
- {
- label: t("instance.iam-extension.specific-credential"),
- value: "specific-credential",
- },
- ];
- }
- return [];
-};
-
// Extra connection parameters management
const addNewParameter = () => {
// Skip if key is empty
@@ -1843,9 +1514,3 @@ const removeExtraConnectionParam = (index: number) => {
ds.extraConnectionParameters = plainParams;
};
</script>
-
-<style lang="postcss" scoped>
-.credential :deep(.code) {
- @apply bg-gray-100 p-1 rounded-sm mr-1;
-}
-</style>
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceSection.vue b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceSection.vue
index a42624dfaf..41f150e4db 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceSection.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceSection.vue
@@ -3,9 +3,9 @@
@add-readonly-datasource="handleCreateRODataSource"
/>
- <div class="mt-2 grid grid-cols-1 gap-y-2 gap-x-4 border-none sm:grid-cols-3">
+ <div class="mt-2 gap-y-2 gap-x-4 border-none">
<DataSourceTabs
- class="sm:col-span-3"
+ class="sm:col-span-3 mb-4"
@add-readonly-datasource="handleCreateRODataSource"
/>
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceTabs.vue b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceTabs.vue
index 2d9cf536df..9d74a821d8 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceTabs.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceTabs.vue
@@ -14,7 +14,7 @@
<span>{{ $t("common.read-only") }}</span>
<BBButtonConfirm
v-if="hasReadOnlyDataSource"
- class="!ml-1"
+ class="!ml-2"
:type="'DELETE'"
:disabled="!allowUpdate"
:require-confirm="!ds.pendingCreate"
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/GcpCredentialInput.vue b/frontend/src/components/InstanceForm/DataSourceSection/GcpCredentialInput.vue
index ce43b0b88d..13f6159493 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/GcpCredentialInput.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/GcpCredentialInput.vue
@@ -1,9 +1,5 @@
<template>
<div class="space-y-1 w-full">
- <div>
- <span>{{ $t("common.credentials") }}</span>
- <span class="text-red-600">*</span>
- </div>
<p class="textinfolabel">
<span>{{ $t("instance.create-gcp-credentials") }}</span>
<a
@@ -18,37 +14,21 @@
<DroppableTextarea
:value="value"
:resizable="false"
- :placeholder="placeholder"
- class="w-full h-24 mt-2 whitespace-pre-wrap"
+ :placeholder="$t('instance.type-or-paste-credentials-write-only')"
+ class="w-full h-24 whitespace-pre-wrap"
@update:value="$emit('update:value', $event ?? '')"
/>
</div>
</template>
<script lang="ts" setup>
-import { computed } from "vue";
-import { useI18n } from "vue-i18n";
import DroppableTextarea from "@/components/misc/DroppableTextarea.vue";
-const props = withDefaults(
- defineProps<{
- value: string;
- writeOnly?: boolean;
- }>(),
- {
- writeOnly: false,
- }
-);
+defineProps<{
+ value: string | undefined;
+}>();
defineEmits<{
(name: "update:value", value: string): void;
}>();
-
-const { t } = useI18n();
-
-const placeholder = computed(() => {
- return props.writeOnly
- ? t("instance.type-or-paste-credentials-write-only")
- : t("instance.type-or-paste-credentials");
-});
</script>
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/OracleSIDAndServiceNameInput.vue b/frontend/src/components/InstanceForm/DataSourceSection/OracleSIDAndServiceNameInput.vue
index 29ab006ad8..234e0900c7 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/OracleSIDAndServiceNameInput.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/OracleSIDAndServiceNameInput.vue
@@ -1,5 +1,5 @@
<template>
- <div class="mt-2 sm:col-span-3 sm:col-start-1">
+ <div class="sm:col-span-3 sm:col-start-1">
<div class="flex items-center gap-x-4">
<NRadio
:checked="state.mode === 'ServiceName'"
@@ -14,7 +14,7 @@
<span class="textlabel">SID</span>
</NRadio>
</div>
- <div class="mt-1">
+ <div class="mt-2">
<NInput
v-if="state.mode === 'ServiceName'"
:value="state.serviceName"
diff --git a/frontend/src/components/InstanceForm/Form.vue b/frontend/src/components/InstanceForm/Form.vue
index a8480bd9ce..90635f4836 100644
--- a/frontend/src/components/InstanceForm/Form.vue
+++ b/frontend/src/components/InstanceForm/Form.vue
@@ -109,7 +109,7 @@
:allow-edit="allowEdit"
/>
</template>
- <template v-if="basicInfo.engine === Engine.BIGQUERY">
+ <template v-else-if="basicInfo.engine === Engine.BIGQUERY">
<BigQueryHostInput
v-model:host="adminDataSource.host"
:allow-edit="allowEdit"
@@ -127,7 +127,7 @@
</template>
<template v-else-if="basicInfo.engine === Engine.COSMOSDB">
{{ $t("instance.endpoint") }}
- <RequiredStar class="mr-2" />
+ <RequiredStar />
</template>
<div
v-else-if="
@@ -137,20 +137,23 @@
>
<span>
{{ $t("instance.sentence.google-cloud-sql.instance-name") }}
- <RequiredStar class="mr-2" />
+ <RequiredStar />
</span>
- <div class="textinfolabel mb-1">
- {{
- $t("instance.sentence.google-cloud-sql.instance-name-tips")
- }}
- </div>
+ <i18n-t
+ tag="div"
+ class="textinfolabel mb-1"
+ keypath="instance.sentence.google-cloud-sql.instance-name-tips"
+ >
+ <template #instance>
+ <span class="font-bold">
+ {project-id}:{region}:{instance-name}
+ </span>
+ </template>
+ </i18n-t>
</div>
<template v-else>
{{ $t("instance.host-or-socket") }}
- <RequiredStar
- v-if="basicInfo.engine !== Engine.DYNAMODB"
- class="mr-2"
- />
+ <RequiredStar v-if="basicInfo.engine !== Engine.DYNAMODB" />
</template>
</label>
<NInput
@@ -390,8 +393,8 @@
}}
</span>
<button
+ v-if="instanceLink.trim().length > 0"
class="ml-1 btn-icon"
- :disabled="instanceLink.trim().length === 0"
@click.prevent="window.open(urlfy(instanceLink), '_blank')"
>
<heroicons-outline:external-link class="w-4 h-4" />
@@ -447,6 +450,8 @@
<div class="mt-6 pt-0 border-none">
<div class="flex flex-row space-x-2">
<NButton
+ tertiary
+ type="primary"
class="whitespace-nowrap flex items-center"
:loading="state.isTestingConnection"
:disabled="!allowCreate || state.isRequesting || !allowEdit"
@@ -640,27 +645,42 @@ const showAdditionalAddresses = computed(() => {
// the host name between 127.0.0.1/host.docker.internal and "" if user hasn't changed default yet.
const changeInstanceEngine = (engine: Engine) => {
context.resetDataSource();
- if (
- engine === Engine.SNOWFLAKE ||
- engine === Engine.SPANNER ||
- engine === Engine.BIGQUERY ||
- engine === Engine.DYNAMODB
- ) {
- if (
- adminDataSource.value.host === "127.0.0.1" ||
- adminDataSource.value.host === "host.docker.internal"
- ) {
- adminDataSource.value.host = "";
+ switch (engine) {
+ case Engine.SNOWFLAKE:
+ case Engine.DYNAMODB: {
+ if (
+ adminDataSource.value.host === "127.0.0.1" ||
+ adminDataSource.value.host === "host.docker.internal"
+ ) {
+ adminDataSource.value.host = "";
+ }
+ break;
}
- } else if (engine === Engine.COSMOSDB) {
- // Cosmos DB supports Azure IAM only.
- adminDataSource.value.authenticationType =
- DataSource_AuthenticationType.AZURE_IAM;
- } else {
- if (!adminDataSource.value.host) {
- adminDataSource.value.host = isDev()
- ? "127.0.0.1"
- : "host.docker.internal";
+ case Engine.SPANNER:
+ case Engine.BIGQUERY: {
+ adminDataSource.value.authenticationType =
+ DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM;
+ if (
+ adminDataSource.value.host === "127.0.0.1" ||
+ adminDataSource.value.host === "host.docker.internal"
+ ) {
+ adminDataSource.value.host = "";
+ }
+ break;
+ }
+ case Engine.COSMOSDB: {
+ // Cosmos DB supports Azure IAM only.
+ adminDataSource.value.authenticationType =
+ DataSource_AuthenticationType.AZURE_IAM;
+ break;
+ }
+ default: {
+ if (!adminDataSource.value.host) {
+ adminDataSource.value.host = isDev()
+ ? "127.0.0.1"
+ : "host.docker.internal";
+ }
+ break;
}
}
basicInfo.value.engine = engine;
diff --git a/frontend/src/components/InstanceForm/common.ts b/frontend/src/components/InstanceForm/common.ts
index 6862fc28c4..528e97593b 100644
--- a/frontend/src/components/InstanceForm/common.ts
+++ b/frontend/src/components/InstanceForm/common.ts
@@ -7,7 +7,10 @@ import type {
DataSource,
Instance,
} from "@/types/proto-es/v1/instance_service_pb";
-import { DataSourceType } from "@/types/proto-es/v1/instance_service_pb";
+import {
+ DataSourceType,
+ DataSource_AuthenticationType,
+} from "@/types/proto-es/v1/instance_service_pb";
import { PlanType } from "@/types/proto-es/v1/subscription_service_pb";
import { calcUpdateMask } from "@/utils";
@@ -145,5 +148,20 @@ export const calcDataSourceUpdateMask = (
updateMask.add("authentication_private_key");
}
+ if (updateMask.has("iam_extension")) {
+ updateMask.delete("iam_extension");
+ switch (editing.authenticationType) {
+ case DataSource_AuthenticationType.AWS_RDS_IAM:
+ updateMask.add("aws_credential");
+ break;
+ case DataSource_AuthenticationType.AZURE_IAM:
+ updateMask.add("azure_credential");
+ break;
+ case DataSource_AuthenticationType.GOOGLE_CLOUD_SQL_IAM:
+ updateMask.add("gcp_credential");
+ break;
+ }
+ }
+
return Array.from(updateMask);
};
diff --git a/frontend/src/components/InstanceForm/context.ts b/frontend/src/components/InstanceForm/context.ts
index a867dbf85c..d703f90c26 100644
--- a/frontend/src/components/InstanceForm/context.ts
+++ b/frontend/src/components/InstanceForm/context.ts
@@ -167,10 +167,9 @@ export const provideInstanceFormContext = (baseContext: {
switch (ds.externalSecret.secretType) {
case DataSourceExternalSecret_SecretType.VAULT_KV_V2:
- if (!ds.externalSecret.url || !ds.externalSecret.engineName) {
- return false;
- }
if (
+ !ds.externalSecret.url ||
+ !ds.externalSecret.engineName ||
!ds.externalSecret.secretName ||
!ds.externalSecret.passwordKeyName
) {
@@ -201,7 +200,7 @@ export const provideInstanceFormContext = (baseContext: {
case DataSourceExternalSecret_AuthType.VAULT_APP_ROLE:
return !!(
ds.externalSecret.authOption?.case === "appRole" &&
- ds.externalSecret.authOption.value?.roleId &&
+ ds.externalSecret.authOption.value.roleId &&
ds.externalSecret.authOption.value.secretId
);
}
@@ -216,9 +215,13 @@ export const provideInstanceFormContext = (baseContext: {
}
if (basicInfo.value.engine === Engine.SPANNER) {
return (
- basicInfo.value.title.trim() &&
- isValidSpannerHost(adminDataSource.value.host) &&
- adminDataSource.value.updatedPassword
+ !!basicInfo.value.title.trim() &&
+ isValidSpannerHost(adminDataSource.value.host)
+ );
+ }
+ if (basicInfo.value.engine === Engine.BIGQUERY) {
+ return (
+ !!basicInfo.value.title.trim() && adminDataSource.value.host !== ""
);
}
@@ -240,8 +243,7 @@ export const provideInstanceFormContext = (baseContext: {
}
return (
- basicInfo.value.title.trim() &&
- resourceIdField.value?.resourceId &&
+ !!basicInfo.value.title.trim() &&
resourceIdField.value?.isValidated &&
checkDataSource([adminDataSource.value])
);
diff --git a/frontend/src/components/v2/Form/ResourceIdField.vue b/frontend/src/components/v2/Form/ResourceIdField.vue
index c4b22868fb..54e92c83b3 100644
--- a/frontend/src/components/v2/Form/ResourceIdField.vue
+++ b/frontend/src/components/v2/Form/ResourceIdField.vue
@@ -22,7 +22,7 @@
{{ $t("resource-id.cannot-be-changed-later") }}
</span>
<span
- class="text-accent font-medium cursor-pointer hover:opacity-80"
+ class="text-accent font-medium cursor-pointer hover:opacity-80 ml-1"
@click="state.manualEdit = true"
>
{{ $t("common.edit") }}
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index f50c94e6b9..e90490ee34 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -21,7 +21,6 @@
"sign-up": "Sign up",
"email": "Email",
"username": "Username",
- "credentials": "Credentials",
"password": "Password",
"save": "Save",
"cancel": "Cancel",
@@ -1319,7 +1318,7 @@
"create-readonly-user-non-sql": "This is the connection used by Bytebase to perform read-only operations.",
"google-cloud-sql": {
"instance-name": "Instance Connection Name",
- "instance-name-tips": "The instance connection name should like project-id:region:instance-name.",
+ "instance-name-tips": "The instance connection name should like {instance}.",
"mysql": {
"template": "Create a service account named {user}, then add it in your Google Cloud SQL as IAM user {user}{'@'}'%'. Grant this user with the needed privileges."
},
@@ -1357,7 +1356,6 @@
"firewall-info": "If you use inbound firewall rules for your database instance, please refer to Bytebase Cloud connection instruction."
},
"no-password": "No password",
- "type-or-paste-credentials": "Type or paste CREDENTIALS",
"type-or-paste-credentials-write-only": "Type or paste CREDENTIALS - write only",
"password-write-only": "YOUR_DB_PWD - write only",
"password-type": {
@@ -1422,7 +1420,7 @@
"grants": "Grants",
"find-gcp-project-id": "To find GCP Project ID, see",
"find-gcp-project-id-and-instance-id": "To find GCP Project ID and instance ID, see",
- "create-gcp-credentials": "To create Credentials, see",
+ "create-gcp-credentials": "To create credentials, see",
"all": "All instances",
"force-archive-description": "Force to archive. All databases will be unassigned.",
"scan-interval": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 40a079bec5..87c4a0e962 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -21,7 +21,6 @@
"sign-up": "Registrarse",
"email": "Correo electrónico",
"username": "Nombre de usuario",
- "credentials": "Credenciales",
"password": "Contraseña",
"save": "Guardar",
"cancel": "Cancelar",
@@ -1319,7 +1318,7 @@
"create-readonly-user-non-sql": "Esta es la conexión utilizada por Bytebase para realizar operaciones de solo lectura.",
"google-cloud-sql": {
"instance-name": "Nombre de conexión de instancia",
- "instance-name-tips": "El nombre de la conexión de la instancia debería ser project-id:region:instance-name.",
+ "instance-name-tips": "El nombre de la conexión de la instancia debería ser {instance}.",
"mysql": {
"template": "Cree una cuenta de servicio llamada {user} y luego agréguela en su Google Cloud SQL como usuario de IAM {user}{'@'}'%'. Otorgue a este usuario los privilegios necesarios."
},
@@ -1357,7 +1356,6 @@
"firewall-info": "Si usa reglas de firewall entrante para su instancia de base de datos, consulte la instrucción de conexión de Bytebase Cloud."
},
"no-password": "Sin contraseña",
- "type-or-paste-credentials": "Escriba o pegue las CREDENCIALES",
"type-or-paste-credentials-write-only": "Escriba o pegue las CREDENCIALES - solo escritura",
"password-write-only": "SU_DB_PWD - solo escritura",
"password-type": {
@@ -2913,4 +2911,4 @@
"last-visit": "Última visita",
"changelog-for-version": "Registro de cambios para {version}"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index d8b02e4ba7..773717a7ee 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -21,7 +21,6 @@
"sign-up": "登録する",
"email": "メールアドレス",
"username": "ユーザー名",
- "credentials": "資格",
"password": "パスワード",
"save": "保存",
"cancel": "キャンセル",
@@ -1319,7 +1318,7 @@
"create-readonly-user-non-sql": "これは、データベースに接続して読み取り専用操作を実行するために Bytebase によって使用されるユーザーです。",
"google-cloud-sql": {
"instance-name": "インスタンス接続名",
- "instance-name-tips": "インスタンス接続名は project-id:region:instance-name である必要があります。",
+ "instance-name-tips": "インスタンス接続名は {instance} である必要があります。",
"mysql": {
"template": "{user} という名前のサービス アカウントを作成し、IAM ユーザー {user}{'@'}'%' として Google Cloud SQL に追加します。このユーザーに必要な権限を付与します。"
},
@@ -1357,7 +1356,6 @@
"firewall-info": "データベースインスタンスにインバウンドファイアウォールルールを使用する場合は、ByteBase Cloud Connection命令を参照してください。"
},
"no-password": "パスワードがありません",
- "type-or-paste-credentials": "資格情報を入力または貼り付けます",
"type-or-paste-credentials-write-only": "資格情報を入力または貼り付けます - 書き込みのみ",
"password-write-only": "YOUR_DB_PWD - 書き込み専用",
"password-type": {
@@ -2913,4 +2911,4 @@
"last-visit": "最終訪問",
"changelog-for-version": "{version} の変更履歴"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index ea081b00e7..7455225330 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -21,7 +21,6 @@
"sign-up": "Đăng ký",
"email": "Email",
"username": "Tên người dùng",
- "credentials": "Thông tin xác thực",
"password": "Mật khẩu",
"save": "Lưu",
"cancel": "Hủy",
@@ -1319,7 +1318,7 @@
"create-readonly-user-non-sql": "Đây là kết nối được Bytebase sử dụng để thực hiện các hoạt động chỉ đọc.",
"google-cloud-sql": {
"instance-name": "Tên kết nối phiên bản",
- "instance-name-tips": "Tên kết nối phiên bản phải giống như project-id:region:instance-name.",
+ "instance-name-tips": "Tên kết nối phiên bản phải giống như {instance}.",
"mysql": {
"template": "Tạo một tài khoản dịch vụ có tên {user}, sau đó thêm nó vào Google Cloud SQL của bạn với tư cách là người dùng IAM {user}{'@'}'%'. Cấp cho người dùng này các đặc quyền cần thiết."
},
@@ -1357,7 +1356,6 @@
"firewall-info": "Nếu bạn sử dụng các quy tắc tường lửa gửi đến cho thể hiện cơ sở dữ liệu của mình, vui lòng tham khảo Hướng dẫn kết nối đám mây Bytebase."
},
"no-password": "Không có mật khẩu",
- "type-or-paste-credentials": "Nhập hoặc dán THÔNG TIN XÁC THỰC",
"type-or-paste-credentials-write-only": "Nhập hoặc dán THÔNG TIN XÁC THỰC - chỉ ghi",
"password-write-only": "YOUR_DB_PWD - chỉ ghi",
"password-type": {
@@ -2913,4 +2911,4 @@
"last-visit": "Lần truy cập cuối",
"changelog-for-version": "Nhật ký thay đổi cho phiên bản {version}"
}
-}
\ No newline at end of file
+}
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 5963b2dcbe..5ca22a45c1 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -21,7 +21,6 @@
"sign-up": "注册",
"email": "邮箱",
"username": "用户名",
- "credentials": "凭据",
"password": "密码",
"save": "保存",
"cancel": "取消",
@@ -1319,7 +1318,7 @@
"create-readonly-user-non-sql": "这是 Bytebase 用于连接数据库,执行只读操作的用户。",
"google-cloud-sql": {
"instance-name": "实例连接名称",
- "instance-name-tips": "实例连接名称应为 project-id:region:instance-name。",
+ "instance-name-tips": "实例连接名称应为 {instance}。",
"mysql": {
"template": "创建一个名为 {user} 的服务帐户,然后将其作为 IAM 用户 {user}{'@'}'%' 添加到您的 Google Cloud SQL 中。授予此用户所需的权限。"
},
@@ -1357,7 +1356,6 @@
"firewall-info": "如果您为数据库实例使用入站防火墙规则,请参阅 ByteBase Cloud Connection 文档。"
},
"no-password": "无密码",
- "type-or-paste-credentials": "输入或粘贴 CREDENTIALS",
"type-or-paste-credentials-write-only": "输入或粘贴 CREDENTIALS - 仅写入",
"password-write-only": "YOUR_DB_PWD - 仅写入",
"password-type": {