Skip to content

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

feat: move environment to setting (#15794)

p0ny131fd9e96ef9
diff --git a/backend/api/v1/actuator_service.go b/backend/api/v1/actuator_service.go
index 480d2ef45e..7a00bffb60 100644
--- a/backend/api/v1/actuator_service.go
+++ b/backend/api/v1/actuator_service.go
@@ -217,12 +217,12 @@ func (s *ActuatorService) getUsedFeatures(ctx context.Context) ([]base.FeatureTy
}
// environment tier
- environments, err := s.store.ListEnvironmentV2(ctx, &store.FindEnvironmentMessage{})
+ environments, err := s.store.GetEnvironmentSetting(ctx)
if err != nil {
- return nil, errors.Wrapf(err, "failed to list environments")
+ return nil, errors.Wrapf(err, "failed to get environment setting")
}
- for _, env := range environments {
- if env.Protected {
+ for _, env := range environments.GetEnvironments() {
+ if v, ok := env.Tags["protected"]; ok && v == "protected" {
features = append(features, base.FeatureEnvironmentTierPolicy)
break
}
diff --git a/backend/api/v1/audit.go b/backend/api/v1/audit.go
index ed70f6b497..9a8497e601 100644
--- a/backend/api/v1/audit.go
+++ b/backend/api/v1/audit.go
@@ -217,14 +217,6 @@ func getRequestResource(request any) string {
return r.Name
case *v1pb.UpdateRiskRequest:
return r.GetRisk().GetName()
- case *v1pb.CreateEnvironmentRequest:
- return r.GetEnvironment().GetName()
- case *v1pb.UpdateEnvironmentRequest:
- return r.GetEnvironment().GetName()
- case *v1pb.DeleteEnvironmentRequest:
- return r.Name
- case *v1pb.UndeleteEnvironmentRequest:
- return r.Name
case *v1pb.CreateInstanceRequest:
return r.GetInstance().GetName()
case *v1pb.UpdateInstanceRequest:
diff --git a/backend/api/v1/database_service.go b/backend/api/v1/database_service.go
index 1d12943b5d..1cd000a0c1 100644
--- a/backend/api/v1/database_service.go
+++ b/backend/api/v1/database_service.go
@@ -440,19 +440,13 @@ func (s *DatabaseService) UpdateDatabase(ctx context.Context, request *v1pb.Upda
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
- environment, err := s.store.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{
- ResourceID: &environmentID,
- ShowDeleted: true,
- })
+ environment, err := s.store.GetEnvironmentByID(ctx, environmentID)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
if environment == nil {
return nil, status.Errorf(codes.NotFound, "environment %q not found", environmentID)
}
- if environment.Deleted {
- return nil, status.Errorf(codes.FailedPrecondition, "environment %q is deleted", environmentID)
- }
patch.EnvironmentID = &environmentID
} else {
unsetEnvironment := ""
@@ -614,19 +608,13 @@ func (s *DatabaseService) BatchUpdateDatabases(ctx context.Context, request *v1p
}
}
if batchUpdate.EnvironmentID != nil && *batchUpdate.EnvironmentID != "" {
- environment, err := s.store.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{
- ResourceID: batchUpdate.EnvironmentID,
- ShowDeleted: true,
- })
+ environment, err := s.store.GetEnvironmentByID(ctx, *batchUpdate.EnvironmentID)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
if environment == nil {
return nil, status.Errorf(codes.NotFound, "environment %q not found", *batchUpdate.EnvironmentID)
}
- if environment.Deleted {
- return nil, status.Errorf(codes.FailedPrecondition, "environment %q is deleted", *batchUpdate.EnvironmentID)
- }
}
updatedDatabases, err := s.store.BatchUpdateDatabases(ctx, databases, batchUpdate)
diff --git a/backend/api/v1/environment_service.go b/backend/api/v1/environment_service.go
deleted file mode 100644
index 9aa2384cac..0000000000
--- a/backend/api/v1/environment_service.go
+++ /dev/null
@@ -1,229 +0,0 @@
-package v1
-
-import (
- "context"
-
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
- "google.golang.org/protobuf/types/known/emptypb"
-
- "github.com/bytebase/bytebase/backend/base"
- "github.com/bytebase/bytebase/backend/common"
- enterprise "github.com/bytebase/bytebase/backend/enterprise/api"
- "github.com/bytebase/bytebase/backend/store"
- v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
-)
-
-// EnvironmentService implements the environment service.
-type EnvironmentService struct {
- v1pb.UnimplementedEnvironmentServiceServer
- store *store.Store
- licenseService enterprise.LicenseService
-}
-
-// NewEnvironmentService creates a new EnvironmentService.
-func NewEnvironmentService(store *store.Store, licenseService enterprise.LicenseService) *EnvironmentService {
- return &EnvironmentService{
- store: store,
- licenseService: licenseService,
- }
-}
-
-// GetEnvironment gets an environment.
-func (s *EnvironmentService) GetEnvironment(ctx context.Context, request *v1pb.GetEnvironmentRequest) (*v1pb.Environment, error) {
- environment, err := s.getEnvironmentMessage(ctx, request.Name)
- if err != nil {
- return nil, err
- }
- return convertToEnvironment(environment), nil
-}
-
-// ListEnvironments lists all environments.
-func (s *EnvironmentService) ListEnvironments(ctx context.Context, request *v1pb.ListEnvironmentsRequest) (*v1pb.ListEnvironmentsResponse, error) {
- environments, err := s.store.ListEnvironmentV2(ctx, &store.FindEnvironmentMessage{ShowDeleted: request.ShowDeleted})
- if err != nil {
- return nil, status.Error(codes.Internal, err.Error())
- }
- response := &v1pb.ListEnvironmentsResponse{}
- for _, environment := range environments {
- response.Environments = append(response.Environments, convertToEnvironment(environment))
- }
- return response, nil
-}
-
-// CreateEnvironment creates an environment.
-func (s *EnvironmentService) CreateEnvironment(ctx context.Context, request *v1pb.CreateEnvironmentRequest) (*v1pb.Environment, error) {
- if request.Environment == nil {
- return nil, status.Errorf(codes.InvalidArgument, "environment must be set")
- }
-
- if err := base.IsValidEnvironmentName(request.Environment.Title); err != nil {
- return nil, status.Errorf(codes.InvalidArgument, "invalid environment title, error %v", err.Error())
- }
- if !isValidResourceID(request.EnvironmentId) {
- return nil, status.Errorf(codes.InvalidArgument, "invalid environment ID %v", request.EnvironmentId)
- }
-
- // Environment limit in the plan.
- environments, err := s.store.ListEnvironmentV2(ctx, &store.FindEnvironmentMessage{ShowDeleted: false})
- if err != nil {
- return nil, status.Error(codes.Internal, err.Error())
- }
- maximumEnvironmentLimit := s.licenseService.GetPlanLimitValue(ctx, enterprise.PlanLimitMaximumEnvironment)
- if len(environments) >= maximumEnvironmentLimit {
- return nil, status.Errorf(codes.ResourceExhausted, "current plan can create up to %d environments.", maximumEnvironmentLimit)
- }
-
- pendingCreate := &store.EnvironmentMessage{
- ResourceID: request.EnvironmentId,
- Title: request.Environment.Title,
- Order: request.Environment.Order,
- Protected: request.Environment.Tier == v1pb.EnvironmentTier_PROTECTED,
- Color: request.Environment.Color,
- }
- if pendingCreate.Protected || pendingCreate.Color != "" {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureEnvironmentTierPolicy); err != nil {
- return nil, status.Error(codes.PermissionDenied, err.Error())
- }
- }
-
- environment, err := s.store.CreateEnvironmentV2(ctx,
- pendingCreate,
- )
- if err != nil {
- return nil, status.Error(codes.Internal, err.Error())
- }
- return convertToEnvironment(environment), nil
-}
-
-// UpdateEnvironment updates an environment.
-func (s *EnvironmentService) UpdateEnvironment(ctx context.Context, request *v1pb.UpdateEnvironmentRequest) (*v1pb.Environment, error) {
- if request.Environment == nil {
- return nil, status.Errorf(codes.InvalidArgument, "environment must be set")
- }
- if request.UpdateMask == nil {
- return nil, status.Errorf(codes.InvalidArgument, "update_mask must be set")
- }
-
- environment, err := s.getEnvironmentMessage(ctx, request.Environment.Name)
- if err != nil {
- return nil, err
- }
- if environment.Deleted {
- return nil, status.Errorf(codes.NotFound, "environment %q has been deleted", request.Environment.Name)
- }
-
- patch := &store.UpdateEnvironmentMessage{
- ResourceID: environment.ResourceID,
- }
- for _, path := range request.UpdateMask.Paths {
- switch path {
- case "title":
- patch.Name = &request.Environment.Title
- case "order":
- patch.Order = &request.Environment.Order
- case "tier":
- protected := request.Environment.Tier == v1pb.EnvironmentTier_PROTECTED
- patch.Protected = &protected
- case "color":
- patch.Color = &request.Environment.Color
- }
- }
-
- if patch.Protected != nil || patch.Color != nil {
- if err := s.licenseService.IsFeatureEnabled(base.FeatureEnvironmentTierPolicy); err != nil {
- return nil, status.Error(codes.PermissionDenied, err.Error())
- }
- }
-
- environment, err = s.store.UpdateEnvironmentV2(ctx, patch)
- if err != nil {
- return nil, status.Error(codes.Internal, err.Error())
- }
- return convertToEnvironment(environment), nil
-}
-
-// DeleteEnvironment deletes an environment.
-func (s *EnvironmentService) DeleteEnvironment(ctx context.Context, request *v1pb.DeleteEnvironmentRequest) (*emptypb.Empty, error) {
- environment, err := s.getEnvironmentMessage(ctx, request.Name)
- if err != nil {
- return nil, err
- }
- if environment.Deleted {
- return nil, status.Errorf(codes.NotFound, "environment %q has been deleted", request.Name)
- }
-
- // All instances in the environment must be deleted.
- count, err := s.store.CountInstance(ctx, &store.CountInstanceMessage{EnvironmentID: &environment.ResourceID})
- if err != nil {
- return nil, status.Error(codes.Internal, err.Error())
- }
- if count > 0 {
- return nil, status.Errorf(codes.FailedPrecondition, "all instances in the environment should be deleted first")
- }
-
- if _, err := s.store.UpdateEnvironmentV2(ctx, &store.UpdateEnvironmentMessage{
- ResourceID: environment.ResourceID,
- Delete: &deletePatch,
- }); err != nil {
- return nil, status.Error(codes.Internal, err.Error())
- }
- return &emptypb.Empty{}, nil
-}
-
-// UndeleteEnvironment undeletes an environment.
-func (s *EnvironmentService) UndeleteEnvironment(ctx context.Context, request *v1pb.UndeleteEnvironmentRequest) (*v1pb.Environment, error) {
- environment, err := s.getEnvironmentMessage(ctx, request.Name)
- if err != nil {
- return nil, err
- }
- if !environment.Deleted {
- return nil, status.Errorf(codes.InvalidArgument, "environment %q is active", request.Name)
- }
-
- environment, err = s.store.UpdateEnvironmentV2(ctx, &store.UpdateEnvironmentMessage{
- ResourceID: environment.ResourceID,
- Delete: &undeletePatch,
- })
- if err != nil {
- return nil, status.Error(codes.Internal, err.Error())
- }
-
- return convertToEnvironment(environment), nil
-}
-
-func (s *EnvironmentService) getEnvironmentMessage(ctx context.Context, name string) (*store.EnvironmentMessage, error) {
- environmentID, err := common.GetEnvironmentID(name)
- if err != nil {
- return nil, status.Error(codes.InvalidArgument, err.Error())
- }
-
- find := &store.FindEnvironmentMessage{
- ResourceID: &environmentID,
- ShowDeleted: true,
- }
- environment, err := s.store.GetEnvironmentV2(ctx, find)
- if err != nil {
- return nil, status.Error(codes.Internal, err.Error())
- }
- if environment == nil {
- return nil, status.Errorf(codes.NotFound, "environment %q not found", name)
- }
-
- return environment, nil
-}
-
-func convertToEnvironment(environment *store.EnvironmentMessage) *v1pb.Environment {
- tier := v1pb.EnvironmentTier_UNPROTECTED
- if environment.Protected {
- tier = v1pb.EnvironmentTier_PROTECTED
- }
- return &v1pb.Environment{
- Name: common.FormatEnvironment(environment.ResourceID),
- State: convertDeletedToState(environment.Deleted),
- Title: environment.Title,
- Order: environment.Order,
- Tier: tier,
- Color: environment.Color,
- }
-}
diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.go
index e1de60a0bd..5bc5cd902b 100644
--- a/backend/api/v1/instance_service.go
+++ b/backend/api/v1/instance_service.go
@@ -434,20 +434,14 @@ func (s *InstanceService) UpdateInstance(ctx context.Context, request *v1pb.Upda
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
- environment, err := s.store.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{
- ResourceID: &environmentID,
- ShowDeleted: true,
- })
+ environment, err := s.store.GetEnvironmentByID(ctx, environmentID)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
if environment == nil {
return nil, status.Errorf(codes.NotFound, "environment %q not found", environmentID)
}
- if environment.Deleted {
- return nil, status.Errorf(codes.FailedPrecondition, "environment %q is deleted", environmentID)
- }
- patch.EnvironmentID = &environment.ResourceID
+ patch.EnvironmentID = &environmentID
case "external_link":
patch.Metadata.ExternalLink = request.Instance.ExternalLink
case "data_sources":
diff --git a/backend/api/v1/plan_service.go b/backend/api/v1/plan_service.go
index cbc40557cb..76c163f9b5 100644
--- a/backend/api/v1/plan_service.go
+++ b/backend/api/v1/plan_service.go
@@ -1314,12 +1314,12 @@ func getPlanSpecDatabaseGroups(steps []*storepb.PlanConfig_Step) []string {
func getPlanDeployment(ctx context.Context, s *store.Store, steps []*storepb.PlanConfig_Step, project *store.ProjectMessage) (*storepb.PlanConfig_Deployment, error) {
snapshot := &storepb.PlanConfig_Deployment{}
- environments, err := s.ListEnvironmentV2(ctx, &store.FindEnvironmentMessage{})
+ environments, err := s.GetEnvironmentSetting(ctx)
if err != nil {
return nil, errors.Wrapf(err, "failed to list environments")
}
- for _, e := range environments {
- snapshot.Environments = append(snapshot.Environments, e.ResourceID)
+ for _, e := range environments.GetEnvironments() {
+ snapshot.Environments = append(snapshot.Environments, e.Id)
}
databaseGroups := getPlanSpecDatabaseGroups(steps)
diff --git a/backend/api/v1/review_config_service.go b/backend/api/v1/review_config_service.go
index 7ce48f3f2a..13e1b02300 100644
--- a/backend/api/v1/review_config_service.go
+++ b/backend/api/v1/review_config_service.go
@@ -212,17 +212,14 @@ func (s *ReviewConfigService) convertToV1ReviewConfig(ctx context.Context, revie
if err != nil {
return nil, err
}
- environment, err := s.store.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{
- ResourceID: &environmentID,
- ShowDeleted: false,
- })
+ environment, err := s.store.GetEnvironmentByID(ctx, environmentID)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get environment %s with error: %v", environmentID, err)
}
if environment == nil {
continue
}
- config.Resources = append(config.Resources, common.FormatEnvironment(environment.ResourceID))
+ config.Resources = append(config.Resources, common.FormatEnvironment(environment.Id))
case base.PolicyResourceTypeProject:
projectID, err := common.GetProjectID(policy.Resource)
if err != nil {
diff --git a/backend/api/v1/rollout_service.go b/backend/api/v1/rollout_service.go
index 1365910607..fb65595df8 100644
--- a/backend/api/v1/rollout_service.go
+++ b/backend/api/v1/rollout_service.go
@@ -965,12 +965,12 @@ func GetPipelineCreate(ctx context.Context, s *store.Store, sheetManager *sheet.
// Step 2 - list snapshot environments.
snapshotEnvironments := deployment.GetEnvironments()
if len(snapshotEnvironments) == 0 {
- environments, err := s.ListEnvironmentV2(ctx, &store.FindEnvironmentMessage{})
+ environments, err := s.GetEnvironmentSetting(ctx)
if err != nil {
return nil, errors.Wrapf(err, "failed to list environments")
}
- for _, e := range environments {
- snapshotEnvironments = append(snapshotEnvironments, e.ResourceID)
+ for _, e := range environments.GetEnvironments() {
+ snapshotEnvironments = append(snapshotEnvironments, e.Id)
}
}
environmentIndex := make(map[string]int)
@@ -1006,11 +1006,11 @@ func GetPipelineCreate(ctx context.Context, s *store.Store, sheetManager *sheet.
return nil, errors.Wrap(err, "failed to get task creates from spec")
}
for _, t := range tc {
- e, err := s.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{ResourceID: &t.EnvironmentID})
+ e, err := s.GetEnvironmentByID(ctx, t.EnvironmentID)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
- environmentIndex := environmentIndex[e.ResourceID]
+ environmentIndex := environmentIndex[e.Id]
stages[environmentIndex].TaskList = append(stages[environmentIndex].TaskList, t)
}
}
@@ -1037,12 +1037,12 @@ func getPipelineCreateToTargetStage(ctx context.Context, s *store.Store, snapsho
return nil, errors.Wrapf(err, "failed to get environment id from %q", *targetEnvironment)
}
if len(snapshotEnvironments) == 0 {
- environments, err := s.ListEnvironmentV2(ctx, &store.FindEnvironmentMessage{})
+ environments, err := s.GetEnvironmentSetting(ctx)
if err != nil {
return nil, errors.Wrapf(err, "failed to list environments")
}
- for _, e := range environments {
- snapshotEnvironments = append(snapshotEnvironments, e.ResourceID)
+ for _, e := range environments.GetEnvironments() {
+ snapshotEnvironments = append(snapshotEnvironments, e.Id)
}
}
diff --git a/backend/api/v1/rollout_service_task.go b/backend/api/v1/rollout_service_task.go
index 680084935f..ac8cb596df 100644
--- a/backend/api/v1/rollout_service_task.go
+++ b/backend/api/v1/rollout_service_task.go
@@ -154,7 +154,7 @@ func getTaskCreatesFromCreateDatabaseConfig(ctx context.Context, s *store.Store,
if dbEnvironmentID != "" {
effectiveEnvironmentID = dbEnvironmentID
}
- environment, err := s.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{ResourceID: &effectiveEnvironmentID})
+ environment, err := s.GetEnvironmentByID(ctx, effectiveEnvironmentID)
if err != nil {
return nil, err
}
diff --git a/backend/api/v1/setting_service.go b/backend/api/v1/setting_service.go
index d2e39787cf..9605a091fa 100644
--- a/backend/api/v1/setting_service.go
+++ b/backend/api/v1/setting_service.go
@@ -602,11 +602,8 @@ func (s *SettingService) UpdateSetting(ctx context.Context, request *v1pb.Update
if serr := validateEnvironments(request.Setting.Value.GetEnvironmentSetting().GetEnvironments()); serr != nil {
return nil, serr.Err()
}
- environmentSetting := &storepb.EnvironmentSetting{}
- if err := convertProtoToProto(request.Setting.Value.GetEnvironmentSetting(), environmentSetting); err != nil {
- return nil, status.Errorf(codes.Internal, "failed to unmarshal setting value for %s with error: %v", apiSettingName, err)
- }
+ environmentSetting := convertEnvironmentSetting(request.Setting.Value.GetEnvironmentSetting())
oldEnvironmentSetting, err := s.store.GetEnvironmentSetting(ctx)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get old environment setting with error: %v", err)
@@ -894,9 +891,9 @@ func (s *SettingService) convertToSettingMessage(ctx context.Context, setting *s
},
}, nil
case base.SettingEnvironment:
- v1Value := new(v1pb.EnvironmentSetting)
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(setting.Value), v1Value); err != nil {
- return nil, status.Errorf(codes.Internal, "failed to unmarshal setting value for %s with error: %v", setting.Name, err)
+ v1Value, err := convertToEnvironmentSetting(setting.Value)
+ if err != nil {
+ return nil, status.Errorf(codes.Internal, "failed to convert setting value for %s with error: %v", setting.Name, err)
}
return &v1pb.Setting{
Name: settingName,
@@ -1352,3 +1349,43 @@ func validateEnvironments(envs []*v1pb.EnvironmentSetting_Environment) *status.S
}
return nil
}
+
+func convertToEnvironmentSetting(value string) (*v1pb.EnvironmentSetting, error) {
+ var setting storepb.EnvironmentSetting
+ if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(value), &setting); err != nil {
+ return nil, errors.Wrapf(err, "failed to unmarshal environment setting")
+ }
+ var environments []*v1pb.EnvironmentSetting_Environment
+
+ for _, e := range setting.Environments {
+ environments = append(environments, convertToEnvironment(e))
+ }
+ return &v1pb.EnvironmentSetting{
+ Environments: environments,
+ }, nil
+}
+
+func convertToEnvironment(e *storepb.EnvironmentSetting_Environment) *v1pb.EnvironmentSetting_Environment {
+ return &v1pb.EnvironmentSetting_Environment{
+ Name: common.FormatEnvironment(e.Id),
+ Id: e.Id,
+ Title: e.Title,
+ Tags: e.Tags,
+ Color: e.Color,
+ }
+}
+
+func convertEnvironmentSetting(e *v1pb.EnvironmentSetting) *storepb.EnvironmentSetting {
+ var environments []*storepb.EnvironmentSetting_Environment
+ for _, env := range e.Environments {
+ environments = append(environments, &storepb.EnvironmentSetting_Environment{
+ Id: env.Id,
+ Title: env.Title,
+ Tags: env.Tags,
+ Color: env.Color,
+ })
+ }
+ return &storepb.EnvironmentSetting{
+ Environments: environments,
+ }
+}
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index b47e93e6ce..1362e07164 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -1845,7 +1845,7 @@ func checkAndGetDataSourceQueriable(ctx context.Context, storeInstance *store.St
}
var envAdminDataSourceRestriction, projectAdminDataSourceRestriction v1pb.DataSourceQueryPolicy_Restriction
- environment, err := storeInstance.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{ResourceID: &database.EffectiveEnvironmentID})
+ environment, err := storeInstance.GetEnvironmentByID(ctx, database.EffectiveEnvironmentID)
if err != nil {
return nil, errors.Wrapf(err, "failed to get environment")
}
@@ -1854,7 +1854,7 @@ func checkAndGetDataSourceQueriable(ctx context.Context, storeInstance *store.St
}
dataSourceQueryPolicyType := base.PolicyTypeDataSourceQuery
environmentResourceType := base.PolicyResourceTypeEnvironment
- environmentResource := common.FormatEnvironment(environment.ResourceID)
+ environmentResource := common.FormatEnvironment(environment.Id)
environmentPolicy, err := storeInstance.GetPolicyV2(ctx, &store.FindPolicyMessage{
ResourceType: &environmentResourceType,
Resource: &environmentResource,
@@ -1905,9 +1905,7 @@ func checkAndGetDataSourceQueriable(ctx context.Context, storeInstance *store.St
}
func checkDataSourceQueryPolicy(ctx context.Context, storeInstance *store.Store, database *store.DatabaseMessage, statementTp parserbase.QueryType) error {
- environment, err := storeInstance.GetEnvironmentV2(ctx, &store.FindEnvironmentMessage{
- ResourceID: &database.EffectiveEnvironmentID,
- })
+ environment, err := storeInstance.GetEnvironmentByID(ctx, database.EffectiveEnvironmentID)
if err != nil {
return err
}
@@ -1915,7 +1913,7 @@ func checkDataSourceQueryPolicy(ctx context.Context, storeInstance *store.Store,
return status.Errorf(codes.NotFound, "environment %q not found", database.EffectiveEnvironmentID)
}
resourceType := base.PolicyResourceTypeEnvironment
- environmentResource := common.FormatEnvironment(environment.ResourceID)
+ environmentResource := common.FormatEnvironment(environment.Id)
policyType := base.PolicyTypeDataSourceQuery
dataSourceQueryPolicy, err := storeInstance.GetPolicyV2(ctx, &store.FindPolicyMessage{
ResourceType: &resourceType,
diff --git a/backend/migrator/migration/3.6/0001##move_environment_to_setting.sql b/backend/migrator/migration/3.6/0001##move_environment_to_setting.sql
new file mode 100644
index 0000000000..0a5f2188f4
--- /dev/null
+++ b/backend/migrator/migration/3.6/0001##move_environment_to_setting.sql
@@ -0,0 +1,29 @@
+ALTER TABLE instance DROP CONSTRAINT instance_environment_fkey;
+
+ALTER TABLE db DROP CONSTRAINT db_environment_fkey;
+
+ALTER TABLE stage DROP CONSTRAINT stage_environment_fkey;
+
+
+INSERT INTO setting (
+ name,
+ value
+) SELECT
+ 'bb.workspace.environment',
+ jsonb_agg(v) FROM (
+ SELECT
+ jsonb_build_object('title', name) ||
+ jsonb_build_object('id', resource_id) ||
+ CASE WHEN policy.payload->>'environmentTier' = 'PROTECTED' THEN jsonb_build_object('tags', jsonb_build_object('protected', 'protected'))
+ ELSE '{"tags": {}}'
+ END
+ AS v
+ FROM environment
+ LEFT JOIN policy ON (policy.resource = 'environments/'||environment.resource_id AND policy.type = 'bb.policy.environment-tier')
+ WHERE environment.deleted IS FALSE
+ ORDER BY environment."order" ASC
+ )
+ON CONFLICT (name) DO UPDATE SET value = EXCLUDED.value;
+
+
+DROP TABLE IF EXISTS environment;
diff --git a/backend/migrator/migration/LATEST.sql b/backend/migrator/migration/LATEST.sql
index 48eb00ca8c..e1ad4f45a8 100644
--- a/backend/migrator/migration/LATEST.sql
+++ b/backend/migrator/migration/LATEST.sql
@@ -53,19 +53,6 @@ CREATE UNIQUE INDEX idx_role_unique_resource_id on role (resource_id);
ALTER SEQUENCE role_id_seq RESTART WITH 101;
--- Environment
-CREATE TABLE environment (
- id serial PRIMARY KEY,
- deleted boolean NOT NULL DEFAULT FALSE,
- name text NOT NULL,
- "order" integer NOT NULL CHECK ("order" >= 0),
- resource_id text NOT NULL
-);
-
-CREATE UNIQUE INDEX idx_environment_unique_resource_id ON environment(resource_id);
-
-ALTER SEQUENCE environment_id_seq RESTART WITH 101;
-
-- Policy
-- policy stores the policies for each resources.
CREATE TABLE policy (
@@ -114,7 +101,7 @@ ALTER SEQUENCE project_webhook_id_seq RESTART WITH 101;
CREATE TABLE instance (
id serial PRIMARY KEY,
deleted boolean NOT NULL DEFAULT FALSE,
- environment text REFERENCES environment(resource_id),
+ environment text,
resource_id text NOT NULL,
metadata jsonb NOT NULL DEFAULT '{}'
);
@@ -131,7 +118,7 @@ CREATE TABLE db (
project text NOT NULL REFERENCES project(resource_id),
instance text NOT NULL REFERENCES instance(resource_id),
name text NOT NULL,
- environment text REFERENCES environment(resource_id),
+ environment text,
metadata jsonb NOT NULL DEFAULT '{}'
);
@@ -202,7 +189,7 @@ ALTER SEQUENCE pipeline_id_seq RESTART WITH 101;
CREATE TABLE stage (
id serial PRIMARY KEY,
pipeline_id integer NOT NULL REFERENCES pipeline(id),
- environment text NOT NULL REFERENCES environment(resource_id)
+ environment text
);
CREATE INDEX idx_stage_pipeline_id ON stage(pipeline_id);
@@ -557,9 +544,3 @@ ALTER SEQUENCE principal_id_seq RESTART WITH 101;
INSERT INTO project (id, name, resource_id) VALUES (1, 'Default', 'default');
ALTER SEQUENCE project_id_seq RESTART WITH 101;
-
--- Create "test" and "prod" environments
-INSERT INTO environment (id, name, "order", resource_id) VALUES (101, 'Test', 0, 'test');
-INSERT INTO environment (id, name, "order", resource_id) VALUES (102, 'Prod', 1, 'prod');
-
-ALTER SEQUENCE environment_id_seq RESTART WITH 103;
diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index 8a23be9226..005f9b6e4f 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.6.0"), *files[len(files)-1].version)
+ require.Equal(t, semver.MustParse("3.6.1"), *files[len(files)-1].version)
}
func TestGetVersionFromPath(t *testing.T) {
diff --git a/backend/runner/taskrun/schedulerv2.go b/backend/runner/taskrun/schedulerv2.go
index cb4da8668b..34c62f2d5c 100644
--- a/backend/runner/taskrun/schedulerv2.go
+++ b/backend/runner/taskrun/schedulerv2.go
@@ -112,19 +112,19 @@ func (s *SchedulerV2) runOnce(ctx context.Context) {
}
func (s *SchedulerV2) scheduleAutoRolloutTasks(ctx context.Context) error {
- environments, err := s.store.ListEnvironmentV2(ctx, &store.FindEnvironmentMessage{ShowDeleted: true})
+ environments, err := s.store.GetEnvironmentSetting(ctx)
if err != nil {
return errors.Wrapf(err, "failed to list environments")
}
var envs []string
- for _, environment := range environments {
- policy, err := s.store.GetRolloutPolicy(ctx, environment.ResourceID)
+ for _, environment := range environments.GetEnvironments() {
+ policy, err := s.store.GetRolloutPolicy(ctx, environment.Id)
if err != nil {
- return errors.Wrapf(err, "failed to get rollout policy for environment %s", environment.ResourceID)
+ return errors.Wrapf(err, "failed to get rollout policy for environment %s", environment.Id)
}
if policy.Automatic {
- envs = append(envs, environment.ResourceID)
+ envs = append(envs, environment.Id)
}
}
taskIDs, err := s.store.ListTasksToAutoRollout(ctx, envs)
diff --git a/backend/server/grpc_routes.go b/backend/server/grpc_routes.go
index c0060c8801..e256ee4937 100644
--- a/backend/server/grpc_routes.go
+++ b/backend/server/grpc_routes.go
@@ -51,7 +51,6 @@ func configureGrpcRouters(
profile,
metricReporter,
licenseService))
- v1pb.RegisterEnvironmentServiceServer(grpcServer, apiv1.NewEnvironmentService(stores, licenseService))
v1pb.RegisterInstanceServiceServer(grpcServer, apiv1.NewInstanceService(
stores,
licenseService,
@@ -129,9 +128,6 @@ func configureGrpcRouters(
if err := v1pb.RegisterDatabaseCatalogServiceHandler(ctx, mux, grpcConn); err != nil {
return err
}
- if err := v1pb.RegisterEnvironmentServiceHandler(ctx, mux, grpcConn); err != nil {
- return err
- }
if err := v1pb.RegisterGroupServiceHandler(ctx, mux, grpcConn); err != nil {
return err
}
diff --git a/backend/store/database.go b/backend/store/database.go
index 534470971b..83eb84c894 100644
--- a/backend/store/database.go
+++ b/backend/store/database.go
@@ -359,8 +359,8 @@ func (*Store) listDatabaseImplV2(ctx context.Context, txn *sql.Tx, find *FindDat
if v := find.EffectiveEnvironmentID; v != nil {
where, args = append(where, fmt.Sprintf(`
COALESCE(
- (SELECT environment.resource_id FROM environment where environment.resource_id = db.environment),
- (SELECT environment.resource_id FROM environment JOIN instance ON environment.resource_id = instance.environment WHERE instance.resource_id = db.instance)
+ db.environment,
+ instance.environment
) = $%d`, len(args)+1)), append(args, *v)
}
if v := find.InstanceID; v != nil {
@@ -377,17 +377,6 @@ func (*Store) listDatabaseImplV2(ctx context.Context, txn *sql.Tx, find *FindDat
where, args = append(where, fmt.Sprintf("instance.metadata->>'engine' = $%d", len(args)+1)), append(args, *v)
}
if !find.ShowDeleted {
- where, args = append(where, fmt.Sprintf(`
- COALESCE(
- (SELECT environment.deleted AS instance_environment_status FROM environment JOIN instance ON environment.resource_id = instance.environment WHERE instance.resource_id = db.instance),
- $%d
- ) = $%d`, len(args)+1, len(args)+2)), append(args, false, false)
- where, args = append(where, fmt.Sprintf(`
- COALESCE(
- (SELECT environment.deleted AS db_environment_status FROM environment WHERE environment.resource_id = db.environment),
- $%d
- ) = $%d`, len(args)+1, len(args)+2)), append(args, false, false)
-
where, args = append(where, fmt.Sprintf("instance.deleted = $%d", len(args)+1)), append(args, false)
// We don't show databases that are deleted by users already.
where, args = append(where, fmt.Sprintf("db.deleted = $%d", len(args)+1)), append(args, false)
@@ -397,10 +386,10 @@ func (*Store) listDatabaseImplV2(ctx context.Context, txn *sql.Tx, find *FindDat
SELECT
db.project,
COALESCE(
- (SELECT environment.resource_id FROM environment WHERE environment.resource_id = db.environment),
- (SELECT environment.resource_id FROM environment JOIN instance ON environment.resource_id = instance.environment WHERE instance.resource_id = db.instance)
+ db.environment,
+ instance.environment
),
- (SELECT environment.resource_id FROM environment WHERE environment.resource_id = db.environment),
+ db.environment,
db.instance,
db.name,
db.deleted,
diff --git a/backend/store/environment.go b/backend/store/environment.go
index 848c0e56c6..6c687577b3 100644
--- a/backend/store/environment.go
+++ b/backend/store/environment.go
@@ -2,323 +2,19 @@ package store
import (
"context"
- "database/sql"
- "fmt"
- "strings"
- "github.com/pkg/errors"
- "google.golang.org/protobuf/encoding/protojson"
-
- "github.com/bytebase/bytebase/backend/base"
- "github.com/bytebase/bytebase/backend/common"
storepb "github.com/bytebase/bytebase/proto/generated-go/store"
)
-// EnvironmentMessage is the mssage for environment.
-type EnvironmentMessage struct {
- ResourceID string
- Title string
- Order int32
- Protected bool
- Color string
- Deleted bool
-}
-
-// FindEnvironmentMessage is the message to find environments.
-type FindEnvironmentMessage struct {
- ResourceID *string
- ShowDeleted bool
-}
-
-// UpdateEnvironmentMessage is the message for updating an environment.
-type UpdateEnvironmentMessage struct {
- ResourceID string
-
- Name *string
- Order *int32
- Protected *bool
- Delete *bool
- Color *string
-}
-
-// GetEnvironmentV2 gets environment by resource ID.
-func (s *Store) GetEnvironmentV2(ctx context.Context, find *FindEnvironmentMessage) (*EnvironmentMessage, error) {
- if find.ResourceID != nil {
- if v, ok := s.environmentCache.Get(*find.ResourceID); ok && s.enableCache {
- return v, nil
- }
- }
-
- // We will always return the resource regardless of its deleted state.
- find.ShowDeleted = true
-
- tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
- if err != nil {
- return nil, err
- }
- defer tx.Rollback()
-
- environment, err := s.getEnvironmentImplV2(ctx, tx, find)
- if err != nil {
- return nil, err
- }
- if environment == nil {
- return nil, nil
- }
-
- if err := tx.Commit(); err != nil {
- return nil, err
- }
-
- s.environmentCache.Add(environment.ResourceID, environment)
- return environment, nil
-}
-
-// ListEnvironmentV2 lists all environment.
-func (s *Store) ListEnvironmentV2(ctx context.Context, find *FindEnvironmentMessage) ([]*EnvironmentMessage, error) {
- tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
- if err != nil {
- return nil, err
- }
- defer tx.Rollback()
-
- environments, err := listEnvironmentImplV2(ctx, tx, find)
- if err != nil {
- return nil, err
- }
-
- if err := tx.Commit(); err != nil {
- return nil, err
- }
-
- for _, environment := range environments {
- s.environmentCache.Add(environment.ResourceID, environment)
- }
- return environments, nil
-}
-
-// CreateEnvironmentV2 creates an environment.
-func (s *Store) CreateEnvironmentV2(ctx context.Context, create *EnvironmentMessage) (*EnvironmentMessage, error) {
- tx, err := s.db.BeginTx(ctx, nil)
- if err != nil {
- return nil, err
- }
- defer tx.Rollback()
-
- if _, err := tx.ExecContext(ctx, `
- INSERT INTO environment (
- resource_id,
- name,
- "order"
- )
- VALUES ($1, $2, $3)
- `,
- create.ResourceID,
- create.Title,
- create.Order,
- ); err != nil {
- return nil, err
- }
-
- value := storepb.EnvironmentTierPolicy_UNPROTECTED
- if create.Protected {
- value = storepb.EnvironmentTierPolicy_PROTECTED
- }
- payload, err := protojson.Marshal(&storepb.EnvironmentTierPolicy{
- EnvironmentTier: value,
- Color: create.Color,
- })
- if err != nil {
- return nil, err
- }
- if _, err := upsertPolicyV2Impl(ctx, tx, &PolicyMessage{
- ResourceType: base.PolicyResourceTypeEnvironment,
- Resource: common.FormatEnvironment(create.ResourceID),
- Type: base.PolicyTypeEnvironmentTier,
- InheritFromParent: true,
- Payload: string(payload),
- Enforce: true,
- }); err != nil {
- return nil, err
- }
-
- if err := tx.Commit(); err != nil {
- return nil, err
- }
-
- environment := &EnvironmentMessage{
- ResourceID: create.ResourceID,
- Title: create.Title,
- Order: create.Order,
- Protected: create.Protected,
- Color: create.Color,
- Deleted: false,
- }
- s.environmentCache.Add(environment.ResourceID, environment)
- return environment, nil
-}
-
-// UpdateEnvironmentV2 updates an environment.
-func (s *Store) UpdateEnvironmentV2(ctx context.Context, patch *UpdateEnvironmentMessage) (*EnvironmentMessage, error) {
- set, args := []string{}, []any{}
- if v := patch.Name; v != nil {
- set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
- }
- if v := patch.Order; v != nil {
- set, args = append(set, fmt.Sprintf(`"order" = $%d`, len(args)+1)), append(args, *v)
- }
- if v := patch.Delete; v != nil {
- set, args = append(set, fmt.Sprintf("deleted = $%d", len(args)+1)), append(args, *v)
- }
- args = append(args, patch.ResourceID)
-
- tx, err := s.db.BeginTx(ctx, nil)
- if err != nil {
- return nil, err
- }
- defer tx.Rollback()
-
- if len(set) > 0 {
- if _, err := tx.ExecContext(ctx, fmt.Sprintf(`
- UPDATE environment
- SET `+strings.Join(set, ", ")+`
- WHERE resource_id = $%d
- `, len(args)),
- args...,
- ); err != nil {
- if err == sql.ErrNoRows {
- return nil, nil
- }
- return nil, err
- }
- }
-
- // TODO(d): consider moving tier to environment table to simplify things.
- if patch.Protected != nil || patch.Color != nil {
- resourceType := base.PolicyResourceTypeEnvironment
- resource := common.FormatEnvironment(patch.ResourceID)
- policyType := base.PolicyTypeEnvironmentTier
- policy, err := s.GetPolicyV2(ctx, &FindPolicyMessage{
- ResourceType: &resourceType,
- Type: &policyType,
- Resource: &resource,
- })
- if err != nil {
- return nil, err
- }
- environmentPolicy := &storepb.EnvironmentTierPolicy{
- EnvironmentTier: storepb.EnvironmentTierPolicy_UNPROTECTED,
- }
- if policy != nil {
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(policy.Payload), environmentPolicy); err != nil {
- return nil, errors.Wrapf(err, "failed to unmarshal environment policy payload")
- }
- }
- if patch.Protected != nil {
- value := storepb.EnvironmentTierPolicy_UNPROTECTED
- if *patch.Protected {
- value = storepb.EnvironmentTierPolicy_PROTECTED
- }
- environmentPolicy.EnvironmentTier = value
- }
- if v := patch.Color; v != nil {
- environmentPolicy.Color = *v
- }
- payload, err := protojson.Marshal(environmentPolicy)
- if err != nil {
- return nil, err
- }
- if _, err := upsertPolicyV2Impl(ctx, tx, &PolicyMessage{
- ResourceType: resourceType,
- Resource: resource,
- Type: policyType,
- InheritFromParent: true,
- Payload: string(payload),
- Enforce: true,
- }); err != nil {
- return nil, err
- }
- }
-
- if err := tx.Commit(); err != nil {
- return nil, err
- }
- // Invalid the cache and read the value again.
- s.environmentCache.Remove(patch.ResourceID)
-
- return s.GetEnvironmentV2(ctx, &FindEnvironmentMessage{
- ResourceID: &patch.ResourceID,
- })
-}
-
-func (*Store) getEnvironmentImplV2(ctx context.Context, txn *sql.Tx, find *FindEnvironmentMessage) (*EnvironmentMessage, error) {
- environments, err := listEnvironmentImplV2(ctx, txn, find)
+func (s *Store) GetEnvironmentByID(ctx context.Context, id string) (*storepb.EnvironmentSetting_Environment, error) {
+ environments, err := s.GetEnvironmentSetting(ctx)
if err != nil {
return nil, err
}
- if len(environments) == 0 {
- return nil, nil
- }
- if len(environments) > 1 {
- return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d environments with resource ID %s, expect 1", len(environments), *find.ResourceID)}
- }
- return environments[0], nil
-}
-
-func listEnvironmentImplV2(ctx context.Context, txn *sql.Tx, find *FindEnvironmentMessage) ([]*EnvironmentMessage, error) {
- where, args := []string{"TRUE"}, []any{}
- if v := find.ResourceID; v != nil {
- where, args = append(where, fmt.Sprintf("environment.resource_id = $%d", len(args)+1)), append(args, *v)
- }
- if !find.ShowDeleted {
- where, args = append(where, fmt.Sprintf("environment.deleted = $%d", len(args)+1)), append(args, false)
- }
-
- var environments []*EnvironmentMessage
- environmentResource := `format('environments/%s', environment.resource_id)`
- rows, err := txn.QueryContext(ctx, fmt.Sprintf(`
- SELECT
- environment.resource_id,
- environment.name,
- environment.order,
- environment.deleted,
- policy.payload
- FROM environment
- LEFT JOIN policy ON %s = policy.resource AND policy.resource_type = 'ENVIRONMENT' AND policy.type = 'bb.policy.environment-tier'
- WHERE %s
- ORDER BY environment.order ASC`, environmentResource, strings.Join(where, " AND ")),
- args...,
- )
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- for rows.Next() {
- var environment EnvironmentMessage
- var tierPayload sql.NullString
- if err := rows.Scan(
- &environment.ResourceID,
- &environment.Title,
- &environment.Order,
- &environment.Deleted,
- &tierPayload,
- ); err != nil {
- return nil, err
- }
- if tierPayload.Valid {
- policy := &storepb.EnvironmentTierPolicy{}
- if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(tierPayload.String), policy); err != nil {
- return nil, err
- }
- environment.Protected = policy.EnvironmentTier == storepb.EnvironmentTierPolicy_PROTECTED
- environment.Color = policy.Color
+ for _, environment := range environments.GetEnvironments() {
+ if environment.Id == id {
+ return environment, nil
}
-
- environments = append(environments, &environment)
}
- if err := rows.Err(); err != nil {
- return nil, err
- }
-
- return environments, nil
+ return nil, nil
}
diff --git a/backend/store/store.go b/backend/store/store.go
index 259b542d57..bf3296e655 100644
--- a/backend/store/store.go
+++ b/backend/store/store.go
@@ -23,7 +23,6 @@ type Store struct {
Secret string
userIDCache *lru.Cache[int, *UserMessage]
userEmailCache *lru.Cache[string, *UserMessage]
- environmentCache *lru.Cache[string, *EnvironmentMessage]
instanceCache *lru.Cache[string, *InstanceMessage]
databaseCache *lru.Cache[string, *DatabaseMessage]
projectCache *lru.Cache[string, *ProjectMessage]
@@ -54,10 +53,6 @@ func New(ctx context.Context, pgURL string, enableCache bool) (*Store, error) {
if err != nil {
return nil, err
}
- environmentCache, err := lru.New[string, *EnvironmentMessage](32)
- if err != nil {
- return nil, err
- }
instanceCache, err := lru.New[string, *InstanceMessage](32768)
if err != nil {
return nil, err
@@ -151,7 +146,6 @@ func New(ctx context.Context, pgURL string, enableCache bool) (*Store, error) {
// Cache.
userIDCache: userIDCache,
userEmailCache: userEmailCache,
- environmentCache: environmentCache,
instanceCache: instanceCache,
databaseCache: databaseCache,
projectCache: projectCache,
diff --git a/backend/tests/database.go b/backend/tests/database.go
index ccb17831a5..78d3d84dab 100644
--- a/backend/tests/database.go
+++ b/backend/tests/database.go
@@ -9,7 +9,7 @@ import (
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
-func (ctl *controller) createDatabaseV2(ctx context.Context, project *v1pb.Project, instance *v1pb.Instance, environment *v1pb.Environment, databaseName string, owner string) error {
+func (ctl *controller) createDatabaseV2(ctx context.Context, project *v1pb.Project, instance *v1pb.Instance, environment *v1pb.EnvironmentSetting_Environment, databaseName string, owner string) error {
characterSet, collation := "utf8mb4", "utf8mb4_general_ci"
if instance.Engine == v1pb.Engine_POSTGRES {
characterSet = "UTF8"
diff --git a/backend/tests/environment.go b/backend/tests/environment.go
index 66861b635a..e9eb8ac634 100644
--- a/backend/tests/environment.go
+++ b/backend/tests/environment.go
@@ -2,20 +2,65 @@ package tests
import (
"context"
- "fmt"
+
+ "github.com/pkg/errors"
+ "google.golang.org/protobuf/types/known/fieldmaskpb"
v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
)
// getEnvironment gets the environments.
-func (ctl *controller) getEnvironment(ctx context.Context, id string) (*v1pb.Environment, error) {
- environment, err := ctl.environmentServiceClient.GetEnvironment(ctx,
- &v1pb.GetEnvironmentRequest{
- Name: fmt.Sprintf("environments/%s", id),
- },
- )
+func (ctl *controller) getEnvironment(ctx context.Context, id string) (*v1pb.EnvironmentSetting_Environment, error) {
+ setting, err := ctl.settingServiceClient.GetSetting(ctx,
+ &v1pb.GetSettingRequest{
+ Name: "settings/bb.workspace.environment",
+ })
+ if err != nil {
+ return nil, err
+ }
+ for _, environment := range setting.Value.GetEnvironmentSetting().GetEnvironments() {
+ if environment.Id == id {
+ return environment, nil
+ }
+ }
+
+ return nil, errors.Errorf("environment %q not found", id)
+}
+
+// createEnvironment creates a new environment.
+// The created environment will be appended to the existing environments.
+// It returns the created environment.
+func (ctl *controller) createEnvironment(ctx context.Context, id, title string) (*v1pb.EnvironmentSetting_Environment, error) {
+ setting, err := ctl.settingServiceClient.GetSetting(ctx,
+ &v1pb.GetSettingRequest{
+ Name: "settings/bb.workspace.environment",
+ })
+ if err != nil {
+ return nil, err
+ }
+ environments := setting.Value.GetEnvironmentSetting().GetEnvironments()
+ environments = append(environments, &v1pb.EnvironmentSetting_Environment{
+ Id: id,
+ Title: title,
+ })
+ _, err = ctl.settingServiceClient.UpdateSetting(ctx,
+ &v1pb.UpdateSettingRequest{
+ Setting: &v1pb.Setting{
+ Name: "settings/bb.workspace.environment",
+ Value: &v1pb.Value{
+ Value: &v1pb.Value_EnvironmentSetting{
+ EnvironmentSetting: &v1pb.EnvironmentSetting{
+ Environments: environments,
+ },
+ },
+ },
+ },
+ UpdateMask: &fieldmaskpb.FieldMask{
+ Paths: []string{"environment_setting"},
+ },
+ })
if err != nil {
return nil, err
}
- return environment, nil
+ return ctl.getEnvironment(ctx, id)
}
diff --git a/backend/tests/schema_update_test.go b/backend/tests/schema_update_test.go
index 8f5c9c46c9..b476717976 100644
--- a/backend/tests/schema_update_test.go
+++ b/backend/tests/schema_update_test.go
@@ -254,12 +254,8 @@ CREATE TABLE "public"."book" (
defer func() {
_ = ctl.Close(ctx)
}()
- environmentName := t.Name()
- environment, err := ctl.environmentServiceClient.CreateEnvironment(ctx,
- &v1pb.CreateEnvironmentRequest{
- Environment: &v1pb.Environment{Title: environmentName},
- EnvironmentId: strings.ToLower(environmentName),
- })
+ environmentName := strings.ToLower(t.Name())
+ environment, err := ctl.createEnvironment(ctx, environmentName, environmentName)
a.NoError(err)
for _, test := range tests {
diff --git a/backend/tests/tests.go b/backend/tests/tests.go
index 2a72452eef..6c12ddcdf5 100644
--- a/backend/tests/tests.go
+++ b/backend/tests/tests.go
@@ -71,7 +71,6 @@ type controller struct {
authServiceClient v1pb.AuthServiceClient
userServiceClient v1pb.UserServiceClient
settingServiceClient v1pb.SettingServiceClient
- environmentServiceClient v1pb.EnvironmentServiceClient
instanceServiceClient v1pb.InstanceServiceClient
databaseServiceClient v1pb.DatabaseServiceClient
databaseCatalogServiceClient v1pb.DatabaseCatalogServiceClient
@@ -255,7 +254,6 @@ func (ctl *controller) start(ctx context.Context, port int) (context.Context, er
ctl.authServiceClient = v1pb.NewAuthServiceClient(ctl.grpcConn)
ctl.userServiceClient = v1pb.NewUserServiceClient(ctl.grpcConn)
ctl.settingServiceClient = v1pb.NewSettingServiceClient(ctl.grpcConn)
- ctl.environmentServiceClient = v1pb.NewEnvironmentServiceClient(ctl.grpcConn)
ctl.instanceServiceClient = v1pb.NewInstanceServiceClient(ctl.grpcConn)
ctl.databaseServiceClient = v1pb.NewDatabaseServiceClient(ctl.grpcConn)
ctl.databaseCatalogServiceClient = v1pb.NewDatabaseCatalogServiceClient(ctl.grpcConn)
diff --git a/frontend/public/help/en/help.instance.md b/frontend/public/help/en/help.instance.md
index 17765038c4..567754721e 100644
--- a/frontend/public/help/en/help.instance.md
+++ b/frontend/public/help/en/help.instance.md
@@ -8,5 +8,4 @@ title: What is 'Instance' ?
#### Learn more
-- [Add an Instance](https://www.bytebase.com/docs/get-started/step-by-step/add-an-instance)
-- [Add a MySQL Testing Instance](https://www.bytebase.com/docs/get-started/step-by-step/add-an-instance/)
\ No newline at end of file
+- [Add an Instance](https://www.bytebase.com/docs/get-started/step-by-step/add-an-instance)
\ No newline at end of file
diff --git a/frontend/public/help/ja/help.instance.md b/frontend/public/help/ja/help.instance.md
index 864be245e2..d1e4c8421e 100644
--- a/frontend/public/help/ja/help.instance.md
+++ b/frontend/public/help/ja/help.instance.md
@@ -9,4 +9,3 @@ title: 「インスタンス」とは?
#### Learn more
- [インスタンスの追加](https://www.bytebase.com/docs/get-started/step-by-step/add-an-instance)
-- [MySQL テストインスタンスを追加する](https://www.bytebase.com/docs/get-started/step-by-step/add-an-instance/)
diff --git a/frontend/public/help/zh/help.instance.md b/frontend/public/help/zh/help.instance.md
index 0cb59377c6..4479c1a97f 100644
--- a/frontend/public/help/zh/help.instance.md
+++ b/frontend/public/help/zh/help.instance.md
@@ -10,4 +10,3 @@ RDS 实例,也可能是您私有化部署的 MySQL 实例。
#### 了解更多
- [添加实例](https://www.bytebase.com/docs/get-started/step-by-step/add-an-instance)
-- [添加一个 MySQL 测试实例](https://www.bytebase.com/docs/get-started/step-by-step/add-an-instance/)
\ No newline at end of file
diff --git a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
index 091fc3da99..c6cb5e454e 100644
--- a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
+++ b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts
@@ -8,6 +8,7 @@ import {
} from "@/components/v2";
import { t } from "@/plugins/i18n";
import {
+ environmentNamePrefix,
useEnvironmentV1List,
useEnvironmentV1Store,
useInstanceV1Store,
@@ -139,8 +140,8 @@ export const useCommonSearchScopeOptions = (
description: t("issue.advanced-search.scope.environment.description"),
options: environmentList.value.map((env) => {
return {
- value: extractEnvironmentResourceName(env.name),
- keywords: [env.name, env.title],
+ value: env.id,
+ keywords: [`${environmentNamePrefix}${env.id}`, env.title],
render: () =>
h(EnvironmentV1Name, {
environment: env,
diff --git a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts
index 2da65e475b..22bafa03ed 100644
--- a/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/RiskCenter/RiskDialog/template.ts
@@ -6,7 +6,6 @@ import { t, te } from "@/plugins/i18n";
import { useEnvironmentV1List } from "@/store";
import { PresetRiskLevel } from "@/types";
import { Risk_Source } from "@/types/proto/v1/risk_service";
-import { extractEnvironmentResourceName } from "@/utils";
/*
@@ -48,10 +47,7 @@ export const useRuleTemplates = () => {
expr: wrapAsGroup({
type: ExprType.Condition,
operator: "_==_",
- args: [
- "environment_id",
- extractEnvironmentResourceName(prod.value.name),
- ],
+ args: ["environment_id", prod.value.id],
}),
level: PresetRiskLevel.HIGH,
source: Risk_Source.SOURCE_UNSPECIFIED,
@@ -64,10 +60,7 @@ export const useRuleTemplates = () => {
expr: wrapAsGroup({
type: ExprType.Condition,
operator: "_==_",
- args: [
- "environment_id",
- extractEnvironmentResourceName(dev.value.name),
- ],
+ args: ["environment_id", dev.value.id],
}),
level: PresetRiskLevel.LOW,
source: Risk_Source.SOURCE_UNSPECIFIED,
@@ -85,10 +78,7 @@ export const useRuleTemplates = () => {
{
type: ExprType.Condition,
operator: "_==_",
- args: [
- "environment_id",
- extractEnvironmentResourceName(prod.value.name),
- ],
+ args: ["environment_id", prod.value.id],
},
{
type: ExprType.Condition,
@@ -115,10 +105,7 @@ export const useRuleTemplates = () => {
expr: wrapAsGroup({
type: ExprType.Condition,
operator: "_==_",
- args: [
- "environment_id",
- extractEnvironmentResourceName(prod.value.name),
- ],
+ args: ["environment_id", prod.value.id],
}),
level: PresetRiskLevel.MODERATE,
source: Risk_Source.CREATE_DATABASE,
diff --git a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
index ccf09308e3..878d78412f 100644
--- a/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
+++ b/frontend/src/components/CustomApproval/Settings/components/common/utils.ts
@@ -5,7 +5,11 @@ import { h, type VNode } from "vue";
import { type OptionConfig } from "@/components/ExprEditor/context";
import { type Factor, SQLTypeList } from "@/plugins/cel";
import { t } from "@/plugins/i18n";
-import { useEnvironmentV1Store, useProjectV1Store } from "@/store";
+import {
+ environmentNamePrefix,
+ useEnvironmentV1Store,
+ useProjectV1Store,
+} from "@/store";
import {
PresetRiskLevelList,
DEFAULT_PROJECT_NAME,
@@ -16,7 +20,6 @@ import type { Risk } from "@/types/proto/v1/risk_service";
import { Risk_Source, risk_SourceToJSON } from "@/types/proto/v1/risk_service";
import {
engineNameV1,
- extractEnvironmentResourceName,
extractProjectResourceName,
supportedEngineV1List,
getDefaultPagination,
@@ -196,11 +199,14 @@ export const getRenderOptionFunc = (resource: {
export const getEnvironmentIdOptions = () => {
const environmentList = useEnvironmentV1Store().getEnvironmentList();
return environmentList.map<SelectOption>((env) => {
- const environmentId = extractEnvironmentResourceName(env.name);
+ const environmentId = env.id;
return {
label: `${env.title} (${environmentId})`,
value: environmentId,
- render: getRenderOptionFunc(env),
+ render: getRenderOptionFunc({
+ name: `${environmentNamePrefix}${env.id}`,
+ title: env.title,
+ }),
};
});
};
diff --git a/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue b/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue
index 3446cecd44..6e70a0c208 100644
--- a/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue
+++ b/frontend/src/components/DatabaseDetail/Settings/DatabaseSettingsPanel.vue
@@ -7,7 +7,7 @@
</p>
<EnvironmentSelect
class="mt-1 max-w-md"
- :environment-name="environment?.name"
+ :environment-name="`${environmentNamePrefix}${environment.id}`"
:disabled="!allowUpdateDatabase"
:render-suffix="
(env: string) =>
@@ -47,6 +47,7 @@ import {
useEnvironmentV1Store,
pushNotification,
useAppFeature,
+ environmentNamePrefix,
} from "@/store";
import { type ComposedDatabase } from "@/types";
import { DatabaseChangeMode } from "@/types/proto/v1/setting_service";
diff --git a/frontend/src/components/DatabaseGroup/utils.ts b/frontend/src/components/DatabaseGroup/utils.ts
index 12a06d8691..8279dd25b8 100644
--- a/frontend/src/components/DatabaseGroup/utils.ts
+++ b/frontend/src/components/DatabaseGroup/utils.ts
@@ -3,8 +3,12 @@ import { getRenderOptionFunc } from "@/components/CustomApproval/Settings/compon
import { type OptionConfig } from "@/components/ExprEditor/context";
import { getInstanceIdOptions } from "@/components/SensitiveData/components/utils";
import type { Factor } from "@/plugins/cel";
-import { useEnvironmentV1Store, useInstanceV1Store } from "@/store";
-import { extractEnvironmentResourceName, getDefaultPagination } from "@/utils";
+import {
+ environmentNamePrefix,
+ useEnvironmentV1Store,
+ useInstanceV1Store,
+} from "@/store";
+import { getDefaultPagination } from "@/utils";
export const FactorList: Factor[] = [
"resource.environment_name",
@@ -53,11 +57,15 @@ export const getDatabaseGroupOptionConfigMap = () => {
const getEnvironmentOptions = () => {
const environmentList = useEnvironmentV1Store().getEnvironmentList();
return environmentList.map<SelectOption>((env) => {
- const environmentName = extractEnvironmentResourceName(env.name);
+ const id = env.id;
+ const name = `${environmentNamePrefix}${id}`;
return {
- label: environmentName,
- value: env.name,
- render: getRenderOptionFunc(env),
+ label: id,
+ value: name,
+ render: getRenderOptionFunc({
+ name: name,
+ title: env.title,
+ }),
};
});
};
diff --git a/frontend/src/components/DatabaseInfo.vue b/frontend/src/components/DatabaseInfo.vue
index 4805e27bce..cf17b83315 100644
--- a/frontend/src/components/DatabaseInfo.vue
+++ b/frontend/src/components/DatabaseInfo.vue
@@ -7,7 +7,7 @@
:text-class="link ? 'hover:underline' : ''"
>
<template
- v-if="instanceEnvironment.name !== database.effectiveEnvironment"
+ v-if="formatEnvironmentName(instanceEnvironment.id) !== database.effectiveEnvironment"
#prefix
>
<EnvironmentV1Name
@@ -53,7 +53,7 @@ import {
InstanceV1Name,
} from "@/components/v2";
import { useEnvironmentV1Store } from "@/store";
-import { unknownEnvironment, type ComposedDatabase } from "@/types";
+import { formatEnvironmentName, unknownEnvironment, type ComposedDatabase } from "@/types";
const props = withDefaults(
defineProps<{
diff --git a/frontend/src/components/EnvironmentForm/Buttons.vue b/frontend/src/components/EnvironmentForm/Buttons.vue
index faf43e5f34..91ac245d4d 100644
--- a/frontend/src/components/EnvironmentForm/Buttons.vue
+++ b/frontend/src/components/EnvironmentForm/Buttons.vue
@@ -43,7 +43,6 @@ const {
state,
environment,
rolloutPolicy,
- environmentTier,
create,
resourceIdField,
allowEdit,
@@ -55,7 +54,6 @@ const {
const revertEnvironment = () => {
state.value.environment = cloneDeep(environment.value);
state.value.rolloutPolicy = cloneDeep(rolloutPolicy.value);
- state.value.environmentTier = cloneDeep(environmentTier.value);
events.emit("revert-access-control");
events.emit("revert-sql-review");
};
@@ -63,12 +61,13 @@ const revertEnvironment = () => {
const createEnvironment = () => {
events.emit("create", {
environment: {
- name: resourceIdField.value?.resourceId,
+ id: resourceIdField.value?.resourceId,
title: state.value.environment.title,
color: state.value.environment.color,
+ tags: state.value.environment.tags,
+ order: state.value.environment.order,
},
rolloutPolicy: state.value.rolloutPolicy,
- environmentTier: state.value.environmentTier,
});
};
@@ -87,13 +86,13 @@ const updateEnvironment = () => {
const env = cloneDeep(environment.value);
if (
state.value.environment.title !== env.title ||
- state.value.environmentTier !== env.tier ||
+ !isEqual(state.value.environment.tags, env.tags) ||
state.value.environment.color !== env.color
) {
const environmentPatch = {
...env,
title: state.value.environment.title,
- tier: state.value.environmentTier,
+ tags: state.value.environment.tags,
color: state.value.environment.color,
};
events.emit("update", environmentPatch);
diff --git a/frontend/src/components/EnvironmentForm/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm/EnvironmentForm.vue
index a45ee4d113..9f26342626 100644
--- a/frontend/src/components/EnvironmentForm/EnvironmentForm.vue
+++ b/frontend/src/components/EnvironmentForm/EnvironmentForm.vue
@@ -15,10 +15,8 @@ import { useI18n } from "vue-i18n";
import { onBeforeRouteLeave } from "vue-router";
import { useEmitteryEventListener } from "@/composables/useEmitteryEventListener";
import { hasFeature } from "@/store";
-import { defaultEnvironmentTier } from "@/store/modules/v1/environment";
import { VirtualRoleType } from "@/types";
-import type { Environment } from "@/types/proto/v1/environment_service";
-import { EnvironmentTier } from "@/types/proto/v1/environment_service";
+import type { Environment } from "@/types/v1/environment";
import type { Policy } from "@/types/proto/v1/org_policy_service";
import { PolicyType } from "@/types/proto/v1/org_policy_service";
import { FeatureModal } from "../FeatureGuard";
@@ -29,7 +27,6 @@ const props = withDefaults(
create?: boolean;
environment: Environment;
rolloutPolicy: Policy;
- environmentTier: EnvironmentTier;
}>(),
{
create: false,
@@ -42,7 +39,6 @@ const emit = defineEmits<{
params: {
environment: Partial<Environment>;
rolloutPolicy: Policy;
- environmentTier: EnvironmentTier;
}
): void;
(event: "update", environment: Environment): void;
@@ -64,7 +60,6 @@ const context = provideEnvironmentFormContext({
create: toRef(props, "create"),
environment: toRef(props, "environment"),
rolloutPolicy: toRef(props, "rolloutPolicy"),
- environmentTier: toRef(props, "environmentTier"),
});
const { valueChanged, events, missingFeature } = context;
@@ -86,8 +81,10 @@ onBeforeRouteLeave((to, from, next) => {
});
useEmitteryEventListener(events, "create", (params) => {
- const { rolloutPolicy, environmentTier } = params;
- if (environmentTier === EnvironmentTier.PROTECTED) {
+ console.log(params)
+ debugger;
+ const { rolloutPolicy, environment } = params;
+ if (environment.tags?.protected === "protected") {
if (!hasFeature("bb.feature.custom-approval")) {
missingFeature.value = "bb.feature.environment-tier-policy";
return;
@@ -111,8 +108,7 @@ useEmitteryEventListener(events, "create", (params) => {
});
useEmitteryEventListener(events, "update", (environment) => {
if (
- environment.tier != props.environment.tier &&
- environment.tier !== defaultEnvironmentTier &&
+ environment.tags.protected === "protected" &&
!hasFeature("bb.feature.environment-tier-policy")
) {
missingFeature.value = "bb.feature.environment-tier-policy";
diff --git a/frontend/src/components/EnvironmentForm/Form.vue b/frontend/src/components/EnvironmentForm/Form.vue
index 3a73ddff57..628769c62c 100644
--- a/frontend/src/components/EnvironmentForm/Form.vue
+++ b/frontend/src/components/EnvironmentForm/Form.vue
@@ -21,7 +21,7 @@
ref="resourceIdField"
resource-type="environment"
:readonly="!create"
- :value="extractEnvironmentResourceName(state.environment.name)"
+ :value="state.environment.id"
:resource-title="state.environment.title"
:validate="validateResourceId"
/>
@@ -45,13 +45,13 @@
/></a>
</p>
<NCheckbox
- :checked="state.environmentTier === EnvironmentTier.PROTECTED"
+ :checked="state.environment.tags.protected === 'protected'"
:disabled="!allowEdit"
@update:checked="
(on: boolean) => {
- state.environmentTier = on
- ? EnvironmentTier.PROTECTED
- : EnvironmentTier.UNPROTECTED;
+ state.environment.tags.protected = on
+ ? 'protected'
+ : 'unprotected';
}
"
>
@@ -94,14 +94,14 @@
<SQLReviewForResource
v-if="features.includes('SQL_REVIEW') && !create"
ref="sqlReviewForResourceRef"
- :resource="environment.name"
+ :resource="`${environmentNamePrefix}${environment.id}`"
:allow-edit="allowEdit"
/>
<AccessControlConfigure
v-if="features.includes('ACCESS_CONTROL') && !create"
ref="accessControlConfigureRef"
- :resource="environment.name"
+ :resource="`${environmentNamePrefix}${environment.id}`"
:allow-edit="allowEdit"
/>
</div>
@@ -110,34 +110,18 @@
v-if="!create && !hideArchiveRestore"
class="mt-6 border-t border-block-border flex justify-between items-center pt-4 pb-2"
>
- <template v-if="state.environment.state === State.ACTIVE">
- <BBButtonConfirm
- v-if="allowArchive"
- :type="'ARCHIVE'"
- :button-text="$t('environment.delete')"
- :ok-text="$t('common.delete')"
- :confirm-title="
- $t('environment.delete') + ` '${state.environment.title}'?`
- "
- :confirm-description="$t('common.cannot-undo-this-action')"
- :require-confirm="true"
- @confirm="archiveEnvironment"
- />
- </template>
- <template v-else-if="state.environment.state === State.DELETED">
- <BBButtonConfirm
- v-if="allowRestore"
- :type="'RESTORE'"
- :button-text="$t('environment.restore')"
- :ok-text="$t('common.restore')"
- :confirm-title="
- $t('environment.restore') + ` '${state.environment.title}'?`
- "
- :confirm-description="''"
- :require-confirm="true"
- @confirm="restoreEnvironment"
- />
- </template>
+ <BBButtonConfirm
+ v-if="allowArchive"
+ :type="'ARCHIVE'"
+ :button-text="$t('environment.delete')"
+ :ok-text="$t('common.delete')"
+ :confirm-title="
+ $t('environment.delete') + ` '${state.environment.title}'?`
+ "
+ :confirm-description="$t('common.cannot-undo-this-action')"
+ :require-confirm="true"
+ @confirm="archiveEnvironment"
+ />
<div v-else></div>
</div>
</div>
@@ -158,9 +142,6 @@ import {
} from "@/store";
import { environmentNamePrefix } from "@/store/modules/v1/common";
import type { ResourceId, ValidatedMessage } from "@/types";
-import { State } from "@/types/proto/v1/common";
-import { EnvironmentTier } from "@/types/proto/v1/environment_service";
-import { extractEnvironmentResourceName } from "@/utils";
import { getErrorCode } from "@/utils/grpcweb";
import { FeatureBadge } from "../FeatureGuard";
import SQLReviewForResource from "../SQLReview/components/SQLReviewForResource.vue";
@@ -231,10 +212,6 @@ const allowArchive = computed(() => {
);
});
-// TODO(p0ny): hard-delete environment.
-const allowRestore = computed(() => {
- return false;
-});
const renderColorPicker = () => {
return (
@@ -308,10 +285,6 @@ const archiveEnvironment = () => {
events.emit("archive", state.value.environment);
};
-const restoreEnvironment = () => {
- events.emit("restore", state.value.environment);
-};
-
useEmitteryEventListener(events, "update-access-control", async () => {
if (accessControlConfigureRef.value?.isDirty) {
await accessControlConfigureRef.value.update();
diff --git a/frontend/src/components/EnvironmentForm/context.ts b/frontend/src/components/EnvironmentForm/context.ts
index 803cb94123..779f509720 100644
--- a/frontend/src/components/EnvironmentForm/context.ts
+++ b/frontend/src/components/EnvironmentForm/context.ts
@@ -5,18 +5,13 @@ import type { InjectionKey, Ref } from "vue";
import { provide, inject, computed, ref, watch } from "vue";
import type { ResourceIdField } from "@/components/v2";
import type { FeatureType } from "@/types";
-import { State } from "@/types/proto/v1/common";
-import type {
- Environment,
- EnvironmentTier,
-} from "@/types/proto/v1/environment_service";
import { PolicyType, type Policy } from "@/types/proto/v1/org_policy_service";
+import type { Environment } from "@/types/v1/environment";
import { hasWorkspacePermissionV2 } from "@/utils";
export type LocalState = {
environment: Environment;
rolloutPolicy: Policy;
- environmentTier: EnvironmentTier;
policyChanged: boolean;
};
@@ -28,14 +23,12 @@ export const provideEnvironmentFormContext = (baseContext: {
create: Ref<boolean>;
environment: Ref<Environment>;
rolloutPolicy: Ref<Policy>;
- environmentTier: Ref<EnvironmentTier>;
}) => {
const $d = useDialog();
const events = new Emittery<{
create: {
environment: Partial<Environment>;
rolloutPolicy: Policy;
- environmentTier: EnvironmentTier;
};
update: Environment;
"update-policy": {
@@ -51,36 +44,28 @@ export const provideEnvironmentFormContext = (baseContext: {
restore: Environment;
cancel: undefined;
}>();
- const { create, environment, rolloutPolicy, environmentTier } = baseContext;
+ const { create, environment, rolloutPolicy } = baseContext;
const state = ref<LocalState>({
environment: cloneDeep(environment.value),
rolloutPolicy: cloneDeep(rolloutPolicy.value),
- environmentTier: environmentTier.value,
policyChanged: false,
});
const missingFeature = ref<FeatureType | undefined>(undefined);
const resourceIdField = ref<InstanceType<typeof ResourceIdField>>();
const valueChanged = (
- field?:
- | "environment"
- | "approvalPolicy"
- | "rolloutPolicy"
- | "environmentTier"
+ field?: "environment" | "approvalPolicy" | "rolloutPolicy"
): boolean => {
switch (field) {
case "environment":
return !isEqual(environment.value, state.value.environment);
case "rolloutPolicy":
return !isEqual(rolloutPolicy.value, state.value.rolloutPolicy);
- case "environmentTier":
- return !isEqual(environmentTier.value, state.value.environmentTier);
default:
return (
!isEqual(environment.value, state.value.environment) ||
!isEqual(rolloutPolicy.value, state.value.rolloutPolicy) ||
- !isEqual(environmentTier.value, state.value.environmentTier) ||
state.value.policyChanged
);
}
@@ -95,11 +80,7 @@ export const provideEnvironmentFormContext = (baseContext: {
});
const allowEdit = computed(() => {
- return (
- create.value ||
- (state.value.environment.state === State.ACTIVE &&
- hasWorkspacePermissionV2("bb.environments.update"))
- );
+ return create.value || hasWorkspacePermissionV2("bb.environments.update");
});
watch(environment, (cur) => {
@@ -108,9 +89,6 @@ export const provideEnvironmentFormContext = (baseContext: {
watch(rolloutPolicy, (cur) => {
state.value.rolloutPolicy = cloneDeep(cur);
});
- watch(environmentTier, (cur) => {
- state.value.environmentTier = cur;
- });
const context = {
...baseContext,
diff --git a/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vue b/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vue
index 824470ed3f..7ab8a01c14 100644
--- a/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vue
+++ b/frontend/src/components/InstanceForm/DataSourceSection/CreateDataSourceExample.vue
@@ -81,10 +81,6 @@
<span class="text-red-600"> YOUR_DB_PWD </span>
</template>
</i18n-t>
- <LearnMoreLink
- url="https://www.bytebase.com/docs/get-started/step-by-step/add-an-instance/?source=console"
- class="ml-1 text-sm"
- />
</template>
<template v-else-if="props.engine === Engine.CLICKHOUSE">
<i18n-t
@@ -215,7 +211,6 @@ import { NCode, NConfigProvider } from "naive-ui";
import { reactive, computed } from "vue";
import { useI18n } from "vue-i18n";
import { BBAttention } from "@/bbkit";
-import LearnMoreLink from "@/components/LearnMoreLink.vue";
import { pushNotification } from "@/store";
import {
languageOfEngineV1,
diff --git a/frontend/src/components/InstanceForm/Form.vue b/frontend/src/components/InstanceForm/Form.vue
index cb41767b5e..f62d699e1a 100644
--- a/frontend/src/components/InstanceForm/Form.vue
+++ b/frontend/src/components/InstanceForm/Form.vue
@@ -86,8 +86,8 @@
class="mt-1 w-full"
required="true"
:environment-name="
- isValidEnvironmentName(environment.name)
- ? environment.name
+ isValidEnvironmentName(`${environmentNamePrefix}${environment.id}`)
+ ? `${environmentNamePrefix}${environment.id}`
: undefined
"
:disabled="!allowEdit"
@@ -497,7 +497,7 @@ import {
useSubscriptionV1Store,
pushNotification,
} from "@/store";
-import { instanceNamePrefix } from "@/store/modules/v1/common";
+import { environmentNamePrefix, instanceNamePrefix } from "@/store/modules/v1/common";
import type { ResourceId, ValidatedMessage, ComposedInstance } from "@/types";
import { UNKNOWN_ID, isValidEnvironmentName } from "@/types";
import type { Duration } from "@/types/proto/google/protobuf/duration";
diff --git a/frontend/src/components/InstanceForm/context.ts b/frontend/src/components/InstanceForm/context.ts
index d5191842ec..fd6e039b2b 100644
--- a/frontend/src/components/InstanceForm/context.ts
+++ b/frontend/src/components/InstanceForm/context.ts
@@ -1,5 +1,6 @@
import { instanceServiceClient } from "@/grpcweb";
import {
+ environmentNamePrefix,
pushNotification,
useEnvironmentV1Store,
useSubscriptionV1Store,
@@ -203,7 +204,7 @@ export const provideInstanceFormContext = (baseContext: {
if (!hasWorkspacePermissionV2("bb.instances.create")) {
return false;
}
- if (!isValidEnvironmentName(environment.value.name)) {
+ if (!isValidEnvironmentName(`${environmentNamePrefix}${environment.value.id}`)) {
return false;
}
if (basicInfo.value.engine === Engine.SPANNER) {
diff --git a/frontend/src/components/IssueV1/components/TaskListSection/CurrentTaskSection.vue b/frontend/src/components/IssueV1/components/TaskListSection/CurrentTaskSection.vue
index c39c814713..c54528264e 100644
--- a/frontend/src/components/IssueV1/components/TaskListSection/CurrentTaskSection.vue
+++ b/frontend/src/components/IssueV1/components/TaskListSection/CurrentTaskSection.vue
@@ -11,7 +11,7 @@
<template
v-if="
database &&
- instanceEnvironment.name !== database.effectiveEnvironment
+ formatEnvironmentName(instanceEnvironment.id) !== database.effectiveEnvironment
"
#prefix
>
@@ -85,7 +85,7 @@ import {
InstanceV1Name,
} from "@/components/v2";
import { useDatabaseV1Store, useEnvironmentV1Store } from "@/store";
-import { isValidDatabaseName, unknownEnvironment } from "@/types";
+import { formatEnvironmentName, isValidDatabaseName, unknownEnvironment } from "@/types";
import { Task_Status, Task_Type } from "@/types/proto/v1/rollout_service";
import { extractInstanceResourceName } from "@/utils";
diff --git a/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue b/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue
index 877ba7c4d8..011896040e 100644
--- a/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue
+++ b/frontend/src/components/Rollout/RolloutDetail/Panels/TaskAdvancedSearch/TaskAdvancedSearch.vue
@@ -17,6 +17,7 @@ import { Task_Status } from "@/types/proto/v1/rollout_service";
import { type SearchParams } from "@/utils";
import { useRolloutDetailContext } from "../../context";
import { databaseForTask } from "../../utils";
+import { formatEnvironmentName } from "@/types";
defineProps<{
params: SearchParams;
@@ -59,11 +60,11 @@ const scopeOptions = computed((): ScopeOption[] => {
databasesFromTasks.value.map(
(database) => database.effectiveEnvironmentEntity
),
- (env) => env.name
+ (env) => formatEnvironmentName(env.id)
).map((environment) => {
return {
- value: environment.name,
- keywords: [environment.name, environment.title],
+ value: formatEnvironmentName(environment.id),
+ keywords: [formatEnvironmentName(environment.id), environment.title],
render: () => environment.title,
};
}),
diff --git a/frontend/src/components/SQLReview/SQLReviewInfo.vue b/frontend/src/components/SQLReview/SQLReviewInfo.vue
index 74fe663125..ec557b0661 100644
--- a/frontend/src/components/SQLReview/SQLReviewInfo.vue
+++ b/frontend/src/components/SQLReview/SQLReviewInfo.vue
@@ -26,7 +26,7 @@
name="environment"
:environment-name="attachedResources[0]"
:disabled="!allowChangeAttachedResource"
- :filter="(env: Environment, _: number) => filterResource(env.name)"
+ :filter="(env: Environment, _: number) => filterResource(formatEnvironmentName(env.id))"
@update:environment-name="
(val: string | undefined) => {
if (!val) {
@@ -121,7 +121,7 @@ import type {
ValidatedMessage,
} from "@/types";
import type { Database } from "@/types/proto/v1/database_service";
-import type { Environment } from "@/types/proto/v1/environment_service";
+import { formatEnvironmentName, type Environment } from "@/types/v1/environment";
import { getErrorCode } from "@/utils/grpcweb";
import { DatabaseSelect, EnvironmentSelect, ProjectSelect } from "../v2";
import { SQLReviewTemplateSelector } from "./components";
diff --git a/frontend/src/components/TransferDatabaseForm/TransferDatabaseForm.vue b/frontend/src/components/TransferDatabaseForm/TransferDatabaseForm.vue
index 07b3113545..2e79731fc0 100644
--- a/frontend/src/components/TransferDatabaseForm/TransferDatabaseForm.vue
+++ b/frontend/src/components/TransferDatabaseForm/TransferDatabaseForm.vue
@@ -91,10 +91,11 @@ import type { ComposedDatabase, ComposedProject } from "@/types";
import {
DEFAULT_PROJECT_NAME,
defaultProject,
+ formatEnvironmentName,
isValidProjectName,
} from "@/types";
import { UpdateDatabaseRequest } from "@/types/proto/v1/database_service";
-import type { Environment } from "@/types/proto/v1/environment_service";
+import type { Environment } from "@/types/v1/environment";
import type { InstanceResource } from "@/types/proto/v1/instance_service";
import { hasProjectPermissionV2 } from "@/utils";
import { DrawerContent, ProjectSelect } from "../v2";
@@ -153,7 +154,7 @@ const { project: sourceProject } = useProjectByName(sourceProjectName);
const filter = computed(() => ({
instance: state.instanceFilter?.name,
- environment: state.environmentFilter?.name,
+ environment: formatEnvironmentName(state.environmentFilter?.id),
query: state.searchText,
}));
diff --git a/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vue b/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vue
index 110a531693..a0cba9ab2d 100644
--- a/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vue
+++ b/frontend/src/components/TransferDatabaseForm/TransferSourceSelector.vue
@@ -21,7 +21,7 @@
<NInputGroup style="width: auto">
<EnvironmentSelect
class="!w-40"
- :environment-name="environment?.name"
+ :environment-name="formatEnvironmentName(environment?.id)"
@update:environment-name="changeEnvironmentFilter"
/>
<InstanceSelect
@@ -48,8 +48,8 @@
import { NInputGroup, NRadio, NRadioGroup } from "naive-ui";
import { InstanceSelect, SearchBox } from "@/components/v2";
import { useEnvironmentV1Store, useInstanceResourceByName } from "@/store";
-import { isValidEnvironmentName, isValidInstanceName } from "@/types";
-import type { Environment } from "@/types/proto/v1/environment_service";
+import { formatEnvironmentName, isValidEnvironmentName, isValidInstanceName } from "@/types";
+import type { Environment } from "@/types/v1/environment";
import type { InstanceResource } from "@/types/proto/v1/instance_service";
import EnvironmentSelect from "../v2/Select/EnvironmentSelect.vue";
import type { TransferSource } from "./utils";
diff --git a/frontend/src/components/v2/Model/EnvironmentV1Name.vue b/frontend/src/components/v2/Model/EnvironmentV1Name.vue
index e1aa1d7127..fe3013d517 100644
--- a/frontend/src/components/v2/Model/EnvironmentV1Name.vue
+++ b/frontend/src/components/v2/Model/EnvironmentV1Name.vue
@@ -25,7 +25,7 @@
<script lang="ts" setup>
import { computed } from "vue";
import { useRouter } from "vue-router";
-import type { Environment } from "@/types/proto/v1/environment_service";
+import type { Environment } from "@/types/v1/environment";
import type { VueClass } from "@/utils";
import {
autoEnvironmentRoute,
diff --git a/frontend/src/components/v2/Model/EnvironmentV1Table.vue b/frontend/src/components/v2/Model/EnvironmentV1Table.vue
index 615bfdd92d..e40e1bcc69 100644
--- a/frontend/src/components/v2/Model/EnvironmentV1Table.vue
+++ b/frontend/src/components/v2/Model/EnvironmentV1Table.vue
@@ -7,7 +7,7 @@
:data="environmentList"
:striped="true"
:bordered="bordered"
- :row-key="(data: Environment) => data.name"
+ :row-key="(data: Environment) => data.id"
:row-props="rowProps"
:paginate-single-page="false"
/>
@@ -18,7 +18,7 @@ import { NDataTable, type DataTableColumn } from "naive-ui";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
-import type { Environment } from "@/types/proto/v1/environment_service";
+import { formatEnvironmentName, type Environment } from "@/types/v1/environment";
import { EnvironmentV1Name } from ".";
withDefaults(
@@ -39,7 +39,7 @@ const rowProps = (environment: Environment) => {
return {
style: "cursor: pointer;",
onClick: (e: MouseEvent) => {
- const url = `/${environment.name}`;
+ const url = `/${formatEnvironmentName(environment.id)}`;
if (e.ctrlKey || e.metaKey) {
window.open(url, "_blank");
} else {
@@ -57,7 +57,7 @@ const columnList = computed((): DataTableColumn<Environment>[] => {
resizable: true,
ellipsis: true,
render: (env) => {
- return env.name;
+ return formatEnvironmentName(env.id);
},
},
{
diff --git a/frontend/src/components/v2/Model/ProductionEnvironmentV1Icon.vue b/frontend/src/components/v2/Model/ProductionEnvironmentV1Icon.vue
index 1deec73cae..7bf1ec10e2 100644
--- a/frontend/src/components/v2/Model/ProductionEnvironmentV1Icon.vue
+++ b/frontend/src/components/v2/Model/ProductionEnvironmentV1Icon.vue
@@ -16,17 +16,14 @@
import { NTooltip } from "naive-ui";
import { computed } from "vue";
import { featureToRef } from "@/store";
-import type { Environment } from "@/types/proto/v1/environment_service";
-import { EnvironmentTier } from "@/types/proto/v1/environment_service";
+import type { Environment } from "@/types/v1/environment";
const props = withDefaults(
defineProps<{
environment: Environment;
- tier?: EnvironmentTier;
tooltip?: boolean;
}>(),
{
- tier: EnvironmentTier.UNPROTECTED,
tooltip: false,
}
);
@@ -39,6 +36,6 @@ const enabled = computed((): boolean => {
if (!hasEnvironmentTierPolicyFeature.value) {
return false;
}
- return (props.environment?.tier ?? props.tier) === EnvironmentTier.PROTECTED;
+ return props.environment?.tags?.protected === "protected"
});
</script>
diff --git a/frontend/src/components/v2/ResourceOccupiedModal/useResourceByName.ts b/frontend/src/components/v2/ResourceOccupiedModal/useResourceByName.ts
index 26ada92380..a7469d1a66 100644
--- a/frontend/src/components/v2/ResourceOccupiedModal/useResourceByName.ts
+++ b/frontend/src/components/v2/ResourceOccupiedModal/useResourceByName.ts
@@ -18,6 +18,7 @@ import {
isValidEnvironmentName,
isValidDatabaseName,
isValidProjectName,
+ formatEnvironmentName,
} from "@/types";
import { hasWorkspacePermissionV2 } from "@/utils";
@@ -103,7 +104,7 @@ export const useResourceByName = ({
const environment = environmentV1Store.getEnvironmentByName(
resource.value
);
- if (!isValidEnvironmentName(environment.name)) {
+ if (!isValidEnvironmentName(formatEnvironmentName(environment.id))) {
return h("div", resource.value);
}
return h(EnvironmentV1Name, { environment, link });
diff --git a/frontend/src/components/v2/Select/EnvironmentSelect.vue b/frontend/src/components/v2/Select/EnvironmentSelect.vue
index 7a01a9882b..cf64f47251 100644
--- a/frontend/src/components/v2/Select/EnvironmentSelect.vue
+++ b/frontend/src/components/v2/Select/EnvironmentSelect.vue
@@ -16,8 +16,8 @@
<script lang="tsx" setup>
import { computed } from "vue";
import { useEnvironmentV1Store } from "@/store";
-import { State } from "@/types/proto/v1/common";
-import type { Environment } from "@/types/proto/v1/environment_service";
+import { formatEnvironmentName } from "@/types";
+import type { Environment } from "@/types/v1/environment";
import { EnvironmentV1Name } from "../Model";
import ResourceSelect from "./ResourceSelect.vue";
@@ -49,19 +49,12 @@ defineEmits<{
const environmentV1Store = useEnvironmentV1Store();
const rawEnvironmentList = computed(() => {
- const list = environmentV1Store.getEnvironmentList(true /* showDeleted */);
+ const list = environmentV1Store.getEnvironmentList();
return list;
});
const combinedEnvironmentList = computed(() => {
- let list = rawEnvironmentList.value.filter((environment) => {
- if (props.includeArchived) return true;
- if (environment.state === State.ACTIVE) return true;
- // ARCHIVED
- if (environment.name === props.environmentName) return true;
- return false;
- });
-
+ let list = rawEnvironmentList.value;
if (props.filter) {
list = list.filter(props.filter);
}
@@ -72,8 +65,11 @@ const combinedEnvironmentList = computed(() => {
const options = computed(() => {
return combinedEnvironmentList.value.map((environment) => {
return {
- resource: environment,
- value: environment.name,
+ resource: {
+ ...environment,
+ name: formatEnvironmentName(environment.id),
+ },
+ value: formatEnvironmentName(environment.id),
label: environment.title,
};
});
diff --git a/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vue b/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vue
index 0b2f616d4b..86844ffd19 100644
--- a/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vue
+++ b/frontend/src/components/v2/TabFilter/EnvironmentTabFilter.vue
@@ -21,8 +21,8 @@
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useEnvironmentV1List } from "@/store";
-import { UNKNOWN_ENVIRONMENT_NAME, unknownEnvironment } from "@/types";
-import type { Environment } from "@/types/proto/v1/environment_service";
+import { formatEnvironmentName, UNKNOWN_ENVIRONMENT_NAME, unknownEnvironment } from "@/types";
+import type { Environment } from "@/types/v1/environment";
import { EnvironmentV1Name } from "../Model";
import TabFilter from "./TabFilter.vue";
import type { TabFilterItem } from "./types";
@@ -47,13 +47,13 @@ defineEmits<{
}>();
const { t } = useI18n();
-const environmentList = useEnvironmentV1List(false /* !showDeleted */);
+const environmentList = useEnvironmentV1List();
const items = computed(() => {
const reversedEnvironmentList = [...environmentList.value].reverse();
const environmentItems =
reversedEnvironmentList.map<EnvironmentTabFilterItem>((env) => ({
- value: env.name,
+ value: formatEnvironmentName(env.id),
label: env.title,
environment: env,
}));
@@ -63,7 +63,7 @@ const items = computed(() => {
title: t("common.all"),
};
environmentItems.unshift({
- value: dummyAll.name,
+ value: formatEnvironmentName(dummyAll.id),
label: dummyAll.title,
environment: dummyAll,
});
diff --git a/frontend/src/grpcweb/index.ts b/frontend/src/grpcweb/index.ts
index 75808bb03b..faad4ec38d 100644
--- a/frontend/src/grpcweb/index.ts
+++ b/frontend/src/grpcweb/index.ts
@@ -6,7 +6,6 @@ import { ChangelistServiceDefinition } from "@/types/proto/v1/changelist_service
import { DatabaseCatalogServiceDefinition } from "@/types/proto/v1/database_catalog_service";
import { DatabaseGroupServiceDefinition } from "@/types/proto/v1/database_group_service";
import { DatabaseServiceDefinition } from "@/types/proto/v1/database_service";
-import { EnvironmentServiceDefinition } from "@/types/proto/v1/environment_service";
import { GroupServiceDefinition } from "@/types/proto/v1/group_service";
import { IdentityProviderServiceDefinition } from "@/types/proto/v1/idp_service";
import { InstanceRoleServiceDefinition } from "@/types/proto/v1/instance_role_service";
@@ -86,11 +85,6 @@ export const roleServiceClient = clientFactory.create(
channel
);
-export const environmentServiceClient = clientFactory.create(
- EnvironmentServiceDefinition,
- channel
-);
-
export const instanceServiceClient = clientFactory.create(
InstanceServiceDefinition,
channel
diff --git a/frontend/src/grpcweb/methods.ts b/frontend/src/grpcweb/methods.ts
index 75788e71ed..8c8413914e 100644
--- a/frontend/src/grpcweb/methods.ts
+++ b/frontend/src/grpcweb/methods.ts
@@ -5,7 +5,6 @@ import { CelServiceDefinition } from "@/types/proto/v1/cel_service";
import { ChangelistServiceDefinition } from "@/types/proto/v1/changelist_service";
import { DatabaseGroupServiceDefinition } from "@/types/proto/v1/database_group_service";
import { DatabaseServiceDefinition } from "@/types/proto/v1/database_service";
-import { EnvironmentServiceDefinition } from "@/types/proto/v1/environment_service";
import { GroupServiceDefinition } from "@/types/proto/v1/group_service";
import { IdentityProviderServiceDefinition } from "@/types/proto/v1/idp_service";
import { InstanceServiceDefinition } from "@/types/proto/v1/instance_service";
@@ -42,7 +41,6 @@ export const ALL_METHODS_WITH_AUDIT = [
ChangelistServiceDefinition,
DatabaseGroupServiceDefinition,
DatabaseServiceDefinition,
- EnvironmentServiceDefinition,
GroupServiceDefinition,
IdentityProviderServiceDefinition,
InstanceServiceDefinition,
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 0eeb7620f3..066754b5b9 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1253,7 +1253,6 @@
"select": "Select environment",
"delete": "Delete this environment",
"create": "Create Environment",
- "restore": "Restore this environment",
"successfully-updated-environment": "Successfully updated environment '{name}'.",
"production-environment": "Production environment",
"access-control": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index c52096af2e..0976d6140f 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1253,7 +1253,6 @@
"select": "Seleccionar entorno",
"delete": "Eliminar este entorno",
"create": "Crear entorno",
- "restore": "Restaurar este entorno",
"successfully-updated-environment": "entorno '{name}' actualizado exitosamente.",
"production-environment": "Entorno de producción",
"access-control": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 8acc30795b..d091772fe6 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1253,7 +1253,6 @@
"select": "環境を選ぶ",
"delete": "この環境を削除します",
"create": "環境を作成する",
- "restore": "この環境を復元する",
"successfully-updated-environment": "環境「{name}」は正常に更新されました",
"production-environment": "本番環境",
"access-control": {
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 05e7a94c9f..73d0023b34 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -1253,7 +1253,6 @@
"select": "Chọn môi trường",
"delete": "Xóa môi trường này",
"create": "Tạo môi trường",
- "restore": "Khôi phục môi trường này",
"successfully-updated-environment": "Đã cập nhật thành công môi trường '{name}'.",
"production-environment": "Môi trường sản xuất",
"access-control": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 09be46f33e..86d2c016e2 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1253,7 +1253,6 @@
"select": "选择环境",
"delete": "删除此环境",
"create": "创建环境",
- "restore": "恢复此环境",
"successfully-updated-environment": "环境'{name}'更新成功",
"production-environment": "生产环境",
"access-control": {
diff --git a/frontend/src/store/modules/sqlEditor/tree.ts b/frontend/src/store/modules/sqlEditor/tree.ts
index c1eb07de99..6a9f2ba096 100644
--- a/frontend/src/store/modules/sqlEditor/tree.ts
+++ b/frontend/src/store/modules/sqlEditor/tree.ts
@@ -17,8 +17,9 @@ import {
extractSQLEditorLabelFactor as extractLabelFactor,
unknownEnvironment,
LeafTreeNodeTypes,
+ formatEnvironmentName,
} from "@/types";
-import type { Environment } from "@/types/proto/v1/environment_service";
+import type { Environment } from "@/types/v1/environment";
import type { InstanceResource } from "@/types/proto/v1/instance_service";
import { getSemanticLabelValue, groupBy, isDatabaseV1Queryable } from "@/utils";
import {
@@ -253,15 +254,17 @@ export const idForSQLEditorTreeNodeTarget = <T extends NodeType>(
type: T,
target: NodeTarget<T>
) => {
- if (type === "instance" || type === "environment" || type === "database") {
+ if (type === "instance" || type === "database") {
return (
target as
| ComposedProject
| InstanceResource
- | Environment
| ComposedDatabase
).name;
}
+ if (type === "environment") {
+ return formatEnvironmentName((target as Environment).id);
+ }
if (type === "label") {
const kv = target as NodeTarget<"label">;
return `labels/${kv.key}:${kv.value}`;
diff --git a/frontend/src/store/modules/v1/environment.ts b/frontend/src/store/modules/v1/environment.ts
index 30a5e959e9..fb0110ef78 100644
--- a/frontend/src/store/modules/v1/environment.ts
+++ b/frontend/src/store/modules/v1/environment.ts
@@ -1,16 +1,14 @@
import { orderBy } from "lodash-es";
import { defineStore } from "pinia";
import { computed } from "vue";
-import { environmentServiceClient, settingServiceClient } from "@/grpcweb";
+import { settingServiceClient } from "@/grpcweb";
import type { ResourceId } from "@/types";
import { unknownEnvironment } from "@/types";
-import { State } from "@/types/proto/v1/common";
-import { Environment } from "@/types/proto/v1/environment_service";
-import { EnvironmentTier } from "@/types/proto/v1/environment_service";
import {
EnvironmentSetting,
EnvironmentSetting_Environment,
} from "@/types/proto/v1/setting_service";
+import type { Environment } from "@/types/v1/environment";
import { environmentNamePrefix } from "./common";
interface EnvironmentState {
@@ -21,7 +19,7 @@ const getEnvironmentByIdMap = (
environments: Environment[]
): Map<ResourceId, Environment> => {
return new Map(
- environments.map((environment) => [environment.name, environment])
+ environments.map((environment) => [environment.id, environment])
);
};
@@ -31,32 +29,32 @@ const convertToEnvironments = (
return environments.map<Environment>((env, i) => {
return {
name: `${environmentNamePrefix}${env.id}`,
+ id: env.id,
title: env.title,
order: i,
color: env.color,
- tier: env.tags["protected"] === "protected"
- ? EnvironmentTier.PROTECTED
- : EnvironmentTier.UNPROTECTED,
- state: State.ACTIVE,
+ tags: env.tags,
};
});
};
+const convertEnvironment = (
+ env: Environment
+): EnvironmentSetting_Environment => {
+ const res: EnvironmentSetting_Environment = {
+ name: env.name,
+ id: env.id,
+ title: env.title,
+ color: env.color,
+ tags: env.tags,
+ };
+ return res;
+};
+
const convertEnvironments = (
environments: Environment[]
): EnvironmentSetting_Environment[] => {
- return environments.map((env) => {
- const res: EnvironmentSetting_Environment = {
- id: env.name.replace(environmentNamePrefix, ""),
- title: env.title,
- color: env.color,
- tags: {},
- };
- if (env.tier === EnvironmentTier.PROTECTED) {
- res.tags.protected = "protected";
- }
- return res;
- });
+ return environments.map(convertEnvironment);
};
const getEnvironmentSetting = async (
@@ -109,26 +107,19 @@ export const useEnvironmentV1Store = defineStore("environment_v1", {
this.environmentMapById = getEnvironmentByIdMap(environments);
return environments;
},
- getEnvironmentList(showDeleted = false): Environment[] {
- return this.environmentList.filter((environment: Environment) => {
- if (environment.state == State.DELETED && !showDeleted) {
- return false;
- }
- return true;
- });
+ getEnvironmentList(): Environment[] {
+ return this.environmentList;
},
async createEnvironment(
environment: Partial<Environment>
): Promise<Environment> {
const e: EnvironmentSetting_Environment = {
- id: environment.name?.replace(environmentNamePrefix, "") ?? "",
+ name: "",
+ id: environment.id ?? "",
title: environment.title ?? "",
color: environment.color ?? "",
- tags: {},
+ tags: environment.tags ?? {},
};
- if (environment.tier === EnvironmentTier.PROTECTED) {
- e.tags.protected = "protected";
- }
const newEnvironmentSettingValue = [
...convertEnvironments(this.environmentList),
e,
@@ -140,9 +131,9 @@ export const useEnvironmentV1Store = defineStore("environment_v1", {
const newEnvironmentMapById = getEnvironmentByIdMap(newEnvironments);
this.environmentMapById = newEnvironmentMapById;
- const newEnvironment = newEnvironmentMapById.get(environment.name ?? "");
+ const newEnvironment = newEnvironmentMapById.get(environment.id ?? "");
if (!newEnvironment) {
- throw new Error(`environment with name ${environment.name} not found`);
+ throw new Error(`environment with id ${environment.id} not found`);
}
return newEnvironment;
},
@@ -150,18 +141,18 @@ export const useEnvironmentV1Store = defineStore("environment_v1", {
update: Partial<Environment>
): Promise<Environment> {
const originData = await this.getOrFetchEnvironmentByName(
- update.name || ""
+ update.id || ""
);
if (!originData) {
- throw new Error(`environment with name ${update.name} not found`);
+ throw new Error(`environment with id ${update.id} not found`);
}
const newEnvironments = await updateEnvironmentSetting({
environments: convertEnvironments(
this.environmentList.map((environment) => {
- if (environment.name === update.name) {
+ if (environment.id === update.id) {
environment.title = update.title ?? environment.title;
environment.color = update.color ?? environment.color;
- environment.tier = update.tier ?? environment.tier;
+ environment.tags = update.tags ?? environment.tags;
environment.order = update.order ?? environment.order;
}
return environment;
@@ -171,45 +162,29 @@ export const useEnvironmentV1Store = defineStore("environment_v1", {
const newEnvironmentMapById = getEnvironmentByIdMap(newEnvironments);
this.environmentMapById = newEnvironmentMapById;
- const newEnvironment = newEnvironmentMapById.get(update.name || "");
+ const newEnvironment = newEnvironmentMapById.get(update.id ?? "");
if (!newEnvironment) {
- throw new Error(`environment with name ${update.name} not found`);
+ throw new Error(`environment with id ${update.id} not found`);
}
return newEnvironment;
},
async deleteEnvironment(name: string): Promise<void> {
+ const id = name.replace(environmentNamePrefix, "");
const newEnvironments = await updateEnvironmentSetting({
environments: convertEnvironments(
- this.environmentList.filter(
- (environment) => environment.name !== name
- )
+ this.environmentList.filter((environment) => environment.id !== id)
),
});
this.environmentMapById = getEnvironmentByIdMap(newEnvironments);
},
- async undeleteEnvironment(name: string) {
- const environment = await environmentServiceClient.undeleteEnvironment({
- name,
- });
- this.environmentMapById.set(environment.name, environment);
- return environment;
- },
- async reorderEnvironmentList(orderedEnvironmentList: Environment[]) {
- const updatedEnvironmentList = await Promise.all(
- orderedEnvironmentList.map((environment, order) => {
- return environmentServiceClient.updateEnvironment({
- environment: {
- ...environment,
- order,
- },
- updateMask: ["order"],
- });
- })
- );
- updatedEnvironmentList.forEach((environment) => {
- this.environmentMapById.set(environment.name, environment);
+ async reorderEnvironmentList(
+ orderedEnvironmentList: Environment[]
+ ): Promise<Environment[]> {
+ const newEnvironments = await updateEnvironmentSetting({
+ environments: convertEnvironments(orderedEnvironmentList),
});
- return updatedEnvironmentList;
+ this.environmentMapById = getEnvironmentByIdMap(newEnvironments);
+ return newEnvironments;
},
async getOrFetchEnvironmentByName(
name: string,
@@ -224,14 +199,13 @@ export const useEnvironmentV1Store = defineStore("environment_v1", {
return environment;
},
getEnvironmentByName(name: string) {
- return this.environmentMapById.get(name) ?? unknownEnvironment();
+ const id = name.replace(environmentNamePrefix, "");
+ return this.environmentMapById.get(id) ?? unknownEnvironment();
},
},
});
-export const useEnvironmentV1List = (showDeleted = false) => {
+export const useEnvironmentV1List = () => {
const store = useEnvironmentV1Store();
- return computed(() => store.getEnvironmentList(showDeleted));
+ return computed(() => store.getEnvironmentList());
};
-
-export const defaultEnvironmentTier = EnvironmentTier.UNPROTECTED;
diff --git a/frontend/src/types/proto/store/deployment_config.ts b/frontend/src/types/proto/store/deployment_config.ts
deleted file mode 100644
index 2d5bbbf344..0000000000
--- a/frontend/src/types/proto/store/deployment_config.ts
+++ /dev/null
@@ -1,561 +0,0 @@
-// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
-// versions:
-// protoc-gen-ts_proto v2.3.0
-// protoc unknown
-// source: store/deployment_config.proto
-
-/* eslint-disable */
-import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
-import Long from "long";
-
-export const protobufPackage = "bytebase.store";
-
-export interface DeploymentConfig {
- schedule: Schedule | undefined;
-}
-
-/** Schedule is the message for deployment schedule. */
-export interface Schedule {
- deployments: ScheduleDeployment[];
-}
-
-export interface ScheduleDeployment {
- /** The title of the deployment (stage) in a schedule. */
- title: string;
- id: string;
- spec: DeploymentSpec | undefined;
-}
-
-export interface DeploymentSpec {
- selector: LabelSelector | undefined;
-}
-
-export interface LabelSelector {
- /** match_expressions is a list of label selector requirements. The requirements are ANDed. */
- matchExpressions: LabelSelectorRequirement[];
-}
-
-export interface LabelSelectorRequirement {
- key: string;
- operator: LabelSelectorRequirement_OperatorType;
- /** Values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch. */
- values: string[];
-}
-
-export enum LabelSelectorRequirement_OperatorType {
- /** OPERATOR_TYPE_UNSPECIFIED - The operator is not specified. */
- OPERATOR_TYPE_UNSPECIFIED = "OPERATOR_TYPE_UNSPECIFIED",
- /** IN - The operator is "In". */
- IN = "IN",
- /** EXISTS - The operator is "Exists". */
- EXISTS = "EXISTS",
- /** NOT_IN - The operator is "Not In". */
- NOT_IN = "NOT_IN",
- UNRECOGNIZED = "UNRECOGNIZED",
-}
-
-export function labelSelectorRequirement_OperatorTypeFromJSON(object: any): LabelSelectorRequirement_OperatorType {
- switch (object) {
- case 0:
- case "OPERATOR_TYPE_UNSPECIFIED":
- return LabelSelectorRequirement_OperatorType.OPERATOR_TYPE_UNSPECIFIED;
- case 1:
- case "IN":
- return LabelSelectorRequirement_OperatorType.IN;
- case 2:
- case "EXISTS":
- return LabelSelectorRequirement_OperatorType.EXISTS;
- case 3:
- case "NOT_IN":
- return LabelSelectorRequirement_OperatorType.NOT_IN;
- case -1:
- case "UNRECOGNIZED":
- default:
- return LabelSelectorRequirement_OperatorType.UNRECOGNIZED;
- }
-}
-
-export function labelSelectorRequirement_OperatorTypeToJSON(object: LabelSelectorRequirement_OperatorType): string {
- switch (object) {
- case LabelSelectorRequirement_OperatorType.OPERATOR_TYPE_UNSPECIFIED:
- return "OPERATOR_TYPE_UNSPECIFIED";
- case LabelSelectorRequirement_OperatorType.IN:
- return "IN";
- case LabelSelectorRequirement_OperatorType.EXISTS:
- return "EXISTS";
- case LabelSelectorRequirement_OperatorType.NOT_IN:
- return "NOT_IN";
- case LabelSelectorRequirement_OperatorType.UNRECOGNIZED:
- default:
- return "UNRECOGNIZED";
- }
-}
-
-export function labelSelectorRequirement_OperatorTypeToNumber(object: LabelSelectorRequirement_OperatorType): number {
- switch (object) {
- case LabelSelectorRequirement_OperatorType.OPERATOR_TYPE_UNSPECIFIED:
- return 0;
- case LabelSelectorRequirement_OperatorType.IN:
- return 1;
- case LabelSelectorRequirement_OperatorType.EXISTS:
- return 2;
- case LabelSelectorRequirement_OperatorType.NOT_IN:
- return 3;
- case LabelSelectorRequirement_OperatorType.UNRECOGNIZED:
- default:
- return -1;
- }
-}
-
-function createBaseDeploymentConfig(): DeploymentConfig {
- return { schedule: undefined };
-}
-
-export const DeploymentConfig: MessageFns<DeploymentConfig> = {
- encode(message: DeploymentConfig, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.schedule !== undefined) {
- Schedule.encode(message.schedule, writer.uint32(10).fork()).join();
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): DeploymentConfig {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseDeploymentConfig();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.schedule = Schedule.decode(reader, reader.uint32());
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): DeploymentConfig {
- return { schedule: isSet(object.schedule) ? Schedule.fromJSON(object.schedule) : undefined };
- },
-
- toJSON(message: DeploymentConfig): unknown {
- const obj: any = {};
- if (message.schedule !== undefined) {
- obj.schedule = Schedule.toJSON(message.schedule);
- }
- return obj;
- },
-
- create(base?: DeepPartial<DeploymentConfig>): DeploymentConfig {
- return DeploymentConfig.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<DeploymentConfig>): DeploymentConfig {
- const message = createBaseDeploymentConfig();
- message.schedule = (object.schedule !== undefined && object.schedule !== null)
- ? Schedule.fromPartial(object.schedule)
- : undefined;
- return message;
- },
-};
-
-function createBaseSchedule(): Schedule {
- return { deployments: [] };
-}
-
-export const Schedule: MessageFns<Schedule> = {
- encode(message: Schedule, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- for (const v of message.deployments) {
- ScheduleDeployment.encode(v!, writer.uint32(10).fork()).join();
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): Schedule {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseSchedule();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.deployments.push(ScheduleDeployment.decode(reader, reader.uint32()));
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): Schedule {
- return {
- deployments: globalThis.Array.isArray(object?.deployments)
- ? object.deployments.map((e: any) => ScheduleDeployment.fromJSON(e))
- : [],
- };
- },
-
- toJSON(message: Schedule): unknown {
- const obj: any = {};
- if (message.deployments?.length) {
- obj.deployments = message.deployments.map((e) => ScheduleDeployment.toJSON(e));
- }
- return obj;
- },
-
- create(base?: DeepPartial<Schedule>): Schedule {
- return Schedule.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<Schedule>): Schedule {
- const message = createBaseSchedule();
- message.deployments = object.deployments?.map((e) => ScheduleDeployment.fromPartial(e)) || [];
- return message;
- },
-};
-
-function createBaseScheduleDeployment(): ScheduleDeployment {
- return { title: "", id: "", spec: undefined };
-}
-
-export const ScheduleDeployment: MessageFns<ScheduleDeployment> = {
- encode(message: ScheduleDeployment, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.title !== "") {
- writer.uint32(10).string(message.title);
- }
- if (message.id !== "") {
- writer.uint32(18).string(message.id);
- }
- if (message.spec !== undefined) {
- DeploymentSpec.encode(message.spec, writer.uint32(26).fork()).join();
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): ScheduleDeployment {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseScheduleDeployment();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.title = reader.string();
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.id = reader.string();
- continue;
- }
- case 3: {
- if (tag !== 26) {
- break;
- }
-
- message.spec = DeploymentSpec.decode(reader, reader.uint32());
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): ScheduleDeployment {
- return {
- title: isSet(object.title) ? globalThis.String(object.title) : "",
- id: isSet(object.id) ? globalThis.String(object.id) : "",
- spec: isSet(object.spec) ? DeploymentSpec.fromJSON(object.spec) : undefined,
- };
- },
-
- toJSON(message: ScheduleDeployment): unknown {
- const obj: any = {};
- if (message.title !== "") {
- obj.title = message.title;
- }
- if (message.id !== "") {
- obj.id = message.id;
- }
- if (message.spec !== undefined) {
- obj.spec = DeploymentSpec.toJSON(message.spec);
- }
- return obj;
- },
-
- create(base?: DeepPartial<ScheduleDeployment>): ScheduleDeployment {
- return ScheduleDeployment.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<ScheduleDeployment>): ScheduleDeployment {
- const message = createBaseScheduleDeployment();
- message.title = object.title ?? "";
- message.id = object.id ?? "";
- message.spec = (object.spec !== undefined && object.spec !== null)
- ? DeploymentSpec.fromPartial(object.spec)
- : undefined;
- return message;
- },
-};
-
-function createBaseDeploymentSpec(): DeploymentSpec {
- return { selector: undefined };
-}
-
-export const DeploymentSpec: MessageFns<DeploymentSpec> = {
- encode(message: DeploymentSpec, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.selector !== undefined) {
- LabelSelector.encode(message.selector, writer.uint32(10).fork()).join();
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): DeploymentSpec {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseDeploymentSpec();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.selector = LabelSelector.decode(reader, reader.uint32());
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): DeploymentSpec {
- return { selector: isSet(object.selector) ? LabelSelector.fromJSON(object.selector) : undefined };
- },
-
- toJSON(message: DeploymentSpec): unknown {
- const obj: any = {};
- if (message.selector !== undefined) {
- obj.selector = LabelSelector.toJSON(message.selector);
- }
- return obj;
- },
-
- create(base?: DeepPartial<DeploymentSpec>): DeploymentSpec {
- return DeploymentSpec.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<DeploymentSpec>): DeploymentSpec {
- const message = createBaseDeploymentSpec();
- message.selector = (object.selector !== undefined && object.selector !== null)
- ? LabelSelector.fromPartial(object.selector)
- : undefined;
- return message;
- },
-};
-
-function createBaseLabelSelector(): LabelSelector {
- return { matchExpressions: [] };
-}
-
-export const LabelSelector: MessageFns<LabelSelector> = {
- encode(message: LabelSelector, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- for (const v of message.matchExpressions) {
- LabelSelectorRequirement.encode(v!, writer.uint32(10).fork()).join();
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): LabelSelector {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseLabelSelector();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.matchExpressions.push(LabelSelectorRequirement.decode(reader, reader.uint32()));
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): LabelSelector {
- return {
- matchExpressions: globalThis.Array.isArray(object?.matchExpressions)
- ? object.matchExpressions.map((e: any) => LabelSelectorRequirement.fromJSON(e))
- : [],
- };
- },
-
- toJSON(message: LabelSelector): unknown {
- const obj: any = {};
- if (message.matchExpressions?.length) {
- obj.matchExpressions = message.matchExpressions.map((e) => LabelSelectorRequirement.toJSON(e));
- }
- return obj;
- },
-
- create(base?: DeepPartial<LabelSelector>): LabelSelector {
- return LabelSelector.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<LabelSelector>): LabelSelector {
- const message = createBaseLabelSelector();
- message.matchExpressions = object.matchExpressions?.map((e) => LabelSelectorRequirement.fromPartial(e)) || [];
- return message;
- },
-};
-
-function createBaseLabelSelectorRequirement(): LabelSelectorRequirement {
- return { key: "", operator: LabelSelectorRequirement_OperatorType.OPERATOR_TYPE_UNSPECIFIED, values: [] };
-}
-
-export const LabelSelectorRequirement: MessageFns<LabelSelectorRequirement> = {
- encode(message: LabelSelectorRequirement, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.key !== "") {
- writer.uint32(10).string(message.key);
- }
- if (message.operator !== LabelSelectorRequirement_OperatorType.OPERATOR_TYPE_UNSPECIFIED) {
- writer.uint32(16).int32(labelSelectorRequirement_OperatorTypeToNumber(message.operator));
- }
- for (const v of message.values) {
- writer.uint32(26).string(v!);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): LabelSelectorRequirement {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseLabelSelectorRequirement();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.key = reader.string();
- continue;
- }
- case 2: {
- if (tag !== 16) {
- break;
- }
-
- message.operator = labelSelectorRequirement_OperatorTypeFromJSON(reader.int32());
- continue;
- }
- case 3: {
- if (tag !== 26) {
- break;
- }
-
- message.values.push(reader.string());
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): LabelSelectorRequirement {
- return {
- key: isSet(object.key) ? globalThis.String(object.key) : "",
- operator: isSet(object.operator)
- ? labelSelectorRequirement_OperatorTypeFromJSON(object.operator)
- : LabelSelectorRequirement_OperatorType.OPERATOR_TYPE_UNSPECIFIED,
- values: globalThis.Array.isArray(object?.values) ? object.values.map((e: any) => globalThis.String(e)) : [],
- };
- },
-
- toJSON(message: LabelSelectorRequirement): unknown {
- const obj: any = {};
- if (message.key !== "") {
- obj.key = message.key;
- }
- if (message.operator !== LabelSelectorRequirement_OperatorType.OPERATOR_TYPE_UNSPECIFIED) {
- obj.operator = labelSelectorRequirement_OperatorTypeToJSON(message.operator);
- }
- if (message.values?.length) {
- obj.values = message.values;
- }
- return obj;
- },
-
- create(base?: DeepPartial<LabelSelectorRequirement>): LabelSelectorRequirement {
- return LabelSelectorRequirement.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<LabelSelectorRequirement>): LabelSelectorRequirement {
- const message = createBaseLabelSelectorRequirement();
- message.key = object.key ?? "";
- message.operator = object.operator ?? LabelSelectorRequirement_OperatorType.OPERATOR_TYPE_UNSPECIFIED;
- message.values = object.values?.map((e) => e) || [];
- return message;
- },
-};
-
-type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
-
-export type DeepPartial<T> = T extends Builtin ? T
- : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
- : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
- : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
- : Partial<T>;
-
-function isSet(value: any): boolean {
- return value !== null && value !== undefined;
-}
-
-export interface MessageFns<T> {
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
- decode(input: BinaryReader | Uint8Array, length?: number): T;
- fromJSON(object: any): T;
- toJSON(message: T): unknown;
- create(base?: DeepPartial<T>): T;
- fromPartial(object: DeepPartial<T>): T;
-}
diff --git a/frontend/src/types/proto/store/deprecated.ts b/frontend/src/types/proto/store/deprecated.ts
deleted file mode 100644
index 366495a365..0000000000
--- a/frontend/src/types/proto/store/deprecated.ts
+++ /dev/null
@@ -1,261 +0,0 @@
-// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
-// versions:
-// protoc-gen-ts_proto v2.3.0
-// protoc unknown
-// source: store/deprecated.proto
-
-/* eslint-disable */
-import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
-import Long from "long";
-import { MaskingLevel, maskingLevelFromJSON, maskingLevelToJSON, maskingLevelToNumber } from "./common";
-
-export const protobufPackage = "bytebase.store";
-
-export interface DeprecatedMaskingPolicy {
- maskData: DeprecatedMaskData[];
-}
-
-export interface DeprecatedMaskData {
- schema: string;
- table: string;
- column: string;
- maskingLevel: MaskingLevel;
- fullMaskingAlgorithmId: string;
- partialMaskingAlgorithmId: string;
-}
-
-function createBaseDeprecatedMaskingPolicy(): DeprecatedMaskingPolicy {
- return { maskData: [] };
-}
-
-export const DeprecatedMaskingPolicy: MessageFns<DeprecatedMaskingPolicy> = {
- encode(message: DeprecatedMaskingPolicy, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- for (const v of message.maskData) {
- DeprecatedMaskData.encode(v!, writer.uint32(10).fork()).join();
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): DeprecatedMaskingPolicy {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseDeprecatedMaskingPolicy();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.maskData.push(DeprecatedMaskData.decode(reader, reader.uint32()));
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): DeprecatedMaskingPolicy {
- return {
- maskData: globalThis.Array.isArray(object?.maskData)
- ? object.maskData.map((e: any) => DeprecatedMaskData.fromJSON(e))
- : [],
- };
- },
-
- toJSON(message: DeprecatedMaskingPolicy): unknown {
- const obj: any = {};
- if (message.maskData?.length) {
- obj.maskData = message.maskData.map((e) => DeprecatedMaskData.toJSON(e));
- }
- return obj;
- },
-
- create(base?: DeepPartial<DeprecatedMaskingPolicy>): DeprecatedMaskingPolicy {
- return DeprecatedMaskingPolicy.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<DeprecatedMaskingPolicy>): DeprecatedMaskingPolicy {
- const message = createBaseDeprecatedMaskingPolicy();
- message.maskData = object.maskData?.map((e) => DeprecatedMaskData.fromPartial(e)) || [];
- return message;
- },
-};
-
-function createBaseDeprecatedMaskData(): DeprecatedMaskData {
- return {
- schema: "",
- table: "",
- column: "",
- maskingLevel: MaskingLevel.MASKING_LEVEL_UNSPECIFIED,
- fullMaskingAlgorithmId: "",
- partialMaskingAlgorithmId: "",
- };
-}
-
-export const DeprecatedMaskData: MessageFns<DeprecatedMaskData> = {
- encode(message: DeprecatedMaskData, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.schema !== "") {
- writer.uint32(10).string(message.schema);
- }
- if (message.table !== "") {
- writer.uint32(18).string(message.table);
- }
- if (message.column !== "") {
- writer.uint32(26).string(message.column);
- }
- if (message.maskingLevel !== MaskingLevel.MASKING_LEVEL_UNSPECIFIED) {
- writer.uint32(32).int32(maskingLevelToNumber(message.maskingLevel));
- }
- if (message.fullMaskingAlgorithmId !== "") {
- writer.uint32(42).string(message.fullMaskingAlgorithmId);
- }
- if (message.partialMaskingAlgorithmId !== "") {
- writer.uint32(50).string(message.partialMaskingAlgorithmId);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): DeprecatedMaskData {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseDeprecatedMaskData();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.schema = reader.string();
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.table = reader.string();
- continue;
- }
- case 3: {
- if (tag !== 26) {
- break;
- }
-
- message.column = reader.string();
- continue;
- }
- case 4: {
- if (tag !== 32) {
- break;
- }
-
- message.maskingLevel = maskingLevelFromJSON(reader.int32());
- continue;
- }
- case 5: {
- if (tag !== 42) {
- break;
- }
-
- message.fullMaskingAlgorithmId = reader.string();
- continue;
- }
- case 6: {
- if (tag !== 50) {
- break;
- }
-
- message.partialMaskingAlgorithmId = reader.string();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): DeprecatedMaskData {
- return {
- schema: isSet(object.schema) ? globalThis.String(object.schema) : "",
- table: isSet(object.table) ? globalThis.String(object.table) : "",
- column: isSet(object.column) ? globalThis.String(object.column) : "",
- maskingLevel: isSet(object.maskingLevel)
- ? maskingLevelFromJSON(object.maskingLevel)
- : MaskingLevel.MASKING_LEVEL_UNSPECIFIED,
- fullMaskingAlgorithmId: isSet(object.fullMaskingAlgorithmId)
- ? globalThis.String(object.fullMaskingAlgorithmId)
- : "",
- partialMaskingAlgorithmId: isSet(object.partialMaskingAlgorithmId)
- ? globalThis.String(object.partialMaskingAlgorithmId)
- : "",
- };
- },
-
- toJSON(message: DeprecatedMaskData): unknown {
- const obj: any = {};
- if (message.schema !== "") {
- obj.schema = message.schema;
- }
- if (message.table !== "") {
- obj.table = message.table;
- }
- if (message.column !== "") {
- obj.column = message.column;
- }
- if (message.maskingLevel !== MaskingLevel.MASKING_LEVEL_UNSPECIFIED) {
- obj.maskingLevel = maskingLevelToJSON(message.maskingLevel);
- }
- if (message.fullMaskingAlgorithmId !== "") {
- obj.fullMaskingAlgorithmId = message.fullMaskingAlgorithmId;
- }
- if (message.partialMaskingAlgorithmId !== "") {
- obj.partialMaskingAlgorithmId = message.partialMaskingAlgorithmId;
- }
- return obj;
- },
-
- create(base?: DeepPartial<DeprecatedMaskData>): DeprecatedMaskData {
- return DeprecatedMaskData.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<DeprecatedMaskData>): DeprecatedMaskData {
- const message = createBaseDeprecatedMaskData();
- message.schema = object.schema ?? "";
- message.table = object.table ?? "";
- message.column = object.column ?? "";
- message.maskingLevel = object.maskingLevel ?? MaskingLevel.MASKING_LEVEL_UNSPECIFIED;
- message.fullMaskingAlgorithmId = object.fullMaskingAlgorithmId ?? "";
- message.partialMaskingAlgorithmId = object.partialMaskingAlgorithmId ?? "";
- return message;
- },
-};
-
-type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
-
-export type DeepPartial<T> = T extends Builtin ? T
- : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
- : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
- : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
- : Partial<T>;
-
-function isSet(value: any): boolean {
- return value !== null && value !== undefined;
-}
-
-export interface MessageFns<T> {
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
- decode(input: BinaryReader | Uint8Array, length?: number): T;
- fromJSON(object: any): T;
- toJSON(message: T): unknown;
- create(base?: DeepPartial<T>): T;
- fromPartial(object: DeepPartial<T>): T;
-}
diff --git a/frontend/src/types/proto/store/setting.ts b/frontend/src/types/proto/store/setting.ts
index 818e03c73b..ce75522151 100644
--- a/frontend/src/types/proto/store/setting.ts
+++ b/frontend/src/types/proto/store/setting.ts
@@ -684,14 +684,14 @@ export interface EnvironmentSetting {
}
export interface EnvironmentSetting_Environment {
- /** The display name of the environment. */
- title: string;
/**
* The resource id of the environment.
* This value should be 4-63 characters, and valid characters
* are /[a-z][0-9]-/.
*/
id: string;
+ /** The display name of the environment. */
+ title: string;
tags: { [key: string]: string };
color: string;
}
@@ -4281,16 +4281,16 @@ export const EnvironmentSetting: MessageFns<EnvironmentSetting> = {
};
function createBaseEnvironmentSetting_Environment(): EnvironmentSetting_Environment {
- return { title: "", id: "", tags: {}, color: "" };
+ return { id: "", title: "", tags: {}, color: "" };
}
export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Environment> = {
encode(message: EnvironmentSetting_Environment, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.title !== "") {
- writer.uint32(10).string(message.title);
- }
if (message.id !== "") {
- writer.uint32(18).string(message.id);
+ writer.uint32(10).string(message.id);
+ }
+ if (message.title !== "") {
+ writer.uint32(18).string(message.title);
}
Object.entries(message.tags).forEach(([key, value]) => {
EnvironmentSetting_Environment_TagsEntry.encode({ key: key as any, value }, writer.uint32(26).fork()).join();
@@ -4313,7 +4313,7 @@ export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Envir
break;
}
- message.title = reader.string();
+ message.id = reader.string();
continue;
}
case 2: {
@@ -4321,7 +4321,7 @@ export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Envir
break;
}
- message.id = reader.string();
+ message.title = reader.string();
continue;
}
case 3: {
@@ -4354,8 +4354,8 @@ export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Envir
fromJSON(object: any): EnvironmentSetting_Environment {
return {
- title: isSet(object.title) ? globalThis.String(object.title) : "",
id: isSet(object.id) ? globalThis.String(object.id) : "",
+ title: isSet(object.title) ? globalThis.String(object.title) : "",
tags: isObject(object.tags)
? Object.entries(object.tags).reduce<{ [key: string]: string }>((acc, [key, value]) => {
acc[key] = String(value);
@@ -4368,12 +4368,12 @@ export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Envir
toJSON(message: EnvironmentSetting_Environment): unknown {
const obj: any = {};
- if (message.title !== "") {
- obj.title = message.title;
- }
if (message.id !== "") {
obj.id = message.id;
}
+ if (message.title !== "") {
+ obj.title = message.title;
+ }
if (message.tags) {
const entries = Object.entries(message.tags);
if (entries.length > 0) {
@@ -4394,8 +4394,8 @@ export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Envir
},
fromPartial(object: DeepPartial<EnvironmentSetting_Environment>): EnvironmentSetting_Environment {
const message = createBaseEnvironmentSetting_Environment();
- message.title = object.title ?? "";
message.id = object.id ?? "";
+ message.title = object.title ?? "";
message.tags = Object.entries(object.tags ?? {}).reduce<{ [key: string]: string }>((acc, [key, value]) => {
if (value !== undefined) {
acc[key] = globalThis.String(value);
diff --git a/frontend/src/types/proto/v1/environment_service.ts b/frontend/src/types/proto/v1/environment_service.ts
deleted file mode 100644
index 8e9ca60d6a..0000000000
--- a/frontend/src/types/proto/v1/environment_service.ts
+++ /dev/null
@@ -1,1312 +0,0 @@
-// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
-// versions:
-// protoc-gen-ts_proto v2.3.0
-// protoc unknown
-// source: v1/environment_service.proto
-
-/* eslint-disable */
-import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
-import Long from "long";
-import { Empty } from "../google/protobuf/empty";
-import { FieldMask } from "../google/protobuf/field_mask";
-import { State, stateFromJSON, stateToJSON, stateToNumber } from "./common";
-
-export const protobufPackage = "bytebase.v1";
-
-export enum EnvironmentTier {
- ENVIRONMENT_TIER_UNSPECIFIED = "ENVIRONMENT_TIER_UNSPECIFIED",
- PROTECTED = "PROTECTED",
- UNPROTECTED = "UNPROTECTED",
- UNRECOGNIZED = "UNRECOGNIZED",
-}
-
-export function environmentTierFromJSON(object: any): EnvironmentTier {
- switch (object) {
- case 0:
- case "ENVIRONMENT_TIER_UNSPECIFIED":
- return EnvironmentTier.ENVIRONMENT_TIER_UNSPECIFIED;
- case 1:
- case "PROTECTED":
- return EnvironmentTier.PROTECTED;
- case 2:
- case "UNPROTECTED":
- return EnvironmentTier.UNPROTECTED;
- case -1:
- case "UNRECOGNIZED":
- default:
- return EnvironmentTier.UNRECOGNIZED;
- }
-}
-
-export function environmentTierToJSON(object: EnvironmentTier): string {
- switch (object) {
- case EnvironmentTier.ENVIRONMENT_TIER_UNSPECIFIED:
- return "ENVIRONMENT_TIER_UNSPECIFIED";
- case EnvironmentTier.PROTECTED:
- return "PROTECTED";
- case EnvironmentTier.UNPROTECTED:
- return "UNPROTECTED";
- case EnvironmentTier.UNRECOGNIZED:
- default:
- return "UNRECOGNIZED";
- }
-}
-
-export function environmentTierToNumber(object: EnvironmentTier): number {
- switch (object) {
- case EnvironmentTier.ENVIRONMENT_TIER_UNSPECIFIED:
- return 0;
- case EnvironmentTier.PROTECTED:
- return 1;
- case EnvironmentTier.UNPROTECTED:
- return 2;
- case EnvironmentTier.UNRECOGNIZED:
- default:
- return -1;
- }
-}
-
-export interface GetEnvironmentRequest {
- /**
- * The name of the environment to retrieve.
- * Format: environments/{environment}
- */
- name: string;
-}
-
-export interface ListEnvironmentsRequest {
- /**
- * Not used.
- * The maximum number of environments to return. The service may return fewer than
- * this value.
- * If unspecified, at most 10 environments will be returned.
- * The maximum value is 1000; values above 1000 will be coerced to 1000.
- */
- pageSize: number;
- /**
- * Not used.
- * A page token, received from a previous `ListEnvironments` call.
- * Provide this to retrieve the subsequent page.
- *
- * When paginating, all other parameters provided to `ListEnvironments` must match
- * the call that provided the page token.
- */
- pageToken: string;
- /** Show deleted environments if specified. */
- showDeleted: boolean;
-}
-
-export interface ListEnvironmentsResponse {
- /** The environments from the specified request. */
- environments: Environment[];
- /**
- * A token, which can be sent as `page_token` to retrieve the next page.
- * If this field is omitted, there are no subsequent pages.
- */
- nextPageToken: string;
-}
-
-export interface CreateEnvironmentRequest {
- /** The environment to create. */
- environment:
- | Environment
- | undefined;
- /**
- * The ID to use for the environment, which will become the final component of
- * the environment's resource name.
- *
- * This value should be 4-63 characters, and valid characters
- * are /[a-z][0-9]-/.
- */
- environmentId: string;
-}
-
-export interface UpdateEnvironmentRequest {
- /**
- * The environment to update.
- *
- * The environment's `name` field is used to identify the environment to update.
- * Format: environments/{environment}
- */
- environment:
- | Environment
- | undefined;
- /** The list of fields to update. */
- updateMask: string[] | undefined;
-}
-
-export interface DeleteEnvironmentRequest {
- /**
- * The name of the environment to delete.
- * Format: environments/{environment}
- */
- name: string;
-}
-
-export interface UndeleteEnvironmentRequest {
- /**
- * The name of the deleted environment.
- * Format: environments/{environment}
- */
- name: string;
-}
-
-export interface Environment {
- /**
- * The name of the environment.
- * Format: environments/{environment}
- */
- name: string;
- state: State;
- title: string;
- order: number;
- tier: EnvironmentTier;
- color: string;
-}
-
-function createBaseGetEnvironmentRequest(): GetEnvironmentRequest {
- return { name: "" };
-}
-
-export const GetEnvironmentRequest: MessageFns<GetEnvironmentRequest> = {
- encode(message: GetEnvironmentRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.name !== "") {
- writer.uint32(10).string(message.name);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): GetEnvironmentRequest {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseGetEnvironmentRequest();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.name = reader.string();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): GetEnvironmentRequest {
- return { name: isSet(object.name) ? globalThis.String(object.name) : "" };
- },
-
- toJSON(message: GetEnvironmentRequest): unknown {
- const obj: any = {};
- if (message.name !== "") {
- obj.name = message.name;
- }
- return obj;
- },
-
- create(base?: DeepPartial<GetEnvironmentRequest>): GetEnvironmentRequest {
- return GetEnvironmentRequest.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<GetEnvironmentRequest>): GetEnvironmentRequest {
- const message = createBaseGetEnvironmentRequest();
- message.name = object.name ?? "";
- return message;
- },
-};
-
-function createBaseListEnvironmentsRequest(): ListEnvironmentsRequest {
- return { pageSize: 0, pageToken: "", showDeleted: false };
-}
-
-export const ListEnvironmentsRequest: MessageFns<ListEnvironmentsRequest> = {
- encode(message: ListEnvironmentsRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.pageSize !== 0) {
- writer.uint32(8).int32(message.pageSize);
- }
- if (message.pageToken !== "") {
- writer.uint32(18).string(message.pageToken);
- }
- if (message.showDeleted !== false) {
- writer.uint32(24).bool(message.showDeleted);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): ListEnvironmentsRequest {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseListEnvironmentsRequest();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 8) {
- break;
- }
-
- message.pageSize = reader.int32();
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.pageToken = reader.string();
- continue;
- }
- case 3: {
- if (tag !== 24) {
- break;
- }
-
- message.showDeleted = reader.bool();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): ListEnvironmentsRequest {
- return {
- pageSize: isSet(object.pageSize) ? globalThis.Number(object.pageSize) : 0,
- pageToken: isSet(object.pageToken) ? globalThis.String(object.pageToken) : "",
- showDeleted: isSet(object.showDeleted) ? globalThis.Boolean(object.showDeleted) : false,
- };
- },
-
- toJSON(message: ListEnvironmentsRequest): unknown {
- const obj: any = {};
- if (message.pageSize !== 0) {
- obj.pageSize = Math.round(message.pageSize);
- }
- if (message.pageToken !== "") {
- obj.pageToken = message.pageToken;
- }
- if (message.showDeleted !== false) {
- obj.showDeleted = message.showDeleted;
- }
- return obj;
- },
-
- create(base?: DeepPartial<ListEnvironmentsRequest>): ListEnvironmentsRequest {
- return ListEnvironmentsRequest.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<ListEnvironmentsRequest>): ListEnvironmentsRequest {
- const message = createBaseListEnvironmentsRequest();
- message.pageSize = object.pageSize ?? 0;
- message.pageToken = object.pageToken ?? "";
- message.showDeleted = object.showDeleted ?? false;
- return message;
- },
-};
-
-function createBaseListEnvironmentsResponse(): ListEnvironmentsResponse {
- return { environments: [], nextPageToken: "" };
-}
-
-export const ListEnvironmentsResponse: MessageFns<ListEnvironmentsResponse> = {
- encode(message: ListEnvironmentsResponse, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- for (const v of message.environments) {
- Environment.encode(v!, writer.uint32(10).fork()).join();
- }
- if (message.nextPageToken !== "") {
- writer.uint32(18).string(message.nextPageToken);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): ListEnvironmentsResponse {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseListEnvironmentsResponse();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.environments.push(Environment.decode(reader, reader.uint32()));
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.nextPageToken = reader.string();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): ListEnvironmentsResponse {
- return {
- environments: globalThis.Array.isArray(object?.environments)
- ? object.environments.map((e: any) => Environment.fromJSON(e))
- : [],
- nextPageToken: isSet(object.nextPageToken) ? globalThis.String(object.nextPageToken) : "",
- };
- },
-
- toJSON(message: ListEnvironmentsResponse): unknown {
- const obj: any = {};
- if (message.environments?.length) {
- obj.environments = message.environments.map((e) => Environment.toJSON(e));
- }
- if (message.nextPageToken !== "") {
- obj.nextPageToken = message.nextPageToken;
- }
- return obj;
- },
-
- create(base?: DeepPartial<ListEnvironmentsResponse>): ListEnvironmentsResponse {
- return ListEnvironmentsResponse.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<ListEnvironmentsResponse>): ListEnvironmentsResponse {
- const message = createBaseListEnvironmentsResponse();
- message.environments = object.environments?.map((e) => Environment.fromPartial(e)) || [];
- message.nextPageToken = object.nextPageToken ?? "";
- return message;
- },
-};
-
-function createBaseCreateEnvironmentRequest(): CreateEnvironmentRequest {
- return { environment: undefined, environmentId: "" };
-}
-
-export const CreateEnvironmentRequest: MessageFns<CreateEnvironmentRequest> = {
- encode(message: CreateEnvironmentRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.environment !== undefined) {
- Environment.encode(message.environment, writer.uint32(10).fork()).join();
- }
- if (message.environmentId !== "") {
- writer.uint32(18).string(message.environmentId);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): CreateEnvironmentRequest {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseCreateEnvironmentRequest();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.environment = Environment.decode(reader, reader.uint32());
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.environmentId = reader.string();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): CreateEnvironmentRequest {
- return {
- environment: isSet(object.environment) ? Environment.fromJSON(object.environment) : undefined,
- environmentId: isSet(object.environmentId) ? globalThis.String(object.environmentId) : "",
- };
- },
-
- toJSON(message: CreateEnvironmentRequest): unknown {
- const obj: any = {};
- if (message.environment !== undefined) {
- obj.environment = Environment.toJSON(message.environment);
- }
- if (message.environmentId !== "") {
- obj.environmentId = message.environmentId;
- }
- return obj;
- },
-
- create(base?: DeepPartial<CreateEnvironmentRequest>): CreateEnvironmentRequest {
- return CreateEnvironmentRequest.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<CreateEnvironmentRequest>): CreateEnvironmentRequest {
- const message = createBaseCreateEnvironmentRequest();
- message.environment = (object.environment !== undefined && object.environment !== null)
- ? Environment.fromPartial(object.environment)
- : undefined;
- message.environmentId = object.environmentId ?? "";
- return message;
- },
-};
-
-function createBaseUpdateEnvironmentRequest(): UpdateEnvironmentRequest {
- return { environment: undefined, updateMask: undefined };
-}
-
-export const UpdateEnvironmentRequest: MessageFns<UpdateEnvironmentRequest> = {
- encode(message: UpdateEnvironmentRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.environment !== undefined) {
- Environment.encode(message.environment, writer.uint32(10).fork()).join();
- }
- if (message.updateMask !== undefined) {
- FieldMask.encode(FieldMask.wrap(message.updateMask), writer.uint32(18).fork()).join();
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): UpdateEnvironmentRequest {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseUpdateEnvironmentRequest();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.environment = Environment.decode(reader, reader.uint32());
- continue;
- }
- case 2: {
- if (tag !== 18) {
- break;
- }
-
- message.updateMask = FieldMask.unwrap(FieldMask.decode(reader, reader.uint32()));
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): UpdateEnvironmentRequest {
- return {
- environment: isSet(object.environment) ? Environment.fromJSON(object.environment) : undefined,
- updateMask: isSet(object.updateMask) ? FieldMask.unwrap(FieldMask.fromJSON(object.updateMask)) : undefined,
- };
- },
-
- toJSON(message: UpdateEnvironmentRequest): unknown {
- const obj: any = {};
- if (message.environment !== undefined) {
- obj.environment = Environment.toJSON(message.environment);
- }
- if (message.updateMask !== undefined) {
- obj.updateMask = FieldMask.toJSON(FieldMask.wrap(message.updateMask));
- }
- return obj;
- },
-
- create(base?: DeepPartial<UpdateEnvironmentRequest>): UpdateEnvironmentRequest {
- return UpdateEnvironmentRequest.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<UpdateEnvironmentRequest>): UpdateEnvironmentRequest {
- const message = createBaseUpdateEnvironmentRequest();
- message.environment = (object.environment !== undefined && object.environment !== null)
- ? Environment.fromPartial(object.environment)
- : undefined;
- message.updateMask = object.updateMask ?? undefined;
- return message;
- },
-};
-
-function createBaseDeleteEnvironmentRequest(): DeleteEnvironmentRequest {
- return { name: "" };
-}
-
-export const DeleteEnvironmentRequest: MessageFns<DeleteEnvironmentRequest> = {
- encode(message: DeleteEnvironmentRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.name !== "") {
- writer.uint32(10).string(message.name);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): DeleteEnvironmentRequest {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseDeleteEnvironmentRequest();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.name = reader.string();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): DeleteEnvironmentRequest {
- return { name: isSet(object.name) ? globalThis.String(object.name) : "" };
- },
-
- toJSON(message: DeleteEnvironmentRequest): unknown {
- const obj: any = {};
- if (message.name !== "") {
- obj.name = message.name;
- }
- return obj;
- },
-
- create(base?: DeepPartial<DeleteEnvironmentRequest>): DeleteEnvironmentRequest {
- return DeleteEnvironmentRequest.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<DeleteEnvironmentRequest>): DeleteEnvironmentRequest {
- const message = createBaseDeleteEnvironmentRequest();
- message.name = object.name ?? "";
- return message;
- },
-};
-
-function createBaseUndeleteEnvironmentRequest(): UndeleteEnvironmentRequest {
- return { name: "" };
-}
-
-export const UndeleteEnvironmentRequest: MessageFns<UndeleteEnvironmentRequest> = {
- encode(message: UndeleteEnvironmentRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.name !== "") {
- writer.uint32(10).string(message.name);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): UndeleteEnvironmentRequest {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseUndeleteEnvironmentRequest();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.name = reader.string();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): UndeleteEnvironmentRequest {
- return { name: isSet(object.name) ? globalThis.String(object.name) : "" };
- },
-
- toJSON(message: UndeleteEnvironmentRequest): unknown {
- const obj: any = {};
- if (message.name !== "") {
- obj.name = message.name;
- }
- return obj;
- },
-
- create(base?: DeepPartial<UndeleteEnvironmentRequest>): UndeleteEnvironmentRequest {
- return UndeleteEnvironmentRequest.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<UndeleteEnvironmentRequest>): UndeleteEnvironmentRequest {
- const message = createBaseUndeleteEnvironmentRequest();
- message.name = object.name ?? "";
- return message;
- },
-};
-
-function createBaseEnvironment(): Environment {
- return {
- name: "",
- state: State.STATE_UNSPECIFIED,
- title: "",
- order: 0,
- tier: EnvironmentTier.ENVIRONMENT_TIER_UNSPECIFIED,
- color: "",
- };
-}
-
-export const Environment: MessageFns<Environment> = {
- encode(message: Environment, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.name !== "") {
- writer.uint32(10).string(message.name);
- }
- if (message.state !== State.STATE_UNSPECIFIED) {
- writer.uint32(24).int32(stateToNumber(message.state));
- }
- if (message.title !== "") {
- writer.uint32(34).string(message.title);
- }
- if (message.order !== 0) {
- writer.uint32(40).int32(message.order);
- }
- if (message.tier !== EnvironmentTier.ENVIRONMENT_TIER_UNSPECIFIED) {
- writer.uint32(48).int32(environmentTierToNumber(message.tier));
- }
- if (message.color !== "") {
- writer.uint32(58).string(message.color);
- }
- return writer;
- },
-
- decode(input: BinaryReader | Uint8Array, length?: number): Environment {
- const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
- let end = length === undefined ? reader.len : reader.pos + length;
- const message = createBaseEnvironment();
- while (reader.pos < end) {
- const tag = reader.uint32();
- switch (tag >>> 3) {
- case 1: {
- if (tag !== 10) {
- break;
- }
-
- message.name = reader.string();
- continue;
- }
- case 3: {
- if (tag !== 24) {
- break;
- }
-
- message.state = stateFromJSON(reader.int32());
- continue;
- }
- case 4: {
- if (tag !== 34) {
- break;
- }
-
- message.title = reader.string();
- continue;
- }
- case 5: {
- if (tag !== 40) {
- break;
- }
-
- message.order = reader.int32();
- continue;
- }
- case 6: {
- if (tag !== 48) {
- break;
- }
-
- message.tier = environmentTierFromJSON(reader.int32());
- continue;
- }
- case 7: {
- if (tag !== 58) {
- break;
- }
-
- message.color = reader.string();
- continue;
- }
- }
- if ((tag & 7) === 4 || tag === 0) {
- break;
- }
- reader.skip(tag & 7);
- }
- return message;
- },
-
- fromJSON(object: any): Environment {
- return {
- name: isSet(object.name) ? globalThis.String(object.name) : "",
- state: isSet(object.state) ? stateFromJSON(object.state) : State.STATE_UNSPECIFIED,
- title: isSet(object.title) ? globalThis.String(object.title) : "",
- order: isSet(object.order) ? globalThis.Number(object.order) : 0,
- tier: isSet(object.tier) ? environmentTierFromJSON(object.tier) : EnvironmentTier.ENVIRONMENT_TIER_UNSPECIFIED,
- color: isSet(object.color) ? globalThis.String(object.color) : "",
- };
- },
-
- toJSON(message: Environment): unknown {
- const obj: any = {};
- if (message.name !== "") {
- obj.name = message.name;
- }
- if (message.state !== State.STATE_UNSPECIFIED) {
- obj.state = stateToJSON(message.state);
- }
- if (message.title !== "") {
- obj.title = message.title;
- }
- if (message.order !== 0) {
- obj.order = Math.round(message.order);
- }
- if (message.tier !== EnvironmentTier.ENVIRONMENT_TIER_UNSPECIFIED) {
- obj.tier = environmentTierToJSON(message.tier);
- }
- if (message.color !== "") {
- obj.color = message.color;
- }
- return obj;
- },
-
- create(base?: DeepPartial<Environment>): Environment {
- return Environment.fromPartial(base ?? {});
- },
- fromPartial(object: DeepPartial<Environment>): Environment {
- const message = createBaseEnvironment();
- message.name = object.name ?? "";
- message.state = object.state ?? State.STATE_UNSPECIFIED;
- message.title = object.title ?? "";
- message.order = object.order ?? 0;
- message.tier = object.tier ?? EnvironmentTier.ENVIRONMENT_TIER_UNSPECIFIED;
- message.color = object.color ?? "";
- return message;
- },
-};
-
-export type EnvironmentServiceDefinition = typeof EnvironmentServiceDefinition;
-export const EnvironmentServiceDefinition = {
- name: "EnvironmentService",
- fullName: "bytebase.v1.EnvironmentService",
- methods: {
- getEnvironment: {
- name: "GetEnvironment",
- requestType: GetEnvironmentRequest,
- requestStream: false,
- responseType: Environment,
- responseStream: false,
- options: {
- _unknownFields: {
- 8410: [new Uint8Array([4, 110, 97, 109, 101])],
- 800010: [
- new Uint8Array([
- 19,
- 98,
- 98,
- 46,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 115,
- 46,
- 103,
- 101,
- 116,
- ]),
- ],
- 800016: [new Uint8Array([1])],
- 578365826: [
- new Uint8Array([
- 27,
- 18,
- 25,
- 47,
- 118,
- 49,
- 47,
- 123,
- 110,
- 97,
- 109,
- 101,
- 61,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 115,
- 47,
- 42,
- 125,
- ]),
- ],
- },
- },
- },
- listEnvironments: {
- name: "ListEnvironments",
- requestType: ListEnvironmentsRequest,
- requestStream: false,
- responseType: ListEnvironmentsResponse,
- responseStream: false,
- options: {
- _unknownFields: {
- 8410: [new Uint8Array([0])],
- 800010: [
- new Uint8Array([
- 20,
- 98,
- 98,
- 46,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 115,
- 46,
- 108,
- 105,
- 115,
- 116,
- ]),
- ],
- 800016: [new Uint8Array([1])],
- 578365826: [
- new Uint8Array([18, 18, 16, 47, 118, 49, 47, 101, 110, 118, 105, 114, 111, 110, 109, 101, 110, 116, 115]),
- ],
- },
- },
- },
- createEnvironment: {
- name: "CreateEnvironment",
- requestType: CreateEnvironmentRequest,
- requestStream: false,
- responseType: Environment,
- responseStream: false,
- options: {
- _unknownFields: {
- 8410: [new Uint8Array([0])],
- 800010: [
- new Uint8Array([
- 22,
- 98,
- 98,
- 46,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 115,
- 46,
- 99,
- 114,
- 101,
- 97,
- 116,
- 101,
- ]),
- ],
- 800016: [new Uint8Array([1])],
- 800024: [new Uint8Array([1])],
- 578365826: [
- new Uint8Array([
- 31,
- 58,
- 11,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 34,
- 16,
- 47,
- 118,
- 49,
- 47,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 115,
- ]),
- ],
- },
- },
- },
- updateEnvironment: {
- name: "UpdateEnvironment",
- requestType: UpdateEnvironmentRequest,
- requestStream: false,
- responseType: Environment,
- responseStream: false,
- options: {
- _unknownFields: {
- 8410: [
- new Uint8Array([
- 23,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 44,
- 117,
- 112,
- 100,
- 97,
- 116,
- 101,
- 95,
- 109,
- 97,
- 115,
- 107,
- ]),
- ],
- 800010: [
- new Uint8Array([
- 22,
- 98,
- 98,
- 46,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 115,
- 46,
- 117,
- 112,
- 100,
- 97,
- 116,
- 101,
- ]),
- ],
- 800016: [new Uint8Array([1])],
- 800024: [new Uint8Array([1])],
- 578365826: [
- new Uint8Array([
- 52,
- 58,
- 11,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 50,
- 37,
- 47,
- 118,
- 49,
- 47,
- 123,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 46,
- 110,
- 97,
- 109,
- 101,
- 61,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 115,
- 47,
- 42,
- 125,
- ]),
- ],
- },
- },
- },
- deleteEnvironment: {
- name: "DeleteEnvironment",
- requestType: DeleteEnvironmentRequest,
- requestStream: false,
- responseType: Empty,
- responseStream: false,
- options: {
- _unknownFields: {
- 8410: [new Uint8Array([4, 110, 97, 109, 101])],
- 800010: [
- new Uint8Array([
- 22,
- 98,
- 98,
- 46,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 115,
- 46,
- 100,
- 101,
- 108,
- 101,
- 116,
- 101,
- ]),
- ],
- 800016: [new Uint8Array([1])],
- 800024: [new Uint8Array([1])],
- 578365826: [
- new Uint8Array([
- 27,
- 42,
- 25,
- 47,
- 118,
- 49,
- 47,
- 123,
- 110,
- 97,
- 109,
- 101,
- 61,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 115,
- 47,
- 42,
- 125,
- ]),
- ],
- },
- },
- },
- undeleteEnvironment: {
- name: "UndeleteEnvironment",
- requestType: UndeleteEnvironmentRequest,
- requestStream: false,
- responseType: Environment,
- responseStream: false,
- options: {
- _unknownFields: {
- 800010: [
- new Uint8Array([
- 24,
- 98,
- 98,
- 46,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 115,
- 46,
- 117,
- 110,
- 100,
- 101,
- 108,
- 101,
- 116,
- 101,
- ]),
- ],
- 800016: [new Uint8Array([1])],
- 800024: [new Uint8Array([1])],
- 578365826: [
- new Uint8Array([
- 39,
- 58,
- 1,
- 42,
- 34,
- 34,
- 47,
- 118,
- 49,
- 47,
- 123,
- 110,
- 97,
- 109,
- 101,
- 61,
- 101,
- 110,
- 118,
- 105,
- 114,
- 111,
- 110,
- 109,
- 101,
- 110,
- 116,
- 115,
- 47,
- 42,
- 125,
- 58,
- 117,
- 110,
- 100,
- 101,
- 108,
- 101,
- 116,
- 101,
- ]),
- ],
- },
- },
- },
- },
-} as const;
-
-type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
-
-export type DeepPartial<T> = T extends Builtin ? T
- : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
- : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
- : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
- : Partial<T>;
-
-function isSet(value: any): boolean {
- return value !== null && value !== undefined;
-}
-
-export interface MessageFns<T> {
- encode(message: T, writer?: BinaryWriter): BinaryWriter;
- decode(input: BinaryReader | Uint8Array, length?: number): T;
- fromJSON(object: any): T;
- toJSON(message: T): unknown;
- create(base?: DeepPartial<T>): T;
- fromPartial(object: DeepPartial<T>): T;
-}
diff --git a/frontend/src/types/proto/v1/setting_service.ts b/frontend/src/types/proto/v1/setting_service.ts
index 76c615a232..e741870399 100644
--- a/frontend/src/types/proto/v1/setting_service.ts
+++ b/frontend/src/types/proto/v1/setting_service.ts
@@ -789,20 +789,25 @@ export function aISetting_ProviderToNumber(object: AISetting_Provider): number {
}
}
-/** TODO(p0ny): implement. */
export interface EnvironmentSetting {
environments: EnvironmentSetting_Environment[];
}
export interface EnvironmentSetting_Environment {
- /** The display name of the environment. */
- title: string;
+ /**
+ * The resource name of the environment.
+ * Format: environments/{environment}.
+ * Output only.
+ */
+ name: string;
/**
* The resource id of the environment.
* This value should be 4-63 characters, and valid characters
* are /[a-z][0-9]-/.
*/
id: string;
+ /** The display name of the environment. */
+ title: string;
tags: { [key: string]: string };
color: string;
}
@@ -5359,22 +5364,25 @@ export const EnvironmentSetting: MessageFns<EnvironmentSetting> = {
};
function createBaseEnvironmentSetting_Environment(): EnvironmentSetting_Environment {
- return { title: "", id: "", tags: {}, color: "" };
+ return { name: "", id: "", title: "", tags: {}, color: "" };
}
export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Environment> = {
encode(message: EnvironmentSetting_Environment, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
- if (message.title !== "") {
- writer.uint32(10).string(message.title);
+ if (message.name !== "") {
+ writer.uint32(10).string(message.name);
}
if (message.id !== "") {
writer.uint32(18).string(message.id);
}
+ if (message.title !== "") {
+ writer.uint32(26).string(message.title);
+ }
Object.entries(message.tags).forEach(([key, value]) => {
- EnvironmentSetting_Environment_TagsEntry.encode({ key: key as any, value }, writer.uint32(26).fork()).join();
+ EnvironmentSetting_Environment_TagsEntry.encode({ key: key as any, value }, writer.uint32(34).fork()).join();
});
if (message.color !== "") {
- writer.uint32(34).string(message.color);
+ writer.uint32(42).string(message.color);
}
return writer;
},
@@ -5391,7 +5399,7 @@ export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Envir
break;
}
- message.title = reader.string();
+ message.name = reader.string();
continue;
}
case 2: {
@@ -5407,10 +5415,7 @@ export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Envir
break;
}
- const entry3 = EnvironmentSetting_Environment_TagsEntry.decode(reader, reader.uint32());
- if (entry3.value !== undefined) {
- message.tags[entry3.key] = entry3.value;
- }
+ message.title = reader.string();
continue;
}
case 4: {
@@ -5418,6 +5423,17 @@ export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Envir
break;
}
+ const entry4 = EnvironmentSetting_Environment_TagsEntry.decode(reader, reader.uint32());
+ if (entry4.value !== undefined) {
+ message.tags[entry4.key] = entry4.value;
+ }
+ continue;
+ }
+ case 5: {
+ if (tag !== 42) {
+ break;
+ }
+
message.color = reader.string();
continue;
}
@@ -5432,8 +5448,9 @@ export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Envir
fromJSON(object: any): EnvironmentSetting_Environment {
return {
- title: isSet(object.title) ? globalThis.String(object.title) : "",
+ name: isSet(object.name) ? globalThis.String(object.name) : "",
id: isSet(object.id) ? globalThis.String(object.id) : "",
+ title: isSet(object.title) ? globalThis.String(object.title) : "",
tags: isObject(object.tags)
? Object.entries(object.tags).reduce<{ [key: string]: string }>((acc, [key, value]) => {
acc[key] = String(value);
@@ -5446,12 +5463,15 @@ export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Envir
toJSON(message: EnvironmentSetting_Environment): unknown {
const obj: any = {};
- if (message.title !== "") {
- obj.title = message.title;
+ if (message.name !== "") {
+ obj.name = message.name;
}
if (message.id !== "") {
obj.id = message.id;
}
+ if (message.title !== "") {
+ obj.title = message.title;
+ }
if (message.tags) {
const entries = Object.entries(message.tags);
if (entries.length > 0) {
@@ -5472,8 +5492,9 @@ export const EnvironmentSetting_Environment: MessageFns<EnvironmentSetting_Envir
},
fromPartial(object: DeepPartial<EnvironmentSetting_Environment>): EnvironmentSetting_Environment {
const message = createBaseEnvironmentSetting_Environment();
- message.title = object.title ?? "";
+ message.name = object.name ?? "";
message.id = object.id ?? "";
+ message.title = object.title ?? "";
message.tags = Object.entries(object.tags ?? {}).reduce<{ [key: string]: string }>((acc, [key, value]) => {
if (value !== undefined) {
acc[key] = globalThis.String(value);
diff --git a/frontend/src/types/sqlEditor/tree.ts b/frontend/src/types/sqlEditor/tree.ts
index d54be2c955..d7bda3ab02 100644
--- a/frontend/src/types/sqlEditor/tree.ts
+++ b/frontend/src/types/sqlEditor/tree.ts
@@ -1,6 +1,6 @@
import type { TreeOption } from "naive-ui";
import { t } from "@/plugins/i18n";
-import type { Environment } from "../proto/v1/environment_service";
+import type { Environment } from "../v1/environment";
import type { InstanceResource } from "../proto/v1/instance_service";
import type { ComposedDatabase } from "../v1";
diff --git a/frontend/src/types/v1/database.ts b/frontend/src/types/v1/database.ts
index 0959dbf865..2fda4facbb 100644
--- a/frontend/src/types/v1/database.ts
+++ b/frontend/src/types/v1/database.ts
@@ -2,9 +2,9 @@ import { extractDatabaseResourceName, isNullOrUndefined } from "@/utils";
import { EMPTY_ID, UNKNOWN_ID } from "../const";
import { State } from "../proto/v1/common";
import { Database } from "../proto/v1/database_service";
-import type { Environment } from "../proto/v1/environment_service";
+import type { Environment } from "../v1/environment";
import type { InstanceResource } from "../proto/v1/instance_service";
-import { unknownEnvironment } from "./environment";
+import { formatEnvironmentName, unknownEnvironment } from "./environment";
import { unknownInstance, unknownInstanceResource } from "./instance";
import type { ComposedProject } from "./project";
import { unknownProject } from "./project";
@@ -33,7 +33,7 @@ export const unknownDatabase = (): ComposedDatabase => {
uid: String(UNKNOWN_ID),
state: State.ACTIVE,
project: projectEntity.name,
- effectiveEnvironment: effectiveEnvironmentEntity.name,
+ effectiveEnvironment: formatEnvironmentName(effectiveEnvironmentEntity.id),
});
return {
...database,
diff --git a/frontend/src/types/v1/environment.ts b/frontend/src/types/v1/environment.ts
index def6d9daaa..93ce1f89a8 100644
--- a/frontend/src/types/v1/environment.ts
+++ b/frontend/src/types/v1/environment.ts
@@ -1,27 +1,30 @@
import { EMPTY_ID, UNKNOWN_ID } from "../const";
-import { State } from "../proto/v1/common";
-import { Environment, EnvironmentTier } from "../proto/v1/environment_service";
+import type { EnvironmentSetting_Environment } from "../proto/v1/setting_service";
+import { environmentNamePrefix } from "@/store";
export const ENVIRONMENT_ALL_NAME = "environments/-";
export const EMPTY_ENVIRONMENT_NAME = `environments/${EMPTY_ID}`;
export const UNKNOWN_ENVIRONMENT_NAME = `environments/${UNKNOWN_ID}`;
-export const emptyEnvironment = () => {
- return Environment.fromJSON({
+export interface Environment extends EnvironmentSetting_Environment {
+ order: number
+}
+
+export const emptyEnvironment = (): Environment => {
+ return {
name: EMPTY_ENVIRONMENT_NAME,
- uid: String(EMPTY_ID),
- title: "",
- state: State.ACTIVE,
+ id: String(EMPTY_ID),
order: 0,
- tier: EnvironmentTier.UNPROTECTED,
- });
+ title: "",
+ tags: {},
+ color: "",
+ }
};
-export const unknownEnvironment = () => {
+export const unknownEnvironment = (): Environment => {
return {
...emptyEnvironment(),
- name: UNKNOWN_ENVIRONMENT_NAME,
- uid: String(UNKNOWN_ID),
+ id: String(UNKNOWN_ID),
title: "<<Unknown environment>>",
};
};
@@ -34,3 +37,7 @@ export const isValidEnvironmentName = (name: any): name is string => {
name !== UNKNOWN_ENVIRONMENT_NAME
);
};
+
+export const formatEnvironmentName = (envId: string | undefined): string => {
+ return `${environmentNamePrefix}${envId ?? ""}`;
+}
\ No newline at end of file
diff --git a/frontend/src/types/v1/instance.ts b/frontend/src/types/v1/instance.ts
index 04442f0573..b1291ab1aa 100644
--- a/frontend/src/types/v1/instance.ts
+++ b/frontend/src/types/v1/instance.ts
@@ -1,6 +1,6 @@
import { EMPTY_ID, UNKNOWN_ID } from "../const";
import { Engine, State } from "../proto/v1/common";
-import type { Environment } from "../proto/v1/environment_service";
+import type { Environment } from "@/types/v1/environment";
import { Instance, InstanceResource } from "../proto/v1/instance_service";
import {
EMPTY_ENVIRONMENT_NAME,
@@ -8,6 +8,7 @@ import {
UNKNOWN_ENVIRONMENT_NAME,
unknownEnvironment,
} from "./environment";
+import { environmentNamePrefix } from "@/store";
export const EMPTY_INSTANCE_NAME = `instances/${EMPTY_ID}`;
export const UNKNOWN_INSTANCE_NAME = `instances/${UNKNOWN_ID}`;
@@ -24,7 +25,7 @@ export const emptyInstance = (): ComposedInstance => {
state: State.ACTIVE,
title: "",
engine: Engine.MYSQL,
- environment: environmentEntity.name,
+ environment: `${environmentNamePrefix}${environmentEntity.id}`,
});
return {
...instance,
@@ -39,7 +40,7 @@ export const unknownInstance = (): ComposedInstance => {
name: UNKNOWN_INSTANCE_NAME,
uid: String(UNKNOWN_ID),
title: "<<Unknown instance>>",
- environment: environmentEntity.name,
+ environment: `${environmentNamePrefix}${environmentEntity.id}`,
};
return {
...instance,
diff --git a/frontend/src/utils/auto-route.ts b/frontend/src/utils/auto-route.ts
index fb7879b772..6dbc39eb2d 100644
--- a/frontend/src/utils/auto-route.ts
+++ b/frontend/src/utils/auto-route.ts
@@ -20,7 +20,7 @@ import {
import { useAppFeature } from "@/store";
import type { User } from "@/types/proto/v1/user_service";
import type { Database } from "@/types/proto/v1/database_service";
-import type { Environment } from "@/types/proto/v1/environment_service";
+import { formatEnvironmentName, type Environment } from "@/types/v1/environment";
import type {
Instance,
InstanceResource,
@@ -29,7 +29,6 @@ import type { Project } from "@/types/proto/v1/project_service";
import { DatabaseChangeMode } from "@/types/proto/v1/setting_service";
import {
extractDatabaseResourceName,
- extractEnvironmentResourceName,
extractInstanceResourceName,
extractProjectResourceName,
} from "./v1";
@@ -107,11 +106,11 @@ export const autoEnvironmentRoute = (
if (shouldGoToSQLEditorRoute(router)) {
return {
name: SQL_EDITOR_SETTING_ENVIRONMENT_MODULE,
- hash: `#${extractEnvironmentResourceName(environment.name)}`,
+ hash: `#${environment.id}`,
};
}
return {
- path: `/${environment.name}`,
+ path: `/${formatEnvironmentName(environment.id)}`,
};
};
diff --git a/frontend/src/utils/v1/database.ts b/frontend/src/utils/v1/database.ts
index f43140436e..97b1a57129 100644
--- a/frontend/src/utils/v1/database.ts
+++ b/frontend/src/utils/v1/database.ts
@@ -5,7 +5,6 @@ import {
} from "@/store/modules/v1/common";
import { QueryPermissionQueryAny, UNKNOWN_ID } from "@/types";
import type { ComposedDatabase, QueryPermission } from "@/types";
-import { State } from "@/types/proto/v1/common";
import {
hasPermissionToCreateChangeDatabaseIssue,
hasWorkspacePermissionV2,
@@ -44,10 +43,8 @@ export const extractDatabaseResourceName = (
};
};
-export const isArchivedDatabaseV1 = (db: ComposedDatabase): boolean => {
- if (db.effectiveEnvironmentEntity.state === State.DELETED) {
- return true;
- }
+// TODO(p0ny): remove
+export const isArchivedDatabaseV1 = (_db: ComposedDatabase): boolean => {
return false;
};
diff --git a/frontend/src/utils/v1/environment.ts b/frontend/src/utils/v1/environment.ts
index a2b7c78ad0..1e2992fbba 100644
--- a/frontend/src/utils/v1/environment.ts
+++ b/frontend/src/utils/v1/environment.ts
@@ -1,5 +1,4 @@
-import { State } from "@/types/proto/v1/common";
-import type { Environment } from "@/types/proto/v1/environment_service";
+import type { Environment } from "@/types/v1/environment";
export const extractEnvironmentResourceName = (name: string) => {
const pattern = /(?:^|\/)environments\/([^/]+)(?:$|\/)/;
@@ -9,8 +8,5 @@ export const extractEnvironmentResourceName = (name: string) => {
export function environmentV1Name(environment: Environment) {
const parts = [environment.title];
- if (environment.state === State.DELETED) {
- parts.push("(Archived)");
- }
return parts.join(" ");
}
diff --git a/frontend/src/views/Archive.vue b/frontend/src/views/Archive.vue
index 937a6d56f3..9f7b748c7c 100644
--- a/frontend/src/views/Archive.vue
+++ b/frontend/src/views/Archive.vue
@@ -88,9 +88,7 @@ const prepareList = async () => {
watchEffect(prepareList);
const environmentList = computed(() => {
- return environmentStore.environmentList.filter(
- (env) => env.state === State.DELETED
- );
+ return environmentStore.environmentList;
});
const deletedSSOList = computed(() => {
diff --git a/frontend/src/views/EnvironmentDashboard.vue b/frontend/src/views/EnvironmentDashboard.vue
index 7c8bdfbb82..1d74f6d773 100644
--- a/frontend/src/views/EnvironmentDashboard.vue
+++ b/frontend/src/views/EnvironmentDashboard.vue
@@ -70,7 +70,6 @@
:create="true"
:environment="getEnvironmentCreate()"
:rollout-policy="DEFAULT_NEW_ROLLOUT_POLICY"
- :environment-tier="defaultEnvironmentTier"
@create="doCreate"
@cancel="state.showCreateModal = false"
>
@@ -107,8 +106,8 @@ import { ENVIRONMENT_V1_ROUTE_DASHBOARD } from "@/router/dashboard/workspaceRout
import {
useUIStateStore,
useEnvironmentV1Store,
- defaultEnvironmentTier,
useEnvironmentV1List,
+ environmentNamePrefix,
} from "@/store";
import {
usePolicyV1Store,
@@ -117,13 +116,11 @@ import {
import { emptyEnvironment } from "@/types";
import type {
Environment,
- EnvironmentTier,
-} from "@/types/proto/v1/environment_service";
+} from "@/types/v1/environment";
import type { Policy } from "@/types/proto/v1/org_policy_service";
import { PolicyResourceType } from "@/types/proto/v1/org_policy_service";
import {
arraySwap,
- extractEnvironmentResourceName,
hasWorkspacePermissionV2,
} from "@/utils";
import EnvironmentDetail from "@/views/EnvironmentDetail.vue";
@@ -159,9 +156,7 @@ const selectEnvironmentOnHash = () => {
if (environmentList.value.length > 0) {
if (router.currentRoute.value.hash) {
for (let i = 0; i < environmentList.value.length; i++) {
- const id = extractEnvironmentResourceName(
- environmentList.value[i].name
- );
+ const id = environmentList.value[i].id
if (id === router.currentRoute.value.hash.slice(1)) {
selectEnvironment(i);
break;
@@ -202,7 +197,7 @@ const tabItemList = computed((): BBTabItem[] => {
: environmentList.value;
return list.map((item, index: number): BBTabItem => {
const title = `${index + 1}. ${item.title}`;
- const id = extractEnvironmentResourceName(item.name);
+ const id = item.id
return { title, id, data: item };
});
}
@@ -221,21 +216,19 @@ const createEnvironment = () => {
const doCreate = async (params: {
environment: Partial<Environment>;
rolloutPolicy: Policy;
- environmentTier: EnvironmentTier;
}) => {
- const { environment, rolloutPolicy, environmentTier } = params;
+ const { environment, rolloutPolicy } = params;
const createdEnvironment = await environmentV1Store.createEnvironment({
- name: environment.name,
+ id: environment.id,
title: environment.title,
order: environmentList.value.length,
color: environment.color,
- tier: environmentTier,
});
await environmentV1Store.fetchEnvironments();
const requests = [
policyV1Store.upsertPolicy({
- parentPath: createdEnvironment.name,
+ parentPath:`${environmentNamePrefix}${createdEnvironment.id}`,
policy: rolloutPolicy,
}),
];
@@ -262,7 +255,7 @@ const reorderEnvironment = (sourceIndex: number, targetIndex: number) => {
const orderChanged = computed(() => {
for (let i = 0; i < state.reorderedEnvironmentList.length; i++) {
if (
- state.reorderedEnvironmentList[i].name != environmentList.value[i].name
+ state.reorderedEnvironmentList[i].id!= environmentList.value[i].id
) {
return true;
}
@@ -289,7 +282,7 @@ const doArchive = (/* environment: Environment */) => {
};
const selectEnvironment = (index: number) => {
- const id = extractEnvironmentResourceName(environmentList.value[index].name);
+ const id = environmentList.value[index].id;
onTabChange(id);
};
diff --git a/frontend/src/views/EnvironmentDetail.vue b/frontend/src/views/EnvironmentDetail.vue
index d29803f1fd..d44379c006 100644
--- a/frontend/src/views/EnvironmentDetail.vue
+++ b/frontend/src/views/EnvironmentDetail.vue
@@ -1,16 +1,10 @@
<template>
- <div v-if="state.environment.state == State.DELETED" class="mb-2 -mt-4">
- <ArchiveBanner />
- </div>
-
<EnvironmentForm
- v-if="state.rolloutPolicy && state.environmentTier"
+ v-if="state.rolloutPolicy"
:environment="state.environment"
:rollout-policy="state.rolloutPolicy"
- :environment-tier="state.environmentTier"
@update="doUpdate"
@archive="doArchive"
- @restore="doRestore"
@update-policy="updatePolicy"
>
<EnvironmentFormBody
@@ -27,10 +21,9 @@
</template>
<script lang="ts" setup>
-import { cloneDeep } from "lodash-es";
-import { reactive, watch, watchEffect } from "vue";
+import { cloneDeep, isEqual } from "lodash-es";
+import { computed, reactive, watch, watchEffect } from "vue";
import { useRouter } from "vue-router";
-import ArchiveBanner from "@/components/ArchiveBanner.vue";
import {
EnvironmentForm,
Form as EnvironmentFormBody,
@@ -43,24 +36,19 @@ import {
usePolicyV1Store,
getEmptyRolloutPolicy,
} from "@/store/modules/v1/policy";
-import { unknownEnvironment } from "@/types";
-import { State } from "@/types/proto/v1/common";
-import type {
- Environment,
- EnvironmentTier,
-} from "@/types/proto/v1/environment_service";
+import { formatEnvironmentName, unknownEnvironment } from "@/types";
import type { Policy } from "@/types/proto/v1/org_policy_service";
import {
PolicyType,
PolicyResourceType,
} from "@/types/proto/v1/org_policy_service";
-import { extractEnvironmentResourceName, type VueClass } from "@/utils";
+import type { Environment } from "@/types/v1/environment";
+import { type VueClass } from "@/utils";
interface LocalState {
environment: Environment;
showArchiveModal: boolean;
rolloutPolicy?: Policy;
- environmentTier?: EnvironmentTier;
}
const props = defineProps<{
@@ -85,6 +73,10 @@ const state = reactive<LocalState>({
showArchiveModal: false,
});
+const stateEnvironmentName = computed(() => {
+ return formatEnvironmentName(state.environment.id);
+});
+
const prepareEnvironment = async () => {
await environmentV1Store.getOrFetchEnvironmentByName(
`${environmentNamePrefix}${props.environmentName}`
@@ -98,7 +90,7 @@ watch(() => props.environmentName, prepareEnvironment, {
const preparePolicy = () => {
policyV1Store
.fetchPolicies({
- parent: state.environment.name,
+ parent: stateEnvironmentName.value,
resourceType: PolicyResourceType.ENVIRONMENT,
})
.then((policies) => {
@@ -108,12 +100,10 @@ const preparePolicy = () => {
state.rolloutPolicy =
rolloutPolicy ||
getEmptyRolloutPolicy(
- state.environment.name,
+ stateEnvironmentName.value,
PolicyResourceType.ENVIRONMENT
);
});
-
- state.environmentTier = state.environment.tier;
};
watchEffect(preparePolicy);
@@ -127,8 +117,8 @@ const doUpdate = (environmentPatch: Environment) => {
if (environmentPatch.title !== pendingUpdate.title) {
pendingUpdate.title = environmentPatch.title;
}
- if (environmentPatch.tier !== pendingUpdate.tier) {
- pendingUpdate.tier = environmentPatch.tier;
+ if (!isEqual(environmentPatch.tags, pendingUpdate.tags)) {
+ pendingUpdate.tags = environmentPatch.tags;
}
if (environmentPatch.color !== pendingUpdate.color) {
pendingUpdate.color = environmentPatch.color;
@@ -140,25 +130,13 @@ const doUpdate = (environmentPatch: Environment) => {
};
const doArchive = (environment: Environment) => {
- environmentV1Store.deleteEnvironment(environment.name).then(() => {
- emit("archive", environment);
- environment.state = State.DELETED;
- assignEnvironment(environment);
- router.replace({
- name: ENVIRONMENT_V1_ROUTE_DASHBOARD,
- });
- });
-};
-
-const doRestore = (environment: Environment) => {
environmentV1Store
- .undeleteEnvironment(environment.name)
- .then((environment) => {
+ .deleteEnvironment(formatEnvironmentName(environment.id))
+ .then(() => {
+ emit("archive", environment);
assignEnvironment(environment);
- const id = extractEnvironmentResourceName(environment.name);
router.replace({
name: ENVIRONMENT_V1_ROUTE_DASHBOARD,
- hash: `#${id}`,
});
});
};
@@ -171,7 +149,7 @@ const updatePolicy = async (params: {
const { environment, policyType, policy } = params;
const updatedPolicy = await policyV1Store.upsertPolicy({
- parentPath: environment.name,
+ parentPath: formatEnvironmentName(environment.id),
policy,
});
switch (policyType) {
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vue
index 65b01211d0..b4520a77ed 100644
--- a/frontend/src/views/InstanceDetail.vue
+++ b/frontend/src/views/InstanceDetail.vue
@@ -76,7 +76,7 @@
:title="$t('quick-action.create-db')"
>
<CreateDatabasePrepPanel
- :environment-name="environment?.name"
+ :environment-name="formatEnvironmentName(environment?.id)"
:instance-name="instance.name"
@dismiss="state.showCreateDatabaseModal = false"
/>
@@ -120,7 +120,11 @@ import {
projectNamePrefix,
environmentNamePrefix,
} from "@/store/modules/v1/common";
-import { type ComposedDatabase, isValidDatabaseName } from "@/types";
+import {
+ type ComposedDatabase,
+ formatEnvironmentName,
+ isValidDatabaseName,
+} from "@/types";
import { State } from "@/types/proto/v1/common";
import { DatabaseChangeMode } from "@/types/proto/v1/setting_service";
import {
diff --git a/frontend/src/views/sql-editor/Setting/Environment/Environment.vue b/frontend/src/views/sql-editor/Setting/Environment/Environment.vue
index 2eb375226a..df7703f081 100644
--- a/frontend/src/views/sql-editor/Setting/Environment/Environment.vue
+++ b/frontend/src/views/sql-editor/Setting/Environment/Environment.vue
@@ -80,7 +80,6 @@
:create="true"
:environment="getEnvironmentCreate()"
:rollout-policy="DEFAULT_NEW_ROLLOUT_POLICY"
- :environment-tier="defaultEnvironmentTier"
@create="doCreate"
@cancel="state.showCreateModal = false"
>
@@ -119,23 +118,20 @@ import { EnvironmentV1Name } from "@/components/v2";
import { SQL_EDITOR_SETTING_ENVIRONMENT_MODULE } from "@/router/sqlEditor";
import {
useEnvironmentV1Store,
- defaultEnvironmentTier,
useEnvironmentV1List,
} from "@/store";
import {
usePolicyV1Store,
getEmptyRolloutPolicy,
} from "@/store/modules/v1/policy";
-import { emptyEnvironment } from "@/types";
+import { emptyEnvironment, formatEnvironmentName } from "@/types";
import type {
Environment,
- EnvironmentTier,
-} from "@/types/proto/v1/environment_service";
+} from "@/types/v1/environment";
import type { Policy } from "@/types/proto/v1/org_policy_service";
import { PolicyResourceType } from "@/types/proto/v1/org_policy_service";
import {
arraySwap,
- extractEnvironmentResourceName,
hasWorkspacePermissionV2,
} from "@/utils";
import EnvironmentDetail from "@/views/EnvironmentDetail.vue";
@@ -175,9 +171,7 @@ const selectEnvironmentOnHash = () => {
if (environmentList.value.length > 0) {
if (route.hash) {
for (let i = 0; i < environmentList.value.length; i++) {
- const id = extractEnvironmentResourceName(
- environmentList.value[i].name
- );
+ const id = environmentList.value[i].id;
if (id === route.hash.slice(1)) {
selectEnvironment(i);
break;
@@ -192,7 +186,7 @@ const selectEnvironmentOnHash = () => {
const orderChanged = computed(() => {
for (let i = 0; i < state.reorderedEnvironmentList.length; i++) {
if (
- state.reorderedEnvironmentList[i].name != environmentList.value[i].name
+ state.reorderedEnvironmentList[i].id != environmentList.value[i].id
) {
return true;
}
@@ -236,7 +230,7 @@ const tabItemList = computed((): BBTabItem[] => {
: environmentList.value;
return list.map((item, index: number): BBTabItem => {
const title = `${index + 1}. ${item.title}`;
- const id = extractEnvironmentResourceName(item.name);
+ const id = item.id
return { title, id, data: item };
});
}
@@ -254,21 +248,20 @@ const handleClickCreateEnvironment = () => {
const doCreate = async (params: {
environment: Partial<Environment>;
rolloutPolicy: Policy;
- environmentTier: EnvironmentTier;
}) => {
- const { environment, rolloutPolicy, environmentTier } = params;
+ const { environment, rolloutPolicy } = params;
const createdEnvironment = await environmentV1Store.createEnvironment({
- name: environment.name,
+ id: environment.id,
title: environment.title,
color: environment.color,
order: environmentList.value.length,
- tier: environmentTier,
+ tags: environment.tags,
});
await environmentV1Store.fetchEnvironments();
const requests = [
policyV1Store.upsertPolicy({
- parentPath: createdEnvironment.name,
+ parentPath: formatEnvironmentName(createdEnvironment.id),
policy: rolloutPolicy,
}),
];
@@ -284,7 +277,7 @@ const doArchive = (/* environment: Environment */) => {
};
const selectEnvironment = (index: number) => {
- const id = extractEnvironmentResourceName(environmentList.value[index].name);
+ const id = environmentList.value[index].id;
onTabChange(id);
};
diff --git a/frontend/src/views/sql-editor/SheetPanel/SheetTable/SheetConnection.vue b/frontend/src/views/sql-editor/SheetPanel/SheetTable/SheetConnection.vue
index 664961a636..262d614c2b 100644
--- a/frontend/src/views/sql-editor/SheetPanel/SheetTable/SheetConnection.vue
+++ b/frontend/src/views/sql-editor/SheetPanel/SheetTable/SheetConnection.vue
@@ -15,7 +15,10 @@
<heroicons-outline:database />
<EnvironmentV1Name
- v-if="instanceEnvironment.name !== database.effectiveEnvironment"
+ v-if="
+ formatEnvironmentName(instanceEnvironment.id) !==
+ database.effectiveEnvironment
+ "
:environment="instanceEnvironment"
:link="false"
:show-icon="false"
@@ -36,7 +39,11 @@ import {
EnvironmentV1Name,
} from "@/components/v2";
import { useDatabaseV1Store, useEnvironmentV1Store } from "@/store";
-import { isValidDatabaseName, unknownEnvironment } from "@/types";
+import {
+ formatEnvironmentName,
+ isValidDatabaseName,
+ unknownEnvironment,
+} from "@/types";
import type { Worksheet } from "@/types/proto/v1/worksheet_service";
const props = defineProps<{
diff --git a/frontend/src/views/sql-editor/TabList/TabItem/AdminLabel.vue b/frontend/src/views/sql-editor/TabList/TabItem/AdminLabel.vue
index 1527131e77..7c053e46b7 100644
--- a/frontend/src/views/sql-editor/TabList/TabItem/AdminLabel.vue
+++ b/frontend/src/views/sql-editor/TabList/TabItem/AdminLabel.vue
@@ -22,7 +22,7 @@ import { ChevronRightIcon } from "lucide-vue-next";
import { computed } from "vue";
import { EnvironmentV1Name } from "@/components/v2";
import { useAppFeature, useDatabaseV1ByName } from "@/store";
-import { type SQLEditorTab, UNKNOWN_ENVIRONMENT_NAME } from "@/types";
+import { type SQLEditorTab, UNKNOWN_ID } from "@/types";
import { isValidInstanceName, isValidDatabaseName } from "@/types";
const props = defineProps<{
@@ -42,7 +42,7 @@ const instance = computed(() => {
const hideEnvironment = computed(() => {
return (
useAppFeature("bb.feature.sql-editor.hide-environments").value ||
- database.value.effectiveEnvironmentEntity?.name === UNKNOWN_ENVIRONMENT_NAME
+ database.value.effectiveEnvironmentEntity?.id === String(UNKNOWN_ID)
);
});
</script>
diff --git a/frontend/src/views/sql-editor/TabList/TabItem/TabItem.vue b/frontend/src/views/sql-editor/TabList/TabItem/TabItem.vue
index 6b344cf121..7690375851 100644
--- a/frontend/src/views/sql-editor/TabList/TabItem/TabItem.vue
+++ b/frontend/src/views/sql-editor/TabList/TabItem/TabItem.vue
@@ -38,7 +38,10 @@
<script lang="ts" setup>
import { computed, reactive } from "vue";
import { useSQLEditorTabStore } from "@/store";
-import { type SQLEditorTab, UNKNOWN_ENVIRONMENT_NAME } from "@/types";
+import {
+ type SQLEditorTab,
+ UNKNOWN_ID,
+} from "@/types";
import { connectionForSQLEditorTab, hexToRgb } from "@/utils";
import AdminLabel from "./AdminLabel.vue";
import Label from "./Label.vue";
@@ -70,7 +73,7 @@ const isCurrentTab = computed(() => props.tab.id === tabStore.currentTabId);
const environment = computed(() => {
const { database } = connectionForSQLEditorTab(props.tab);
const environment = database?.effectiveEnvironmentEntity;
- if (environment?.name === UNKNOWN_ENVIRONMENT_NAME) {
+ if (environment?.id === String(UNKNOWN_ID)) {
return;
}
return environment;
diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yaml
index edc6acc4b0..b5db39ab5c 100644
--- a/proto/gen/grpc-doc/openapi.yaml
+++ b/proto/gen/grpc-doc/openapi.yaml
@@ -260,168 +260,6 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Status'
- /v1/environments:
- get:
- tags:
- - EnvironmentService
- operationId: EnvironmentService_ListEnvironments
- parameters:
- - name: pageSize
- in: query
- description: |-
- Not used.
- The maximum number of environments to return. The service may return fewer than
- this value.
- If unspecified, at most 10 environments will be returned.
- The maximum value is 1000; values above 1000 will be coerced to 1000.
- schema:
- type: integer
- format: int32
- - name: pageToken
- in: query
- description: |-
- Not used.
- A page token, received from a previous `ListEnvironments` call.
- Provide this to retrieve the subsequent page.
-
- When paginating, all other parameters provided to `ListEnvironments` must match
- the call that provided the page token.
- schema:
- type: string
- - name: showDeleted
- in: query
- description: Show deleted environments if specified.
- schema:
- type: boolean
- responses:
- "200":
- description: OK
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/ListEnvironmentsResponse'
- default:
- description: Default error response
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Status'
- post:
- tags:
- - EnvironmentService
- operationId: EnvironmentService_CreateEnvironment
- parameters:
- - name: environmentId
- in: query
- description: |-
- The ID to use for the environment, which will become the final component of
- the environment's resource name.
-
- This value should be 4-63 characters, and valid characters
- are /[a-z][0-9]-/.
- schema:
- type: string
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Environment'
- required: true
- responses:
- "200":
- description: OK
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Environment'
- default:
- description: Default error response
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Status'
- /v1/environments/{environment}:
- get:
- tags:
- - EnvironmentService
- operationId: EnvironmentService_GetEnvironment
- parameters:
- - name: environment
- in: path
- description: The environment id.
- required: true
- schema:
- type: string
- responses:
- "200":
- description: OK
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Environment'
- default:
- description: Default error response
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Status'
- delete:
- tags:
- - EnvironmentService
- operationId: EnvironmentService_DeleteEnvironment
- parameters:
- - name: environment
- in: path
- description: The environment id.
- required: true
- schema:
- type: string
- responses:
- "200":
- description: OK
- content: {}
- default:
- description: Default error response
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Status'
- patch:
- tags:
- - EnvironmentService
- operationId: EnvironmentService_UpdateEnvironment
- parameters:
- - name: environment
- in: path
- description: The environment id.
- required: true
- schema:
- type: string
- - name: updateMask
- in: query
- description: The list of fields to update.
- schema:
- type: string
- format: field-mask
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Environment'
- required: true
- responses:
- "200":
- description: OK
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Environment'
- default:
- description: Default error response
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Status'
/v1/environments/{environment}/policies:
get:
tags:
@@ -643,37 +481,6 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Status'
- /v1/environments/{environment}:undelete:
- post:
- tags:
- - EnvironmentService
- operationId: EnvironmentService_UndeleteEnvironment
- parameters:
- - name: environment
- in: path
- description: The environment id.
- required: true
- schema:
- type: string
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/UndeleteEnvironmentRequest'
- required: true
- responses:
- "200":
- description: OK
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Environment'
- default:
- description: Default error response
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/Status'
/v1/feature:
get:
tags:
@@ -9454,35 +9261,6 @@ components:
properties:
active:
type: boolean
- Environment:
- type: object
- properties:
- name:
- type: string
- description: |-
- The name of the environment.
- Format: environments/{environment}
- state:
- enum:
- - STATE_UNSPECIFIED
- - ACTIVE
- - DELETED
- type: string
- format: enum
- title:
- type: string
- order:
- type: integer
- format: int32
- tier:
- enum:
- - ENVIRONMENT_TIER_UNSPECIFIED
- - PROTECTED
- - UNPROTECTED
- type: string
- format: enum
- color:
- type: string
EnvironmentSetting:
type: object
properties:
@@ -9490,19 +9268,18 @@ components:
type: array
items:
$ref: '#/components/schemas/EnvironmentSetting_Environment'
- description: 'TODO(p0ny): implement.'
EnvironmentSetting_Environment:
type: object
properties:
- title:
- type: string
- description: The display name of the environment.
id:
type: string
description: |-
The resource id of the environment.
This value should be 4-63 characters, and valid characters
are /[a-z][0-9]-/.
+ title:
+ type: string
+ description: The display name of the environment.
tags:
type: object
additionalProperties:
@@ -10503,19 +10280,6 @@ components:
description: |-
A token, which can be sent as `page_token` to retrieve the next page.
If this field is omitted, there are no subsequent pages.
- ListEnvironmentsResponse:
- type: object
- properties:
- environments:
- type: array
- items:
- $ref: '#/components/schemas/Environment'
- description: The environments from the specified request.
- nextPageToken:
- type: string
- description: |-
- A token, which can be sent as `page_token` to retrieve the next page.
- If this field is omitted, there are no subsequent pages.
ListGroupsResponse:
type: object
properties:
@@ -13721,16 +13485,6 @@ components:
type: string
skipDump:
type: boolean
- UndeleteEnvironmentRequest:
- required:
- - name
- type: object
- properties:
- name:
- type: string
- description: |-
- The name of the deleted environment.
- Format: environments/{environment}
UndeleteIdentityProviderRequest:
required:
- name
@@ -14175,7 +13929,6 @@ tags:
- name: DatabaseCatalogService
- name: DatabaseGroupService
- name: DatabaseService
- - name: EnvironmentService
- name: GroupService
- name: IdentityProviderService
- name: InstanceRoleService
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index fb66eb66ba..d6a118b551 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -4205,8 +4205,8 @@ RestrictIssueCreationForSQLReviewPolicy is the policy configuration for restrict
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| title | [string](#string) | | The display name of the environment. |
| id | [string](#string) | | The resource id of the environment. This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. |
+| title | [string](#string) | | The display name of the environment. |
| tags | [EnvironmentSetting.Environment.TagsEntry](#bytebase-store-EnvironmentSetting-Environment-TagsEntry) | repeated | |
| color | [string](#string) | | |
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index 557f234725..8dd6ae835f 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -10882,19 +10882,19 @@ and write back to the schema metadata. </p></td>
<tbody>
<tr>
- <td>title</td>
+ <td>id</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p>The display name of the environment. </p></td>
+ <td><p>The resource id of the environment.
+This value should be 4-63 characters, and valid characters
+are /[a-z][0-9]-/. </p></td>
</tr>
<tr>
- <td>id</td>
+ <td>title</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p>The resource id of the environment.
-This value should be 4-63 characters, and valid characters
-are /[a-z][0-9]-/. </p></td>
+ <td><p>The display name of the environment. </p></td>
</tr>
<tr>
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 6f6173e91a..1e4278fc78 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -370,20 +370,6 @@
- [DatabaseGroupService](#bytebase-v1-DatabaseGroupService)
-- [v1/environment_service.proto](#v1_environment_service-proto)
- - [CreateEnvironmentRequest](#bytebase-v1-CreateEnvironmentRequest)
- - [DeleteEnvironmentRequest](#bytebase-v1-DeleteEnvironmentRequest)
- - [Environment](#bytebase-v1-Environment)
- - [GetEnvironmentRequest](#bytebase-v1-GetEnvironmentRequest)
- - [ListEnvironmentsRequest](#bytebase-v1-ListEnvironmentsRequest)
- - [ListEnvironmentsResponse](#bytebase-v1-ListEnvironmentsResponse)
- - [UndeleteEnvironmentRequest](#bytebase-v1-UndeleteEnvironmentRequest)
- - [UpdateEnvironmentRequest](#bytebase-v1-UpdateEnvironmentRequest)
-
- - [EnvironmentTier](#bytebase-v1-EnvironmentTier)
-
- - [EnvironmentService](#bytebase-v1-EnvironmentService)
-
- [v1/group_service.proto](#v1_group_service-proto)
- [CreateGroupRequest](#bytebase-v1-CreateGroupRequest)
- [DeleteGroupRequest](#bytebase-v1-DeleteGroupRequest)
@@ -4495,7 +4481,7 @@ ANY means approving any node will proceed.
<a name="bytebase-v1-EnvironmentSetting"></a>
### EnvironmentSetting
-TODO(p0ny): implement.
+
| Field | Type | Label | Description |
@@ -4515,8 +4501,9 @@ TODO(p0ny): implement.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| title | [string](#string) | | The display name of the environment. |
+| name | [string](#string) | | The resource name of the environment. Format: environments/{environment}. Output only. |
| id | [string](#string) | | The resource id of the environment. This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. |
+| title | [string](#string) | | The display name of the environment. |
| tags | [EnvironmentSetting.Environment.TagsEntry](#bytebase-v1-EnvironmentSetting-Environment-TagsEntry) | repeated | |
| color | [string](#string) | | |
@@ -6240,186 +6227,6 @@ The database group&#39;s `name` field is used to identify the database group to
-<a name="v1_environment_service-proto"></a>
-<p align="right"><a href="#top">Top</a></p>
-
-## v1/environment_service.proto
-
-
-
-<a name="bytebase-v1-CreateEnvironmentRequest"></a>
-
-### CreateEnvironmentRequest
-
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| environment | [Environment](#bytebase-v1-Environment) | | The environment to create. |
-| environment_id | [string](#string) | | The ID to use for the environment, which will become the final component of the environment&#39;s resource name.
-
-This value should be 4-63 characters, and valid characters are /[a-z][0-9]-/. |
-
-
-
-
-
-
-<a name="bytebase-v1-DeleteEnvironmentRequest"></a>
-
-### DeleteEnvironmentRequest
-
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| name | [string](#string) | | The name of the environment to delete. Format: environments/{environment} |
-
-
-
-
-
-
-<a name="bytebase-v1-Environment"></a>
-
-### Environment
-
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| name | [string](#string) | | The name of the environment. Format: environments/{environment} |
-| state | [State](#bytebase-v1-State) | | |
-| title | [string](#string) | | |
-| order | [int32](#int32) | | |
-| tier | [EnvironmentTier](#bytebase-v1-EnvironmentTier) | | |
-| color | [string](#string) | | |
-
-
-
-
-
-
-<a name="bytebase-v1-GetEnvironmentRequest"></a>
-
-### GetEnvironmentRequest
-
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| name | [string](#string) | | The name of the environment to retrieve. Format: environments/{environment} |
-
-
-
-
-
-
-<a name="bytebase-v1-ListEnvironmentsRequest"></a>
-
-### ListEnvironmentsRequest
-
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| page_size | [int32](#int32) | | Not used. The maximum number of environments to return. The service may return fewer than this value. If unspecified, at most 10 environments will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. |
-| page_token | [string](#string) | | Not used. A page token, received from a previous `ListEnvironments` call. Provide this to retrieve the subsequent page.
-
-When paginating, all other parameters provided to `ListEnvironments` must match the call that provided the page token. |
-| show_deleted | [bool](#bool) | | Show deleted environments if specified. |
-
-
-
-
-
-
-<a name="bytebase-v1-ListEnvironmentsResponse"></a>
-
-### ListEnvironmentsResponse
-
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| environments | [Environment](#bytebase-v1-Environment) | repeated | The environments from the specified request. |
-| next_page_token | [string](#string) | | A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages. |
-
-
-
-
-
-
-<a name="bytebase-v1-UndeleteEnvironmentRequest"></a>
-
-### UndeleteEnvironmentRequest
-
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| name | [string](#string) | | The name of the deleted environment. Format: environments/{environment} |
-
-
-
-
-
-
-<a name="bytebase-v1-UpdateEnvironmentRequest"></a>
-
-### UpdateEnvironmentRequest
-
-
-
-| Field | Type | Label | Description |
-| ----- | ---- | ----- | ----------- |
-| environment | [Environment](#bytebase-v1-Environment) | | The environment to update.
-
-The environment&#39;s `name` field is used to identify the environment to update. Format: environments/{environment} |
-| update_mask | [google.protobuf.FieldMask](#google-protobuf-FieldMask) | | The list of fields to update. |
-
-
-
-
-
-
-
-
-<a name="bytebase-v1-EnvironmentTier"></a>
-
-### EnvironmentTier
-
-
-| Name | Number | Description |
-| ---- | ------ | ----------- |
-| ENVIRONMENT_TIER_UNSPECIFIED | 0 | |
-| PROTECTED | 1 | |
-| UNPROTECTED | 2 | |
-
-
-
-
-
-
-
-<a name="bytebase-v1-EnvironmentService"></a>
-
-### EnvironmentService
-
-
-| Method Name | Request Type | Response Type | Description |
-| ----------- | ------------ | ------------- | ------------|
-| GetEnvironment | [GetEnvironmentRequest](#bytebase-v1-GetEnvironmentRequest) | [Environment](#bytebase-v1-Environment) | |
-| ListEnvironments | [ListEnvironmentsRequest](#bytebase-v1-ListEnvironmentsRequest) | [ListEnvironmentsResponse](#bytebase-v1-ListEnvironmentsResponse) | |
-| CreateEnvironment | [CreateEnvironmentRequest](#bytebase-v1-CreateEnvironmentRequest) | [Environment](#bytebase-v1-Environment) | |
-| UpdateEnvironment | [UpdateEnvironmentRequest](#bytebase-v1-UpdateEnvironmentRequest) | [Environment](#bytebase-v1-Environment) | |
-| DeleteEnvironment | [DeleteEnvironmentRequest](#bytebase-v1-DeleteEnvironmentRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | |
-| UndeleteEnvironment | [UndeleteEnvironmentRequest](#bytebase-v1-UndeleteEnvironmentRequest) | [Environment](#bytebase-v1-Environment) | |
-
-
-
-
-
<a name="v1_group_service-proto"></a>
<p align="right"><a href="#top">Top</a></p>
diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.html
index 414022af7d..c42304ef67 100644
--- a/proto/gen/grpc-doc/v1/index.html
+++ b/proto/gen/grpc-doc/v1/index.html
@@ -1589,57 +1589,6 @@
</li>
- <li>
- <a href="#v1%2fenvironment_service.proto">v1/environment_service.proto</a>
- <ul>
-
- <li>
- <a href="#bytebase.v1.CreateEnvironmentRequest"><span class="badge">M</span>CreateEnvironmentRequest</a>
- </li>
-
- <li>
- <a href="#bytebase.v1.DeleteEnvironmentRequest"><span class="badge">M</span>DeleteEnvironmentRequest</a>
- </li>
-
- <li>
- <a href="#bytebase.v1.Environment"><span class="badge">M</span>Environment</a>
- </li>
-
- <li>
- <a href="#bytebase.v1.GetEnvironmentRequest"><span class="badge">M</span>GetEnvironmentRequest</a>
- </li>
-
- <li>
- <a href="#bytebase.v1.ListEnvironmentsRequest"><span class="badge">M</span>ListEnvironmentsRequest</a>
- </li>
-
- <li>
- <a href="#bytebase.v1.ListEnvironmentsResponse"><span class="badge">M</span>ListEnvironmentsResponse</a>
- </li>
-
- <li>
- <a href="#bytebase.v1.UndeleteEnvironmentRequest"><span class="badge">M</span>UndeleteEnvironmentRequest</a>
- </li>
-
- <li>
- <a href="#bytebase.v1.UpdateEnvironmentRequest"><span class="badge">M</span>UpdateEnvironmentRequest</a>
- </li>
-
-
- <li>
- <a href="#bytebase.v1.EnvironmentTier"><span class="badge">E</span>EnvironmentTier</a>
- </li>
-
-
-
- <li>
- <a href="#bytebase.v1.EnvironmentService"><span class="badge">S</span>EnvironmentService</a>
- </li>
-
- </ul>
- </li>
-
-
<li>
<a href="#v1%2fgroup_service.proto">v1/group_service.proto</a>
<ul>
@@ -13188,7 +13137,7 @@ and write back to the schema metadata. </p></td>
<h3 id="bytebase.v1.EnvironmentSetting">EnvironmentSetting</h3>
- <p>TODO(p0ny): implement.</p>
+ <p></p>
<table class="field-table">
@@ -13222,10 +13171,12 @@ and write back to the schema metadata. </p></td>
<tbody>
<tr>
- <td>title</td>
+ <td>name</td>
<td><a href="#string">string</a></td>
<td></td>
- <td><p>The display name of the environment. </p></td>
+ <td><p>The resource name of the environment.
+Format: environments/{environment}.
+Output only. </p></td>
</tr>
<tr>
@@ -13237,6 +13188,13 @@ This value should be 4-63 characters, and valid characters
are /[a-z][0-9]-/. </p></td>
</tr>
+ <tr>
+ <td>title</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>The display name of the environment. </p></td>
+ </tr>
+
<tr>
<td>tags</td>
<td><a href="#bytebase.v1.EnvironmentSetting.Environment.TagsEntry">EnvironmentSetting.Environment.TagsEntry</a></td>
@@ -17667,464 +17625,6 @@ The API will default to the BASIC view.</p></td>
- <div class="file-heading">
- <h2 id="v1/environment_service.proto">v1/environment_service.proto</h2><a href="#title">Top</a>
- </div>
- <p></p>
-
-
- <h3 id="bytebase.v1.CreateEnvironmentRequest">CreateEnvironmentRequest</h3>
- <p></p>
-
-
- <table class="field-table">
- <thead>
- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
- </thead>
- <tbody>
-
- <tr>
- <td>environment</td>
- <td><a href="#bytebase.v1.Environment">Environment</a></td>
- <td></td>
- <td><p>The environment to create. </p></td>
- </tr>
-
- <tr>
- <td>environment_id</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p>The ID to use for the environment, which will become the final component of
-the environment&#39;s resource name.
-
-This value should be 4-63 characters, and valid characters
-are /[a-z][0-9]-/. </p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
- <h3 id="bytebase.v1.DeleteEnvironmentRequest">DeleteEnvironmentRequest</h3>
- <p></p>
-
-
- <table class="field-table">
- <thead>
- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
- </thead>
- <tbody>
-
- <tr>
- <td>name</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p>The name of the environment to delete.
-Format: environments/{environment} </p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
- <h3 id="bytebase.v1.Environment">Environment</h3>
- <p></p>
-
-
- <table class="field-table">
- <thead>
- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
- </thead>
- <tbody>
-
- <tr>
- <td>name</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p>The name of the environment.
-Format: environments/{environment} </p></td>
- </tr>
-
- <tr>
- <td>state</td>
- <td><a href="#bytebase.v1.State">State</a></td>
- <td></td>
- <td><p> </p></td>
- </tr>
-
- <tr>
- <td>title</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p> </p></td>
- </tr>
-
- <tr>
- <td>order</td>
- <td><a href="#int32">int32</a></td>
- <td></td>
- <td><p> </p></td>
- </tr>
-
- <tr>
- <td>tier</td>
- <td><a href="#bytebase.v1.EnvironmentTier">EnvironmentTier</a></td>
- <td></td>
- <td><p> </p></td>
- </tr>
-
- <tr>
- <td>color</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p> </p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
- <h3 id="bytebase.v1.GetEnvironmentRequest">GetEnvironmentRequest</h3>
- <p></p>
-
-
- <table class="field-table">
- <thead>
- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
- </thead>
- <tbody>
-
- <tr>
- <td>name</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p>The name of the environment to retrieve.
-Format: environments/{environment} </p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
- <h3 id="bytebase.v1.ListEnvironmentsRequest">ListEnvironmentsRequest</h3>
- <p></p>
-
-
- <table class="field-table">
- <thead>
- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
- </thead>
- <tbody>
-
- <tr>
- <td>page_size</td>
- <td><a href="#int32">int32</a></td>
- <td></td>
- <td><p>Not used.
-The maximum number of environments to return. The service may return fewer than
-this value.
-If unspecified, at most 10 environments will be returned.
-The maximum value is 1000; values above 1000 will be coerced to 1000. </p></td>
- </tr>
-
- <tr>
- <td>page_token</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p>Not used.
-A page token, received from a previous `ListEnvironments` call.
-Provide this to retrieve the subsequent page.
-
-When paginating, all other parameters provided to `ListEnvironments` must match
-the call that provided the page token. </p></td>
- </tr>
-
- <tr>
- <td>show_deleted</td>
- <td><a href="#bool">bool</a></td>
- <td></td>
- <td><p>Show deleted environments if specified. </p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
- <h3 id="bytebase.v1.ListEnvironmentsResponse">ListEnvironmentsResponse</h3>
- <p></p>
-
-
- <table class="field-table">
- <thead>
- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
- </thead>
- <tbody>
-
- <tr>
- <td>environments</td>
- <td><a href="#bytebase.v1.Environment">Environment</a></td>
- <td>repeated</td>
- <td><p>The environments from the specified request. </p></td>
- </tr>
-
- <tr>
- <td>next_page_token</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p>A token, which can be sent as `page_token` to retrieve the next page.
-If this field is omitted, there are no subsequent pages. </p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
- <h3 id="bytebase.v1.UndeleteEnvironmentRequest">UndeleteEnvironmentRequest</h3>
- <p></p>
-
-
- <table class="field-table">
- <thead>
- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
- </thead>
- <tbody>
-
- <tr>
- <td>name</td>
- <td><a href="#string">string</a></td>
- <td></td>
- <td><p>The name of the deleted environment.
-Format: environments/{environment} </p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
- <h3 id="bytebase.v1.UpdateEnvironmentRequest">UpdateEnvironmentRequest</h3>
- <p></p>
-
-
- <table class="field-table">
- <thead>
- <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
- </thead>
- <tbody>
-
- <tr>
- <td>environment</td>
- <td><a href="#bytebase.v1.Environment">Environment</a></td>
- <td></td>
- <td><p>The environment to update.
-
-The environment&#39;s `name` field is used to identify the environment to update.
-Format: environments/{environment} </p></td>
- </tr>
-
- <tr>
- <td>update_mask</td>
- <td><a href="#google.protobuf.FieldMask">google.protobuf.FieldMask</a></td>
- <td></td>
- <td><p>The list of fields to update. </p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
-
-
- <h3 id="bytebase.v1.EnvironmentTier">EnvironmentTier</h3>
- <p></p>
- <table class="enum-table">
- <thead>
- <tr><td>Name</td><td>Number</td><td>Description</td></tr>
- </thead>
- <tbody>
-
- <tr>
- <td>ENVIRONMENT_TIER_UNSPECIFIED</td>
- <td>0</td>
- <td><p></p></td>
- </tr>
-
- <tr>
- <td>PROTECTED</td>
- <td>1</td>
- <td><p></p></td>
- </tr>
-
- <tr>
- <td>UNPROTECTED</td>
- <td>2</td>
- <td><p></p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
-
- <h3 id="bytebase.v1.EnvironmentService">EnvironmentService</h3>
- <p></p>
- <table class="enum-table">
- <thead>
- <tr><td>Method Name</td><td>Request Type</td><td>Response Type</td><td>Description</td></tr>
- </thead>
- <tbody>
-
- <tr>
- <td>GetEnvironment</td>
- <td><a href="#bytebase.v1.GetEnvironmentRequest">GetEnvironmentRequest</a></td>
- <td><a href="#bytebase.v1.Environment">Environment</a></td>
- <td><p></p></td>
- </tr>
-
- <tr>
- <td>ListEnvironments</td>
- <td><a href="#bytebase.v1.ListEnvironmentsRequest">ListEnvironmentsRequest</a></td>
- <td><a href="#bytebase.v1.ListEnvironmentsResponse">ListEnvironmentsResponse</a></td>
- <td><p></p></td>
- </tr>
-
- <tr>
- <td>CreateEnvironment</td>
- <td><a href="#bytebase.v1.CreateEnvironmentRequest">CreateEnvironmentRequest</a></td>
- <td><a href="#bytebase.v1.Environment">Environment</a></td>
- <td><p></p></td>
- </tr>
-
- <tr>
- <td>UpdateEnvironment</td>
- <td><a href="#bytebase.v1.UpdateEnvironmentRequest">UpdateEnvironmentRequest</a></td>
- <td><a href="#bytebase.v1.Environment">Environment</a></td>
- <td><p></p></td>
- </tr>
-
- <tr>
- <td>DeleteEnvironment</td>
- <td><a href="#bytebase.v1.DeleteEnvironmentRequest">DeleteEnvironmentRequest</a></td>
- <td><a href="#google.protobuf.Empty">.google.protobuf.Empty</a></td>
- <td><p></p></td>
- </tr>
-
- <tr>
- <td>UndeleteEnvironment</td>
- <td><a href="#bytebase.v1.UndeleteEnvironmentRequest">UndeleteEnvironmentRequest</a></td>
- <td><a href="#bytebase.v1.Environment">Environment</a></td>
- <td><p></p></td>
- </tr>
-
- </tbody>
- </table>
-
-
-
-
- <h4>Methods with HTTP bindings</h4>
- <table>
- <thead>
- <tr>
- <td>Method Name</td>
- <td>Method</td>
- <td>Pattern</td>
- <td>Body</td>
- </tr>
- </thead>
- <tbody>
-
-
-
- <tr>
- <td>GetEnvironment</td>
- <td>GET</td>
- <td>/v1/{name=environments/*}</td>
- <td></td>
- </tr>
-
-
-
-
- <tr>
- <td>ListEnvironments</td>
- <td>GET</td>
- <td>/v1/environments</td>
- <td></td>
- </tr>
-
-
-
-
- <tr>
- <td>CreateEnvironment</td>
- <td>POST</td>
- <td>/v1/environments</td>
- <td>environment</td>
- </tr>
-
-
-
-
- <tr>
- <td>UpdateEnvironment</td>
- <td>PATCH</td>
- <td>/v1/{environment.name=environments/*}</td>
- <td>environment</td>
- </tr>
-
-
-
-
- <tr>
- <td>DeleteEnvironment</td>
- <td>DELETE</td>
- <td>/v1/{name=environments/*}</td>
- <td></td>
- </tr>
-
-
-
-
- <tr>
- <td>UndeleteEnvironment</td>
- <td>POST</td>
- <td>/v1/{name=environments/*}:undelete</td>
- <td>*</td>
- </tr>
-
-
- </tbody>
- </table>
-
-
-
-
<div class="file-heading">
<h2 id="v1/group_service.proto">v1/group_service.proto</h2><a href="#title">Top</a>
</div>
diff --git a/proto/generated-go/store/deployment_config.pb.go b/proto/generated-go/store/deployment_config.pb.go
deleted file mode 100644
index 83239073ba..0000000000
--- a/proto/generated-go/store/deployment_config.pb.go
+++ /dev/null
@@ -1,493 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// versions:
-// protoc-gen-go v1.36.5
-// protoc (unknown)
-// source: store/deployment_config.proto
-
-package store
-
-import (
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
- unsafe "unsafe"
-)
-
-const (
- // Verify that this generated code is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
- // Verify that runtime/protoimpl is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
-)
-
-type LabelSelectorRequirement_OperatorType int32
-
-const (
- // The operator is not specified.
- LabelSelectorRequirement_OPERATOR_TYPE_UNSPECIFIED LabelSelectorRequirement_OperatorType = 0
- // The operator is "In".
- LabelSelectorRequirement_IN LabelSelectorRequirement_OperatorType = 1
- // The operator is "Exists".
- LabelSelectorRequirement_EXISTS LabelSelectorRequirement_OperatorType = 2
- // The operator is "Not In".
- LabelSelectorRequirement_NOT_IN LabelSelectorRequirement_OperatorType = 3
-)
-
-// Enum value maps for LabelSelectorRequirement_OperatorType.
-var (
- LabelSelectorRequirement_OperatorType_name = map[int32]string{
- 0: "OPERATOR_TYPE_UNSPECIFIED",
- 1: "IN",
- 2: "EXISTS",
- 3: "NOT_IN",
- }
- LabelSelectorRequirement_OperatorType_value = map[string]int32{
- "OPERATOR_TYPE_UNSPECIFIED": 0,
- "IN": 1,
- "EXISTS": 2,
- "NOT_IN": 3,
- }
-)
-
-func (x LabelSelectorRequirement_OperatorType) Enum() *LabelSelectorRequirement_OperatorType {
- p := new(LabelSelectorRequirement_OperatorType)
- *p = x
- return p
-}
-
-func (x LabelSelectorRequirement_OperatorType) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (LabelSelectorRequirement_OperatorType) Descriptor() protoreflect.EnumDescriptor {
- return file_store_deployment_config_proto_enumTypes[0].Descriptor()
-}
-
-func (LabelSelectorRequirement_OperatorType) Type() protoreflect.EnumType {
- return &file_store_deployment_config_proto_enumTypes[0]
-}
-
-func (x LabelSelectorRequirement_OperatorType) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Use LabelSelectorRequirement_OperatorType.Descriptor instead.
-func (LabelSelectorRequirement_OperatorType) EnumDescriptor() ([]byte, []int) {
- return file_store_deployment_config_proto_rawDescGZIP(), []int{5, 0}
-}
-
-type DeploymentConfig struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Schedule *Schedule `protobuf:"bytes,1,opt,name=schedule,proto3" json:"schedule,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *DeploymentConfig) Reset() {
- *x = DeploymentConfig{}
- mi := &file_store_deployment_config_proto_msgTypes[0]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *DeploymentConfig) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*DeploymentConfig) ProtoMessage() {}
-
-func (x *DeploymentConfig) ProtoReflect() protoreflect.Message {
- mi := &file_store_deployment_config_proto_msgTypes[0]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use DeploymentConfig.ProtoReflect.Descriptor instead.
-func (*DeploymentConfig) Descriptor() ([]byte, []int) {
- return file_store_deployment_config_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *DeploymentConfig) GetSchedule() *Schedule {
- if x != nil {
- return x.Schedule
- }
- return nil
-}
-
-// Schedule is the message for deployment schedule.
-type Schedule struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Deployments []*ScheduleDeployment `protobuf:"bytes,1,rep,name=deployments,proto3" json:"deployments,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *Schedule) Reset() {
- *x = Schedule{}
- mi := &file_store_deployment_config_proto_msgTypes[1]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *Schedule) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Schedule) ProtoMessage() {}
-
-func (x *Schedule) ProtoReflect() protoreflect.Message {
- mi := &file_store_deployment_config_proto_msgTypes[1]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Schedule.ProtoReflect.Descriptor instead.
-func (*Schedule) Descriptor() ([]byte, []int) {
- return file_store_deployment_config_proto_rawDescGZIP(), []int{1}
-}
-
-func (x *Schedule) GetDeployments() []*ScheduleDeployment {
- if x != nil {
- return x.Deployments
- }
- return nil
-}
-
-type ScheduleDeployment struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // The title of the deployment (stage) in a schedule.
- Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
- Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
- Spec *DeploymentSpec `protobuf:"bytes,3,opt,name=spec,proto3" json:"spec,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *ScheduleDeployment) Reset() {
- *x = ScheduleDeployment{}
- mi := &file_store_deployment_config_proto_msgTypes[2]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *ScheduleDeployment) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*ScheduleDeployment) ProtoMessage() {}
-
-func (x *ScheduleDeployment) ProtoReflect() protoreflect.Message {
- mi := &file_store_deployment_config_proto_msgTypes[2]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use ScheduleDeployment.ProtoReflect.Descriptor instead.
-func (*ScheduleDeployment) Descriptor() ([]byte, []int) {
- return file_store_deployment_config_proto_rawDescGZIP(), []int{2}
-}
-
-func (x *ScheduleDeployment) GetTitle() string {
- if x != nil {
- return x.Title
- }
- return ""
-}
-
-func (x *ScheduleDeployment) GetId() string {
- if x != nil {
- return x.Id
- }
- return ""
-}
-
-func (x *ScheduleDeployment) GetSpec() *DeploymentSpec {
- if x != nil {
- return x.Spec
- }
- return nil
-}
-
-type DeploymentSpec struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Selector *LabelSelector `protobuf:"bytes,1,opt,name=selector,proto3" json:"selector,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *DeploymentSpec) Reset() {
- *x = DeploymentSpec{}
- mi := &file_store_deployment_config_proto_msgTypes[3]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *DeploymentSpec) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*DeploymentSpec) ProtoMessage() {}
-
-func (x *DeploymentSpec) ProtoReflect() protoreflect.Message {
- mi := &file_store_deployment_config_proto_msgTypes[3]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use DeploymentSpec.ProtoReflect.Descriptor instead.
-func (*DeploymentSpec) Descriptor() ([]byte, []int) {
- return file_store_deployment_config_proto_rawDescGZIP(), []int{3}
-}
-
-func (x *DeploymentSpec) GetSelector() *LabelSelector {
- if x != nil {
- return x.Selector
- }
- return nil
-}
-
-type LabelSelector struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // match_expressions is a list of label selector requirements. The requirements are ANDed.
- MatchExpressions []*LabelSelectorRequirement `protobuf:"bytes,1,rep,name=match_expressions,json=matchExpressions,proto3" json:"match_expressions,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *LabelSelector) Reset() {
- *x = LabelSelector{}
- mi := &file_store_deployment_config_proto_msgTypes[4]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *LabelSelector) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*LabelSelector) ProtoMessage() {}
-
-func (x *LabelSelector) ProtoReflect() protoreflect.Message {
- mi := &file_store_deployment_config_proto_msgTypes[4]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use LabelSelector.ProtoReflect.Descriptor instead.
-func (*LabelSelector) Descriptor() ([]byte, []int) {
- return file_store_deployment_config_proto_rawDescGZIP(), []int{4}
-}
-
-func (x *LabelSelector) GetMatchExpressions() []*LabelSelectorRequirement {
- if x != nil {
- return x.MatchExpressions
- }
- return nil
-}
-
-type LabelSelectorRequirement struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
- Operator LabelSelectorRequirement_OperatorType `protobuf:"varint,2,opt,name=operator,proto3,enum=bytebase.store.LabelSelectorRequirement_OperatorType" json:"operator,omitempty"`
- // Values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
- Values []string `protobuf:"bytes,3,rep,name=values,proto3" json:"values,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *LabelSelectorRequirement) Reset() {
- *x = LabelSelectorRequirement{}
- mi := &file_store_deployment_config_proto_msgTypes[5]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *LabelSelectorRequirement) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*LabelSelectorRequirement) ProtoMessage() {}
-
-func (x *LabelSelectorRequirement) ProtoReflect() protoreflect.Message {
- mi := &file_store_deployment_config_proto_msgTypes[5]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use LabelSelectorRequirement.ProtoReflect.Descriptor instead.
-func (*LabelSelectorRequirement) Descriptor() ([]byte, []int) {
- return file_store_deployment_config_proto_rawDescGZIP(), []int{5}
-}
-
-func (x *LabelSelectorRequirement) GetKey() string {
- if x != nil {
- return x.Key
- }
- return ""
-}
-
-func (x *LabelSelectorRequirement) GetOperator() LabelSelectorRequirement_OperatorType {
- if x != nil {
- return x.Operator
- }
- return LabelSelectorRequirement_OPERATOR_TYPE_UNSPECIFIED
-}
-
-func (x *LabelSelectorRequirement) GetValues() []string {
- if x != nil {
- return x.Values
- }
- return nil
-}
-
-var File_store_deployment_config_proto protoreflect.FileDescriptor
-
-var file_store_deployment_config_proto_rawDesc = string([]byte{
- 0x0a, 0x1d, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65,
- 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
- 0x0e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x22,
- 0x48, 0x0a, 0x10, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e,
- 0x66, 0x69, 0x67, 0x12, 0x34, 0x0a, 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x18,
- 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
- 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x52,
- 0x08, 0x73, 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x22, 0x50, 0x0a, 0x08, 0x53, 0x63, 0x68,
- 0x65, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d,
- 0x65, 0x6e, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x62, 0x79, 0x74,
- 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x63, 0x68, 0x65,
- 0x64, 0x75, 0x6c, 0x65, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0b,
- 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x6e, 0x0a, 0x12, 0x53,
- 0x63, 0x68, 0x65, 0x64, 0x75, 0x6c, 0x65, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e,
- 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
- 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20,
- 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x32, 0x0a, 0x04, 0x73, 0x70, 0x65, 0x63, 0x18,
- 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
- 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e,
- 0x74, 0x53, 0x70, 0x65, 0x63, 0x52, 0x04, 0x73, 0x70, 0x65, 0x63, 0x22, 0x4b, 0x0a, 0x0e, 0x44,
- 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x70, 0x65, 0x63, 0x12, 0x39, 0x0a,
- 0x08, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
- 0x1d, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65,
- 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x52, 0x08,
- 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x22, 0x66, 0x0a, 0x0d, 0x4c, 0x61, 0x62, 0x65,
- 0x6c, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x12, 0x55, 0x0a, 0x11, 0x6d, 0x61, 0x74,
- 0x63, 0x68, 0x5f, 0x65, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01,
- 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,
- 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x53, 0x65, 0x6c, 0x65, 0x63,
- 0x74, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x10,
- 0x6d, 0x61, 0x74, 0x63, 0x68, 0x45, 0x78, 0x70, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73,
- 0x22, 0xe6, 0x01, 0x0a, 0x18, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74,
- 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x10, 0x0a,
- 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
- 0x51, 0x0a, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28,
- 0x0e, 0x32, 0x35, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f,
- 0x72, 0x65, 0x2e, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x6f, 0x72,
- 0x52, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x4f, 0x70, 0x65, 0x72,
- 0x61, 0x74, 0x6f, 0x72, 0x54, 0x79, 0x70, 0x65, 0x52, 0x08, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74,
- 0x6f, 0x72, 0x12, 0x16, 0x0a, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03,
- 0x28, 0x09, 0x52, 0x06, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x22, 0x4d, 0x0a, 0x0c, 0x4f, 0x70,
- 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1d, 0x0a, 0x19, 0x4f, 0x50,
- 0x45, 0x52, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x50,
- 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x06, 0x0a, 0x02, 0x49, 0x4e, 0x10,
- 0x01, 0x12, 0x0a, 0x0a, 0x06, 0x45, 0x58, 0x49, 0x53, 0x54, 0x53, 0x10, 0x02, 0x12, 0x0a, 0x0a,
- 0x06, 0x4e, 0x4f, 0x54, 0x5f, 0x49, 0x4e, 0x10, 0x03, 0x42, 0x14, 0x5a, 0x12, 0x67, 0x65, 0x6e,
- 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62,
- 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
-})
-
-var (
- file_store_deployment_config_proto_rawDescOnce sync.Once
- file_store_deployment_config_proto_rawDescData []byte
-)
-
-func file_store_deployment_config_proto_rawDescGZIP() []byte {
- file_store_deployment_config_proto_rawDescOnce.Do(func() {
- file_store_deployment_config_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_store_deployment_config_proto_rawDesc), len(file_store_deployment_config_proto_rawDesc)))
- })
- return file_store_deployment_config_proto_rawDescData
-}
-
-var file_store_deployment_config_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_store_deployment_config_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
-var file_store_deployment_config_proto_goTypes = []any{
- (LabelSelectorRequirement_OperatorType)(0), // 0: bytebase.store.LabelSelectorRequirement.OperatorType
- (*DeploymentConfig)(nil), // 1: bytebase.store.DeploymentConfig
- (*Schedule)(nil), // 2: bytebase.store.Schedule
- (*ScheduleDeployment)(nil), // 3: bytebase.store.ScheduleDeployment
- (*DeploymentSpec)(nil), // 4: bytebase.store.DeploymentSpec
- (*LabelSelector)(nil), // 5: bytebase.store.LabelSelector
- (*LabelSelectorRequirement)(nil), // 6: bytebase.store.LabelSelectorRequirement
-}
-var file_store_deployment_config_proto_depIdxs = []int32{
- 2, // 0: bytebase.store.DeploymentConfig.schedule:type_name -> bytebase.store.Schedule
- 3, // 1: bytebase.store.Schedule.deployments:type_name -> bytebase.store.ScheduleDeployment
- 4, // 2: bytebase.store.ScheduleDeployment.spec:type_name -> bytebase.store.DeploymentSpec
- 5, // 3: bytebase.store.DeploymentSpec.selector:type_name -> bytebase.store.LabelSelector
- 6, // 4: bytebase.store.LabelSelector.match_expressions:type_name -> bytebase.store.LabelSelectorRequirement
- 0, // 5: bytebase.store.LabelSelectorRequirement.operator:type_name -> bytebase.store.LabelSelectorRequirement.OperatorType
- 6, // [6:6] is the sub-list for method output_type
- 6, // [6:6] is the sub-list for method input_type
- 6, // [6:6] is the sub-list for extension type_name
- 6, // [6:6] is the sub-list for extension extendee
- 0, // [0:6] is the sub-list for field type_name
-}
-
-func init() { file_store_deployment_config_proto_init() }
-func file_store_deployment_config_proto_init() {
- if File_store_deployment_config_proto != nil {
- return
- }
- type x struct{}
- out := protoimpl.TypeBuilder{
- File: protoimpl.DescBuilder{
- GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
- RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_deployment_config_proto_rawDesc), len(file_store_deployment_config_proto_rawDesc)),
- NumEnums: 1,
- NumMessages: 6,
- NumExtensions: 0,
- NumServices: 0,
- },
- GoTypes: file_store_deployment_config_proto_goTypes,
- DependencyIndexes: file_store_deployment_config_proto_depIdxs,
- EnumInfos: file_store_deployment_config_proto_enumTypes,
- MessageInfos: file_store_deployment_config_proto_msgTypes,
- }.Build()
- File_store_deployment_config_proto = out.File
- file_store_deployment_config_proto_goTypes = nil
- file_store_deployment_config_proto_depIdxs = nil
-}
diff --git a/proto/generated-go/store/deprecated.pb.go b/proto/generated-go/store/deprecated.pb.go
deleted file mode 100644
index b4fdd31b89..0000000000
--- a/proto/generated-go/store/deprecated.pb.go
+++ /dev/null
@@ -1,238 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// versions:
-// protoc-gen-go v1.36.5
-// protoc (unknown)
-// source: store/deprecated.proto
-
-package store
-
-import (
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
- unsafe "unsafe"
-)
-
-const (
- // Verify that this generated code is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
- // Verify that runtime/protoimpl is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
-)
-
-type DeprecatedMaskingPolicy struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- MaskData []*DeprecatedMaskData `protobuf:"bytes,1,rep,name=mask_data,json=maskData,proto3" json:"mask_data,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *DeprecatedMaskingPolicy) Reset() {
- *x = DeprecatedMaskingPolicy{}
- mi := &file_store_deprecated_proto_msgTypes[0]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *DeprecatedMaskingPolicy) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*DeprecatedMaskingPolicy) ProtoMessage() {}
-
-func (x *DeprecatedMaskingPolicy) ProtoReflect() protoreflect.Message {
- mi := &file_store_deprecated_proto_msgTypes[0]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use DeprecatedMaskingPolicy.ProtoReflect.Descriptor instead.
-func (*DeprecatedMaskingPolicy) Descriptor() ([]byte, []int) {
- return file_store_deprecated_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *DeprecatedMaskingPolicy) GetMaskData() []*DeprecatedMaskData {
- if x != nil {
- return x.MaskData
- }
- return nil
-}
-
-type DeprecatedMaskData struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- Schema string `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"`
- Table string `protobuf:"bytes,2,opt,name=table,proto3" json:"table,omitempty"`
- Column string `protobuf:"bytes,3,opt,name=column,proto3" json:"column,omitempty"`
- MaskingLevel MaskingLevel `protobuf:"varint,4,opt,name=masking_level,json=maskingLevel,proto3,enum=bytebase.store.MaskingLevel" json:"masking_level,omitempty"`
- FullMaskingAlgorithmId string `protobuf:"bytes,5,opt,name=full_masking_algorithm_id,json=fullMaskingAlgorithmId,proto3" json:"full_masking_algorithm_id,omitempty"`
- PartialMaskingAlgorithmId string `protobuf:"bytes,6,opt,name=partial_masking_algorithm_id,json=partialMaskingAlgorithmId,proto3" json:"partial_masking_algorithm_id,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *DeprecatedMaskData) Reset() {
- *x = DeprecatedMaskData{}
- mi := &file_store_deprecated_proto_msgTypes[1]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *DeprecatedMaskData) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*DeprecatedMaskData) ProtoMessage() {}
-
-func (x *DeprecatedMaskData) ProtoReflect() protoreflect.Message {
- mi := &file_store_deprecated_proto_msgTypes[1]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use DeprecatedMaskData.ProtoReflect.Descriptor instead.
-func (*DeprecatedMaskData) Descriptor() ([]byte, []int) {
- return file_store_deprecated_proto_rawDescGZIP(), []int{1}
-}
-
-func (x *DeprecatedMaskData) GetSchema() string {
- if x != nil {
- return x.Schema
- }
- return ""
-}
-
-func (x *DeprecatedMaskData) GetTable() string {
- if x != nil {
- return x.Table
- }
- return ""
-}
-
-func (x *DeprecatedMaskData) GetColumn() string {
- if x != nil {
- return x.Column
- }
- return ""
-}
-
-func (x *DeprecatedMaskData) GetMaskingLevel() MaskingLevel {
- if x != nil {
- return x.MaskingLevel
- }
- return MaskingLevel_MASKING_LEVEL_UNSPECIFIED
-}
-
-func (x *DeprecatedMaskData) GetFullMaskingAlgorithmId() string {
- if x != nil {
- return x.FullMaskingAlgorithmId
- }
- return ""
-}
-
-func (x *DeprecatedMaskData) GetPartialMaskingAlgorithmId() string {
- if x != nil {
- return x.PartialMaskingAlgorithmId
- }
- return ""
-}
-
-var File_store_deprecated_proto protoreflect.FileDescriptor
-
-var file_store_deprecated_proto_rawDesc = string([]byte{
- 0x0a, 0x16, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74,
- 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
- 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x1a, 0x12, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f,
- 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5a, 0x0a, 0x17,
- 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x69, 0x6e,
- 0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x3f, 0x0a, 0x09, 0x6d, 0x61, 0x73, 0x6b, 0x5f,
- 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x62, 0x79, 0x74,
- 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x44, 0x65, 0x70, 0x72,
- 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x52, 0x08,
- 0x6d, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x22, 0x99, 0x02, 0x0a, 0x12, 0x44, 0x65, 0x70,
- 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x4d, 0x61, 0x73, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x12,
- 0x16, 0x0a, 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
- 0x06, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65,
- 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x16, 0x0a,
- 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63,
- 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x41, 0x0a, 0x0d, 0x6d, 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67,
- 0x5f, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x62,
- 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x4d, 0x61,
- 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x52, 0x0c, 0x6d, 0x61, 0x73, 0x6b,
- 0x69, 0x6e, 0x67, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x39, 0x0a, 0x19, 0x66, 0x75, 0x6c, 0x6c,
- 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x61, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74,
- 0x68, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x16, 0x66, 0x75, 0x6c,
- 0x6c, 0x4d, 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x41, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68,
- 0x6d, 0x49, 0x64, 0x12, 0x3f, 0x0a, 0x1c, 0x70, 0x61, 0x72, 0x74, 0x69, 0x61, 0x6c, 0x5f, 0x6d,
- 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x5f, 0x61, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74, 0x68, 0x6d,
- 0x5f, 0x69, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x19, 0x70, 0x61, 0x72, 0x74, 0x69,
- 0x61, 0x6c, 0x4d, 0x61, 0x73, 0x6b, 0x69, 0x6e, 0x67, 0x41, 0x6c, 0x67, 0x6f, 0x72, 0x69, 0x74,
- 0x68, 0x6d, 0x49, 0x64, 0x42, 0x14, 0x5a, 0x12, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65,
- 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x33,
-})
-
-var (
- file_store_deprecated_proto_rawDescOnce sync.Once
- file_store_deprecated_proto_rawDescData []byte
-)
-
-func file_store_deprecated_proto_rawDescGZIP() []byte {
- file_store_deprecated_proto_rawDescOnce.Do(func() {
- file_store_deprecated_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_store_deprecated_proto_rawDesc), len(file_store_deprecated_proto_rawDesc)))
- })
- return file_store_deprecated_proto_rawDescData
-}
-
-var file_store_deprecated_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
-var file_store_deprecated_proto_goTypes = []any{
- (*DeprecatedMaskingPolicy)(nil), // 0: bytebase.store.DeprecatedMaskingPolicy
- (*DeprecatedMaskData)(nil), // 1: bytebase.store.DeprecatedMaskData
- (MaskingLevel)(0), // 2: bytebase.store.MaskingLevel
-}
-var file_store_deprecated_proto_depIdxs = []int32{
- 1, // 0: bytebase.store.DeprecatedMaskingPolicy.mask_data:type_name -> bytebase.store.DeprecatedMaskData
- 2, // 1: bytebase.store.DeprecatedMaskData.masking_level:type_name -> bytebase.store.MaskingLevel
- 2, // [2:2] is the sub-list for method output_type
- 2, // [2:2] is the sub-list for method input_type
- 2, // [2:2] is the sub-list for extension type_name
- 2, // [2:2] is the sub-list for extension extendee
- 0, // [0:2] is the sub-list for field type_name
-}
-
-func init() { file_store_deprecated_proto_init() }
-func file_store_deprecated_proto_init() {
- if File_store_deprecated_proto != nil {
- return
- }
- file_store_common_proto_init()
- type x struct{}
- out := protoimpl.TypeBuilder{
- File: protoimpl.DescBuilder{
- GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
- RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_deprecated_proto_rawDesc), len(file_store_deprecated_proto_rawDesc)),
- NumEnums: 0,
- NumMessages: 2,
- NumExtensions: 0,
- NumServices: 0,
- },
- GoTypes: file_store_deprecated_proto_goTypes,
- DependencyIndexes: file_store_deprecated_proto_depIdxs,
- MessageInfos: file_store_deprecated_proto_msgTypes,
- }.Build()
- File_store_deprecated_proto = out.File
- file_store_deprecated_proto_goTypes = nil
- file_store_deprecated_proto_depIdxs = nil
-}
diff --git a/proto/generated-go/store/setting.pb.go b/proto/generated-go/store/setting.pb.go
index 4f12b80fe0..f86ff6b8d5 100644
--- a/proto/generated-go/store/setting.pb.go
+++ b/proto/generated-go/store/setting.pb.go
@@ -2550,12 +2550,12 @@ func (x *AppIMSetting_DingTalk) GetRobotCode() string {
type EnvironmentSetting_Environment struct {
state protoimpl.MessageState `protogen:"open.v1"`
- // The display name of the environment.
- Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
// The resource id of the environment.
// This value should be 4-63 characters, and valid characters
// are /[a-z][0-9]-/.
- Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
+ Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
+ // The display name of the environment.
+ Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
Tags map[string]string `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
Color string `protobuf:"bytes,4,opt,name=color,proto3" json:"color,omitempty"`
unknownFields protoimpl.UnknownFields
@@ -2592,16 +2592,16 @@ func (*EnvironmentSetting_Environment) Descriptor() ([]byte, []int) {
return file_store_setting_proto_rawDescGZIP(), []int{14, 0}
}
-func (x *EnvironmentSetting_Environment) GetTitle() string {
+func (x *EnvironmentSetting_Environment) GetId() string {
if x != nil {
- return x.Title
+ return x.Id
}
return ""
}
-func (x *EnvironmentSetting_Environment) GetId() string {
+func (x *EnvironmentSetting_Environment) GetTitle() string {
if x != nil {
- return x.Id
+ return x.Title
}
return ""
}
@@ -2823,9 +2823,9 @@ const file_store_setting_proto_rawDesc = "" +
"\fAZURE_OPENAI\x10\x04\"\xbb\x02\n" +
"\x12EnvironmentSetting\x12R\n" +
"\fenvironments\x18\x01 \x03(\v2..bytebase.store.EnvironmentSetting.EnvironmentR\fenvironments\x1a\xd0\x01\n" +
- "\vEnvironment\x12\x14\n" +
- "\x05title\x18\x01 \x01(\tR\x05title\x12\x0e\n" +
- "\x02id\x18\x02 \x01(\tR\x02id\x12L\n" +
+ "\vEnvironment\x12\x0e\n" +
+ "\x02id\x18\x01 \x01(\tR\x02id\x12\x14\n" +
+ "\x05title\x18\x02 \x01(\tR\x05title\x12L\n" +
"\x04tags\x18\x03 \x03(\v28.bytebase.store.EnvironmentSetting.Environment.TagsEntryR\x04tags\x12\x14\n" +
"\x05color\x18\x04 \x01(\tR\x05color\x1a7\n" +
"\tTagsEntry\x12\x10\n" +
diff --git a/proto/generated-go/v1/environment_service.pb.go b/proto/generated-go/v1/environment_service.pb.go
deleted file mode 100644
index 8f28fc247c..0000000000
--- a/proto/generated-go/v1/environment_service.pb.go
+++ /dev/null
@@ -1,670 +0,0 @@
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// versions:
-// protoc-gen-go v1.36.6
-// protoc (unknown)
-// source: v1/environment_service.proto
-
-package v1
-
-import (
- _ "google.golang.org/genproto/googleapis/api/annotations"
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- emptypb "google.golang.org/protobuf/types/known/emptypb"
- fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
- reflect "reflect"
- sync "sync"
- unsafe "unsafe"
-)
-
-const (
- // Verify that this generated code is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
- // Verify that runtime/protoimpl is sufficiently up-to-date.
- _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
-)
-
-type EnvironmentTier int32
-
-const (
- EnvironmentTier_ENVIRONMENT_TIER_UNSPECIFIED EnvironmentTier = 0
- EnvironmentTier_PROTECTED EnvironmentTier = 1
- EnvironmentTier_UNPROTECTED EnvironmentTier = 2
-)
-
-// Enum value maps for EnvironmentTier.
-var (
- EnvironmentTier_name = map[int32]string{
- 0: "ENVIRONMENT_TIER_UNSPECIFIED",
- 1: "PROTECTED",
- 2: "UNPROTECTED",
- }
- EnvironmentTier_value = map[string]int32{
- "ENVIRONMENT_TIER_UNSPECIFIED": 0,
- "PROTECTED": 1,
- "UNPROTECTED": 2,
- }
-)
-
-func (x EnvironmentTier) Enum() *EnvironmentTier {
- p := new(EnvironmentTier)
- *p = x
- return p
-}
-
-func (x EnvironmentTier) String() string {
- return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
-}
-
-func (EnvironmentTier) Descriptor() protoreflect.EnumDescriptor {
- return file_v1_environment_service_proto_enumTypes[0].Descriptor()
-}
-
-func (EnvironmentTier) Type() protoreflect.EnumType {
- return &file_v1_environment_service_proto_enumTypes[0]
-}
-
-func (x EnvironmentTier) Number() protoreflect.EnumNumber {
- return protoreflect.EnumNumber(x)
-}
-
-// Deprecated: Use EnvironmentTier.Descriptor instead.
-func (EnvironmentTier) EnumDescriptor() ([]byte, []int) {
- return file_v1_environment_service_proto_rawDescGZIP(), []int{0}
-}
-
-type GetEnvironmentRequest struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // The name of the environment to retrieve.
- // Format: environments/{environment}
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *GetEnvironmentRequest) Reset() {
- *x = GetEnvironmentRequest{}
- mi := &file_v1_environment_service_proto_msgTypes[0]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *GetEnvironmentRequest) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*GetEnvironmentRequest) ProtoMessage() {}
-
-func (x *GetEnvironmentRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_environment_service_proto_msgTypes[0]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use GetEnvironmentRequest.ProtoReflect.Descriptor instead.
-func (*GetEnvironmentRequest) Descriptor() ([]byte, []int) {
- return file_v1_environment_service_proto_rawDescGZIP(), []int{0}
-}
-
-func (x *GetEnvironmentRequest) GetName() string {
- if x != nil {
- return x.Name
- }
- return ""
-}
-
-type ListEnvironmentsRequest struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // Not used.
- // The maximum number of environments to return. The service may return fewer than
- // this value.
- // If unspecified, at most 10 environments will be returned.
- // The maximum value is 1000; values above 1000 will be coerced to 1000.
- PageSize int32 `protobuf:"varint,1,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
- // Not used.
- // A page token, received from a previous `ListEnvironments` call.
- // Provide this to retrieve the subsequent page.
- //
- // When paginating, all other parameters provided to `ListEnvironments` must match
- // the call that provided the page token.
- PageToken string `protobuf:"bytes,2,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"`
- // Show deleted environments if specified.
- ShowDeleted bool `protobuf:"varint,3,opt,name=show_deleted,json=showDeleted,proto3" json:"show_deleted,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *ListEnvironmentsRequest) Reset() {
- *x = ListEnvironmentsRequest{}
- mi := &file_v1_environment_service_proto_msgTypes[1]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *ListEnvironmentsRequest) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*ListEnvironmentsRequest) ProtoMessage() {}
-
-func (x *ListEnvironmentsRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_environment_service_proto_msgTypes[1]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use ListEnvironmentsRequest.ProtoReflect.Descriptor instead.
-func (*ListEnvironmentsRequest) Descriptor() ([]byte, []int) {
- return file_v1_environment_service_proto_rawDescGZIP(), []int{1}
-}
-
-func (x *ListEnvironmentsRequest) GetPageSize() int32 {
- if x != nil {
- return x.PageSize
- }
- return 0
-}
-
-func (x *ListEnvironmentsRequest) GetPageToken() string {
- if x != nil {
- return x.PageToken
- }
- return ""
-}
-
-func (x *ListEnvironmentsRequest) GetShowDeleted() bool {
- if x != nil {
- return x.ShowDeleted
- }
- return false
-}
-
-type ListEnvironmentsResponse struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // The environments from the specified request.
- Environments []*Environment `protobuf:"bytes,1,rep,name=environments,proto3" json:"environments,omitempty"`
- // A token, which can be sent as `page_token` to retrieve the next page.
- // If this field is omitted, there are no subsequent pages.
- NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *ListEnvironmentsResponse) Reset() {
- *x = ListEnvironmentsResponse{}
- mi := &file_v1_environment_service_proto_msgTypes[2]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *ListEnvironmentsResponse) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*ListEnvironmentsResponse) ProtoMessage() {}
-
-func (x *ListEnvironmentsResponse) ProtoReflect() protoreflect.Message {
- mi := &file_v1_environment_service_proto_msgTypes[2]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use ListEnvironmentsResponse.ProtoReflect.Descriptor instead.
-func (*ListEnvironmentsResponse) Descriptor() ([]byte, []int) {
- return file_v1_environment_service_proto_rawDescGZIP(), []int{2}
-}
-
-func (x *ListEnvironmentsResponse) GetEnvironments() []*Environment {
- if x != nil {
- return x.Environments
- }
- return nil
-}
-
-func (x *ListEnvironmentsResponse) GetNextPageToken() string {
- if x != nil {
- return x.NextPageToken
- }
- return ""
-}
-
-type CreateEnvironmentRequest struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // The environment to create.
- Environment *Environment `protobuf:"bytes,1,opt,name=environment,proto3" json:"environment,omitempty"`
- // The ID to use for the environment, which will become the final component of
- // the environment's resource name.
- //
- // This value should be 4-63 characters, and valid characters
- // are /[a-z][0-9]-/.
- EnvironmentId string `protobuf:"bytes,2,opt,name=environment_id,json=environmentId,proto3" json:"environment_id,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *CreateEnvironmentRequest) Reset() {
- *x = CreateEnvironmentRequest{}
- mi := &file_v1_environment_service_proto_msgTypes[3]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *CreateEnvironmentRequest) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*CreateEnvironmentRequest) ProtoMessage() {}
-
-func (x *CreateEnvironmentRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_environment_service_proto_msgTypes[3]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use CreateEnvironmentRequest.ProtoReflect.Descriptor instead.
-func (*CreateEnvironmentRequest) Descriptor() ([]byte, []int) {
- return file_v1_environment_service_proto_rawDescGZIP(), []int{3}
-}
-
-func (x *CreateEnvironmentRequest) GetEnvironment() *Environment {
- if x != nil {
- return x.Environment
- }
- return nil
-}
-
-func (x *CreateEnvironmentRequest) GetEnvironmentId() string {
- if x != nil {
- return x.EnvironmentId
- }
- return ""
-}
-
-type UpdateEnvironmentRequest struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // The environment to update.
- //
- // The environment's `name` field is used to identify the environment to update.
- // Format: environments/{environment}
- Environment *Environment `protobuf:"bytes,1,opt,name=environment,proto3" json:"environment,omitempty"`
- // The list of fields to update.
- UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *UpdateEnvironmentRequest) Reset() {
- *x = UpdateEnvironmentRequest{}
- mi := &file_v1_environment_service_proto_msgTypes[4]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *UpdateEnvironmentRequest) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*UpdateEnvironmentRequest) ProtoMessage() {}
-
-func (x *UpdateEnvironmentRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_environment_service_proto_msgTypes[4]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use UpdateEnvironmentRequest.ProtoReflect.Descriptor instead.
-func (*UpdateEnvironmentRequest) Descriptor() ([]byte, []int) {
- return file_v1_environment_service_proto_rawDescGZIP(), []int{4}
-}
-
-func (x *UpdateEnvironmentRequest) GetEnvironment() *Environment {
- if x != nil {
- return x.Environment
- }
- return nil
-}
-
-func (x *UpdateEnvironmentRequest) GetUpdateMask() *fieldmaskpb.FieldMask {
- if x != nil {
- return x.UpdateMask
- }
- return nil
-}
-
-type DeleteEnvironmentRequest struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // The name of the environment to delete.
- // Format: environments/{environment}
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *DeleteEnvironmentRequest) Reset() {
- *x = DeleteEnvironmentRequest{}
- mi := &file_v1_environment_service_proto_msgTypes[5]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *DeleteEnvironmentRequest) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*DeleteEnvironmentRequest) ProtoMessage() {}
-
-func (x *DeleteEnvironmentRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_environment_service_proto_msgTypes[5]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use DeleteEnvironmentRequest.ProtoReflect.Descriptor instead.
-func (*DeleteEnvironmentRequest) Descriptor() ([]byte, []int) {
- return file_v1_environment_service_proto_rawDescGZIP(), []int{5}
-}
-
-func (x *DeleteEnvironmentRequest) GetName() string {
- if x != nil {
- return x.Name
- }
- return ""
-}
-
-type UndeleteEnvironmentRequest struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // The name of the deleted environment.
- // Format: environments/{environment}
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *UndeleteEnvironmentRequest) Reset() {
- *x = UndeleteEnvironmentRequest{}
- mi := &file_v1_environment_service_proto_msgTypes[6]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *UndeleteEnvironmentRequest) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*UndeleteEnvironmentRequest) ProtoMessage() {}
-
-func (x *UndeleteEnvironmentRequest) ProtoReflect() protoreflect.Message {
- mi := &file_v1_environment_service_proto_msgTypes[6]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use UndeleteEnvironmentRequest.ProtoReflect.Descriptor instead.
-func (*UndeleteEnvironmentRequest) Descriptor() ([]byte, []int) {
- return file_v1_environment_service_proto_rawDescGZIP(), []int{6}
-}
-
-func (x *UndeleteEnvironmentRequest) GetName() string {
- if x != nil {
- return x.Name
- }
- return ""
-}
-
-type Environment struct {
- state protoimpl.MessageState `protogen:"open.v1"`
- // The name of the environment.
- // Format: environments/{environment}
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- State State `protobuf:"varint,3,opt,name=state,proto3,enum=bytebase.v1.State" json:"state,omitempty"`
- Title string `protobuf:"bytes,4,opt,name=title,proto3" json:"title,omitempty"`
- Order int32 `protobuf:"varint,5,opt,name=order,proto3" json:"order,omitempty"`
- Tier EnvironmentTier `protobuf:"varint,6,opt,name=tier,proto3,enum=bytebase.v1.EnvironmentTier" json:"tier,omitempty"`
- Color string `protobuf:"bytes,7,opt,name=color,proto3" json:"color,omitempty"`
- unknownFields protoimpl.UnknownFields
- sizeCache protoimpl.SizeCache
-}
-
-func (x *Environment) Reset() {
- *x = Environment{}
- mi := &file_v1_environment_service_proto_msgTypes[7]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
-}
-
-func (x *Environment) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Environment) ProtoMessage() {}
-
-func (x *Environment) ProtoReflect() protoreflect.Message {
- mi := &file_v1_environment_service_proto_msgTypes[7]
- if x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Environment.ProtoReflect.Descriptor instead.
-func (*Environment) Descriptor() ([]byte, []int) {
- return file_v1_environment_service_proto_rawDescGZIP(), []int{7}
-}
-
-func (x *Environment) GetName() string {
- if x != nil {
- return x.Name
- }
- return ""
-}
-
-func (x *Environment) GetState() State {
- if x != nil {
- return x.State
- }
- return State_STATE_UNSPECIFIED
-}
-
-func (x *Environment) GetTitle() string {
- if x != nil {
- return x.Title
- }
- return ""
-}
-
-func (x *Environment) GetOrder() int32 {
- if x != nil {
- return x.Order
- }
- return 0
-}
-
-func (x *Environment) GetTier() EnvironmentTier {
- if x != nil {
- return x.Tier
- }
- return EnvironmentTier_ENVIRONMENT_TIER_UNSPECIFIED
-}
-
-func (x *Environment) GetColor() string {
- if x != nil {
- return x.Color
- }
- return ""
-}
-
-var File_v1_environment_service_proto protoreflect.FileDescriptor
-
-const file_v1_environment_service_proto_rawDesc = "" +
- "\n" +
- "\x1cv1/environment_service.proto\x12\vbytebase.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x13v1/annotation.proto\x1a\x0fv1/common.proto\"N\n" +
- "\x15GetEnvironmentRequest\x125\n" +
- "\x04name\x18\x01 \x01(\tB!\xe2A\x01\x02\xfaA\x1a\n" +
- "\x18bytebase.com/EnvironmentR\x04name\"x\n" +
- "\x17ListEnvironmentsRequest\x12\x1b\n" +
- "\tpage_size\x18\x01 \x01(\x05R\bpageSize\x12\x1d\n" +
- "\n" +
- "page_token\x18\x02 \x01(\tR\tpageToken\x12!\n" +
- "\fshow_deleted\x18\x03 \x01(\bR\vshowDeleted\"\x80\x01\n" +
- "\x18ListEnvironmentsResponse\x12<\n" +
- "\fenvironments\x18\x01 \x03(\v2\x18.bytebase.v1.EnvironmentR\fenvironments\x12&\n" +
- "\x0fnext_page_token\x18\x02 \x01(\tR\rnextPageToken\"\x83\x01\n" +
- "\x18CreateEnvironmentRequest\x12@\n" +
- "\venvironment\x18\x01 \x01(\v2\x18.bytebase.v1.EnvironmentB\x04\xe2A\x01\x02R\venvironment\x12%\n" +
- "\x0eenvironment_id\x18\x02 \x01(\tR\renvironmentId\"\x99\x01\n" +
- "\x18UpdateEnvironmentRequest\x12@\n" +
- "\venvironment\x18\x01 \x01(\v2\x18.bytebase.v1.EnvironmentB\x04\xe2A\x01\x02R\venvironment\x12;\n" +
- "\vupdate_mask\x18\x02 \x01(\v2\x1a.google.protobuf.FieldMaskR\n" +
- "updateMask\"Q\n" +
- "\x18DeleteEnvironmentRequest\x125\n" +
- "\x04name\x18\x01 \x01(\tB!\xe2A\x01\x02\xfaA\x1a\n" +
- "\x18bytebase.com/EnvironmentR\x04name\"S\n" +
- "\x1aUndeleteEnvironmentRequest\x125\n" +
- "\x04name\x18\x01 \x01(\tB!\xe2A\x01\x02\xfaA\x1a\n" +
- "\x18bytebase.com/EnvironmentR\x04name\"\x80\x02\n" +
- "\vEnvironment\x12\x12\n" +
- "\x04name\x18\x01 \x01(\tR\x04name\x12(\n" +
- "\x05state\x18\x03 \x01(\x0e2\x12.bytebase.v1.StateR\x05state\x12\x14\n" +
- "\x05title\x18\x04 \x01(\tR\x05title\x12\x14\n" +
- "\x05order\x18\x05 \x01(\x05R\x05order\x120\n" +
- "\x04tier\x18\x06 \x01(\x0e2\x1c.bytebase.v1.EnvironmentTierR\x04tier\x12\x14\n" +
- "\x05color\x18\a \x01(\tR\x05color:9\xeaA6\n" +
- "\x18bytebase.com/Environment\x12\x1aenvironments/{environment}J\x04\b\x02\x10\x03*S\n" +
- "\x0fEnvironmentTier\x12 \n" +
- "\x1cENVIRONMENT_TIER_UNSPECIFIED\x10\x00\x12\r\n" +
- "\tPROTECTED\x10\x01\x12\x0f\n" +
- "\vUNPROTECTED\x10\x022\x86\b\n" +
- "\x12EnvironmentService\x12\x93\x01\n" +
- "\x0eGetEnvironment\x12\".bytebase.v1.GetEnvironmentRequest\x1a\x18.bytebase.v1.Environment\"C\xdaA\x04name\x8a\xea0\x13bb.environments.get\x90\xea0\x01\x82\xd3\xe4\x93\x02\x1b\x12\x19/v1/{name=environments/*}\x12\x98\x01\n" +
- "\x10ListEnvironments\x12$.bytebase.v1.ListEnvironmentsRequest\x1a%.bytebase.v1.ListEnvironmentsResponse\"7\xdaA\x00\x8a\xea0\x14bb.environments.list\x90\xea0\x01\x82\xd3\xe4\x93\x02\x12\x12\x10/v1/environments\x12\xa0\x01\n" +
- "\x11CreateEnvironment\x12%.bytebase.v1.CreateEnvironmentRequest\x1a\x18.bytebase.v1.Environment\"J\xdaA\x00\x8a\xea0\x16bb.environments.create\x90\xea0\x01\x98\xea0\x01\x82\xd3\xe4\x93\x02\x1f:\venvironment\"\x10/v1/environments\x12\xcc\x01\n" +
- "\x11UpdateEnvironment\x12%.bytebase.v1.UpdateEnvironmentRequest\x1a\x18.bytebase.v1.Environment\"v\xdaA\x17environment,update_mask\x8a\xea0\x16bb.environments.update\x90\xea0\x01\x98\xea0\x01\x82\xd3\xe4\x93\x024:\venvironment2%/v1/{environment.name=environments/*}\x12\x9e\x01\n" +
- "\x11DeleteEnvironment\x12%.bytebase.v1.DeleteEnvironmentRequest\x1a\x16.google.protobuf.Empty\"J\xdaA\x04name\x8a\xea0\x16bb.environments.delete\x90\xea0\x01\x98\xea0\x01\x82\xd3\xe4\x93\x02\x1b*\x19/v1/{name=environments/*}\x12\xab\x01\n" +
- "\x13UndeleteEnvironment\x12'.bytebase.v1.UndeleteEnvironmentRequest\x1a\x18.bytebase.v1.Environment\"Q\x8a\xea0\x18bb.environments.undelete\x90\xea0\x01\x98\xea0\x01\x82\xd3\xe4\x93\x02':\x01*\"\"/v1/{name=environments/*}:undeleteB\x11Z\x0fgenerated-go/v1b\x06proto3"
-
-var (
- file_v1_environment_service_proto_rawDescOnce sync.Once
- file_v1_environment_service_proto_rawDescData []byte
-)
-
-func file_v1_environment_service_proto_rawDescGZIP() []byte {
- file_v1_environment_service_proto_rawDescOnce.Do(func() {
- file_v1_environment_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_v1_environment_service_proto_rawDesc), len(file_v1_environment_service_proto_rawDesc)))
- })
- return file_v1_environment_service_proto_rawDescData
-}
-
-var file_v1_environment_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
-var file_v1_environment_service_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
-var file_v1_environment_service_proto_goTypes = []any{
- (EnvironmentTier)(0), // 0: bytebase.v1.EnvironmentTier
- (*GetEnvironmentRequest)(nil), // 1: bytebase.v1.GetEnvironmentRequest
- (*ListEnvironmentsRequest)(nil), // 2: bytebase.v1.ListEnvironmentsRequest
- (*ListEnvironmentsResponse)(nil), // 3: bytebase.v1.ListEnvironmentsResponse
- (*CreateEnvironmentRequest)(nil), // 4: bytebase.v1.CreateEnvironmentRequest
- (*UpdateEnvironmentRequest)(nil), // 5: bytebase.v1.UpdateEnvironmentRequest
- (*DeleteEnvironmentRequest)(nil), // 6: bytebase.v1.DeleteEnvironmentRequest
- (*UndeleteEnvironmentRequest)(nil), // 7: bytebase.v1.UndeleteEnvironmentRequest
- (*Environment)(nil), // 8: bytebase.v1.Environment
- (*fieldmaskpb.FieldMask)(nil), // 9: google.protobuf.FieldMask
- (State)(0), // 10: bytebase.v1.State
- (*emptypb.Empty)(nil), // 11: google.protobuf.Empty
-}
-var file_v1_environment_service_proto_depIdxs = []int32{
- 8, // 0: bytebase.v1.ListEnvironmentsResponse.environments:type_name -> bytebase.v1.Environment
- 8, // 1: bytebase.v1.CreateEnvironmentRequest.environment:type_name -> bytebase.v1.Environment
- 8, // 2: bytebase.v1.UpdateEnvironmentRequest.environment:type_name -> bytebase.v1.Environment
- 9, // 3: bytebase.v1.UpdateEnvironmentRequest.update_mask:type_name -> google.protobuf.FieldMask
- 10, // 4: bytebase.v1.Environment.state:type_name -> bytebase.v1.State
- 0, // 5: bytebase.v1.Environment.tier:type_name -> bytebase.v1.EnvironmentTier
- 1, // 6: bytebase.v1.EnvironmentService.GetEnvironment:input_type -> bytebase.v1.GetEnvironmentRequest
- 2, // 7: bytebase.v1.EnvironmentService.ListEnvironments:input_type -> bytebase.v1.ListEnvironmentsRequest
- 4, // 8: bytebase.v1.EnvironmentService.CreateEnvironment:input_type -> bytebase.v1.CreateEnvironmentRequest
- 5, // 9: bytebase.v1.EnvironmentService.UpdateEnvironment:input_type -> bytebase.v1.UpdateEnvironmentRequest
- 6, // 10: bytebase.v1.EnvironmentService.DeleteEnvironment:input_type -> bytebase.v1.DeleteEnvironmentRequest
- 7, // 11: bytebase.v1.EnvironmentService.UndeleteEnvironment:input_type -> bytebase.v1.UndeleteEnvironmentRequest
- 8, // 12: bytebase.v1.EnvironmentService.GetEnvironment:output_type -> bytebase.v1.Environment
- 3, // 13: bytebase.v1.EnvironmentService.ListEnvironments:output_type -> bytebase.v1.ListEnvironmentsResponse
- 8, // 14: bytebase.v1.EnvironmentService.CreateEnvironment:output_type -> bytebase.v1.Environment
- 8, // 15: bytebase.v1.EnvironmentService.UpdateEnvironment:output_type -> bytebase.v1.Environment
- 11, // 16: bytebase.v1.EnvironmentService.DeleteEnvironment:output_type -> google.protobuf.Empty
- 8, // 17: bytebase.v1.EnvironmentService.UndeleteEnvironment:output_type -> bytebase.v1.Environment
- 12, // [12:18] is the sub-list for method output_type
- 6, // [6:12] is the sub-list for method input_type
- 6, // [6:6] is the sub-list for extension type_name
- 6, // [6:6] is the sub-list for extension extendee
- 0, // [0:6] is the sub-list for field type_name
-}
-
-func init() { file_v1_environment_service_proto_init() }
-func file_v1_environment_service_proto_init() {
- if File_v1_environment_service_proto != nil {
- return
- }
- file_v1_annotation_proto_init()
- file_v1_common_proto_init()
- type x struct{}
- out := protoimpl.TypeBuilder{
- File: protoimpl.DescBuilder{
- GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
- RawDescriptor: unsafe.Slice(unsafe.StringData(file_v1_environment_service_proto_rawDesc), len(file_v1_environment_service_proto_rawDesc)),
- NumEnums: 1,
- NumMessages: 8,
- NumExtensions: 0,
- NumServices: 1,
- },
- GoTypes: file_v1_environment_service_proto_goTypes,
- DependencyIndexes: file_v1_environment_service_proto_depIdxs,
- EnumInfos: file_v1_environment_service_proto_enumTypes,
- MessageInfos: file_v1_environment_service_proto_msgTypes,
- }.Build()
- File_v1_environment_service_proto = out.File
- file_v1_environment_service_proto_goTypes = nil
- file_v1_environment_service_proto_depIdxs = nil
-}
diff --git a/proto/generated-go/v1/environment_service.pb.gw.go b/proto/generated-go/v1/environment_service.pb.gw.go
deleted file mode 100644
index 2410e674d1..0000000000
--- a/proto/generated-go/v1/environment_service.pb.gw.go
+++ /dev/null
@@ -1,590 +0,0 @@
-// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
-// source: v1/environment_service.proto
-
-/*
-Package v1 is a reverse proxy.
-
-It translates gRPC into RESTful JSON APIs.
-*/
-package v1
-
-import (
- "context"
- "errors"
- "io"
- "net/http"
-
- "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
- "github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
- "google.golang.org/grpc"
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/grpclog"
- "google.golang.org/grpc/metadata"
- "google.golang.org/grpc/status"
- "google.golang.org/protobuf/proto"
-)
-
-// Suppress "imported and not used" errors
-var (
- _ codes.Code
- _ io.Reader
- _ status.Status
- _ = errors.New
- _ = runtime.String
- _ = utilities.NewDoubleArray
- _ = metadata.Join
-)
-
-func request_EnvironmentService_GetEnvironment_0(ctx context.Context, marshaler runtime.Marshaler, client EnvironmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq GetEnvironmentRequest
- metadata runtime.ServerMetadata
- err error
- )
- io.Copy(io.Discard, req.Body)
- val, ok := pathParams["name"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
- }
- protoReq.Name, err = runtime.String(val)
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
- }
- msg, err := client.GetEnvironment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-}
-
-func local_request_EnvironmentService_GetEnvironment_0(ctx context.Context, marshaler runtime.Marshaler, server EnvironmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq GetEnvironmentRequest
- metadata runtime.ServerMetadata
- err error
- )
- val, ok := pathParams["name"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
- }
- protoReq.Name, err = runtime.String(val)
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
- }
- msg, err := server.GetEnvironment(ctx, &protoReq)
- return msg, metadata, err
-}
-
-var filter_EnvironmentService_ListEnvironments_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
-
-func request_EnvironmentService_ListEnvironments_0(ctx context.Context, marshaler runtime.Marshaler, client EnvironmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq ListEnvironmentsRequest
- metadata runtime.ServerMetadata
- )
- io.Copy(io.Discard, req.Body)
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EnvironmentService_ListEnvironments_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- msg, err := client.ListEnvironments(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-}
-
-func local_request_EnvironmentService_ListEnvironments_0(ctx context.Context, marshaler runtime.Marshaler, server EnvironmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq ListEnvironmentsRequest
- metadata runtime.ServerMetadata
- )
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EnvironmentService_ListEnvironments_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- msg, err := server.ListEnvironments(ctx, &protoReq)
- return msg, metadata, err
-}
-
-var filter_EnvironmentService_CreateEnvironment_0 = &utilities.DoubleArray{Encoding: map[string]int{"environment": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
-
-func request_EnvironmentService_CreateEnvironment_0(ctx context.Context, marshaler runtime.Marshaler, client EnvironmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq CreateEnvironmentRequest
- metadata runtime.ServerMetadata
- )
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Environment); err != nil && !errors.Is(err, io.EOF) {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EnvironmentService_CreateEnvironment_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- msg, err := client.CreateEnvironment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-}
-
-func local_request_EnvironmentService_CreateEnvironment_0(ctx context.Context, marshaler runtime.Marshaler, server EnvironmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq CreateEnvironmentRequest
- metadata runtime.ServerMetadata
- )
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Environment); err != nil && !errors.Is(err, io.EOF) {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EnvironmentService_CreateEnvironment_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- msg, err := server.CreateEnvironment(ctx, &protoReq)
- return msg, metadata, err
-}
-
-var filter_EnvironmentService_UpdateEnvironment_0 = &utilities.DoubleArray{Encoding: map[string]int{"environment": 0, "name": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}}
-
-func request_EnvironmentService_UpdateEnvironment_0(ctx context.Context, marshaler runtime.Marshaler, client EnvironmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq UpdateEnvironmentRequest
- metadata runtime.ServerMetadata
- err error
- )
- newReader, berr := utilities.IOReaderFactory(req.Body)
- if berr != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
- }
- if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Environment); err != nil && !errors.Is(err, io.EOF) {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
- if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Environment); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- } else {
- protoReq.UpdateMask = fieldMask
- }
- }
- val, ok := pathParams["environment.name"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "environment.name")
- }
- err = runtime.PopulateFieldFromPath(&protoReq, "environment.name", val)
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "environment.name", err)
- }
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EnvironmentService_UpdateEnvironment_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- msg, err := client.UpdateEnvironment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-}
-
-func local_request_EnvironmentService_UpdateEnvironment_0(ctx context.Context, marshaler runtime.Marshaler, server EnvironmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq UpdateEnvironmentRequest
- metadata runtime.ServerMetadata
- err error
- )
- newReader, berr := utilities.IOReaderFactory(req.Body)
- if berr != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
- }
- if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.Environment); err != nil && !errors.Is(err, io.EOF) {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
- if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.Environment); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- } else {
- protoReq.UpdateMask = fieldMask
- }
- }
- val, ok := pathParams["environment.name"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "environment.name")
- }
- err = runtime.PopulateFieldFromPath(&protoReq, "environment.name", val)
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "environment.name", err)
- }
- if err := req.ParseForm(); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_EnvironmentService_UpdateEnvironment_0); err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- msg, err := server.UpdateEnvironment(ctx, &protoReq)
- return msg, metadata, err
-}
-
-func request_EnvironmentService_DeleteEnvironment_0(ctx context.Context, marshaler runtime.Marshaler, client EnvironmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq DeleteEnvironmentRequest
- metadata runtime.ServerMetadata
- err error
- )
- io.Copy(io.Discard, req.Body)
- val, ok := pathParams["name"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
- }
- protoReq.Name, err = runtime.String(val)
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
- }
- msg, err := client.DeleteEnvironment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-}
-
-func local_request_EnvironmentService_DeleteEnvironment_0(ctx context.Context, marshaler runtime.Marshaler, server EnvironmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq DeleteEnvironmentRequest
- metadata runtime.ServerMetadata
- err error
- )
- val, ok := pathParams["name"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
- }
- protoReq.Name, err = runtime.String(val)
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
- }
- msg, err := server.DeleteEnvironment(ctx, &protoReq)
- return msg, metadata, err
-}
-
-func request_EnvironmentService_UndeleteEnvironment_0(ctx context.Context, marshaler runtime.Marshaler, client EnvironmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq UndeleteEnvironmentRequest
- metadata runtime.ServerMetadata
- err error
- )
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- val, ok := pathParams["name"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
- }
- protoReq.Name, err = runtime.String(val)
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
- }
- msg, err := client.UndeleteEnvironment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
- return msg, metadata, err
-}
-
-func local_request_EnvironmentService_UndeleteEnvironment_0(ctx context.Context, marshaler runtime.Marshaler, server EnvironmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
- var (
- protoReq UndeleteEnvironmentRequest
- metadata runtime.ServerMetadata
- err error
- )
- if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
- }
- val, ok := pathParams["name"]
- if !ok {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
- }
- protoReq.Name, err = runtime.String(val)
- if err != nil {
- return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
- }
- msg, err := server.UndeleteEnvironment(ctx, &protoReq)
- return msg, metadata, err
-}
-
-// RegisterEnvironmentServiceHandlerServer registers the http handlers for service EnvironmentService to "mux".
-// UnaryRPC :call EnvironmentServiceServer directly.
-// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
-// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterEnvironmentServiceHandlerFromEndpoint instead.
-// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
-func RegisterEnvironmentServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server EnvironmentServiceServer) error {
- mux.Handle(http.MethodGet, pattern_EnvironmentService_GetEnvironment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/GetEnvironment", runtime.WithHTTPPathPattern("/v1/{name=environments/*}"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_EnvironmentService_GetEnvironment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_GetEnvironment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
- mux.Handle(http.MethodGet, pattern_EnvironmentService_ListEnvironments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/ListEnvironments", runtime.WithHTTPPathPattern("/v1/environments"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_EnvironmentService_ListEnvironments_0(annotatedContext, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_ListEnvironments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
- mux.Handle(http.MethodPost, pattern_EnvironmentService_CreateEnvironment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/CreateEnvironment", runtime.WithHTTPPathPattern("/v1/environments"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_EnvironmentService_CreateEnvironment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_CreateEnvironment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
- mux.Handle(http.MethodPatch, pattern_EnvironmentService_UpdateEnvironment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/UpdateEnvironment", runtime.WithHTTPPathPattern("/v1/{environment.name=environments/*}"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_EnvironmentService_UpdateEnvironment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_UpdateEnvironment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
- mux.Handle(http.MethodDelete, pattern_EnvironmentService_DeleteEnvironment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/DeleteEnvironment", runtime.WithHTTPPathPattern("/v1/{name=environments/*}"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_EnvironmentService_DeleteEnvironment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_DeleteEnvironment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
- mux.Handle(http.MethodPost, pattern_EnvironmentService_UndeleteEnvironment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- var stream runtime.ServerTransportStream
- ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/UndeleteEnvironment", runtime.WithHTTPPathPattern("/v1/{name=environments/*}:undelete"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := local_request_EnvironmentService_UndeleteEnvironment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
- md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_UndeleteEnvironment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
-
- return nil
-}
-
-// RegisterEnvironmentServiceHandlerFromEndpoint is same as RegisterEnvironmentServiceHandler but
-// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
-func RegisterEnvironmentServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
- conn, err := grpc.NewClient(endpoint, opts...)
- if err != nil {
- return err
- }
- defer func() {
- if err != nil {
- if cerr := conn.Close(); cerr != nil {
- grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- return
- }
- go func() {
- <-ctx.Done()
- if cerr := conn.Close(); cerr != nil {
- grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
- }
- }()
- }()
- return RegisterEnvironmentServiceHandler(ctx, mux, conn)
-}
-
-// RegisterEnvironmentServiceHandler registers the http handlers for service EnvironmentService to "mux".
-// The handlers forward requests to the grpc endpoint over "conn".
-func RegisterEnvironmentServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
- return RegisterEnvironmentServiceHandlerClient(ctx, mux, NewEnvironmentServiceClient(conn))
-}
-
-// RegisterEnvironmentServiceHandlerClient registers the http handlers for service EnvironmentService
-// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "EnvironmentServiceClient".
-// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "EnvironmentServiceClient"
-// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
-// "EnvironmentServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares.
-func RegisterEnvironmentServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client EnvironmentServiceClient) error {
- mux.Handle(http.MethodGet, pattern_EnvironmentService_GetEnvironment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/GetEnvironment", runtime.WithHTTPPathPattern("/v1/{name=environments/*}"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_EnvironmentService_GetEnvironment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_GetEnvironment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
- mux.Handle(http.MethodGet, pattern_EnvironmentService_ListEnvironments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/ListEnvironments", runtime.WithHTTPPathPattern("/v1/environments"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_EnvironmentService_ListEnvironments_0(annotatedContext, inboundMarshaler, client, req, pathParams)
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_ListEnvironments_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
- mux.Handle(http.MethodPost, pattern_EnvironmentService_CreateEnvironment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/CreateEnvironment", runtime.WithHTTPPathPattern("/v1/environments"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_EnvironmentService_CreateEnvironment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_CreateEnvironment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
- mux.Handle(http.MethodPatch, pattern_EnvironmentService_UpdateEnvironment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/UpdateEnvironment", runtime.WithHTTPPathPattern("/v1/{environment.name=environments/*}"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_EnvironmentService_UpdateEnvironment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_UpdateEnvironment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
- mux.Handle(http.MethodDelete, pattern_EnvironmentService_DeleteEnvironment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/DeleteEnvironment", runtime.WithHTTPPathPattern("/v1/{name=environments/*}"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_EnvironmentService_DeleteEnvironment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_DeleteEnvironment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
- mux.Handle(http.MethodPost, pattern_EnvironmentService_UndeleteEnvironment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
- ctx, cancel := context.WithCancel(req.Context())
- defer cancel()
- inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
- annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.EnvironmentService/UndeleteEnvironment", runtime.WithHTTPPathPattern("/v1/{name=environments/*}:undelete"))
- if err != nil {
- runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
- return
- }
- resp, md, err := request_EnvironmentService_UndeleteEnvironment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
- annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
- if err != nil {
- runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
- return
- }
- forward_EnvironmentService_UndeleteEnvironment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
- })
- return nil
-}
-
-var (
- pattern_EnvironmentService_GetEnvironment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "environments", "name"}, ""))
- pattern_EnvironmentService_ListEnvironments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "environments"}, ""))
- pattern_EnvironmentService_CreateEnvironment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "environments"}, ""))
- pattern_EnvironmentService_UpdateEnvironment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "environments", "environment.name"}, ""))
- pattern_EnvironmentService_DeleteEnvironment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "environments", "name"}, ""))
- pattern_EnvironmentService_UndeleteEnvironment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "environments", "name"}, "undelete"))
-)
-
-var (
- forward_EnvironmentService_GetEnvironment_0 = runtime.ForwardResponseMessage
- forward_EnvironmentService_ListEnvironments_0 = runtime.ForwardResponseMessage
- forward_EnvironmentService_CreateEnvironment_0 = runtime.ForwardResponseMessage
- forward_EnvironmentService_UpdateEnvironment_0 = runtime.ForwardResponseMessage
- forward_EnvironmentService_DeleteEnvironment_0 = runtime.ForwardResponseMessage
- forward_EnvironmentService_UndeleteEnvironment_0 = runtime.ForwardResponseMessage
-)
diff --git a/proto/generated-go/v1/environment_service_grpc.pb.go b/proto/generated-go/v1/environment_service_grpc.pb.go
deleted file mode 100644
index ff301883ef..0000000000
--- a/proto/generated-go/v1/environment_service_grpc.pb.go
+++ /dev/null
@@ -1,312 +0,0 @@
-// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
-// versions:
-// - protoc-gen-go-grpc v1.5.1
-// - protoc (unknown)
-// source: v1/environment_service.proto
-
-package v1
-
-import (
- context "context"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
- emptypb "google.golang.org/protobuf/types/known/emptypb"
-)
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-// Requires gRPC-Go v1.64.0 or later.
-const _ = grpc.SupportPackageIsVersion9
-
-const (
- EnvironmentService_GetEnvironment_FullMethodName = "/bytebase.v1.EnvironmentService/GetEnvironment"
- EnvironmentService_ListEnvironments_FullMethodName = "/bytebase.v1.EnvironmentService/ListEnvironments"
- EnvironmentService_CreateEnvironment_FullMethodName = "/bytebase.v1.EnvironmentService/CreateEnvironment"
- EnvironmentService_UpdateEnvironment_FullMethodName = "/bytebase.v1.EnvironmentService/UpdateEnvironment"
- EnvironmentService_DeleteEnvironment_FullMethodName = "/bytebase.v1.EnvironmentService/DeleteEnvironment"
- EnvironmentService_UndeleteEnvironment_FullMethodName = "/bytebase.v1.EnvironmentService/UndeleteEnvironment"
-)
-
-// EnvironmentServiceClient is the client API for EnvironmentService service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
-type EnvironmentServiceClient interface {
- GetEnvironment(ctx context.Context, in *GetEnvironmentRequest, opts ...grpc.CallOption) (*Environment, error)
- ListEnvironments(ctx context.Context, in *ListEnvironmentsRequest, opts ...grpc.CallOption) (*ListEnvironmentsResponse, error)
- CreateEnvironment(ctx context.Context, in *CreateEnvironmentRequest, opts ...grpc.CallOption) (*Environment, error)
- UpdateEnvironment(ctx context.Context, in *UpdateEnvironmentRequest, opts ...grpc.CallOption) (*Environment, error)
- DeleteEnvironment(ctx context.Context, in *DeleteEnvironmentRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
- UndeleteEnvironment(ctx context.Context, in *UndeleteEnvironmentRequest, opts ...grpc.CallOption) (*Environment, error)
-}
-
-type environmentServiceClient struct {
- cc grpc.ClientConnInterface
-}
-
-func NewEnvironmentServiceClient(cc grpc.ClientConnInterface) EnvironmentServiceClient {
- return &environmentServiceClient{cc}
-}
-
-func (c *environmentServiceClient) GetEnvironment(ctx context.Context, in *GetEnvironmentRequest, opts ...grpc.CallOption) (*Environment, error) {
- cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
- out := new(Environment)
- err := c.cc.Invoke(ctx, EnvironmentService_GetEnvironment_FullMethodName, in, out, cOpts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *environmentServiceClient) ListEnvironments(ctx context.Context, in *ListEnvironmentsRequest, opts ...grpc.CallOption) (*ListEnvironmentsResponse, error) {
- cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
- out := new(ListEnvironmentsResponse)
- err := c.cc.Invoke(ctx, EnvironmentService_ListEnvironments_FullMethodName, in, out, cOpts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *environmentServiceClient) CreateEnvironment(ctx context.Context, in *CreateEnvironmentRequest, opts ...grpc.CallOption) (*Environment, error) {
- cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
- out := new(Environment)
- err := c.cc.Invoke(ctx, EnvironmentService_CreateEnvironment_FullMethodName, in, out, cOpts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *environmentServiceClient) UpdateEnvironment(ctx context.Context, in *UpdateEnvironmentRequest, opts ...grpc.CallOption) (*Environment, error) {
- cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
- out := new(Environment)
- err := c.cc.Invoke(ctx, EnvironmentService_UpdateEnvironment_FullMethodName, in, out, cOpts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *environmentServiceClient) DeleteEnvironment(ctx context.Context, in *DeleteEnvironmentRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
- cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
- out := new(emptypb.Empty)
- err := c.cc.Invoke(ctx, EnvironmentService_DeleteEnvironment_FullMethodName, in, out, cOpts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *environmentServiceClient) UndeleteEnvironment(ctx context.Context, in *UndeleteEnvironmentRequest, opts ...grpc.CallOption) (*Environment, error) {
- cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
- out := new(Environment)
- err := c.cc.Invoke(ctx, EnvironmentService_UndeleteEnvironment_FullMethodName, in, out, cOpts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// EnvironmentServiceServer is the server API for EnvironmentService service.
-// All implementations must embed UnimplementedEnvironmentServiceServer
-// for forward compatibility.
-type EnvironmentServiceServer interface {
- GetEnvironment(context.Context, *GetEnvironmentRequest) (*Environment, error)
- ListEnvironments(context.Context, *ListEnvironmentsRequest) (*ListEnvironmentsResponse, error)
- CreateEnvironment(context.Context, *CreateEnvironmentRequest) (*Environment, error)
- UpdateEnvironment(context.Context, *UpdateEnvironmentRequest) (*Environment, error)
- DeleteEnvironment(context.Context, *DeleteEnvironmentRequest) (*emptypb.Empty, error)
- UndeleteEnvironment(context.Context, *UndeleteEnvironmentRequest) (*Environment, error)
- mustEmbedUnimplementedEnvironmentServiceServer()
-}
-
-// UnimplementedEnvironmentServiceServer must be embedded to have
-// forward compatible implementations.
-//
-// NOTE: this should be embedded by value instead of pointer to avoid a nil
-// pointer dereference when methods are called.
-type UnimplementedEnvironmentServiceServer struct{}
-
-func (UnimplementedEnvironmentServiceServer) GetEnvironment(context.Context, *GetEnvironmentRequest) (*Environment, error) {
- return nil, status.Errorf(codes.Unimplemented, "method GetEnvironment not implemented")
-}
-func (UnimplementedEnvironmentServiceServer) ListEnvironments(context.Context, *ListEnvironmentsRequest) (*ListEnvironmentsResponse, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ListEnvironments not implemented")
-}
-func (UnimplementedEnvironmentServiceServer) CreateEnvironment(context.Context, *CreateEnvironmentRequest) (*Environment, error) {
- return nil, status.Errorf(codes.Unimplemented, "method CreateEnvironment not implemented")
-}
-func (UnimplementedEnvironmentServiceServer) UpdateEnvironment(context.Context, *UpdateEnvironmentRequest) (*Environment, error) {
- return nil, status.Errorf(codes.Unimplemented, "method UpdateEnvironment not implemented")
-}
-func (UnimplementedEnvironmentServiceServer) DeleteEnvironment(context.Context, *DeleteEnvironmentRequest) (*emptypb.Empty, error) {
- return nil, status.Errorf(codes.Unimplemented, "method DeleteEnvironment not implemented")
-}
-func (UnimplementedEnvironmentServiceServer) UndeleteEnvironment(context.Context, *UndeleteEnvironmentRequest) (*Environment, error) {
- return nil, status.Errorf(codes.Unimplemented, "method UndeleteEnvironment not implemented")
-}
-func (UnimplementedEnvironmentServiceServer) mustEmbedUnimplementedEnvironmentServiceServer() {}
-func (UnimplementedEnvironmentServiceServer) testEmbeddedByValue() {}
-
-// UnsafeEnvironmentServiceServer may be embedded to opt out of forward compatibility for this service.
-// Use of this interface is not recommended, as added methods to EnvironmentServiceServer will
-// result in compilation errors.
-type UnsafeEnvironmentServiceServer interface {
- mustEmbedUnimplementedEnvironmentServiceServer()
-}
-
-func RegisterEnvironmentServiceServer(s grpc.ServiceRegistrar, srv EnvironmentServiceServer) {
- // If the following call pancis, it indicates UnimplementedEnvironmentServiceServer was
- // embedded by pointer and is nil. This will cause panics if an
- // unimplemented method is ever invoked, so we test this at initialization
- // time to prevent it from happening at runtime later due to I/O.
- if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
- t.testEmbeddedByValue()
- }
- s.RegisterService(&EnvironmentService_ServiceDesc, srv)
-}
-
-func _EnvironmentService_GetEnvironment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(GetEnvironmentRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(EnvironmentServiceServer).GetEnvironment(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: EnvironmentService_GetEnvironment_FullMethodName,
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(EnvironmentServiceServer).GetEnvironment(ctx, req.(*GetEnvironmentRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _EnvironmentService_ListEnvironments_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(ListEnvironmentsRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(EnvironmentServiceServer).ListEnvironments(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: EnvironmentService_ListEnvironments_FullMethodName,
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(EnvironmentServiceServer).ListEnvironments(ctx, req.(*ListEnvironmentsRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _EnvironmentService_CreateEnvironment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(CreateEnvironmentRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(EnvironmentServiceServer).CreateEnvironment(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: EnvironmentService_CreateEnvironment_FullMethodName,
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(EnvironmentServiceServer).CreateEnvironment(ctx, req.(*CreateEnvironmentRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _EnvironmentService_UpdateEnvironment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(UpdateEnvironmentRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(EnvironmentServiceServer).UpdateEnvironment(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: EnvironmentService_UpdateEnvironment_FullMethodName,
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(EnvironmentServiceServer).UpdateEnvironment(ctx, req.(*UpdateEnvironmentRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _EnvironmentService_DeleteEnvironment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(DeleteEnvironmentRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(EnvironmentServiceServer).DeleteEnvironment(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: EnvironmentService_DeleteEnvironment_FullMethodName,
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(EnvironmentServiceServer).DeleteEnvironment(ctx, req.(*DeleteEnvironmentRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _EnvironmentService_UndeleteEnvironment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(UndeleteEnvironmentRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(EnvironmentServiceServer).UndeleteEnvironment(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: EnvironmentService_UndeleteEnvironment_FullMethodName,
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(EnvironmentServiceServer).UndeleteEnvironment(ctx, req.(*UndeleteEnvironmentRequest))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-// EnvironmentService_ServiceDesc is the grpc.ServiceDesc for EnvironmentService service.
-// It's only intended for direct use with grpc.RegisterService,
-// and not to be introspected or modified (even as a copy)
-var EnvironmentService_ServiceDesc = grpc.ServiceDesc{
- ServiceName: "bytebase.v1.EnvironmentService",
- HandlerType: (*EnvironmentServiceServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "GetEnvironment",
- Handler: _EnvironmentService_GetEnvironment_Handler,
- },
- {
- MethodName: "ListEnvironments",
- Handler: _EnvironmentService_ListEnvironments_Handler,
- },
- {
- MethodName: "CreateEnvironment",
- Handler: _EnvironmentService_CreateEnvironment_Handler,
- },
- {
- MethodName: "UpdateEnvironment",
- Handler: _EnvironmentService_UpdateEnvironment_Handler,
- },
- {
- MethodName: "DeleteEnvironment",
- Handler: _EnvironmentService_DeleteEnvironment_Handler,
- },
- {
- MethodName: "UndeleteEnvironment",
- Handler: _EnvironmentService_UndeleteEnvironment_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "v1/environment_service.proto",
-}
diff --git a/proto/generated-go/v1/setting_service.pb.go b/proto/generated-go/v1/setting_service.pb.go
index 90f862a988..1c222de0a4 100644
--- a/proto/generated-go/v1/setting_service.pb.go
+++ b/proto/generated-go/v1/setting_service.pb.go
@@ -2100,7 +2100,6 @@ func (x *AISetting) GetVersion() string {
return ""
}
-// TODO(p0ny): implement.
type EnvironmentSetting struct {
state protoimpl.MessageState `protogen:"open.v1"`
Environments []*EnvironmentSetting_Environment `protobuf:"bytes,1,rep,name=environments,proto3" json:"environments,omitempty"`
@@ -3271,14 +3270,18 @@ func (x *Algorithm_RangeMask_Slice) GetSubstitution() string {
type EnvironmentSetting_Environment struct {
state protoimpl.MessageState `protogen:"open.v1"`
- // The display name of the environment.
- Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
+ // The resource name of the environment.
+ // Format: environments/{environment}.
+ // Output only.
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// The resource id of the environment.
// This value should be 4-63 characters, and valid characters
// are /[a-z][0-9]-/.
- Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
- Tags map[string]string `protobuf:"bytes,3,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
- Color string `protobuf:"bytes,4,opt,name=color,proto3" json:"color,omitempty"`
+ Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
+ // The display name of the environment.
+ Title string `protobuf:"bytes,3,opt,name=title,proto3" json:"title,omitempty"`
+ Tags map[string]string `protobuf:"bytes,4,rep,name=tags,proto3" json:"tags,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"`
+ Color string `protobuf:"bytes,5,opt,name=color,proto3" json:"color,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -3313,9 +3316,9 @@ func (*EnvironmentSetting_Environment) Descriptor() ([]byte, []int) {
return file_v1_setting_service_proto_rawDescGZIP(), []int{22, 0}
}
-func (x *EnvironmentSetting_Environment) GetTitle() string {
+func (x *EnvironmentSetting_Environment) GetName() string {
if x != nil {
- return x.Title
+ return x.Name
}
return ""
}
@@ -3327,6 +3330,13 @@ func (x *EnvironmentSetting_Environment) GetId() string {
return ""
}
+func (x *EnvironmentSetting_Environment) GetTitle() string {
+ if x != nil {
+ return x.Title
+ }
+ return ""
+}
+
func (x *EnvironmentSetting_Environment) GetTags() map[string]string {
if x != nil {
return x.Tags
@@ -3593,14 +3603,15 @@ const file_v1_setting_service_proto_rawDesc = "" +
"\x06CLAUDE\x10\x02\x12\n" +
"\n" +
"\x06GEMINI\x10\x03\x12\x10\n" +
- "\fAZURE_OPENAI\x10\x04\"\xb5\x02\n" +
+ "\fAZURE_OPENAI\x10\x04\"\xcf\x02\n" +
"\x12EnvironmentSetting\x12O\n" +
- "\fenvironments\x18\x01 \x03(\v2+.bytebase.v1.EnvironmentSetting.EnvironmentR\fenvironments\x1a\xcd\x01\n" +
- "\vEnvironment\x12\x14\n" +
- "\x05title\x18\x01 \x01(\tR\x05title\x12\x0e\n" +
- "\x02id\x18\x02 \x01(\tR\x02id\x12I\n" +
- "\x04tags\x18\x03 \x03(\v25.bytebase.v1.EnvironmentSetting.Environment.TagsEntryR\x04tags\x12\x14\n" +
- "\x05color\x18\x04 \x01(\tR\x05color\x1a7\n" +
+ "\fenvironments\x18\x01 \x03(\v2+.bytebase.v1.EnvironmentSetting.EnvironmentR\fenvironments\x1a\xe7\x01\n" +
+ "\vEnvironment\x12\x18\n" +
+ "\x04name\x18\x01 \x01(\tB\x04\xe2A\x01\x03R\x04name\x12\x0e\n" +
+ "\x02id\x18\x02 \x01(\tR\x02id\x12\x14\n" +
+ "\x05title\x18\x03 \x01(\tR\x05title\x12I\n" +
+ "\x04tags\x18\x04 \x03(\v25.bytebase.v1.EnvironmentSetting.Environment.TagsEntryR\x04tags\x12\x14\n" +
+ "\x05color\x18\x05 \x01(\tR\x05color\x1a7\n" +
"\tTagsEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x01*T\n" +
diff --git a/proto/store/setting.proto b/proto/store/setting.proto
index 7507f11d1e..d808ac1e21 100644
--- a/proto/store/setting.proto
+++ b/proto/store/setting.proto
@@ -354,12 +354,12 @@ message EnvironmentSetting {
repeated Environment environments = 1;
message Environment {
- // The display name of the environment.
- string title = 1;
// The resource id of the environment.
// This value should be 4-63 characters, and valid characters
// are /[a-z][0-9]-/.
- string id = 2;
+ string id = 1;
+ // The display name of the environment.
+ string title = 2;
map<string, string> tags = 3;
string color = 4;
}
diff --git a/proto/v1/environment_service.proto b/proto/v1/environment_service.proto
deleted file mode 100644
index 007c804f9a..0000000000
--- a/proto/v1/environment_service.proto
+++ /dev/null
@@ -1,178 +0,0 @@
-syntax = "proto3";
-
-package bytebase.v1;
-
-import "google/api/annotations.proto";
-import "google/api/client.proto";
-import "google/api/field_behavior.proto";
-import "google/api/resource.proto";
-import "google/protobuf/empty.proto";
-import "google/protobuf/field_mask.proto";
-import "v1/annotation.proto";
-import "v1/common.proto";
-
-option go_package = "generated-go/v1";
-
-service EnvironmentService {
- rpc GetEnvironment(GetEnvironmentRequest) returns (Environment) {
- option (google.api.http) = {get: "/v1/{name=environments/*}"};
- option (google.api.method_signature) = "name";
- option (bytebase.v1.permission) = "bb.environments.get";
- option (bytebase.v1.auth_method) = IAM;
- }
-
- rpc ListEnvironments(ListEnvironmentsRequest) returns (ListEnvironmentsResponse) {
- option (google.api.http) = {get: "/v1/environments"};
- option (google.api.method_signature) = "";
- option (bytebase.v1.permission) = "bb.environments.list";
- option (bytebase.v1.auth_method) = IAM;
- }
-
- rpc CreateEnvironment(CreateEnvironmentRequest) returns (Environment) {
- option (google.api.http) = {
- post: "/v1/environments"
- body: "environment"
- };
- option (google.api.method_signature) = "";
- option (bytebase.v1.permission) = "bb.environments.create";
- option (bytebase.v1.auth_method) = IAM;
- option (bytebase.v1.audit) = true;
- }
-
- rpc UpdateEnvironment(UpdateEnvironmentRequest) returns (Environment) {
- option (google.api.http) = {
- patch: "/v1/{environment.name=environments/*}"
- body: "environment"
- };
- option (google.api.method_signature) = "environment,update_mask";
- option (bytebase.v1.permission) = "bb.environments.update";
- option (bytebase.v1.auth_method) = IAM;
- option (bytebase.v1.audit) = true;
- }
-
- rpc DeleteEnvironment(DeleteEnvironmentRequest) returns (google.protobuf.Empty) {
- option (google.api.http) = {delete: "/v1/{name=environments/*}"};
- option (google.api.method_signature) = "name";
- option (bytebase.v1.permission) = "bb.environments.delete";
- option (bytebase.v1.auth_method) = IAM;
- option (bytebase.v1.audit) = true;
- }
-
- rpc UndeleteEnvironment(UndeleteEnvironmentRequest) returns (Environment) {
- option (google.api.http) = {
- post: "/v1/{name=environments/*}:undelete"
- body: "*"
- };
- option (bytebase.v1.permission) = "bb.environments.undelete";
- option (bytebase.v1.auth_method) = IAM;
- option (bytebase.v1.audit) = true;
- }
-}
-
-message GetEnvironmentRequest {
- // The name of the environment to retrieve.
- // Format: environments/{environment}
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {type: "bytebase.com/Environment"}
- ];
-}
-
-message ListEnvironmentsRequest {
- // Not used.
- // The maximum number of environments to return. The service may return fewer than
- // this value.
- // If unspecified, at most 10 environments will be returned.
- // The maximum value is 1000; values above 1000 will be coerced to 1000.
- int32 page_size = 1;
-
- // Not used.
- // A page token, received from a previous `ListEnvironments` call.
- // Provide this to retrieve the subsequent page.
- //
- // When paginating, all other parameters provided to `ListEnvironments` must match
- // the call that provided the page token.
- string page_token = 2;
-
- // Show deleted environments if specified.
- bool show_deleted = 3;
-}
-
-message ListEnvironmentsResponse {
- // The environments from the specified request.
- repeated Environment environments = 1;
-
- // A token, which can be sent as `page_token` to retrieve the next page.
- // If this field is omitted, there are no subsequent pages.
- string next_page_token = 2;
-}
-
-message CreateEnvironmentRequest {
- // The environment to create.
- Environment environment = 1 [(google.api.field_behavior) = REQUIRED];
-
- // The ID to use for the environment, which will become the final component of
- // the environment's resource name.
- //
- // This value should be 4-63 characters, and valid characters
- // are /[a-z][0-9]-/.
- string environment_id = 2;
-}
-
-message UpdateEnvironmentRequest {
- // The environment to update.
- //
- // The environment's `name` field is used to identify the environment to update.
- // Format: environments/{environment}
- Environment environment = 1 [(google.api.field_behavior) = REQUIRED];
-
- // The list of fields to update.
- google.protobuf.FieldMask update_mask = 2;
-}
-
-message DeleteEnvironmentRequest {
- // The name of the environment to delete.
- // Format: environments/{environment}
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {type: "bytebase.com/Environment"}
- ];
-}
-
-message UndeleteEnvironmentRequest {
- // The name of the deleted environment.
- // Format: environments/{environment}
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {type: "bytebase.com/Environment"}
- ];
-}
-
-message Environment {
- option (google.api.resource) = {
- type: "bytebase.com/Environment"
- pattern: "environments/{environment}"
- };
-
- reserved 2;
-
- // The name of the environment.
- // Format: environments/{environment}
- string name = 1;
-
- State state = 3;
-
- string title = 4;
-
- int32 order = 5;
-
- EnvironmentTier tier = 6;
-
- string color = 7;
-}
-
-enum EnvironmentTier {
- ENVIRONMENT_TIER_UNSPECIFIED = 0;
- PROTECTED = 1;
- UNPROTECTED = 2;
-}
diff --git a/proto/v1/setting_service.proto b/proto/v1/setting_service.proto
index 00c85ee562..57a48f1475 100644
--- a/proto/v1/setting_service.proto
+++ b/proto/v1/setting_service.proto
@@ -495,18 +495,21 @@ message AISetting {
string version = 6;
}
-// TODO(p0ny): implement.
message EnvironmentSetting {
repeated Environment environments = 1;
message Environment {
- // The display name of the environment.
- string title = 1;
+ // The resource name of the environment.
+ // Format: environments/{environment}.
+ // Output only.
+ string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];
// The resource id of the environment.
// This value should be 4-63 characters, and valid characters
// are /[a-z][0-9]-/.
string id = 2;
- map<string, string> tags = 3;
- string color = 4;
+ // The display name of the environment.
+ string title = 3;
+ map<string, string> tags = 4;
+ string color = 5;
}
}