From 456283dc902a914a05640ee2d3c0656a5277d933 Mon Sep 17 00:00:00 2001 From: Jehoszafat Zimnowoda Date: Tue, 28 Nov 2023 11:40:18 +0100 Subject: [PATCH] feat: init values repo --- .env.sample | 2 +- package.json | 4 ++-- src/tasks/gitea/gitea.ts | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.env.sample b/.env.sample index aa85257b..4d071dc0 100644 --- a/.env.sample +++ b/.env.sample @@ -31,7 +31,7 @@ REDIRECT_URIS='["http://localhost:8084/*","https://auth.dev.gke.otomi.cloud/*"," GITEA_PASSWORD='' GITEA_URL='http://127.0.0.1:8082' DRONE_URL='http://127.0.0.1:8081' - +OTOMI_VALUES='{"apps":{"argocd":{"enabled":true}},"cluster":{"domainSuffix":"test.localhost"},"teamConfig":{"team-admin":{"selfService":{"apps":[]}}}}' # Drone task DRONE_TOKEN='' diff --git a/package.json b/package.json index 9fc196e5..ffce2d32 100644 --- a/package.json +++ b/package.json @@ -125,10 +125,10 @@ "tasks:copy-certs-argo": "node dist/tasks/otomi/copy-certs-argo.js", "tasks:drone-dev": "ts-node-dev ./src/tasks/drone/drone.ts", "tasks:drone": "node dist/tasks/drone/drone.js", - "tasks:gitea-dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 ts-node-dev ./src/tasks/gitea/gitea.ts && ts-node-dev ./src/tasks/gitea/gitea-drone-oauth.ts", + "tasks:gitea-dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 ts-node-dev ./src/tasks/gitea/gitea.ts", "tasks:gitea-drone-auth-dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 ts-node-dev ./src/tasks/gitea/gitea-drone-oauth.ts", "tasks:gitea-drone-auth": "node dist/tasks/gitea/gitea-drone-oauth.js", - "tasks:gitea": "node dist/tasks/gitea/gitea.js && node dist/tasks/gitea/gitea-drone-oauth.js", + "tasks:gitea": "node dist/tasks/gitea/gitea.js", "tasks:harbor-dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 ts-node-dev ./src/tasks/harbor/harbor.ts", "tasks:harbor": "node dist/tasks/harbor/harbor.js", "tasks:keycloak-dev": "NODE_TLS_REJECT_UNAUTHORIZED=0 ts-node-dev ./src/tasks/keycloak/keycloak.ts", diff --git a/src/tasks/gitea/gitea.ts b/src/tasks/gitea/gitea.ts index 372c1670..f7b16c8e 100644 --- a/src/tasks/gitea/gitea.ts +++ b/src/tasks/gitea/gitea.ts @@ -74,7 +74,7 @@ async function hasSpecificHook(repoApi: RepositoryApi, hookToFind: string): Prom const hooks: any[] = await doApiCall( errors, `Getting hooks in repo "otomi/values"`, - () => repoApi.repoListHooks(orgName, 'values'), + () => repoApi.repoListHooks(orgName, otomiValuesRepoName), 400, ) if (!hooks) { @@ -154,7 +154,7 @@ export async function addTektonHook(repoApi: RepositoryApi): Promise { errors, `Adding hook "tekton" to repo otomi/values`, () => - repoApi.repoCreateHook(orgName, 'values', { + repoApi.repoCreateHook(orgName, otomiValuesRepoName, { type: CreateHookOption.TypeEnum.Gitea, active: true, config: { @@ -175,7 +175,7 @@ export async function deleteDroneHook(repoApi: RepositoryApi): Promise { if (hasDroneHook.hasHook) { console.debug('Drone Hook needs to be deleted') await doApiCall(errors, `Deleting hook "drone" from repo otomi/values`, () => - repoApi.repoDeleteHook(orgName, 'values', hasDroneHook.id!), + repoApi.repoDeleteHook(orgName, otomiValuesRepoName, hasDroneHook.id!), ) } } @@ -213,7 +213,7 @@ export default async function main(): Promise { const repoOption: CreateRepoOption = { ...new CreateRepoOption(), autoInit: false, - name: otomiValuesRepoName, + name: '', _private: true, } const valuesRepoOption: CreateRepoOption = { @@ -242,7 +242,7 @@ export default async function main(): Promise { await doApiCall( errors, `Adding repo values to team otomi-viewer`, - () => repoApi.repoAddTeam(orgName, 'values', 'otomi-viewer'), + () => repoApi.repoAddTeam(orgName, otomiValuesRepoName, 'otomi-viewer'), 422, ) @@ -250,7 +250,7 @@ export default async function main(): Promise { await doApiCall( errors, `Adding repo values to team otomi-viewer`, - () => repoApi.repoAddTeam(orgName, 'values', 'otomi-viewer'), + () => repoApi.repoAddTeam(orgName, otomiValuesRepoName, 'otomi-viewer'), 422, )