fix(core): update

This commit is contained in:
2024-04-20 12:21:41 +02:00
commit c24262f765
84 changed files with 14340 additions and 0 deletions

View File

View File

@ -0,0 +1,83 @@
import * as plugins from '../cloudly.plugins.js';
// Create an array to hold 10 ISecretGroup objects
const demoSecretGroups: plugins.servezoneInterfaces.data.ISecretGroup[] = [];
// Generate 10 ISecretGroup objects
for (let i = 1; i <= 10; i++) {
const secretGroup: plugins.servezoneInterfaces.data.ISecretGroup = {
id: `${plugins.smartunique.shortId(8)}`,
data: {
name: `Demo Secret Group ${i}`,
description: `This is a demo secret group for testing purposes ${i}`,
key: `CI_RUNNER_TOKEN_${i}`,
priority: i,
tags: [
{
key: 'project',
value: `my_project_${i}`,
},
{
key: 'environment',
value: i % 2 === 0 ? 'staging' : 'production',
},
],
environments: {
production: {
value: `prod_secret_value_${i}`,
lastUpdated: 1630522000 + i,
history: [
{
timestamp: String(1630521000 + i),
value: `old_prod_value_${i}`,
},
],
},
staging: {
value: `stag_secret_value_${i}`,
updateToken: `updateToken${i}`,
lastUpdated: 1630522500 + i,
history: [
{
timestamp: String(1630521500 + i),
value: `old_stag_value_${i}`,
},
],
},
},
},
};
// Push each ISecretGroup object into the array
demoSecretGroups.push(secretGroup);
}
// Create an array to hold 10 IConfigBundle objects
const demoConfigBundles: plugins.servezoneInterfaces.data.ISecretBundle[] = [];
// Generate 10 IConfigBundle objects that match demoSecretGroups
for (let i = 0; i < demoSecretGroups.length; i++) {
const secretGroup = demoSecretGroups[i];
const configBundle: plugins.servezoneInterfaces.data.ISecretBundle = {
id: `configBundleId${i + 1}`,
data: {
name: `Demo Config Bundle ${i + 1}`,
description: 'Demo Purpose',
includedSecretGroupIds: [secretGroup.id],
includedTags: secretGroup.data.tags,
authorizations: Object.keys(secretGroup.data.environments).map((env) => {
return {
secretAccessKey: `mockSecretAccessKeyFor${env}`,
environment: env,
};
}),
},
};
// Push each IConfigBundle object into the array
demoConfigBundles.push(configBundle);
}
// Exporting the array of demo IConfigBundle objects
export { demoSecretGroups, demoConfigBundles };

38
ts/demo/index.ts Normal file
View File

@ -0,0 +1,38 @@
import type { Cloudly } from '../cloudly.classes.cloudly.js';
export const installDemoData = async (cloudlyRef: Cloudly) => {
// ================================================================================
// SECRETS
const demoDataSecrets = await import('./demo.data.secrets.js');
const secretGroups = await cloudlyRef.secretManager.CSecretGroup.getInstances({});
for (const secretGroup of secretGroups) {
await secretGroup.delete();
}
const secretBundles = await cloudlyRef.secretManager.CSecretBundle.getInstances({});
for (const secretBundle of secretBundles) {
await secretBundle.delete();
}
for (const secretData of demoDataSecrets.demoSecretGroups) {
const secretGroup = new cloudlyRef.secretManager.CSecretGroup();
Object.assign(secretGroup, secretData);
await secretGroup.save();
}
for (const secretBundleData of demoDataSecrets.demoConfigBundles) {
const secretBundle = new cloudlyRef.secretManager.CSecretBundle();
Object.assign(secretBundle, secretBundleData);
await secretBundle.save();
}
// ================================================================================
// CLUSTERS
const clusters = await cloudlyRef.clusterManager.CCluster.getInstances({});
for (const cluster of clusters) {
await cluster.delete();
}
}