Skip to content

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

chore: allow manual no role (#15338)

Danny Xu66d177698e58
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.go
index f231fb0a8c..f3ca1a041a 100644
--- a/backend/api/v1/issue_service.go
+++ b/backend/api/v1/issue_service.go
@@ -807,7 +807,7 @@ func (s *IssueService) ApproveIssue(ctx context.Context, request *v1pb.ApproveIs
return nil
}
- policy, err := GetValidRolloutPolicyForStage(ctx, s.store, s.licenseService, stages[0])
+ policy, err := GetValidRolloutPolicyForStage(ctx, s.store, stages[0])
if err != nil {
return err
}
diff --git a/backend/api/v1/issue_service_convert.go b/backend/api/v1/issue_service_convert.go
index 13f55fdfe5..d7d62f535d 100644
--- a/backend/api/v1/issue_service_convert.go
+++ b/backend/api/v1/issue_service_convert.go
@@ -118,7 +118,7 @@ func (s *IssueService) convertToIssueReleasers(ctx context.Context, issue *store
if activeStage == nil {
return nil, nil
}
- policy, err := GetValidRolloutPolicyForStage(ctx, s.store, s.licenseService, activeStage)
+ policy, err := GetValidRolloutPolicyForStage(ctx, s.store, activeStage)
if err != nil {
return nil, err
}
diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.go
index 44d988191f..34e5a8fcf5 100644
--- a/backend/api/v1/rollout_service.go
+++ b/backend/api/v1/rollout_service.go
@@ -1209,14 +1209,7 @@ func getPipelineCreateToTargetStage(ctx context.Context, s *store.Store, snapsho
return pipelineCreate, nil
}
-func GetValidRolloutPolicyForStage(ctx context.Context, stores *store.Store, licenseService enterprise.LicenseService, stage *store.StageMessage) (*storepb.RolloutPolicy, error) {
- if licenseService.IsFeatureEnabled(api.FeatureRolloutPolicy) != nil {
- // nolint:nilerr
- return &storepb.RolloutPolicy{
- Automatic: true,
- }, nil
- }
-
+func GetValidRolloutPolicyForStage(ctx context.Context, stores *store.Store, stage *store.StageMessage) (*storepb.RolloutPolicy, error) {
for _, task := range stage.TaskList {
instance, err := stores.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &task.InstanceID})
if err != nil {
@@ -1225,12 +1218,6 @@ func GetValidRolloutPolicyForStage(ctx context.Context, stores *store.Store, lic
if instance == nil || instance.Deleted {
continue
}
- if licenseService.IsFeatureEnabledForInstance(api.FeatureRolloutPolicy, instance) != nil {
- // nolint:nilerr
- return &storepb.RolloutPolicy{
- Automatic: true,
- }, nil
- }
}
policy, err := stores.GetRolloutPolicy(ctx, stage.Environment)
@@ -1257,7 +1244,7 @@ func (s *RolloutService) canUserRunStageTasks(ctx context.Context, user *store.U
return true, nil
}
- p, err := GetValidRolloutPolicyForStage(ctx, s.store, s.licenseService, stage)
+ p, err := GetValidRolloutPolicyForStage(ctx, s.store, stage)
if err != nil {
return false, err
}
diff --git a/backend/legacyapi/plan.go b/backend/legacyapi/plan.go
index d9d41988fd..59769d1f65 100644
--- a/backend/legacyapi/plan.go
+++ b/backend/legacyapi/plan.go
@@ -335,7 +335,7 @@ var FeatureMatrix = map[FeatureType][3]bool{
FeatureSyncSchemaAllVersions: {false, true, true},
FeatureIndexAdvisor: {true, true, true},
// Policy Control
- FeatureRolloutPolicy: {false, true, true},
+ FeatureRolloutPolicy: {true, true, true},
FeatureEnvironmentTierPolicy: {false, false, true},
FeatureSensitiveData: {false, false, true},
FeatureAccessControl: {false, false, true},
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 45d6530d21..6029ef1c43 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -226,7 +226,7 @@ func (r *Runner) findApprovalTemplateForIssue(ctx context.Context, issue *store.
if len(stages) == 0 {
return nil
}
- policy, err := apiv1.GetValidRolloutPolicyForStage(ctx, r.store, r.licenseService, stages[0])
+ policy, err := apiv1.GetValidRolloutPolicyForStage(ctx, r.store, stages[0])
if err != nil {
return err
}
diff --git a/backend/store/policy.go b/backend/store/policy.go
index 0a051cda27..b9c1b0f86b 100644
--- a/backend/store/policy.go
+++ b/backend/store/policy.go
@@ -141,9 +141,7 @@ func (s *Store) GetRolloutPolicy(ctx context.Context, environment string) (*stor
return nil, errors.Wrapf(err, "failed to get policy")
}
if policy == nil {
- return &storepb.RolloutPolicy{
- Automatic: true,
- }, nil
+ return &storepb.RolloutPolicy{}, nil
}
p := &storepb.RolloutPolicy{}
diff --git a/frontend/src/components/EnvironmentForm/Buttons.vue b/frontend/src/components/EnvironmentForm/Buttons.vue
index c3bcc05cdd..c75608caa1 100644
--- a/frontend/src/components/EnvironmentForm/Buttons.vue
+++ b/frontend/src/components/EnvironmentForm/Buttons.vue
@@ -75,18 +75,6 @@ const createEnvironment = () => {
const updateEnvironment = () => {
if (!isEqual(rolloutPolicy.value, state.value.rolloutPolicy)) {
// Validate rollout policy.
- if (
- !state.value.rolloutPolicy.rolloutPolicy?.automatic &&
- state.value.rolloutPolicy.rolloutPolicy?.roles.length === 0 &&
- state.value.rolloutPolicy.rolloutPolicy?.issueRoles.length === 0
- ) {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: t("policy.rollout.select-at-least-one-role"),
- });
- return;
- }
events.emit("update-policy", {
environment: state.value.environment,
policyType: PolicyType.ROLLOUT_POLICY,
diff --git a/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue b/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue
index 7983f25dd7..88376a372b 100644
--- a/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue
+++ b/frontend/src/components/EnvironmentForm/RolloutPolicyConfig.vue
@@ -1,45 +1,7 @@
<template>
<div class="flex flex-col items-start gap-y-2">
<div class="flex flex-col gap-y-2">
- <NRadio
- :checked="isAutomaticRolloutChecked"
- :disabled="disabled"
- style="--n-label-padding: 0 0 0 1rem"
- @update:checked="toggleAutomaticRollout(true)"
- >
- <div class="flex flex-col gap-y-1">
- <div class="textlabel">
- {{ $t("policy.rollout.auto") }}
- </div>
- <div class="textinfolabel">
- {{ $t("policy.rollout.auto-info") }}
- </div>
- </div>
- </NRadio>
- </div>
- <div class="flex flex-col gap-y-2">
- <NRadio
- :checked="!isAutomaticRolloutChecked"
- :disabled="disabled"
- style="--n-label-padding: 0 0 0 1rem"
- @update:checked="toggleAutomaticRollout(false)"
- >
- <div class="flex flex-col gap-y-1">
- <div class="textlabel flex flex-row gap-x-1">
- <span>{{ $t("policy.rollout.manual-by-dedicated-roles") }}</span>
- <FeatureBadge feature="bb.feature.rollout-policy" />
- <FeatureBadgeForInstanceLicense
- :show="hasRolloutPolicyFeature"
- feature="bb.feature.rollout-policy"
- :tooltip="$t('subscription.instance-assignment.require-license')"
- />
- </div>
- <div class="textinfolabel">
- {{ $t("policy.rollout.manual-by-dedicated-roles-info") }}
- </div>
- </div>
- </NRadio>
- <div class="flex flex-col gap-y-2 pl-8" v-if="!isAutomaticRolloutChecked">
+ <div class="flex flex-col gap-y-2">
<RoleSelect
v-model:value="rolloutPolicy.roles"
:disabled="disabled"
@@ -65,25 +27,37 @@
"
>
<div class="textlabel">
- {{ $t("policy.rollout.last-approver-from-custom-approval") }}
+ {{ $t("policy.rollout.last-issue-approver") }}
</div>
</NCheckbox>
</div>
+ <NCheckbox
+ :checked="isAutomaticRolloutChecked"
+ :disabled="disabled"
+ style="--n-label-padding: 0 0 0 1rem"
+ @update:checked="toggleAutomaticRollout($event)"
+ >
+ <div class="flex flex-col gap-y-1">
+ <div class="textlabel">
+ {{ $t("policy.rollout.auto") }}
+ </div>
+ <div class="textinfolabel">
+ {{ $t("policy.rollout.auto-info") }}
+ </div>
+ </div>
+ </NCheckbox>
</div>
</div>
</template>
<script setup lang="ts">
import { cloneDeep, uniq } from "lodash-es";
-import { NCheckbox, NRadio } from "naive-ui";
+import { NCheckbox } from "naive-ui";
import { ref, watch } from "vue";
import { computed } from "vue";
-import { featureToRef } from "@/store";
import { VirtualRoleType } from "@/types";
import type { Policy } from "@/types/proto/v1/org_policy_service";
import { RolloutPolicy } from "@/types/proto/v1/org_policy_service";
-import FeatureBadge from "../FeatureGuard/FeatureBadge.vue";
-import FeatureBadgeForInstanceLicense from "../FeatureGuard/FeatureBadgeForInstanceLicense.vue";
import { RoleSelect } from "../v2";
const props = defineProps<{
@@ -97,8 +71,6 @@ const emit = defineEmits<{
const rolloutPolicy = ref(cloneDeep(props.policy.rolloutPolicy!));
-const hasRolloutPolicyFeature = featureToRef("bb.feature.rollout-policy");
-
const isAutomaticRolloutChecked = computed(() => {
return rolloutPolicy.value.automatic;
});
@@ -115,47 +87,34 @@ const update = (rp: RolloutPolicy) => {
rolloutPolicy: rp,
});
};
-const toggleAutomaticRollout = (checked: boolean) => {
- update(
- RolloutPolicy.fromPartial(
- checked
- ? {
- automatic: true,
- roles: [],
- issueRoles: [],
- }
- : {
- automatic: false,
- roles: rolloutPolicy.value.roles,
- issueRoles: rolloutPolicy.value.issueRoles,
- }
- )
- );
+const toggleAutomaticRollout = (selected: boolean) => {
+ update(RolloutPolicy.fromJSON({
+ ...rolloutPolicy.value,
+ automatic: selected,
+ }));
};
const toggleIssueRoles = (checked: boolean, role: string) => {
- const roles = rolloutPolicy.value.issueRoles;
+ const issueRoles = rolloutPolicy.value.issueRoles;
if (checked) {
- roles.push(role);
+ issueRoles.push(role);
} else {
- const index = roles.indexOf(role);
+ const index = issueRoles.indexOf(role);
if (index !== -1) {
- roles.splice(index, 1);
+ issueRoles.splice(index, 1);
}
}
update(
RolloutPolicy.fromPartial({
- automatic: false,
- roles: rolloutPolicy.value.roles,
- issueRoles: uniq(roles),
+ ...rolloutPolicy.value,
+ issueRoles: uniq(issueRoles),
})
);
};
const updateRoles = (roles: string[]) => {
update(
RolloutPolicy.fromPartial({
- automatic: false,
- roles,
- issueRoles: rolloutPolicy.value.issueRoles,
+ ...rolloutPolicy.value,
+ roles: roles,
})
);
};
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index bf15f322c6..5730cb4df0 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1310,13 +1310,10 @@
"rollout": {
"name": "Rollout Policy",
"tip": "The policy is applied to issues retroactively.",
- "info": "For rolling out database change, this setting controls whether the rollout requires manual approval.",
- "auto": "Automatic rollout",
+ "info": "Tasks can be executed by users with 'taskRuns.create' permission or the following roles",
+ "auto": "Automatic",
"auto-info": "If all check pass, the change will be rolled out and executed automatically.",
- "last-approver-from-custom-approval": "Last approver from the custom approval",
- "select-at-least-one-role": "Please select at least one role in rollout policy",
- "manual-by-dedicated-roles": "Manual rollout by dedicated roles",
- "manual-by-dedicated-roles-info": "Allow any of the following selected roles to click the \"Rollout\" button, and then the change will be executed."
+ "last-issue-approver": "Last Issue Approver"
},
"environment-tier": {
"name": "Environment Tier",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 0ad89063b0..8b73be4cca 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1310,13 +1310,10 @@
"rollout": {
"name": "Política de Implementación",
"tip": "La política se aplica retrospectivamente a las incidencias.",
- "info": "Para implementar cambios en la base de datos, esta configuración controla si la implementación requiere aprobación manual.",
- "auto": "Implementar automático",
+ "info": "Las tareas pueden ser ejecutadas por usuarios con el permiso 'taskRuns.create' o los siguientes roles",
+ "auto": "Automático",
"auto-info": "Si se aprueban todas las comprobaciones, el cambio se implementará y ejecutará automáticamente.",
- "last-approver-from-custom-approval": "Último aprobador de la aprobación personalizada",
- "select-at-least-one-role": "Seleccione al menos un rol en la política de implementación",
- "manual-by-dedicated-roles": "Implementación manual por roles especializados",
- "manual-by-dedicated-roles-info": "Permita que cualquiera de los siguientes roles seleccionados haga clic en el botón \"Implementar\" y luego se ejecutará el cambio."
+ "last-issue-approver": "Aprobador de último tema"
},
"environment-tier": {
"name": "Nivel de Entorno",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 3fdffd6e3c..02e1bf8a88 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1310,13 +1310,10 @@
"rollout": {
"name": "リリース戦略",
"tip": "新しいポリシーは古いイシューにも適用されます",
- "info": "このオプションは、データベースへの変更を公開するときに手動で公開する必要があるかどうかを制御します。",
- "auto": "自動公開",
+ "info": "タスクは、「taskRuns.create」許可または次の役割でユーザーが実行できます",
+ "auto": "自動",
"auto-info": "すべての事前チェックに合格すると、自動的にリリースされ、変更が反映されます。",
- "last-approver-from-custom-approval": "カスタム承認の最終承認者",
- "select-at-least-one-role": "ロールアウトポリシーで少なくとも 1 つのロールを選択してください",
- "manual-by-dedicated-roles": "特定の役割の手動リリース",
- "manual-by-dedicated-roles-info": "以下の選択したロールのいずれかを許可し、「公開」ボタンをクリックして変更を実行します。"
+ "last-issue-approver": "前号承認者"
},
"environment-tier": {
"name": "環境レベル",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index b3fb597a95..b8b997e9a8 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1310,13 +1310,10 @@
"rollout": {
"name": "Chính sách triển khai",
"tip": "Chính sách được áp dụng cho các vấn đề hồi tố.",
- "info": "Để triển khai thay đổi cơ sở dữ liệu, cài đặt này kiểm soát việc triển khai có yêu cầu phê duyệt thủ công hay không.",
+ "info": "Các tác vụ có thể được thực hiện bởi người dùng có quyền 'taskRuns.Create' hoặc các vai trò sau",
"auto": "Triển khai tự động",
"auto-info": "Nếu tất cả kiểm tra vượt qua, thay đổi sẽ được triển khai và thực hiện tự động.",
- "last-approver-from-custom-approval": "Người phê duyệt cuối cùng từ phê duyệt tùy chỉnh",
- "select-at-least-one-role": "Vui lòng chọn ít nhất một vai trò trong chính sách triển khai",
- "manual-by-dedicated-roles": "Triển khai thủ công bởi các vai trò chuyên dụng",
- "manual-by-dedicated-roles-info": "Cho phép bất kỳ vai trò nào được chọn sau đây nhấp vào nút \"Triển khai\" và sau đó thay đổi sẽ được thực hiện."
+ "last-issue-approver": "Người phê duyệt vấn đề cuối cùng"
},
"environment-tier": {
"name": "Cấp môi trường",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 0eecd8498a..bd561553b3 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1310,13 +1310,10 @@
"rollout": {
"name": "发布策略",
"tip": "新策略对旧工单也生效",
- "info": "当要发布对数据库的变更时,该选项控制了是否需要人工发布。",
+ "info": "拥有 “taskRuns.create” 权限或以下角色的用户可以发布",
"auto": "自动发布",
"auto-info": "如果预检查都通过的话,会自动发布,执行变更。",
- "last-approver-from-custom-approval": "自定义审批的最后一个审批人",
- "select-at-least-one-role": "请在发布策略中至少选择一个角色",
- "manual-by-dedicated-roles": "特定角色手工发布",
- "manual-by-dedicated-roles-info": "允许以下任一选中角色,点击「发布」按钮后,执行变更。"
+ "last-issue-approver": "自定义审批的最后一个审批人"
},
"environment-tier": {
"name": "环境级别",
diff --git a/frontend/src/store/modules/v1/policy.ts b/frontend/src/store/modules/v1/policy.ts
index 8da19e5b84..ca0c3bc44c 100644
--- a/frontend/src/store/modules/v1/policy.ts
+++ b/frontend/src/store/modules/v1/policy.ts
@@ -254,7 +254,7 @@ export const getEmptyRolloutPolicy = (
resourceType,
enforce: true,
rolloutPolicy: {
- automatic: true,
+ automatic: false,
roles: [],
issueRoles: [],
},