Skip to content

Commit bd05457

Browse files
committed
fix: update ordering
1 parent 466b4d9 commit bd05457

File tree

1 file changed

+155
-9
lines changed

1 file changed

+155
-9
lines changed

wrongsecrets-balancer/src/teams/teams.js

Lines changed: 155 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,6 @@ async function createTeam(req, res) {
321321
res.status(500).send({ message: 'Failed to Create Instance' });
322322
}
323323

324-
try {
325-
logger.info(`Creating challenge53 Deployment for team '${team}'`);
326-
await createK8sChallenge53DeploymentForTeam({ team, passcodeHash: hash });
327-
logger.info(`Created challenge53 Deployment for team '${team}'`);
328-
} catch (error) {
329-
logger.error(`Error while creating challenge53 deployment for team ${team}: ${error.message}`);
330-
res.status(500).send({ message: 'Failed to Create Instance' });
331-
}
332-
333324
try {
334325
logger.info(`Creating role for virtual desktop in K8s '${team}'`);
335326
await createRoleForWebTop(team);
@@ -373,6 +364,15 @@ async function createTeam(req, res) {
373364
res.status(500).send({ message: 'Failed to Create Instance' });
374365
}
375366

367+
try {
368+
logger.info(`Creating challenge53 Deployment for team '${team}'`);
369+
await createK8sChallenge53DeploymentForTeam({ team, passcodeHash: hash });
370+
logger.info(`Created challenge53 Deployment for team '${team}'`);
371+
} catch (error) {
372+
logger.error(`Error while creating challenge53 deployment for team ${team}: ${error.message}`);
373+
res.status(500).send({ message: 'Failed to Create Instance' });
374+
}
375+
376376
try {
377377
loginCounter.inc({ type: 'registration', userType: 'user' }, 1);
378378

@@ -613,6 +613,152 @@ async function createAzureTeam(req, res) {
613613

614614
try {
615615
logger.info(`Creating roleBinding for virtual desktop in Azure '${team}'`);
616+
await createRoleBindingForWebtop(team);
617+
logger.info(`Created roleBinding for virtual desktopfor team '${team}'`);
618+
} catch (error) {
619+
logger.error(
620+
`Error while creating roleBinding for virtual desktop for team ${team}: ${error.message}`
621+
);
622+
res.status(500).send({ message: 'Failed to Create Instance' });
623+
}
624+
625+
try {
626+
logger.info(`Creating virtualdesktop Deployment for team '${team}'`);
627+
await createDesktopDeploymentForTeam({ team, passcodeHash: hash });
628+
await createDesktopServiceForTeam(team);
629+
630+
logger.info(`Created virtualdesktop Deployment for team '${team}'`);
631+
} catch (error) {
632+
logger.error(
633+
`Error while creating Virtualdesktop deployment or service for team ${team}: ${error.message}`
634+
);
635+
res.status(500).send({ message: 'Failed to Create Instance' });
636+
}
637+
638+
try {
639+
logger.info(`Creating network security policies for team '${team}'`);
640+
await createNSPsforTeam(team);
641+
642+
logger.info(`Created network security policies for team '${team}'`);
643+
} catch (error) {
644+
logger.error(`Error while network security policies for team ${team}: ${error}`);
645+
res.status(500).send({ message: 'Failed to Create Instance' });
646+
}
647+
648+
try {
649+
loginCounter.inc({ type: 'registration', userType: 'user' }, 1);
650+
651+
res
652+
.cookie(get('cookieParser.cookieName'), `t-${team}`, {
653+
...cookieSettings,
654+
})
655+
.status(200)
656+
.json({
657+
message: 'Created Instance',
658+
passcode,
659+
});
660+
} catch (error) {
661+
logger.error(
662+
`Error while creating deployment or service for team ${team} on Azure: ${error.message}`
663+
);
664+
res.status(500).send({ message: 'Failed to Create Instance' });
665+
}
666+
}
667+
668+
/**
669+
* @param {import("express").Request} req
670+
* @param {import("express").Response} res
671+
*/
672+
async function createGCPTeam(req, res) {
673+
const { team } = req.params;
674+
const { passcode, hash } = await generatePasscode();
675+
try {
676+
logger.info(`Creating Namespace for team '${team}'`);
677+
await createNameSpaceForTeam(team);
678+
} catch (error) {
679+
logger.error(`Error while creating namespace for ${team}: ${error}`);
680+
res.status(500).send({ message: 'Failed to Create Instance' });
681+
}
682+
try {
683+
logger.info(`Creating Configmap for team '${team}'`);
684+
await createConfigmapForTeam(team);
685+
686+
logger.info(`Creating Secretsfile for team '${team}'`);
687+
await createSecretsfileForTeam(team);
688+
await createChallenge33SecretForTeam(team);
689+
} catch (error) {
690+
logger.error(`Error while creating secretsfile or configmap for ${team}: ${error}`);
691+
res.status(500).send({ message: 'Failed to Create Instance' });
692+
}
693+
try {
694+
logger.info(
695+
`Creating Secrets provider for team ${team}, please make sure the csi driver helm is installed and running`
696+
);
697+
await createGCPSecretsProviderForTeam(team);
698+
} catch (error) {
699+
logger.error(`Error while creating Secretsprovider for team ${team}: ${error}`);
700+
res.status(500).send({ message: 'Failed to Create Instance' });
701+
}
702+
703+
try {
704+
logger.info(`IAM service account for team '${team}'`);
705+
await createIAMServiceAccountForTeam(team);
706+
logger.info(`Created IAM service account for team '${team}'`);
707+
} catch (error) {
708+
logger.error(`Error while creating IAM service account for team ${team}: ${error}`);
709+
res.status(500).send({ message: 'Failed to Create Instance' });
710+
}
711+
712+
try {
713+
logger.info(`Binding IAM service account to workload for team '${team}'`);
714+
await bindIAMServiceAccountToWorkloadForTeam(team);
715+
logger.info(`Bound IAM service account to workload for team '${team}'`);
716+
} catch (error) {
717+
logger.error(`Error while binding IAM service account to workload for team ${team}: ${error}`);
718+
res.status(500).send({ message: 'Failed to Create Instance' });
719+
}
720+
721+
try {
722+
logger.info(`Annotating the service account for ${team},`);
723+
await patchServiceAccountForTeamForGCP(team);
724+
} catch (error) {
725+
logger.error(`Error while annotating the service account for ${team}: ${error}`);
726+
res.status(500).send({ message: 'Failed to Create Instance' });
727+
}
728+
729+
try {
730+
logger.info(`Creating WrongSecrets Deployment for team '${team}' with GCP`);
731+
await createGCPDeploymentForTeam({ team, passcodeHash: hash });
732+
await createServiceForTeam(team);
733+
} catch (error) {
734+
logger.error(
735+
`Error while creating wrongsecrets deployment or service for team ${team}: ${error.message}`
736+
);
737+
res.status(500).send({ message: 'Failed to Create Instance' });
738+
}
739+
740+
try {
741+
logger.info(`Creating service account for virtual desktop in GCP '${team}'`);
742+
await createServiceAccountForWebTop(team);
743+
logger.info(`Created service account for virtual desktopfor team '${team}'`);
744+
} catch (error) {
745+
logger.error(
746+
`Error while creating service account for virtual desktop for team ${team}: ${error.message}`
747+
);
748+
res.status(500).send({ message: 'Failed to Create Instance' });
749+
}
750+
751+
try {
752+
logger.info(`Creating challenge53 Deployment for team '${team}'`);
753+
await createK8sChallenge53DeploymentForTeam({ team, passcodeHash: hash });
754+
logger.info(`Created challenge53 Deployment for team '${team}'`);
755+
} catch (error) {
756+
logger.error(`Error while creating challenge53 deployment for team ${team}: ${error.message}`);
757+
res.status(500).send({ message: 'Failed to Create Instance' });
758+
}
759+
760+
try {
761+
logger.info(`Creating role for virtual desktop in GCP '${team}'`);
616762
await createRoleForWebTop(team);
617763
logger.info(`Created role for virtual desktopfor team '${team}'`);
618764
} catch (error) {

0 commit comments

Comments
 (0)