Skip to content

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

chore: remove bb prefix from database label (#8615)

Danny Xudcf598728c91
diff --git a/backend/api/v1/project_service_test.go b/backend/api/v1/project_service_test.go
index d3d7bf6e6d..8e73106208 100644
--- a/backend/api/v1/project_service_test.go
+++ b/backend/api/v1/project_service_test.go
@@ -201,7 +201,7 @@ func TestValidateAndConvertToStoreDeploymentSchedule(t *testing.T) {
LabelSelector: &v1pb.LabelSelector{
MatchExpressions: []*v1pb.LabelSelectorRequirement{
{
- Key: "bb.environment",
+ Key: "environment",
Operator: v1pb.OperatorType_OPERATOR_TYPE_IN,
Values: []string{"prod"},
},
@@ -227,7 +227,7 @@ func TestValidateAndConvertToStoreDeploymentSchedule(t *testing.T) {
Selector: &store.LabelSelector{
MatchExpressions: []*store.LabelSelectorRequirement{
{
- Key: "bb.environment",
+ Key: "environment",
Operator: store.InOperatorType,
Values: []string{"prod"},
},
@@ -257,7 +257,7 @@ func TestValidateAndConvertToStoreDeploymentSchedule(t *testing.T) {
LabelSelector: &v1pb.LabelSelector{
MatchExpressions: []*v1pb.LabelSelectorRequirement{
{
- Key: "bb.environment",
+ Key: "environment",
Operator: v1pb.OperatorType_OPERATOR_TYPE_IN,
Values: []string{"prod"},
},
@@ -287,7 +287,7 @@ func TestValidateAndConvertToStoreDeploymentSchedule(t *testing.T) {
LabelSelector: &v1pb.LabelSelector{
MatchExpressions: []*v1pb.LabelSelectorRequirement{
{
- Key: "bb.environment",
+ Key: "environment",
Operator: v1pb.OperatorType_OPERATOR_TYPE_IN,
Values: []string{},
},
@@ -337,7 +337,7 @@ func TestValidateAndConvertToStoreDeploymentSchedule(t *testing.T) {
LabelSelector: &v1pb.LabelSelector{
MatchExpressions: []*v1pb.LabelSelectorRequirement{
{
- Key: "bb.environment",
+ Key: "environment",
Operator: v1pb.OperatorType_OPERATOR_TYPE_IN,
Values: []string{"prod", "test"},
},
diff --git a/backend/legacyapi/deploy_test.go b/backend/legacyapi/deploy_test.go
index 02cbc8aeb5..20d71a283e 100644
--- a/backend/legacyapi/deploy_test.go
+++ b/backend/legacyapi/deploy_test.go
@@ -15,7 +15,7 @@ func TestGetDeploymentSchedule(t *testing.T) {
}{
{
"complexDeployments",
- `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["prod"]},{"key":"location","operator":"In","values":["us-central1","europe-west1"]}]}}},{"name":"deployment2","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["prod"]},{"key":"location","operator":"Exists"}]}}}]}`,
+ `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"environment","operator":"In","values":["prod"]},{"key":"location","operator":"In","values":["us-central1","europe-west1"]}]}}},{"name":"deployment2","spec":{"selector":{"matchExpressions":[{"key":"environment","operator":"In","values":["prod"]},{"key":"location","operator":"Exists"}]}}}]}`,
&DeploymentSchedule{
Deployments: []*Deployment{
{
@@ -24,7 +24,7 @@ func TestGetDeploymentSchedule(t *testing.T) {
Selector: &LabelSelector{
MatchExpressions: []*LabelSelectorRequirement{
{
- Key: "bb.environment",
+ Key: "environment",
Operator: "In",
Values: []string{"prod"},
}, {
@@ -42,7 +42,7 @@ func TestGetDeploymentSchedule(t *testing.T) {
Selector: &LabelSelector{
MatchExpressions: []*LabelSelectorRequirement{
{
- Key: "bb.environment",
+ Key: "environment",
Operator: "In",
Values: []string{"prod"},
}, {
@@ -59,7 +59,7 @@ func TestGetDeploymentSchedule(t *testing.T) {
"",
}, {
"invalidPayload",
- `{"unmatchdeployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["prod"]},{"key":"location","operator":"In","values":["us-central1","europe-west1"]}]}}},{"name":"deployment2","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["prod"]},{"key":"location","operator":"Exists"}]}}}]}`,
+ `{"unmatchdeployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"environment","operator":"In","values":["prod"]},{"key":"location","operator":"In","values":["us-central1","europe-west1"]}]}}},{"name":"deployment2","spec":{"selector":{"matchExpressions":[{"key":"environment","operator":"In","values":["prod"]},{"key":"location","operator":"Exists"}]}}}]}`,
&DeploymentSchedule{},
"",
}, {
@@ -69,17 +69,17 @@ func TestGetDeploymentSchedule(t *testing.T) {
"unexpected end of JSON input",
}, {
"inOperatorWithNoValue",
- `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["prod"]},{"key":"location","operator":"In"}]}}}]}`,
+ `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"environment","operator":"In","values":["prod"]},{"key":"location","operator":"In"}]}}}]}`,
nil,
"operator should have at least one value",
}, {
"existsOperatorWithValues",
- `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["prod"]},{"key":"location","operator":"Exists","values":["us-central1","europe-west1"]}]}}}]}`,
+ `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"environment","operator":"In","values":["prod"]},{"key":"location","operator":"Exists","values":["us-central1","europe-west1"]}]}}}]}`,
nil,
"operator shouldn't have values",
}, {
"invalidOperator",
- `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["prod"]},{"key":"location","operator":"invalid"}]}}}]}`,
+ `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"environment","operator":"In","values":["prod"]},{"key":"location","operator":"invalid"}]}}}]}`,
nil,
"has invalid operator",
}, {
@@ -89,12 +89,12 @@ func TestGetDeploymentSchedule(t *testing.T) {
"label",
}, {
"environmentExistsOperator",
- `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"Exists"},{"key":"location","operator":"In","values":["us-central1","europe-west1"]}]}}}]}`,
+ `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"environment","operator":"Exists"},{"key":"location","operator":"In","values":["us-central1","europe-west1"]}]}}}]}`,
nil,
"should must use operator",
}, {
"environmentMultiValues",
- `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"bb.environment","operator":"In","values":["prod", "dev"]},{"key":"location","operator":"In","values":["us-central1","europe-west1"]}]}}}]}`,
+ `{"deployments":[{"name":"deployment1","spec":{"selector":{"matchExpressions":[{"key":"environment","operator":"In","values":["prod", "dev"]},{"key":"location","operator":"In","values":["us-central1","europe-west1"]}]}}}]}`,
nil,
"should must use operator",
},
diff --git a/backend/legacyapi/label.go b/backend/legacyapi/label.go
index 372349437d..ae2bc0e66c 100644
--- a/backend/legacyapi/label.go
+++ b/backend/legacyapi/label.go
@@ -2,11 +2,9 @@ package api
const (
// EnvironmentLabelKey is the reserved key for environment.
- EnvironmentLabelKey string = "bb.environment"
+ EnvironmentLabelKey string = "environment"
// TenantLabelKey is the label key for tenant.
- TenantLabelKey = "bb.tenant"
- // LocationLabelKey is the label key for location.
- LocationLabelKey = "bb.location"
+ TenantLabelKey = "tenant"
// DatabaseLabelSizeMax is the maximum size of database labels.
DatabaseLabelSizeMax = 4
diff --git a/backend/migrator/demo/next/demo.sql.REMOVED.git-id b/backend/migrator/demo/next/demo.sql.REMOVED.git-id
index 2939974745..7c15f5ebbb 100644
--- a/backend/migrator/demo/next/demo.sql.REMOVED.git-id
+++ b/backend/migrator/demo/next/demo.sql.REMOVED.git-id
@@ -1 +1 @@
-7f2cdffeb77e1849f84b8dca08503bafab01d0e7
\ No newline at end of file
+40429e0ebfe716acfc537ac1c0e27f15084728f0
\ No newline at end of file
diff --git a/backend/migrator/migration/prod/2.9/0004##label_prefix.sql b/backend/migrator/migration/prod/2.9/0004##label_prefix.sql
new file mode 100644
index 0000000000..aafe84163d
--- /dev/null
+++ b/backend/migrator/migration/prod/2.9/0004##label_prefix.sql
@@ -0,0 +1,9 @@
+UPDATE db SET
+ metadata = metadata || jsonb_build_object('labels', (metadata->'labels')::JSONB - 'bb.environment')
+WHERE metadata ? 'labels' AND (metadata->'labels')::JSONB ? 'bb.environment';
+
+UPDATE db SET
+ metadata = metadata || jsonb_build_object('labels', REPLACE((metadata->'labels')::TEXT, 'bb.', '')::JSONB)
+WHERE metadata ? 'labels';
+
+UPDATE deployment_config SET config = REPLACE(config::TEXT, 'bb.', '')::JSONB;
\ No newline at end of file
diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index 2952211f98..830dd85eba 100644
--- a/backend/migrator/migrator_test.go
+++ b/backend/migrator/migrator_test.go
@@ -236,5 +236,5 @@ func TestMigrationCompatibility(t *testing.T) {
func TestGetCutoffVersion(t *testing.T) {
releaseVersion, err := getProdCutoffVersion()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("2.9.3"), releaseVersion)
+ require.Equal(t, semver.MustParse("2.9.4"), releaseVersion)
}
diff --git a/backend/store/deploy.go b/backend/store/deploy.go
index 2f08646ccd..edb477460c 100644
--- a/backend/store/deploy.go
+++ b/backend/store/deploy.go
@@ -239,7 +239,7 @@ func (s *Store) getDefaultDeploymentConfigV2(ctx context.Context) (*DeploymentCo
Spec: &DeploymentSpec{
Selector: &LabelSelector{
MatchExpressions: []*LabelSelectorRequirement{
- {Key: "bb.environment", Operator: InOperatorType, Values: []string{environment.ResourceID}},
+ {Key: "environment", Operator: InOperatorType, Values: []string{environment.ResourceID}},
},
},
},
diff --git a/backend/utils/utils_test.go b/backend/utils/utils_test.go
index 05fffc0c36..417852fd5b 100644
--- a/backend/utils/utils_test.go
+++ b/backend/utils/utils_test.go
@@ -18,9 +18,9 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
DatabaseName: "hello",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
- "bb.location": "us-central1",
- "bb.tenant": "bytebase",
- "bb.environment": "dev",
+ "location": "us-central1",
+ "tenant": "bytebase",
+ "environment": "dev",
},
},
},
@@ -29,9 +29,9 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
DatabaseName: "hello",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
- "bb.location": "earth",
- "bb.tenant": "bytebase",
- "bb.environment": "dev",
+ "location": "earth",
+ "tenant": "bytebase",
+ "environment": "dev",
},
},
},
@@ -40,9 +40,9 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
DatabaseName: "hello",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
- "bb.location": "europe-west1",
- "bb.tenant": "bytebase",
- "bb.environment": "dev",
+ "location": "europe-west1",
+ "tenant": "bytebase",
+ "environment": "dev",
},
},
},
@@ -51,8 +51,8 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
DatabaseName: "hello",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
- "bb.location": "earth",
- "bb.environment": "dev",
+ "location": "earth",
+ "environment": "dev",
},
},
},
@@ -61,8 +61,8 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
DatabaseName: "world",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
- "bb.location": "earth",
- "bb.environment": "dev",
+ "location": "earth",
+ "environment": "dev",
},
},
},
@@ -71,8 +71,8 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
DatabaseName: "db1_us",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
- "bb.location": "us",
- "bb.environment": "dev",
+ "location": "us",
+ "environment": "dev",
},
},
},
@@ -81,8 +81,8 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
DatabaseName: "db1_eu",
Metadata: &storepb.DatabaseMetadata{
Labels: map[string]string{
- "bb.location": "eu",
- "bb.environment": "dev",
+ "location": "eu",
+ "environment": "dev",
},
},
},
@@ -105,7 +105,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
Selector: &api.LabelSelector{
MatchExpressions: []*api.LabelSelectorRequirement{
{
- Key: "bb.location",
+ Key: "location",
Operator: "In",
Values: []string{"us-central1", "europe-west1"},
},
@@ -118,7 +118,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
Selector: &api.LabelSelector{
MatchExpressions: []*api.LabelSelectorRequirement{
{
- Key: "bb.location",
+ Key: "location",
Operator: "Exists",
Values: nil,
},
@@ -145,7 +145,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
Selector: &api.LabelSelector{
MatchExpressions: []*api.LabelSelectorRequirement{
{
- Key: "bb.location",
+ Key: "location",
Operator: "In",
Values: []string{"us-central1", "europe-west1"},
},
@@ -158,7 +158,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
Selector: &api.LabelSelector{
MatchExpressions: []*api.LabelSelectorRequirement{
{
- Key: "bb.location",
+ Key: "location",
Operator: "In",
Values: []string{"earth"},
},
@@ -185,7 +185,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
Selector: &api.LabelSelector{
MatchExpressions: []*api.LabelSelectorRequirement{
{
- Key: "bb.tenant",
+ Key: "tenant",
Operator: "In",
Values: []string{"bytebase"},
},
@@ -198,7 +198,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
Selector: &api.LabelSelector{
MatchExpressions: []*api.LabelSelectorRequirement{
{
- Key: "bb.location",
+ Key: "location",
Operator: "In",
Values: []string{"us-central1", "europe-west1"},
},
@@ -225,7 +225,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
Selector: &api.LabelSelector{
MatchExpressions: []*api.LabelSelectorRequirement{
{
- Key: "bb.location",
+ Key: "location",
Operator: "In",
Values: []string{"earth"},
},
@@ -251,7 +251,7 @@ func TestGetDatabaseMatrixFromDeploymentSchedule(t *testing.T) {
Selector: &api.LabelSelector{
MatchExpressions: []*api.LabelSelectorRequirement{
{
- Key: "bb.location",
+ Key: "location",
Operator: "In",
Values: []string{"us", "eu"},
},
diff --git a/docs/design/tenancy.md b/docs/design/tenancy.md
index b0a2e27703..5504addfa7 100644
--- a/docs/design/tenancy.md
+++ b/docs/design/tenancy.md
@@ -24,7 +24,7 @@ Labels are used as queryable key-value pair annotations for resources such as da
The labels applied to a resource have the following requirements:
- Each resource can have multiple labels, up to a maximum of 4. We start with a low number which can be increased later.
- Each label must be a structured key-value pair.
-- Keys and values cannot be empty, and have a maximum length of 63 characters. Keys should only have alphanumeric characters ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.). Dots are used for namespace prefixes, e.g. “bb.location”. Namespace prefix is required.
+- Keys and values cannot be empty, and have a maximum length of 63 characters. Keys should only have alphanumeric characters ([a-z0-9A-Z]) with dashes (-), underscores (_), dots (.). Dots are used for namespace prefixes, e.g. “location”. Namespace prefix is required.
- The key portion of a label must be unique for a resource. However, the same key or key:value label can be applied to different resources so that labels are not unique identifiers for resources.
- Labels follow the CRUD resource model.
- Labels keys are defined at workspace level by workspace owners. Project owners are only allowed to use these predefined label keys. We define it at workspace level for convenience and can be expanded later when we have more hierarchical use cases later (environment, project, etc). Note, we don't allow users to define label keys at all at first but provide several predefined label keys. Initially, workspace owners also need to pre-define label values before values are used as database labels, because many labels such as locations need tight controls by DBAs and this can simplify some of the user journeys without re-typing values every single time.
@@ -329,11 +329,11 @@ We have some reserved/built-in keys to simplify the onboarding and be consistent
| Name | Description |
| -------------- | ------------------------------------------------------------------ |
-| bb.location | The location of a database such as region, zone, datacenter names. |
-| bb.tenant | The tenant name of a customer. |
-| bb.environment | The environment name mapped from instance environment. |
+| location | The location of a database such as region, zone, datacenter names. |
+| tenant | The tenant name of a customer. |
+| environment | The environment name mapped from instance environment. |
-Note, bb.environment labels are reserved labels mapped from database instances' environments. This label is immutable and always returned from database label listing. It must be present and its value must match exactly with instance environment on setting the database labels. Since tenants are identified by labels in the deployment config, we need an environment labels to identify tenants from different environment in a schema update deployment. If we expose the environment label concept in the deployment config, it should look consistent in the label API.
+Note, environment labels are reserved labels mapped from database instances' environments. This label is immutable and always returned from database label listing. It must be present and its value must match exactly with instance environment on setting the database labels. Since tenants are identified by labels in the deployment config, we need an environment labels to identify tenants from different environment in a schema update deployment. If we expose the environment label concept in the deployment config, it should look consistent in the label API.
### Octopus Tenant SaaS Deployment
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
index 308c102bfe..3e37bd049c 100644
--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue
@@ -453,7 +453,7 @@ const state = reactive<LocalState>({
selectedDatabaseUidListForEnvironment: new Map<string, string[]>(),
selectedDatabaseIdListForTenantMode: new Set<string>(),
deployingTenantDatabaseList: [],
- label: "bb.environment",
+ label: "environment",
searchText: "",
databaseSelectedTab: "DATABASE",
showSchemaLessDatabaseList: false,
diff --git a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue
index 6bb1e3eb62..18bc00ef18 100644
--- a/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue
+++ b/frontend/src/components/CreateDatabasePrepForm/CreateDatabasePrepForm.vue
@@ -208,7 +208,7 @@
import { isEmpty } from "lodash-es";
import { NInput } from "naive-ui";
import { v4 as uuidv4 } from "uuid";
-import { computed, reactive, PropType, watchEffect, ref, toRef } from "vue";
+import { computed, reactive, PropType, ref, toRef } from "vue";
import { useRouter } from "vue-router";
import InstanceRoleSelect from "@/components/InstanceRoleSelect.vue";
import MemberSelect from "@/components/MemberSelect.vue";
@@ -250,7 +250,6 @@ import {
import {
extractBackupResourceName,
extractDatabaseResourceName,
- extractEnvironmentResourceName,
hasWorkspacePermissionV1,
instanceV1HasCollationAndCharacterSet,
instanceV1HasCreateDatabase,
@@ -549,20 +548,6 @@ const create = async () => {
await createV1();
};
-// update `state.labelList` when selected Environment changed
-watchEffect(() => {
- const envId = state.environmentId;
- const { labels } = state;
- const key = "bb.environment";
- if (envId) {
- const env = environmentV1Store.getEnvironmentByUID(envId);
- const resourceId = extractEnvironmentResourceName(env.name);
- labels[key] = resourceId;
- } else {
- delete labels[key];
- }
-});
-
defineExpose({
allowCreate,
cancel,
diff --git a/frontend/src/components/CreateDatabasePrepForm/DatabaseNameTemplateTips.vue b/frontend/src/components/CreateDatabasePrepForm/DatabaseNameTemplateTips.vue
index 03f3c62de3..7bb393b83c 100644
--- a/frontend/src/components/CreateDatabasePrepForm/DatabaseNameTemplateTips.vue
+++ b/frontend/src/components/CreateDatabasePrepForm/DatabaseNameTemplateTips.vue
@@ -46,7 +46,7 @@ const mode = computed((): ViewMode => {
const matches = name.match(regex);
if (!matches) return "template-mismatch";
const parsedTenant = matches.groups?.["TENANT"];
- const tenant = labels["bb.tenant"] ?? "";
+ const tenant = labels["tenant"] ?? "";
if (parsedTenant && parsedTenant !== tenant) {
return "value-mismatch";
}
diff --git a/frontend/src/components/CreateDatabasePrepForm/logic.ts b/frontend/src/components/CreateDatabasePrepForm/logic.ts
index 0f87f6eead..d0dae9ac09 100644
--- a/frontend/src/components/CreateDatabasePrepForm/logic.ts
+++ b/frontend/src/components/CreateDatabasePrepForm/logic.ts
@@ -10,7 +10,7 @@ export const useDBNameTemplateInputState = (
labels: MaybeRef<Record<string, string>>;
}
) => {
- const TENANT_LABEL_KEY = "bb.tenant";
+ const TENANT_LABEL_KEY = "tenant";
const TENANT_LABEL_REGEXP_GROUP_NAME = "TENANT";
const tenantValue = computed(() => {
diff --git a/frontend/src/components/DatabaseDetail/Settings/components/Labels.vue b/frontend/src/components/DatabaseDetail/Settings/components/Labels.vue
index 5353cc42dd..32c3dd670b 100644
--- a/frontend/src/components/DatabaseDetail/Settings/components/Labels.vue
+++ b/frontend/src/components/DatabaseDetail/Settings/components/Labels.vue
@@ -132,7 +132,7 @@ const handleSave = async () => {
if (!allowSave.value) return;
state.isUpdating = true;
try {
- // Won't omit empty `bb.tenant` value.
+ // Won't omit empty `tenant` value.
// Otherwise the server API won't update the labels field correctly.
const labels = convertKVListToLabels(state.kvList, false /* !omitEmpty */);
diff --git a/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue b/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue
index fdc2271840..6f559e1633 100644
--- a/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue
+++ b/frontend/src/components/DeploymentConfigTool/DeploymentMatrix.vue
@@ -60,7 +60,7 @@ const props = withDefaults(
);
const state = reactive({
- label: "bb.environment" as LabelKeyType,
+ label: "environment" as LabelKeyType,
keyword: "",
});
diff --git a/frontend/src/components/DeploymentConfigTool/SelectorItem.vue b/frontend/src/components/DeploymentConfigTool/SelectorItem.vue
index e33b4caa9c..08f7bf26a5 100644
--- a/frontend/src/components/DeploymentConfigTool/SelectorItem.vue
+++ b/frontend/src/components/DeploymentConfigTool/SelectorItem.vue
@@ -79,7 +79,7 @@ const keys = computed(() => {
);
});
const allowMultipleValues = computed(() => {
- return props.selector.key !== "bb.environment";
+ return props.selector.key !== "environment";
});
const values = computed(() => {
if (!props.selector.key) return [];
diff --git a/frontend/src/components/ProjectDeploymentConfigPanel.vue b/frontend/src/components/ProjectDeploymentConfigPanel.vue
index aaaed35e4b..85170e5318 100644
--- a/frontend/src/components/ProjectDeploymentConfigPanel.vue
+++ b/frontend/src/components/ProjectDeploymentConfigPanel.vue
@@ -178,7 +178,7 @@ watchEffect(async () => {
const addStage = () => {
if (!state.deployment) return;
const rule: LabelSelectorRequirement = {
- key: "bb.environment",
+ key: "environment",
operator: OperatorType.OPERATOR_TYPE_IN,
values: [],
};
diff --git a/frontend/src/components/TransferDatabaseForm.vue b/frontend/src/components/TransferDatabaseForm.vue
index 9529cff4e5..7ecf10002b 100644
--- a/frontend/src/components/TransferDatabaseForm.vue
+++ b/frontend/src/components/TransferDatabaseForm.vue
@@ -211,9 +211,7 @@ const parseLabelsIfNeeded = (database: ComposedDatabase) => {
const match = database.name.match(regex);
if (!match) return undefined;
- const labels: Record<string, string> = {
- "bb.environment": database.effectiveEnvironment,
- };
+ const labels: Record<string, string> = {};
PRESET_LABEL_KEY_PLACEHOLDERS.forEach(([placeholder, key]) => {
const value = match.groups?.[placeholder];
diff --git a/frontend/src/composables/useExecuteSQL.ts b/frontend/src/composables/useExecuteSQL.ts
index 2e80e2da66..d13835ae7e 100644
--- a/frontend/src/composables/useExecuteSQL.ts
+++ b/frontend/src/composables/useExecuteSQL.ts
@@ -131,7 +131,7 @@ const useExecuteSQL = () => {
const matched = batchQueryContext.selectedLabels.find((labelString) => {
// Filter out the environment label.
const keys = Object.keys(database.labels).filter((key) => {
- return key !== "bb.environment";
+ return key !== "environment";
});
return keys
.map((key) => {
diff --git a/frontend/src/utils/database.ts b/frontend/src/utils/database.ts
index 08d238a151..030462b8fa 100644
--- a/frontend/src/utils/database.ts
+++ b/frontend/src/utils/database.ts
@@ -134,7 +134,7 @@ export function filterDatabaseByKeyword(
if (
columns.includes("tenant") &&
db.labels
- .find((label) => label.key === "bb.tenant")
+ .find((label) => label.key === "tenant")
?.value.toLowerCase()
.includes(keyword)
) {
diff --git a/frontend/src/utils/label.ts b/frontend/src/utils/label.ts
index d442154aea..13efcd98e8 100644
--- a/frontend/src/utils/label.ts
+++ b/frontend/src/utils/label.ts
@@ -11,13 +11,13 @@ import { extractEnvironmentResourceName } from "./v1";
export const MAX_LABEL_VALUE_LENGTH = 63;
-export const RESERVED_LABEL_KEYS = ["bb.environment"];
+export const RESERVED_LABEL_KEYS = ["environment"];
-export const PRESET_LABEL_KEYS = ["bb.tenant"];
+export const PRESET_LABEL_KEYS = ["tenant"];
export const PRESET_DB_NAME_TEMPLATE_PLACEHOLDERS = ["DB_NAME", "TENANT"];
-export const PRESET_LABEL_KEY_PLACEHOLDERS = [["TENANT", "bb.tenant"]];
+export const PRESET_LABEL_KEY_PLACEHOLDERS = [["TENANT", "tenant"]];
export const hidePrefix = (key: string): string => {
return key.replace(/^bb\./, "");
@@ -137,7 +137,7 @@ export const convertKVListToLabels = (
};
export const displayLabelKey = (key: string) => {
- if (key === "bb.environment") {
+ if (key === "environment") {
return "Environment ID";
}
@@ -175,7 +175,7 @@ export const getLabelValuesFromDatabaseV1List = (
databaseList: ComposedDatabase[],
withEmptyValue = false
): string[] => {
- if (key === "bb.environment") {
+ if (key === "environment") {
const environmentList = useEnvironmentV1Store().getEnvironmentList();
return environmentList.map((env) =>
extractEnvironmentResourceName(env.name)
@@ -219,7 +219,7 @@ export const isDatabaseMatchesSelectorV1 = (
};
export const getSemanticLabelValue = (db: ComposedDatabase, key: string) => {
- if (key === "bb.environment") {
+ if (key === "environment") {
return extractEnvironmentResourceName(db.effectiveEnvironment);
}
return db.labels[key] ?? "";
diff --git a/frontend/src/utils/v1/database.ts b/frontend/src/utils/v1/database.ts
index d3cea5f8f5..628f5a3eee 100644
--- a/frontend/src/utils/v1/database.ts
+++ b/frontend/src/utils/v1/database.ts
@@ -303,7 +303,7 @@ export function filterDatabaseV1ByKeyword(
}
if (columns.includes("tenant")) {
- const tenantValue = db.labels["bb.tenant"] ?? "";
+ const tenantValue = db.labels["tenant"] ?? "";
if (tenantValue.toLowerCase().includes(keyword)) {
return true;
}
diff --git a/frontend/src/utils/v1/deploymentConfig.ts b/frontend/src/utils/v1/deploymentConfig.ts
index 86bfda5930..2423527a09 100644
--- a/frontend/src/utils/v1/deploymentConfig.ts
+++ b/frontend/src/utils/v1/deploymentConfig.ts
@@ -37,7 +37,7 @@ export const validateDeploymentSpecV1 = (
if (rules.length === 0) {
return "deployment-config.error.at-least-one-selector";
}
- const envRule = rules.find((rule) => rule.key === "bb.environment");
+ const envRule = rules.find((rule) => rule.key === "environment");
if (!envRule || envRule.operator !== OperatorType.OPERATOR_TYPE_IN) {
return "deployment-config.error.env-in-selector-required";
}
diff --git a/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue b/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
index 7ac3fea6eb..e8cf4464ae 100644
--- a/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/BatchQueryDatabasesSelector.vue
@@ -163,7 +163,7 @@ const handleTriggerClick = () => {
const getFilteredDatabaseLabels = (labels: { [key: string]: string }) => {
// Filter out the environment label.
const keys = Object.keys(labels).filter((key) => {
- return key !== "bb.environment";
+ return key !== "environment";
});
return keys.map((key) => {
return {
@@ -178,7 +178,7 @@ const matchedDatabases = computed(() => {
return selectedLabelsValue.value.find((labelString) => {
// Filter out the environment label.
const keys = Object.keys(db.labels).filter((key) => {
- return key !== "bb.environment";
+ return key !== "environment";
});
return keys
.map((key) => {