mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 00:27:30 +00:00
Merge pull request #4320 from Infisical/daniel/vault-migration-path-fix
fix: improve vault folders mapping
This commit is contained in:
@@ -19,7 +19,7 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvider
|
|||||||
config: {
|
config: {
|
||||||
rateLimit: writeLimit
|
rateLimit: writeLimit
|
||||||
},
|
},
|
||||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
onRequest: verifyAuth([AuthMode.JWT]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
const data = await req.file({
|
const data = await req.file({
|
||||||
limits: {
|
limits: {
|
||||||
@@ -69,7 +69,7 @@ export const registerExternalMigrationRouter = async (server: FastifyZodProvider
|
|||||||
mappingType: z.nativeEnum(VaultMappingType)
|
mappingType: z.nativeEnum(VaultMappingType)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
onRequest: verifyAuth([AuthMode.JWT]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
await server.services.migration.importVaultData({
|
await server.services.migration.importVaultData({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
|
|||||||
@@ -254,29 +254,26 @@ export const transformToInfisicalFormatNamespaceToProjects = (
|
|||||||
let currentFolderId: string | undefined;
|
let currentFolderId: string | undefined;
|
||||||
let currentPath = "";
|
let currentPath = "";
|
||||||
|
|
||||||
if (path.includes("/")) {
|
const pathParts = path.split("/").filter(Boolean);
|
||||||
const pathParts = path.split("/").filter(Boolean);
|
const folderParts = pathParts;
|
||||||
|
|
||||||
const folderParts = pathParts;
|
// create nested folder structure for the entire path
|
||||||
|
for (const folderName of folderParts) {
|
||||||
|
currentPath = currentPath ? `${currentPath}/${folderName}` : folderName;
|
||||||
|
const folderKey = `${namespace}:${mount}:${currentPath}`;
|
||||||
|
|
||||||
// create nested folder structure for the entire path
|
if (!folderMap.has(folderKey)) {
|
||||||
for (const folderName of folderParts) {
|
const folderId = uuidv4();
|
||||||
currentPath = currentPath ? `${currentPath}/${folderName}` : folderName;
|
folderMap.set(folderKey, folderId);
|
||||||
const folderKey = `${namespace}:${mount}:${currentPath}`;
|
folders.push({
|
||||||
|
id: folderId,
|
||||||
if (!folderMap.has(folderKey)) {
|
name: folderName,
|
||||||
const folderId = uuidv4();
|
environmentId,
|
||||||
folderMap.set(folderKey, folderId);
|
parentFolderId: currentFolderId || environmentId
|
||||||
folders.push({
|
});
|
||||||
id: folderId,
|
currentFolderId = folderId;
|
||||||
name: folderName,
|
} else {
|
||||||
environmentId,
|
currentFolderId = folderMap.get(folderKey)!;
|
||||||
parentFolderId: currentFolderId || environmentId
|
|
||||||
});
|
|
||||||
currentFolderId = folderId;
|
|
||||||
} else {
|
|
||||||
currentFolderId = folderMap.get(folderKey)!;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user