Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Always returns environment
天舟e54763322c25
diff --git a/backend/server/instance.go b/backend/server/instance.goindex 8bbca2bf16..6e4baf7ea3 100644--- a/backend/server/instance.go+++ b/backend/server/instance.go@@ -174,14 +174,12 @@ func (s *Server) ComposeInstanceById(ctx context.Context, id int, incluedList []func (s *Server) ComposeInstanceRelationship(ctx context.Context, instance *api.Instance, includeList []string) error {var err error- if sort.SearchStrings(includeList, "environment") >= 0 {- environmentFind := &api.EnvironmentFind{- ID: &instance.EnvironmentId,- }- instance.Environment, err = s.EnvironmentService.FindEnvironment(context.Background(), environmentFind)- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch environment for instance: %v", instance.Name)).SetInternal(err)- }+ environmentFind := &api.EnvironmentFind{+ ID: &instance.EnvironmentId,+ }+ instance.Environment, err = s.EnvironmentService.FindEnvironment(context.Background(), environmentFind)+ if err != nil {+ return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch environment for instance: %v", instance.Name)).SetInternal(err)}if sort.SearchStrings(includeList, "dataSource") >= 0 {diff --git a/frontend/src/store/modules/database.ts b/frontend/src/store/modules/database.tsindex 9aa132966e..7a9302b612 100644--- a/frontend/src/store/modules/database.ts+++ b/frontend/src/store/modules/database.ts@@ -48,7 +48,7 @@ function convert(for (const item of includedList || []) {if (item.type == "instance" && item.id == instanceId) {- instance = rootGetters["instance/convert"](item);+ instance = rootGetters["instance/convert"](item, includedList);}if (item.type == "project" && item.id == projectId) {project = rootGetters["project/convert"](item, includedList);diff --git a/frontend/src/store/modules/environment.ts b/frontend/src/store/modules/environment.tsindex 4c9c85dfee..e65bfdcbf4 100644--- a/frontend/src/store/modules/environment.ts+++ b/frontend/src/store/modules/environment.ts@@ -33,6 +33,12 @@ const state: () => EnvironmentState = () => ({});const getters = {+ convert:+ (state: EnvironmentState, getters: any, rootState: any, rootGetters: any) =>+ (environment: ResourceObject): Environment => {+ return convert(environment, rootGetters);+ },+environmentList:(state: EnvironmentState) =>(rowStatusList?: RowStatus[]): Environment[] => {diff --git a/frontend/src/store/modules/instance.ts b/frontend/src/store/modules/instance.tsindex aadd64a9ed..a686a4ba4a 100644--- a/frontend/src/store/modules/instance.ts+++ b/frontend/src/store/modules/instance.ts@@ -20,15 +20,6 @@ function convert(includedList: ResourceObject[],rootGetters: any): Instance {- const environment = rootGetters["environment/environmentList"]([- "NORMAL",- "ARCHIVED",- ]).find((env: Environment) => {- return (- env.id ==- (instance.relationships!.environment.data as ResourceIdentifier).id- );- });const creator = rootGetters["principal/principalById"](instance.attributes.creatorId);@@ -36,9 +27,14 @@ function convert(instance.attributes.updaterId);+ const environmentId = (+ instance.relationships!.environment.data as ResourceIdentifier+ ).id;+ let environment: Environment = unknown("ENVIRONMENT") as Environment;+ environment.id = environmentId;+let username = undefined;let password = undefined;-for (const item of includedList || []) {if (item.type == "dataSource" &&@@ -47,7 +43,14 @@ function convert() {username = item.attributes.username as string;password = item.attributes.password as string;- break;+ }++ if (+ item.type == "environment" &&+ (instance.relationships!.environment.data as ResourceIdentifier).id ==+ item.id+ ) {+ environment = rootGetters["environment/convert"](item);}}@@ -72,8 +75,8 @@ const state: () => InstanceState = () => ({const getters = {convert:(state: InstanceState, getters: any, rootState: any, rootGetters: any) =>- (instance: ResourceObject): Instance => {- return convert(instance, [], rootGetters);+ (instance: ResourceObject, includedList: ResourceObject[]): Instance => {+ return convert(instance, includedList, rootGetters);},instanceList:diff --git a/frontend/src/store/modules/stage.ts b/frontend/src/store/modules/stage.tsindex 39f0f9f280..9b45dd41c3 100644--- a/frontend/src/store/modules/stage.ts+++ b/frontend/src/store/modules/stage.ts@@ -34,10 +34,11 @@ function convertPartial(let updater: Principal = unknown("PRINCIPAL") as Principal;updater.id = updaterId;- // We should always have a valid environment- const environment: Environment = rootGetters["environment/environmentById"](- (stage.relationships!.environment.data as ResourceIdentifier).id- );+ const environmentId = (+ stage.relationships!.environment.data as ResourceIdentifier+ ).id;+ let environment: Environment = unknown("ENVIRONMENT") as Environment;+ environment.id = environmentId;const taskList: Task[] = [];for (const item of includedList || []) {@@ -55,6 +56,14 @@ function convertPartial(updater = rootGetters["principal/convert"](item);}+ if (+ item.type == "environment" &&+ (stage.relationships!.environment.data as ResourceIdentifier).id ==+ item.id+ ) {+ environment = rootGetters["environment/convert"](item, includedList);+ }+if (item.type == "task") {const taskIdList = stage.relationships!.task.data as ResourceIdentifier[];for (const idItem of taskIdList) {