Skip to content

Commit

Permalink
randomize name generation fixing gateway creation
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledyoussef24 committed Dec 18, 2024
1 parent 4c9e99d commit 524a2d5
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions packages/grid_client/scripts/applications/gitea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ async function deploy(client, vms, subdomain, gatewayNode) {
log(resultVM);
log("================= Deploying VM =================");

const vmPlanetary = (await client.machines.getObj(vms.name))[0].planetary;
const VMmyceliumIP = (await client.machines.getObj(vms.name))[0].myceliumIP;

// Name Gateway Model
const gw: GatewayNameModel = {
name: subdomain,
node_id: gatewayNode.nodeId,
tls_passthrough: true,
backends: ["http://[" + vmPlanetary + "]:3000"],
tls_passthrough: false,
backends: [`http://[${VMmyceliumIP}]:3000`],
};

const resultGateway = await client.gateway.deploy_name(gw);
Expand Down Expand Up @@ -43,10 +44,11 @@ async function cancel(client, vms, gw) {
}

async function main() {
const name = "ng";
const name = `newgitea${Math.random().toString(36).substring(2, 8)}`;
const networkName = `net${Math.random().toString(36).substring(2, 8)}`;
const grid3 = await getClient(`gitea/${name}`);
const subdomain = "gt" + grid3.twinId + name;
const instanceCapacity = { cru: 2, mru: 4, sru: 50 };
const subdomain = `gt${grid3.twinId}${name}${Math.random().toString(36).substring(2, 6)}`;

// VMNode Selection
const vmQueryOptions: FilterOptions = {
Expand All @@ -56,6 +58,7 @@ async function main() {
availableFor: grid3.twinId,
farmId: 1,
};

// GatewayNode Selection
const gatewayQueryOptions: FilterOptions = {
gateway: true,
Expand All @@ -69,16 +72,16 @@ async function main() {
const vms: MachinesModel = {
name,
network: {
name: "gitnet1",
name: networkName,
ip_range: "10.253.0.0/16",
},
machines: [
{
name: "gitea1",
name: `vm${Math.random().toString(36).substring(2, 8)}`,
node_id: vmNode,
disks: [
{
name: "gitDisk1",
name: `disk${Math.random().toString(36).substring(2, 8)}`,
size: instanceCapacity.sru,
mountpoint: "/mnt/data",
},
Expand All @@ -95,19 +98,18 @@ async function main() {
env: {
SSH_KEY: config.ssh_key,
GITEA__HOSTNAME: domain,
// incase of using smtp mail serever
// GITEA__mailer__PROTOCOL: "smtp",
// GITEA__mailer__ENABLED: "true",
// GITEA__mailer__PROTOCOL: "smtp", // Optional: SMTP Configuration
// GITEA__mailer__ENABLED: "false", // Set to true if enabling mail server
// GITEA__mailer__HOST: "smtp.example.com",
// GITEA__mailer__FROM: "[email protected]",
// GITEA__mailer__PORT: "587",
// GITEA__mailer__USER: "admin",
// GITEA__mailer__PASSWD: "123456",
// GITEA__mailer__PASSWD: "password123",
},
},
],
metadata: "",
description: "test deploying Gitea via ts grid3 client",
description: "Deploying Gitea via TS Grid3 client",
};

// Deploy VMs
Expand All @@ -116,7 +118,7 @@ async function main() {
// Get the deployment
await getDeployment(grid3, vms, subdomain);

// // Uncomment the line below to cancel the deployment
// Uncomment to cancel the deployment
// await cancel(grid3, { name }, { name: subdomain });

await grid3.disconnect();
Expand Down

0 comments on commit 524a2d5

Please sign in to comment.