mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 18:27:36 +00:00
Merge pull request #1030 from G3root/update-other
fix: renaming environments not updated in some models
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
import {
|
import {
|
||||||
|
Folder,
|
||||||
Integration,
|
Integration,
|
||||||
Membership,
|
Membership,
|
||||||
Secret,
|
Secret,
|
||||||
@@ -21,9 +22,12 @@ import {
|
|||||||
getUserProjectPermissions
|
getUserProjectPermissions
|
||||||
} from "../../ee/services/ProjectRoleService";
|
} from "../../ee/services/ProjectRoleService";
|
||||||
import { ForbiddenError } from "@casl/ability";
|
import { ForbiddenError } from "@casl/ability";
|
||||||
|
import { SecretImport } from "../../models";
|
||||||
|
import { ServiceAccountWorkspacePermission } from "../../models";
|
||||||
|
import { Webhook } from "../../models";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new workspace environment named [environmentName]
|
* Create new workspace environment named [environmentName]
|
||||||
* with slug [environmentSlug] under workspace with id
|
* with slug [environmentSlug] under workspace with id
|
||||||
* @param req
|
* @param req
|
||||||
* @param res
|
* @param res
|
||||||
@@ -369,13 +373,38 @@ export const renameWorkspaceEnvironment = async (req: Request, res: Response) =>
|
|||||||
{ environment: environmentSlug }
|
{ environment: environmentSlug }
|
||||||
);
|
);
|
||||||
await ServiceTokenData.updateMany(
|
await ServiceTokenData.updateMany(
|
||||||
{ workspace: workspaceId, environment: oldEnvironmentSlug },
|
{
|
||||||
{ environment: environmentSlug }
|
workspace: workspaceId,
|
||||||
|
"scopes.environment": oldEnvironmentSlug
|
||||||
|
},
|
||||||
|
{ $set: { "scopes.$[element].environment": environmentSlug } },
|
||||||
|
{ arrayFilters: [{ "element.environment": oldEnvironmentSlug }] }
|
||||||
);
|
);
|
||||||
await Integration.updateMany(
|
await Integration.updateMany(
|
||||||
{ workspace: workspaceId, environment: oldEnvironmentSlug },
|
{ workspace: workspaceId, environment: oldEnvironmentSlug },
|
||||||
{ environment: environmentSlug }
|
{ environment: environmentSlug }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await Folder.updateMany(
|
||||||
|
{ workspace: workspaceId, environment: oldEnvironmentSlug },
|
||||||
|
{ environment: environmentSlug }
|
||||||
|
);
|
||||||
|
|
||||||
|
await SecretImport.updateMany(
|
||||||
|
{ workspace: workspaceId, environment: oldEnvironmentSlug },
|
||||||
|
{ environment: environmentSlug }
|
||||||
|
);
|
||||||
|
|
||||||
|
await ServiceAccountWorkspacePermission.updateMany(
|
||||||
|
{ workspace: workspaceId, environment: oldEnvironmentSlug },
|
||||||
|
{ environment: environmentSlug }
|
||||||
|
);
|
||||||
|
|
||||||
|
await Webhook.updateMany(
|
||||||
|
{ workspace: workspaceId, environment: oldEnvironmentSlug },
|
||||||
|
{ environment: environmentSlug }
|
||||||
|
);
|
||||||
|
|
||||||
await Membership.updateMany(
|
await Membership.updateMany(
|
||||||
{
|
{
|
||||||
workspace: workspaceId,
|
workspace: workspaceId,
|
||||||
|
|||||||
Reference in New Issue
Block a user