Skip to content

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

chore: feature guard for vault (#11388)

ecmadaoc82f63e0fcb2
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
index 992cbcaf52..fd713d19c1 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/DataSourceForm.vue
@@ -34,7 +34,10 @@
{{ $t("instance.password-type.password") }}
</NRadio>
<NRadio value="EXTERNAL_SECRET">
- {{ $t("instance.password-type.external-secret") }}
+ <div class="flex items-center gap-x-1">
+ <FeatureBadge feature="bb.feature.external-secret-manager" />
+ {{ $t("instance.password-type.external-secret") }}
+ </div>
</NRadio>
</NRadioGroup>
<div v-if="state.passwordType === 'PLAIN'">
@@ -495,7 +498,7 @@ const {
basicInfo,
adminDataSource,
hasReadonlyReplicaFeature,
- showReadOnlyDataSourceFeatureModal,
+ missingFeature,
} = useInstanceFormContext();
const {
@@ -609,7 +612,7 @@ const handleHostInput = (value: string) => {
if (ds.host || ds.port) {
ds.host = adminDataSource.value.host;
ds.port = adminDataSource.value.port;
- showReadOnlyDataSourceFeatureModal.value = true;
+ missingFeature.value = "bb.feature.read-replica-connection";
return;
}
}
@@ -624,7 +627,7 @@ const handlePortInput = (value: string) => {
if (ds.host || ds.port) {
ds.host = adminDataSource.value.host;
ds.port = adminDataSource.value.port;
- showReadOnlyDataSourceFeatureModal.value = true;
+ missingFeature.value = "bb.feature.read-replica-connection";
return;
}
}
diff --git a/frontend/src/components/InstanceForm/InstanceForm.vue b/frontend/src/components/InstanceForm/InstanceForm.vue
index 50723020e8..e683789f36 100644
--- a/frontend/src/components/InstanceForm/InstanceForm.vue
+++ b/frontend/src/components/InstanceForm/InstanceForm.vue
@@ -316,10 +316,11 @@
</component>
<FeatureModal
- feature="bb.feature.read-replica-connection"
- :open="showReadOnlyDataSourceFeatureModal"
+ v-if="missingFeature"
+ :feature="missingFeature"
+ :open="true"
:instance="instance"
- @cancel="showReadOnlyDataSourceFeatureModal = false"
+ @cancel="missingFeature = undefined"
/>
<BBAlert
@@ -424,7 +425,6 @@ const cancel = () => {
interface LocalState {
editingDataSourceId: string | undefined;
- showFeatureModal: boolean;
isTestingConnection: boolean;
isRequesting: boolean;
showCreateInstanceWarningModal: boolean;
@@ -444,7 +444,6 @@ const state = reactive<LocalState>({
editingDataSourceId: props.instance?.dataSources.find(
(ds) => ds.type === DataSourceType.ADMIN
)?.id,
- showFeatureModal: false,
isTestingConnection: false,
isRequesting: false,
showCreateInstanceWarningModal: false,
@@ -462,7 +461,7 @@ const {
editingDataSource,
readonlyDataSourceList,
hasReadonlyReplicaFeature,
- showReadOnlyDataSourceFeatureModal,
+ missingFeature,
} = context;
const {
showDatabase,
@@ -738,6 +737,10 @@ const tryCreate = async () => {
}
};
+const hasExternalSecretFeature = computed(() =>
+ subscriptionStore.hasFeature("bb.feature.external-secret-manager")
+);
+
// We will also create the database * denoting all databases
// and its RW data source. The username, password is actually
// stored in that data source object instead of in the instance self.
@@ -757,6 +760,11 @@ const doCreate = async () => {
);
instanceCreate.dataSources = [adminDataSourceCreate];
+ if (!checkExternalSecretFeature(instanceCreate)) {
+ missingFeature.value = "bb.feature.external-secret-manager";
+ return;
+ }
+
state.isRequesting = true;
try {
await useGracefulRequest(async () => {
@@ -784,7 +792,11 @@ const doUpdate = async () => {
return;
}
if (!checkRODataSourceFeature(instance)) {
- showReadOnlyDataSourceFeatureModal.value = true;
+ missingFeature.value = "bb.feature.read-replica-connection";
+ return;
+ }
+ if (!checkExternalSecretFeature(instance)) {
+ missingFeature.value = "bb.feature.external-secret-manager";
return;
}
// When clicking **Update** we may have more than one thing to do (if needed)
@@ -1108,6 +1120,16 @@ const extractDataSourceFromEdit = (
return ds;
};
+const checkExternalSecretFeature = (instance: Instance) => {
+ if (hasExternalSecretFeature.value) {
+ return true;
+ }
+
+ return instance.dataSources.every((ds) => {
+ return !ds.externalSecret && !/^{{.+}}$/.test(ds.password);
+ });
+};
+
const checkRODataSourceFeature = (instance: Instance) => {
// This is to
// - Disallow creating any new RO data sources
diff --git a/frontend/src/components/InstanceForm/context.ts b/frontend/src/components/InstanceForm/context.ts
index 02082b8493..6893b3df0c 100644
--- a/frontend/src/components/InstanceForm/context.ts
+++ b/frontend/src/components/InstanceForm/context.ts
@@ -8,6 +8,7 @@ import {
ref,
} from "vue";
import { useCurrentUserV1, useSubscriptionV1Store } from "@/store";
+import type { FeatureType } from "@/types";
import { State } from "@/types/proto/v1/common";
import type { Instance } from "@/types/proto/v1/instance_service";
import { DataSourceType } from "@/types/proto/v1/instance_service";
@@ -22,7 +23,7 @@ export type InstanceFormContext = {
basicInfo: Ref<BasicInfo>;
dataSourceEditState: Ref<DataSourceEditState>;
hasReadonlyReplicaFeature: ComputedRef<boolean>;
- showReadOnlyDataSourceFeatureModal: Ref<boolean>;
+ missingFeature: Ref<FeatureType | undefined>;
// derived states
adminDataSource: ComputedRef<EditDataSource>;
@@ -78,7 +79,7 @@ export const provideInstanceFormContext = (
);
});
- const showReadOnlyDataSourceFeatureModal = ref(false);
+ const missingFeature = ref<FeatureType | undefined>(undefined);
const context: InstanceFormContext = {
...baseContext,
@@ -91,7 +92,7 @@ export const provideInstanceFormContext = (
readonlyDataSourceList,
hasReadOnlyDataSource,
hasReadonlyReplicaFeature,
- showReadOnlyDataSourceFeatureModal,
+ missingFeature,
};
provide(KEY, context);
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 068cab4ac3..e734a413c9 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2437,6 +2437,10 @@
"instance-count-exceeds": "Instance count {count} exceeds the limit {limit}"
},
"features": {
+ "bb-feature-external-secret-manager": {
+ "title": "Set external secret",
+ "desc": "Use Vault or a custom URL as the external secret for the database password."
+ },
"bb-feature-task-schedule-time": {
"title": "Set task schedule time",
"desc": "Set task schedule time allows you to set a specific time to run your tasks."
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 781875d6a6..98da5d7725 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2437,6 +2437,10 @@
"instance-count-exceeds": "El número de instancias {count} excedió el límite {limit}"
},
"features": {
+ "bb-feature-external-secret-manager": {
+ "title": "Establecer secreto externo",
+ "desc": "Utilice Vault o una URL personalizada como secreto externo para la contraseña de la base de datos."
+ },
"bb-feature-task-schedule-time": {
"title": "Establecer horario de tareas",
"desc": "Establecer horario de tareas te permite programar una hora específica para ejecutar tus tareas."
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 3643aae6c0..b7116f4e3d 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2437,6 +2437,10 @@
"instance-count-exceeds": "インスタンス数が制限{limit}を超えています"
},
"features": {
+ "bb-feature-external-secret-manager": {
+ "title": "外部シークレットを設定する",
+ "desc": "データベース パスワードの外部シークレットとして Vault またはカスタム URL を使用します。"
+ },
"bb-feature-task-schedule-time": {
"title": "タスクスケジュール時間の設定",
"desc": "タスクスケジュール時間の設定を使用すると、タスクを実行する特定の時間を設定できます。"
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 5ff0030c93..025e7facac 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -2437,6 +2437,10 @@
"instance-count-exceeds": "Số lượng phiên bản {count} vượt quá giới hạn {limit}"
},
"features": {
+ "bb-feature-external-secret-manager": {
+ "title": "Đặt bí mật bên ngoài",
+ "desc": "Sử dụng Vault hoặc URL tùy chỉnh làm bí mật bên ngoài cho mật khẩu cơ sở dữ liệu."
+ },
"bb-feature-task-schedule-time": {
"title": "Đặt thời gian thực hiện nhiệm vụ",
"desc": "Đặt thời gian lập lịch tác vụ cho phép bạn đặt thời gian cụ thể để thực hiện các tác vụ của mình."
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index caf1d45bbf..6c99f07d1b 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2436,6 +2436,10 @@
"instance-count-exceeds": "实例数量 {count} 超出了限制 {limit}"
},
"features": {
+ "bb-feature-external-secret-manager": {
+ "title": "设置外部密钥",
+ "desc": "设置 Vault 或自定义 URL 作为数据库密码的外部密钥"
+ },
"bb-feature-task-schedule-time": {
"title": "设定任务执行时间",
"desc": "「设定任务执行时间」可以将任务设定在特定时间执行"