cloudly/ts/00demo/demo.data.secrets.ts

86 lines
2.5 KiB
TypeScript

import * as plugins from '../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}`,
includedImages: [],
type: 'external',
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 };