mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
PIT: add description to folder versioning
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
import { Knex } from "knex";
|
||||||
|
|
||||||
|
import { TableName } from "../schemas";
|
||||||
|
|
||||||
|
export async function up(knex: Knex): Promise<void> {
|
||||||
|
if (!(await knex.schema.hasColumn(TableName.SecretFolderVersion, "description"))) {
|
||||||
|
await knex.schema.alterTable(TableName.SecretFolderVersion, (t) => {
|
||||||
|
t.string("description").nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down(knex: Knex): Promise<void> {
|
||||||
|
if (await knex.schema.hasColumn(TableName.SecretFolderVersion, "description")) {
|
||||||
|
await knex.schema.alterTable(TableName.SecretFolderVersion, (t) => {
|
||||||
|
t.dropColumn("description");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,8 @@ export const SecretFolderVersionsSchema = z.object({
|
|||||||
createdAt: z.date(),
|
createdAt: z.date(),
|
||||||
updatedAt: z.date(),
|
updatedAt: z.date(),
|
||||||
envId: z.string().uuid(),
|
envId: z.string().uuid(),
|
||||||
folderId: z.string().uuid()
|
folderId: z.string().uuid(),
|
||||||
|
description: z.string().nullable().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TSecretFolderVersions = z.infer<typeof SecretFolderVersionsSchema>;
|
export type TSecretFolderVersions = z.infer<typeof SecretFolderVersionsSchema>;
|
||||||
|
|||||||
@@ -532,11 +532,12 @@ export const secretSnapshotServiceFactory = ({
|
|||||||
});
|
});
|
||||||
await secretTagDAL.saveTagsToSecretV2(secretTagsToBeInsert, tx);
|
await secretTagDAL.saveTagsToSecretV2(secretTagsToBeInsert, tx);
|
||||||
const folderVersions = await folderVersionDAL.insertMany(
|
const folderVersions = await folderVersionDAL.insertMany(
|
||||||
folders.map(({ version, name, id, envId }) => ({
|
folders.map(({ version, name, id, envId, description }) => ({
|
||||||
name,
|
name,
|
||||||
version,
|
version,
|
||||||
folderId: id,
|
folderId: id,
|
||||||
envId
|
envId,
|
||||||
|
description
|
||||||
})),
|
})),
|
||||||
tx
|
tx
|
||||||
);
|
);
|
||||||
@@ -743,11 +744,12 @@ export const secretSnapshotServiceFactory = ({
|
|||||||
});
|
});
|
||||||
await secretTagDAL.saveTagsToSecret(secretTagsToBeInsert, tx);
|
await secretTagDAL.saveTagsToSecret(secretTagsToBeInsert, tx);
|
||||||
const folderVersions = await folderVersionDAL.insertMany(
|
const folderVersions = await folderVersionDAL.insertMany(
|
||||||
folders.map(({ version, name, id, envId }) => ({
|
folders.map(({ version, name, id, envId, description }) => ({
|
||||||
name,
|
name,
|
||||||
version,
|
version,
|
||||||
folderId: id,
|
folderId: id,
|
||||||
envId
|
envId,
|
||||||
|
description
|
||||||
})),
|
})),
|
||||||
tx
|
tx
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -37,7 +37,8 @@ const secretVersionSchema = z.object({
|
|||||||
// Folder-specific versions schema
|
// Folder-specific versions schema
|
||||||
const folderVersionSchema = z.object({
|
const folderVersionSchema = z.object({
|
||||||
version: z.string().optional(),
|
version: z.string().optional(),
|
||||||
name: z.string().optional()
|
name: z.string().optional(),
|
||||||
|
description: z.string().optional().nullable()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Secret commit change schema
|
// Secret commit change schema
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ type FolderChange = BaseChange & {
|
|||||||
folderVersion: string;
|
folderVersion: string;
|
||||||
versions?: {
|
versions?: {
|
||||||
name: string;
|
name: string;
|
||||||
|
description?: string | null;
|
||||||
}[];
|
}[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -604,8 +605,19 @@ export const folderCommitServiceFactory = ({
|
|||||||
version: [Number(change.folderVersion), Number(change.fromVersion)]
|
version: [Number(change.folderVersion), Number(change.fromVersion)]
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const versionsShaped = [...new Set(versions.map((version) => version.name))];
|
const versionsShaped = versions.map((version) => ({
|
||||||
if (versionsShaped.length === 1) {
|
name: version.name,
|
||||||
|
description: version.description
|
||||||
|
}));
|
||||||
|
const uniqueVersions = versionsShaped.filter(
|
||||||
|
(item, index, arr) =>
|
||||||
|
arr.findIndex((other) =>
|
||||||
|
Object.entries(item).every(
|
||||||
|
([key, value]) => JSON.stringify(value) === JSON.stringify(other[key as keyof typeof other])
|
||||||
|
)
|
||||||
|
) === index
|
||||||
|
);
|
||||||
|
if (uniqueVersions.length === 1) {
|
||||||
removeNoChangeUpdate.push(change.id);
|
removeNoChangeUpdate.push(change.id);
|
||||||
}
|
}
|
||||||
} else if (change.type === ResourceType.SECRET && change.secretVersion && change.fromVersion) {
|
} else if (change.type === ResourceType.SECRET && change.secretVersion && change.fromVersion) {
|
||||||
@@ -1108,7 +1120,8 @@ export const folderCommitServiceFactory = ({
|
|||||||
parentId: folderId,
|
parentId: folderId,
|
||||||
envId: folderVersion.envId,
|
envId: folderVersion.envId,
|
||||||
version: (folderVersion.version || 1) + 1,
|
version: (folderVersion.version || 1) + 1,
|
||||||
name: folderVersion.name
|
name: folderVersion.name,
|
||||||
|
description: folderVersion.description
|
||||||
};
|
};
|
||||||
await folderDAL.create(newFolder, tx);
|
await folderDAL.create(newFolder, tx);
|
||||||
|
|
||||||
@@ -1117,6 +1130,7 @@ export const folderCommitServiceFactory = ({
|
|||||||
folderId: change.id,
|
folderId: change.id,
|
||||||
version: (folderVersion.version || 1) + 1,
|
version: (folderVersion.version || 1) + 1,
|
||||||
name: folderVersion.name,
|
name: folderVersion.name,
|
||||||
|
description: folderVersion.description,
|
||||||
envId: folderVersion.envId
|
envId: folderVersion.envId
|
||||||
},
|
},
|
||||||
tx
|
tx
|
||||||
@@ -1170,7 +1184,8 @@ export const folderCommitServiceFactory = ({
|
|||||||
parentId: folderId,
|
parentId: folderId,
|
||||||
envId: versionDetails.envId,
|
envId: versionDetails.envId,
|
||||||
version: (versionDetails.version || 1) + 1,
|
version: (versionDetails.version || 1) + 1,
|
||||||
name: versionDetails.name
|
name: versionDetails.name,
|
||||||
|
description: versionDetails.description
|
||||||
},
|
},
|
||||||
tx
|
tx
|
||||||
);
|
);
|
||||||
@@ -1180,6 +1195,7 @@ export const folderCommitServiceFactory = ({
|
|||||||
folderId: change.id,
|
folderId: change.id,
|
||||||
version: (versionDetails.version || 1) + 1,
|
version: (versionDetails.version || 1) + 1,
|
||||||
name: versionDetails.name,
|
name: versionDetails.name,
|
||||||
|
description: versionDetails.description,
|
||||||
envId: versionDetails.envId
|
envId: versionDetails.envId
|
||||||
},
|
},
|
||||||
tx
|
tx
|
||||||
|
|||||||
@@ -119,7 +119,8 @@ export const secretFolderServiceFactory = ({
|
|||||||
name: doc.name,
|
name: doc.name,
|
||||||
envId: doc.envId,
|
envId: doc.envId,
|
||||||
version: doc.version,
|
version: doc.version,
|
||||||
folderId: doc.id
|
folderId: doc.id,
|
||||||
|
description: doc.description
|
||||||
})),
|
})),
|
||||||
tx
|
tx
|
||||||
);
|
);
|
||||||
@@ -152,7 +153,8 @@ export const secretFolderServiceFactory = ({
|
|||||||
name: doc.name,
|
name: doc.name,
|
||||||
envId: doc.envId,
|
envId: doc.envId,
|
||||||
version: doc.version,
|
version: doc.version,
|
||||||
folderId: doc.id
|
folderId: doc.id,
|
||||||
|
description: doc.description
|
||||||
},
|
},
|
||||||
tx
|
tx
|
||||||
);
|
);
|
||||||
@@ -269,7 +271,8 @@ export const secretFolderServiceFactory = ({
|
|||||||
name: doc.name,
|
name: doc.name,
|
||||||
envId: doc.envId,
|
envId: doc.envId,
|
||||||
version: doc.version,
|
version: doc.version,
|
||||||
folderId: doc.id
|
folderId: doc.id,
|
||||||
|
description: doc.description
|
||||||
},
|
},
|
||||||
tx
|
tx
|
||||||
);
|
);
|
||||||
@@ -385,7 +388,8 @@ export const secretFolderServiceFactory = ({
|
|||||||
name: doc.name,
|
name: doc.name,
|
||||||
envId: doc.envId,
|
envId: doc.envId,
|
||||||
version: doc.version,
|
version: doc.version,
|
||||||
folderId: doc.id
|
folderId: doc.id,
|
||||||
|
description: doc.description
|
||||||
},
|
},
|
||||||
tx
|
tx
|
||||||
);
|
);
|
||||||
@@ -802,7 +806,8 @@ export const secretFolderServiceFactory = ({
|
|||||||
});
|
});
|
||||||
return versions.map((v) => ({
|
return versions.map((v) => ({
|
||||||
version: v.version?.toString() || "1",
|
version: v.version?.toString() || "1",
|
||||||
name: v.name
|
name: v.name,
|
||||||
|
description: v.description
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user