UNPKG

@veecode-platform/safira-cli

Version:

Generate a microservice project from your spec.

37 lines (36 loc) 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ArgoCdSetup = void 0; const application_config_1 = require("../generate/template/argocd/application-config"); const git_credential_secret_1 = require("../generate/template/argocd/git-credential-secret"); const git_utils_1 = require("../git/git-utils"); const commands_1 = require("../kubectl/commands"); const safira_utils_1 = require("../safira-project/safira-utils"); const file_system_utils_1 = require("../utils/file-system-utils"); const credentials_1 = require("../vkpr/credentials/credentials"); class ArgoCdSetup { constructor() { } async setup(params) { const credential = credentials_1.Credentials.instance.getCredential(credentials_1.CredentialsKey[params["ci-provider"]]); const repoUrl = git_utils_1.GitUtils.generateRepoUrl(params["project-name"], params["ci-provider"]); const GitProvider = params["ci-provider"]; const namespace = params["kubernetes-namespace"]; const server = [params["kubernetes-server"]]; const path = git_utils_1.GitUtils.validatePath(params["project-path"]); if (!credential) throw new Error(`Credentials for ${params["ci-provider"]} not found`); const gitCredential = credentials_1.Credentials.instance.getCredential(credentials_1.CredentialsKey[params["ci-provider"]]); new git_credential_secret_1.GitCredentialSecret().create("git-credential", gitCredential.credential, repoUrl, GitProvider); new application_config_1.ArgoApplicationConfig().create("configure-argo", repoUrl, namespace, server, path, params["branch-name"]); const argoFolder = file_system_utils_1.FileSystemUtils.buildPath(safira_utils_1.SafiraUtils.getSafiraProjectFolder(), "argocd"); const files = file_system_utils_1.FileSystemUtils.listFilesRecursive(argoFolder); await commands_1.KubernetesApply.instance.command(files); } static get instance() { if (!this._instance) { this._instance = new this(); } return this._instance; } } exports.ArgoCdSetup = ArgoCdSetup;