@catladder/cli 0.0.0-test7 → 0.0.0-update-meteor-53480fed
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -1
- package/README.md +6 -3
- package/bin/catenv +3 -0
- package/bin/catenv-dev +3 -0
- package/bin/catladder +1 -1
- package/bin/catladder-dev +3 -0
- package/dist/apps/catenv/catenv.d.ts +3 -0
- package/dist/apps/catenv/catenv.js +66 -0
- package/dist/apps/catenv/catenv.js.map +1 -0
- package/dist/apps/catenv/printVariables.d.ts +3 -0
- package/dist/apps/catenv/printVariables.js +115 -0
- package/dist/apps/catenv/printVariables.js.map +1 -0
- package/dist/apps/catenv/types.d.ts +5 -0
- package/dist/apps/catenv/types.js +3 -0
- package/dist/apps/catenv/types.js.map +1 -0
- package/dist/apps/catenv/utils.d.ts +12 -0
- package/dist/apps/catenv/utils.js +108 -0
- package/dist/apps/catenv/utils.js.map +1 -0
- package/dist/apps/catenv/writeDotEnvFiles.d.ts +3 -0
- package/dist/apps/catenv/writeDotEnvFiles.js +94 -0
- package/dist/apps/catenv/writeDotEnvFiles.js.map +1 -0
- package/dist/apps/catenv/writeEnvDTs.d.ts +3 -0
- package/dist/apps/catenv/writeEnvDTs.js +114 -0
- package/dist/apps/catenv/writeEnvDTs.js.map +1 -0
- package/dist/apps/cli/cli.d.ts +2 -0
- package/dist/apps/cli/cli.js +83 -0
- package/dist/apps/cli/cli.js.map +1 -0
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.d.ts +3 -0
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js +180 -0
- package/dist/apps/cli/commands/cloudSQL/commandRestoreDb.js.map +1 -0
- package/dist/apps/cli/commands/cloudSQL/index.d.ts +3 -0
- package/dist/apps/cli/commands/cloudSQL/index.js +50 -0
- package/dist/apps/cli/commands/cloudSQL/index.js.map +1 -0
- package/dist/apps/cli/commands/general/index.d.ts +4 -0
- package/dist/apps/cli/commands/general/index.js +216 -0
- package/dist/apps/cli/commands/general/index.js.map +1 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.d.ts +3 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.js +56 -0
- package/dist/apps/cli/commands/general/namespaceAutoCompletion.js.map +1 -0
- package/dist/apps/cli/commands/general/portForward.d.ts +3 -0
- package/dist/apps/cli/commands/general/portForward.js +97 -0
- package/dist/apps/cli/commands/general/portForward.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/index.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/index.js +53 -0
- package/dist/apps/cli/commands/mongodb/index.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js +191 -0
- package/dist/apps/cli/commands/mongodb/projectMongoDestroyMember.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js +96 -0
- package/dist/apps/cli/commands/mongodb/projectMongoGetShell.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.d.ts +3 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js +121 -0
- package/dist/apps/cli/commands/mongodb/projectMongoPortForward.js.map +1 -0
- package/dist/apps/cli/commands/mongodb/utils/index.d.ts +13 -0
- package/dist/apps/cli/commands/mongodb/utils/index.js +179 -0
- package/dist/apps/cli/commands/mongodb/utils/index.js.map +1 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js +164 -0
- package/dist/apps/cli/commands/project/commandCloudSqlProxy.js.map +1 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.d.ts +5 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.js +334 -0
- package/dist/apps/cli/commands/project/commandConfigSecrets.js.map +1 -0
- package/dist/apps/cli/commands/project/commandDeletePods.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandDeletePods.js +121 -0
- package/dist/apps/cli/commands/project/commandDeletePods.js.map +1 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.js +97 -0
- package/dist/apps/cli/commands/project/commandDeleteProject.js.map +1 -0
- package/dist/apps/cli/commands/project/commandEnvVars.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandEnvVars.js +74 -0
- package/dist/apps/cli/commands/project/commandEnvVars.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js +58 -0
- package/dist/apps/cli/commands/project/commandGetMyTotalWorktime.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGetShell.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGetShell.js +96 -0
- package/dist/apps/cli/commands/project/commandGetShell.js.map +1 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.js +185 -0
- package/dist/apps/cli/commands/project/commandGitlabCi.js.map +1 -0
- package/dist/apps/cli/commands/project/commandInitProject.old.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandInitProject.old.js +345 -0
- package/dist/apps/cli/commands/project/commandInitProject.old.js.map +1 -0
- package/dist/apps/cli/commands/project/commandListPods.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandListPods.js +78 -0
- package/dist/apps/cli/commands/project/commandListPods.js.map +1 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.d.ts +7 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js +112 -0
- package/dist/apps/cli/commands/project/commandMigrateHelm3.js.map +1 -0
- package/dist/apps/cli/commands/project/commandNamespace.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandNamespace.js +70 -0
- package/dist/apps/cli/commands/project/commandNamespace.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js +83 -0
- package/dist/apps/cli/commands/project/commandOpenCostDashboard.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.js +84 -0
- package/dist/apps/cli/commands/project/commandOpenDashboard.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.js +80 -0
- package/dist/apps/cli/commands/project/commandOpenEnv.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGit.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGit.js +56 -0
- package/dist/apps/cli/commands/project/commandOpenGit.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.js +83 -0
- package/dist/apps/cli/commands/project/commandOpenGrafana.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js +100 -0
- package/dist/apps/cli/commands/project/commandOpenGrafanaPod.js.map +1 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.js +74 -0
- package/dist/apps/cli/commands/project/commandOpenLogs.js.map +1 -0
- package/dist/apps/cli/commands/project/commandPauseProject.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandPauseProject.js +97 -0
- package/dist/apps/cli/commands/project/commandPauseProject.js.map +1 -0
- package/dist/apps/cli/commands/project/commandPortForward.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandPortForward.js +168 -0
- package/dist/apps/cli/commands/project/commandPortForward.js.map +1 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.d.ts +5 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js +90 -0
- package/dist/apps/cli/commands/project/commandSecretsClearBackups.js.map +1 -0
- package/dist/apps/cli/commands/project/commandSetup.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandSetup.js +58 -0
- package/dist/apps/cli/commands/project/commandSetup.js.map +1 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.d.ts +3 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js +144 -0
- package/dist/apps/cli/commands/project/commandTriggerCronjob.js.map +1 -0
- package/dist/apps/cli/commands/project/index.d.ts +3 -0
- package/dist/apps/cli/commands/project/index.js +94 -0
- package/dist/apps/cli/commands/project/index.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/index.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/index.js +107 -0
- package/dist/apps/cli/commands/project/setup/index.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js +116 -0
- package/dist/apps/cli/commands/project/setup/setupAccessTokens.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.js +118 -0
- package/dist/apps/cli/commands/project/setup/setupCloudRun.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupContext.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupContext.js +81 -0
- package/dist/apps/cli/commands/project/setup/setupContext.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.d.ts +3 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js +139 -0
- package/dist/apps/cli/commands/project/setup/setupKubernetes.js.map +1 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.d.ts +2 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.js +69 -0
- package/dist/apps/cli/commands/project/setup/setupTopic.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.d.ts +3 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.js +96 -0
- package/dist/apps/cli/commands/project/utils/autocompletions.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.d.ts +1 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.js +84 -0
- package/dist/apps/cli/commands/project/utils/ensureCluster.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.d.ts +2 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js +104 -0
- package/dist/apps/cli/commands/project/utils/ensureNamespace.js.map +1 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.d.ts +2 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.js +58 -0
- package/dist/apps/cli/commands/project/utils/showProjectBanner.js.map +1 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.d.ts +3 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js +101 -0
- package/dist/apps/cli/commands/theStuffThatReallyMatters/index.js.map +1 -0
- package/dist/apps/cli/config/writeConfig.d.ts +5 -0
- package/dist/apps/cli/config/writeConfig.js +106 -0
- package/dist/apps/cli/config/writeConfig.js.map +1 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.d.ts +1 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.js +69 -0
- package/dist/apps/cli/utils/getGoogleAuthUserNumber.js.map +1 -0
- package/dist/apps/cli/verify/index.d.ts +2 -0
- package/dist/apps/cli/verify/index.js +94 -0
- package/dist/apps/cli/verify/index.js.map +1 -0
- package/dist/apps/cli/verify/migration/fromv2.d.ts +4 -0
- package/dist/apps/cli/verify/migration/fromv2.js +349 -0
- package/dist/apps/cli/verify/migration/fromv2.js.map +1 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.d.ts +4 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.js +91 -0
- package/dist/apps/cli/verify/migration/migrateSecrets.js.map +1 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.d.ts +18 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.js +30 -0
- package/dist/apps/cli/verify/migration/oldGitlabCi.js.map +1 -0
- package/dist/bundles/catenv/index.js +46512 -0
- package/dist/bundles/catenv/xdg-open +1066 -0
- package/dist/bundles/cli/clipboard_i686.exe +0 -0
- package/dist/bundles/cli/clipboard_x86_64.exe +0 -0
- package/dist/bundles/cli/exec-child.js +39 -0
- package/dist/bundles/cli/index.js +363134 -0
- package/dist/bundles/cli/xdg-open +1066 -0
- package/dist/bundles/cli/xsel +0 -0
- package/dist/catenv.d.ts +1 -0
- package/dist/catenv.js +13 -0
- package/dist/catenv.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +8 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/constants.d.ts +2 -0
- package/dist/config/constants.js +6 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/getProjectConfig.d.ts +24 -0
- package/dist/config/getProjectConfig.js +313 -0
- package/dist/config/getProjectConfig.js.map +1 -0
- package/dist/config/parseChoice.d.ts +4 -0
- package/dist/config/parseChoice.js +9 -0
- package/dist/config/parseChoice.js.map +1 -0
- package/dist/gcloud/artifactsRegistry.d.ts +5 -0
- package/dist/gcloud/artifactsRegistry.js +59 -0
- package/dist/gcloud/artifactsRegistry.js.map +1 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.d.ts +2 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js +67 -0
- package/dist/gcloud/cloudRun/getCloudRunDomainSuffix.js.map +1 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.d.ts +3 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js +62 -0
- package/dist/gcloud/cloudRun/openCloudRunDashboards.js.map +1 -0
- package/dist/gcloud/cloudSql/startProxy.d.ts +10 -0
- package/dist/gcloud/cloudSql/startProxy.js +121 -0
- package/dist/gcloud/cloudSql/startProxy.js.map +1 -0
- package/dist/gcloud/enableServices.d.ts +3 -0
- package/dist/gcloud/enableServices.js +63 -0
- package/dist/gcloud/enableServices.js.map +1 -0
- package/dist/gcloud/openDashboard.d.ts +2 -0
- package/dist/gcloud/openDashboard.js +66 -0
- package/dist/gcloud/openDashboard.js.map +1 -0
- package/dist/gcloud/serviceAccounts.d.ts +12 -0
- package/dist/gcloud/serviceAccounts.js +144 -0
- package/dist/gcloud/serviceAccounts.js.map +1 -0
- package/dist/k8sApi/index.d.ts +8 -0
- package/dist/k8sApi/index.js +29 -0
- package/dist/k8sApi/index.js.map +1 -0
- package/dist/kubernetes/index.d.ts +3 -0
- package/dist/kubernetes/index.js +88 -0
- package/dist/kubernetes/index.js.map +1 -0
- package/dist/kubernetes/openKubernetesDashboards.d.ts +4 -0
- package/dist/kubernetes/openKubernetesDashboards.js +94 -0
- package/dist/kubernetes/openKubernetesDashboards.js.map +1 -0
- package/dist/kubernetes/portForward.d.ts +1 -0
- package/dist/kubernetes/portForward.js +55 -0
- package/dist/kubernetes/portForward.js.map +1 -0
- package/dist/packageInfos.d.ts +2 -0
- package/dist/packageInfos.js +6 -0
- package/dist/packageInfos.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/types.d.ts +18 -0
- package/dist/types/types.js +3 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/cluster.d.ts +3 -0
- package/dist/utils/cluster.js +68 -0
- package/dist/utils/cluster.js.map +1 -0
- package/dist/utils/editAsFile.d.ts +1 -0
- package/dist/utils/editAsFile.js +85 -0
- package/dist/utils/editAsFile.js.map +1 -0
- package/dist/utils/files.d.ts +2 -0
- package/dist/utils/files.js +83 -0
- package/dist/utils/files.js.map +1 -0
- package/dist/utils/getEditor.d.ts +4 -0
- package/dist/utils/getEditor.js +70 -0
- package/dist/utils/getEditor.js.map +1 -0
- package/dist/utils/gitlab.d.ts +24 -0
- package/dist/utils/gitlab.js +397 -0
- package/dist/utils/gitlab.js.map +1 -0
- package/dist/utils/log.d.ts +1 -0
- package/dist/utils/log.js +14 -0
- package/dist/utils/log.js.map +1 -0
- package/dist/utils/passwordstore/index.d.ts +7 -0
- package/dist/utils/passwordstore/index.js +315 -0
- package/dist/utils/passwordstore/index.js.map +1 -0
- package/dist/utils/portForwards.d.ts +12 -0
- package/dist/utils/portForwards.js +120 -0
- package/dist/utils/portForwards.js.map +1 -0
- package/dist/utils/preferences/index.d.ts +3 -0
- package/dist/utils/preferences/index.js +119 -0
- package/dist/utils/preferences/index.js.map +1 -0
- package/dist/utils/projects/index.d.ts +5 -0
- package/dist/utils/projects/index.js +103 -0
- package/dist/utils/projects/index.js.map +1 -0
- package/dist/utils/promise.d.ts +2 -0
- package/dist/utils/promise.js +62 -0
- package/dist/utils/promise.js.map +1 -0
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.js +81 -0
- package/dist/utils/shell.js.map +1 -0
- package/package.json +32 -35
- package/scripts/bundle +4 -0
- package/src/apps/catenv/catenv.ts +14 -37
- package/src/apps/catenv/printVariables.ts +58 -0
- package/src/apps/catenv/types.ts +6 -0
- package/src/apps/catenv/utils.ts +49 -0
- package/src/apps/catenv/writeDotEnvFiles.ts +44 -0
- package/src/apps/catenv/writeEnvDTs.ts +71 -0
- package/src/apps/{shell/shell.ts → cli/cli.ts} +13 -3
- package/src/apps/cli/commands/cloudSQL/commandRestoreDb.ts +154 -0
- package/src/apps/cli/commands/cloudSQL/index.ts +8 -0
- package/src/apps/{shell → cli}/commands/general/index.ts +16 -52
- package/src/apps/{shell → cli}/commands/general/portForward.ts +7 -6
- package/src/apps/{shell → cli}/commands/mongodb/index.ts +2 -2
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoDestroyMember.ts +20 -22
- package/src/apps/{shell → cli}/commands/mongodb/projectMongoGetShell.ts +13 -11
- package/src/apps/cli/commands/mongodb/projectMongoPortForward.ts +65 -0
- package/src/apps/{shell → cli}/commands/mongodb/utils/index.ts +28 -19
- package/src/apps/cli/commands/project/commandCloudSqlProxy.ts +139 -0
- package/src/apps/cli/commands/project/commandConfigSecrets.ts +234 -0
- package/src/apps/{shell → cli}/commands/project/commandDeletePods.ts +13 -15
- package/src/apps/{shell → cli}/commands/project/commandDeleteProject.ts +8 -9
- package/src/apps/cli/commands/project/commandEnvVars.ts +18 -0
- package/src/apps/{shell → cli}/commands/project/commandGetMyTotalWorktime.ts +4 -4
- package/src/apps/cli/commands/project/commandGetShell.ts +36 -0
- package/src/apps/{shell → cli}/commands/project/commandGitlabCi.ts +3 -2
- package/src/apps/{shell/commands/project/commandInitProject.ts → cli/commands/project/commandInitProject.old.ts} +15 -7
- package/src/apps/cli/commands/project/commandListPods.ts +18 -0
- package/src/apps/{shell → cli}/commands/project/commandMigrateHelm3.ts +18 -8
- package/src/apps/cli/commands/project/commandNamespace.ts +14 -0
- package/src/apps/cli/commands/project/commandOpenCostDashboard.ts +32 -0
- package/src/apps/cli/commands/project/commandOpenDashboard.ts +28 -0
- package/src/apps/cli/commands/project/commandOpenEnv.ts +22 -0
- package/src/apps/{shell → cli}/commands/project/commandOpenGit.ts +2 -2
- package/src/apps/{shell → cli}/commands/project/commandOpenGrafana.ts +10 -10
- package/src/apps/{shell → cli}/commands/project/commandOpenGrafanaPod.ts +14 -17
- package/src/apps/cli/commands/project/commandOpenLogs.ts +21 -0
- package/src/apps/{shell → cli}/commands/project/commandPauseProject.ts +10 -8
- package/src/apps/cli/commands/project/commandPortForward.ts +86 -0
- package/src/apps/cli/commands/project/commandSecretsClearBackups.ts +27 -0
- package/src/apps/cli/commands/project/commandSetup.ts +12 -0
- package/src/apps/{shell → cli}/commands/project/commandTriggerCronjob.ts +13 -12
- package/src/apps/{shell → cli}/commands/project/index.ts +10 -10
- package/src/apps/cli/commands/project/setup/index.ts +44 -0
- package/src/apps/cli/commands/project/setup/setupAccessTokens.ts +84 -0
- package/src/apps/cli/commands/project/setup/setupCloudRun.ts +84 -0
- package/src/apps/cli/commands/project/setup/setupContext.ts +44 -0
- package/src/apps/cli/commands/project/setup/setupKubernetes.ts +140 -0
- package/src/apps/cli/commands/project/setup/setupTopic.ts +22 -0
- package/src/apps/cli/commands/project/utils/autocompletions.ts +26 -0
- package/src/apps/cli/commands/project/utils/ensureCluster.ts +42 -0
- package/src/apps/cli/commands/project/utils/ensureNamespace.ts +58 -0
- package/src/apps/cli/commands/project/utils/showProjectBanner.ts +11 -0
- package/src/apps/cli/commands/theStuffThatReallyMatters/index.ts +32 -0
- package/src/apps/cli/config/writeConfig.ts +71 -0
- package/src/apps/cli/verify/index.ts +30 -0
- package/src/apps/cli/verify/migration/fromv2.ts +262 -0
- package/src/apps/cli/verify/migration/migrateSecrets.ts +47 -0
- package/src/apps/cli/verify/migration/oldGitlabCi.ts +48 -0
- package/src/catenv.ts +10 -0
- package/src/cli.ts +3 -0
- package/src/config/constants.ts +0 -3
- package/src/config/getProjectConfig.ts +200 -0
- package/src/config/parseChoice.ts +4 -0
- package/src/gcloud/artifactsRegistry.ts +16 -0
- package/src/gcloud/cloudRun/getCloudRunDomainSuffix.ts +35 -0
- package/src/gcloud/cloudRun/openCloudRunDashboards.ts +22 -0
- package/src/gcloud/cloudSql/startProxy.ts +74 -0
- package/src/gcloud/enableServices.ts +14 -0
- package/src/gcloud/openDashboard.ts +19 -0
- package/src/gcloud/serviceAccounts.ts +101 -0
- package/src/k8sApi/index.ts +22 -6
- package/src/kubernetes/index.ts +27 -0
- package/src/kubernetes/openKubernetesDashboards.ts +52 -0
- package/src/kubernetes/portForward.ts +15 -0
- package/src/types/child-process-promise.d.ts +37 -1
- package/src/types/types.ts +0 -2
- package/src/utils/cluster.ts +5 -14
- package/src/utils/editAsFile.ts +31 -0
- package/src/utils/files.ts +6 -2
- package/src/utils/gitlab.ts +263 -42
- package/src/utils/passwordstore/index.ts +6 -36
- package/src/utils/{portForward.ts → portForwards.ts} +27 -22
- package/src/utils/preferences/index.ts +6 -3
- package/src/utils/projects/index.ts +9 -149
- package/tsconfig.json +3 -7
- package/bin/catenv.sh +0 -1
- package/src/apps/shell/commands/mongodb/projectMongoPortForward.ts +0 -42
- package/src/apps/shell/commands/project/commandCloudSqlProxy.ts +0 -65
- package/src/apps/shell/commands/project/commandConfigSecrets.ts +0 -245
- package/src/apps/shell/commands/project/commandCopyDB.ts +0 -93
- package/src/apps/shell/commands/project/commandEnvVars.ts +0 -17
- package/src/apps/shell/commands/project/commandGetShell.ts +0 -35
- package/src/apps/shell/commands/project/commandInitGitlab.ts +0 -157
- package/src/apps/shell/commands/project/commandListPods.ts +0 -21
- package/src/apps/shell/commands/project/commandNamespace.ts +0 -12
- package/src/apps/shell/commands/project/commandOpenCostDashboard.ts +0 -29
- package/src/apps/shell/commands/project/commandOpenDashboard.ts +0 -27
- package/src/apps/shell/commands/project/commandOpenEnv.ts +0 -18
- package/src/apps/shell/commands/project/commandOpenLogs.ts +0 -23
- package/src/apps/shell/commands/project/commandPortForward.ts +0 -45
- package/src/apps/shell/commands/project/commandVariables.ts +0 -13
- package/src/apps/shell/commands/project/utils/autocompletions.ts +0 -7
- package/src/apps/shell/commands/project/utils/ensureCluster.ts +0 -31
- package/src/apps/shell/commands/project/utils/ensureNamespace.ts +0 -32
- package/src/apps/shell/commands/project/utils/monorepo.ts +0 -45
- package/src/apps/shell/commands/shared/index.ts +0 -31
- package/src/apps/shell/commands/theStuffThatReallyMatters/index.ts +0 -51
- package/src/config/clusters.ts +0 -45
- package/src/index.ts +0 -17
- package/src/types/git-repo-name.d.ts +0 -1
- package/src/types/yawn-yaml.d.ts +0 -1
- package/src/utils/dashboardToken.ts +0 -20
- package/src/utils/formatEnvVars.ts +0 -7
- /package/src/apps/{shell → cli}/commands/general/namespaceAutoCompletion.ts +0 -0
- /package/src/apps/{shell → cli}/utils/getGoogleAuthUserNumber.ts +0 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BuildConfig,
|
|
3
|
+
ComponentConfig,
|
|
4
|
+
Config,
|
|
5
|
+
DeployConfigKubernetes,
|
|
6
|
+
Env,
|
|
7
|
+
} from "@catladder/pipeline";
|
|
8
|
+
import {
|
|
9
|
+
existsSync,
|
|
10
|
+
lstatSync,
|
|
11
|
+
readdirSync,
|
|
12
|
+
readFile,
|
|
13
|
+
writeFile,
|
|
14
|
+
} from "fs-extra";
|
|
15
|
+
import { isEmpty } from "lodash";
|
|
16
|
+
import { join } from "path";
|
|
17
|
+
import type Vorpal from "vorpal";
|
|
18
|
+
import {
|
|
19
|
+
getGitlabCi,
|
|
20
|
+
getGitlabCiFilePath,
|
|
21
|
+
} from "../../../../config/getProjectConfig";
|
|
22
|
+
import { readYaml } from "../../../../utils/files";
|
|
23
|
+
import { syncBitwarden } from "../../../../utils/passwordstore";
|
|
24
|
+
import { getGitRoot } from "../../../../utils/projects";
|
|
25
|
+
import { writeConfig } from "../../config/writeConfig";
|
|
26
|
+
import { migrateSecrets } from "./migrateSecrets";
|
|
27
|
+
import type { OldGitlabCiFile } from "./oldGitlabCi";
|
|
28
|
+
import { detectBuildConfig, isOldInclude } from "./oldGitlabCi";
|
|
29
|
+
export const LEGACY_ENVS = [
|
|
30
|
+
"dev-local",
|
|
31
|
+
"dev",
|
|
32
|
+
"review",
|
|
33
|
+
"stage",
|
|
34
|
+
"prod",
|
|
35
|
+
] as const;
|
|
36
|
+
|
|
37
|
+
const arrayToRecord = (arr: { name: string }[]): Record<string, any> => {
|
|
38
|
+
if (!arr) return undefined;
|
|
39
|
+
if (!Array.isArray(arr)) return arr;
|
|
40
|
+
return Object.fromEntries(arr.map(({ name, ...rest }) => [name, rest]));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const transformVars = (rawVars: {
|
|
44
|
+
public: Record<string, any>;
|
|
45
|
+
secret: Record<string, any>;
|
|
46
|
+
fromCommponents: any;
|
|
47
|
+
}) => {
|
|
48
|
+
if (rawVars.fromCommponents) {
|
|
49
|
+
console.warn("cant transform legacy fromCommponents");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
public: rawVars.public,
|
|
54
|
+
secret: rawVars.secret ? Object.keys(rawVars.secret) : undefined,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const getLegacyMonorepoSubCiFiles = (dir: string) => {
|
|
59
|
+
return readdirSync(dir)
|
|
60
|
+
.filter((file) => lstatSync(file).isDirectory())
|
|
61
|
+
.map((dir) => ({
|
|
62
|
+
dir,
|
|
63
|
+
ci: join(dir, ".gitlab-ci.yml"),
|
|
64
|
+
}))
|
|
65
|
+
.filter(({ ci }) => existsSync(ci));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const transformValues = (
|
|
69
|
+
valuesIn: Record<string, any>
|
|
70
|
+
): DeployConfigKubernetes["values"] => {
|
|
71
|
+
if (isEmpty(valuesIn)) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
delete valuesIn?.application?.host;
|
|
75
|
+
delete valuesIn?.application?.command;
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
...valuesIn,
|
|
79
|
+
jobs: arrayToRecord(valuesIn?.jobs),
|
|
80
|
+
cronjobs: arrayToRecord(valuesIn?.cronjobs),
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const isV2 = async () => {
|
|
85
|
+
const gitlabCi = await getGitlabCi<OldGitlabCiFile>();
|
|
86
|
+
return isOldInclude(gitlabCi);
|
|
87
|
+
};
|
|
88
|
+
export const migrateV2 = async (vorpal: Vorpal) => {
|
|
89
|
+
const gitlabCi = await getGitlabCi<OldGitlabCiFile>();
|
|
90
|
+
const gitRoot = await getGitRoot();
|
|
91
|
+
|
|
92
|
+
const {
|
|
93
|
+
CUSTOMER_NAME,
|
|
94
|
+
APP_NAME,
|
|
95
|
+
COMPONENT_NAME = "web",
|
|
96
|
+
APP_DIR = ".",
|
|
97
|
+
STAGING_ENABLED,
|
|
98
|
+
} = gitlabCi.variables;
|
|
99
|
+
|
|
100
|
+
vorpal
|
|
101
|
+
.command("migrate")
|
|
102
|
+
|
|
103
|
+
.action(async function () {
|
|
104
|
+
this.log("");
|
|
105
|
+
this.log("⚠️ this project uses legacy catladder (v2)");
|
|
106
|
+
this.log("");
|
|
107
|
+
this.log(
|
|
108
|
+
"😼 I can migrate the project for you. This contains the following steps:"
|
|
109
|
+
);
|
|
110
|
+
this.log("");
|
|
111
|
+
this.log(
|
|
112
|
+
" - migrate the config from values-*.yml to catladder config file"
|
|
113
|
+
);
|
|
114
|
+
this.log(
|
|
115
|
+
" - migrate the secrets from bitwarden to gitlab (this will trash the entries in bitwarden)"
|
|
116
|
+
);
|
|
117
|
+
this.log("");
|
|
118
|
+
this.log(
|
|
119
|
+
"☝ make sure that you checked in your current state in case something goes wrong."
|
|
120
|
+
);
|
|
121
|
+
this.log(
|
|
122
|
+
"☝ secrets in bitwarden are deleted, but can be restored within 30 days."
|
|
123
|
+
);
|
|
124
|
+
this.log("");
|
|
125
|
+
const { shouldContinue } = await this.prompt({
|
|
126
|
+
default: true,
|
|
127
|
+
message: "Migrate project now? 🤔",
|
|
128
|
+
name: "shouldContinue",
|
|
129
|
+
type: "confirm",
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
if (shouldContinue) {
|
|
133
|
+
vorpal.log("");
|
|
134
|
+
vorpal.log("");
|
|
135
|
+
vorpal.log("💪😼 ok, let's go...");
|
|
136
|
+
vorpal.log("");
|
|
137
|
+
vorpal.log("");
|
|
138
|
+
|
|
139
|
+
const createComponent = async (
|
|
140
|
+
dir: string,
|
|
141
|
+
ciFile: OldGitlabCiFile
|
|
142
|
+
): Promise<ComponentConfig> => {
|
|
143
|
+
const { env, ...baseValues } =
|
|
144
|
+
(await readYaml(dir + "/values.yml")) ?? {};
|
|
145
|
+
|
|
146
|
+
const startCommand = Array.isArray(baseValues?.application?.command)
|
|
147
|
+
? baseValues?.application?.command.join(" ")
|
|
148
|
+
: baseValues?.application?.command;
|
|
149
|
+
return {
|
|
150
|
+
vars: env ? transformVars(env) : undefined,
|
|
151
|
+
dir: dir,
|
|
152
|
+
build: {
|
|
153
|
+
type: detectBuildConfig(ciFile),
|
|
154
|
+
startCommand: startCommand,
|
|
155
|
+
} as BuildConfig,
|
|
156
|
+
deploy: {
|
|
157
|
+
type: "kubernetes",
|
|
158
|
+
values: transformValues(baseValues),
|
|
159
|
+
cluster: {
|
|
160
|
+
type: "gcloud",
|
|
161
|
+
name: "ch-production",
|
|
162
|
+
projectId: "skynet-swiss",
|
|
163
|
+
region: "europe-west6-a",
|
|
164
|
+
domainCanonical: "panter.swiss",
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
env: await LEGACY_ENVS.reduce<Promise<Env>>(
|
|
168
|
+
async (acc, envName) => {
|
|
169
|
+
if (envName === "stage" && !STAGING_ENABLED) {
|
|
170
|
+
return {
|
|
171
|
+
...(await acc),
|
|
172
|
+
[envName]: false,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const newEnvName = envName === "dev-local" ? "local" : envName;
|
|
176
|
+
|
|
177
|
+
const envValues =
|
|
178
|
+
(await readYaml(dir + `/values-${envName}.yml`)) ?? {};
|
|
179
|
+
const { env, ...rest } = envValues;
|
|
180
|
+
const host = rest?.application?.host;
|
|
181
|
+
const values = transformValues(rest);
|
|
182
|
+
return {
|
|
183
|
+
...(await acc),
|
|
184
|
+
[newEnvName]: {
|
|
185
|
+
host: host,
|
|
186
|
+
vars: env ? transformVars(env) : undefined,
|
|
187
|
+
deploy: values
|
|
188
|
+
? {
|
|
189
|
+
values: values,
|
|
190
|
+
}
|
|
191
|
+
: undefined,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
Promise.resolve({})
|
|
196
|
+
),
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
let components: Record<string, ComponentConfig>;
|
|
200
|
+
if (detectBuildConfig(gitlabCi) === "monorepo") {
|
|
201
|
+
components = await getLegacyMonorepoSubCiFiles(gitRoot).reduce<
|
|
202
|
+
Promise<Record<string, ComponentConfig>>
|
|
203
|
+
>(async (acc, el) => {
|
|
204
|
+
return {
|
|
205
|
+
...(await acc),
|
|
206
|
+
[el.dir]: await createComponent(el.dir, await readYaml(el.ci)),
|
|
207
|
+
};
|
|
208
|
+
}, Promise.resolve({}));
|
|
209
|
+
} else {
|
|
210
|
+
components = {
|
|
211
|
+
[COMPONENT_NAME]: await createComponent(APP_DIR, gitlabCi),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
// we only have one component
|
|
215
|
+
const config: Config = {
|
|
216
|
+
customerName: CUSTOMER_NAME,
|
|
217
|
+
appName: APP_NAME,
|
|
218
|
+
components,
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const comment =
|
|
222
|
+
"Old migrated config:\n\n" +
|
|
223
|
+
(await readFile(await getGitlabCiFilePath(), {
|
|
224
|
+
encoding: "utf-8",
|
|
225
|
+
}));
|
|
226
|
+
|
|
227
|
+
this.log("-------------------");
|
|
228
|
+
this.log("migrate config");
|
|
229
|
+
await writeConfig(this, config, {
|
|
230
|
+
endComment: comment,
|
|
231
|
+
});
|
|
232
|
+
this.log("write gitlab-ci.yml");
|
|
233
|
+
await writeFile(
|
|
234
|
+
await getGitlabCiFilePath(),
|
|
235
|
+
"include: https://git.panter.ch/api/v4/projects/catladder%2Fcatladder/packages/generic/ci-includes/main/gitlab-ci.yml",
|
|
236
|
+
{ encoding: "utf-8" }
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
this.log("-------------------");
|
|
240
|
+
this.log("migrate secrets");
|
|
241
|
+
await syncBitwarden();
|
|
242
|
+
for (const env of LEGACY_ENVS) {
|
|
243
|
+
if (env === "stage" && !STAGING_ENABLED) return;
|
|
244
|
+
await migrateSecrets(this, config, env);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
this.log("-------------------");
|
|
248
|
+
|
|
249
|
+
this.log("done!");
|
|
250
|
+
this.log("");
|
|
251
|
+
this.log("You can remove the values*.yml files now.");
|
|
252
|
+
|
|
253
|
+
this.log("-------------------");
|
|
254
|
+
} else {
|
|
255
|
+
this.log(
|
|
256
|
+
"☝ if you want to use catladder in legacy mode, install @panter/catladder globally and invoke catladder-legacy"
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
vorpal.exec("migrate");
|
|
262
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Config } from "@catladder/pipeline";
|
|
2
|
+
import { getEnvironment } from "@catladder/pipeline";
|
|
3
|
+
import { load } from "js-yaml";
|
|
4
|
+
import { pick } from "lodash";
|
|
5
|
+
import type { CommandInstance } from "vorpal";
|
|
6
|
+
import { upsertAllVariables } from "../../../../utils/gitlab";
|
|
7
|
+
import { readPass, trashItem } from "../../../../utils/passwordstore";
|
|
8
|
+
import type { LEGACY_ENVS } from "./fromv2";
|
|
9
|
+
|
|
10
|
+
const getPassPath = (newConfig: Config, env: string) => {
|
|
11
|
+
return `${newConfig.customerName}/${newConfig.appName}/${env}/secrets.yml`;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const migrateSecrets = async (
|
|
15
|
+
vorpal: CommandInstance,
|
|
16
|
+
newConfig: Config,
|
|
17
|
+
oldEnv: typeof LEGACY_ENVS[number]
|
|
18
|
+
) => {
|
|
19
|
+
const newEnv = oldEnv === "dev-local" ? "local" : oldEnv;
|
|
20
|
+
const path = getPassPath(newConfig, oldEnv);
|
|
21
|
+
try {
|
|
22
|
+
const yamlstring = await readPass(path);
|
|
23
|
+
const secrets = load(yamlstring);
|
|
24
|
+
|
|
25
|
+
Object.keys(newConfig.components).forEach(async (componentName) => {
|
|
26
|
+
const environment = await getEnvironment(
|
|
27
|
+
newConfig,
|
|
28
|
+
componentName,
|
|
29
|
+
newEnv
|
|
30
|
+
);
|
|
31
|
+
await upsertAllVariables(
|
|
32
|
+
vorpal,
|
|
33
|
+
pick(
|
|
34
|
+
secrets,
|
|
35
|
+
environment.secretEnvVarKeys
|
|
36
|
+
.filter((k) => !k.hidden)
|
|
37
|
+
.map((k) => k.key)
|
|
38
|
+
),
|
|
39
|
+
newEnv,
|
|
40
|
+
componentName
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
await trashItem(path);
|
|
44
|
+
} catch (e) {
|
|
45
|
+
console.warn(`could not migrate secrets for env '${oldEnv}': ${e}`);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { BuildConfig } from "@catladder/pipeline";
|
|
2
|
+
|
|
3
|
+
export type OldGitlabCiFile = {
|
|
4
|
+
variables: {
|
|
5
|
+
CUSTOMER_NAME: string;
|
|
6
|
+
APP_NAME: string;
|
|
7
|
+
COMPONENT_NAME?: string;
|
|
8
|
+
APP_DIR?: string;
|
|
9
|
+
CLUSTER_NAME?: string;
|
|
10
|
+
STAGING_ENABLED?: string;
|
|
11
|
+
};
|
|
12
|
+
include: {
|
|
13
|
+
project: string;
|
|
14
|
+
ref: string;
|
|
15
|
+
file: string;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const isOldInclude = (gitlabCi: OldGitlabCiFile) => {
|
|
20
|
+
return gitlabCi.include[0]?.project === "catladder/gitlab-ci";
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const detectBuildConfig = (
|
|
24
|
+
gitlabCi: OldGitlabCiFile
|
|
25
|
+
): BuildConfig["type"] | "monorepo" => {
|
|
26
|
+
if (!isOldInclude(gitlabCi)) {
|
|
27
|
+
throw new Error("unsupported gitlab-ci file");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const firstInclude = gitlabCi.include[0];
|
|
31
|
+
|
|
32
|
+
if (firstInclude.file === "monorepo.yml") return "monorepo";
|
|
33
|
+
|
|
34
|
+
if (firstInclude.file === "node-kubernetes.yml") {
|
|
35
|
+
return "node";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (firstInclude.file === "static-js-kubernetes.yml") {
|
|
39
|
+
return "node-static";
|
|
40
|
+
}
|
|
41
|
+
if (firstInclude.file === "meteor-kubernetes.yml") {
|
|
42
|
+
return "meteor";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (firstInclude.file === "rails-kubernetes.yml") {
|
|
46
|
+
return "rails";
|
|
47
|
+
}
|
|
48
|
+
};
|
package/src/catenv.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import catenv from "./apps/catenv/catenv";
|
|
2
|
+
|
|
3
|
+
import { parseChoice } from "./config/parseChoice";
|
|
4
|
+
|
|
5
|
+
const choice = process.argv[2] ? parseChoice(process.argv[2]) : null;
|
|
6
|
+
|
|
7
|
+
catenv(choice).then(() => {
|
|
8
|
+
// we have to exit manually, because we have some file watches
|
|
9
|
+
process.exit();
|
|
10
|
+
});
|
package/src/cli.ts
ADDED
package/src/config/constants.ts
CHANGED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import type { Config, EnvironmentEnvVars } from "@catladder/pipeline";
|
|
2
|
+
import {
|
|
3
|
+
readConfigSync,
|
|
4
|
+
getAllEnvs,
|
|
5
|
+
getEnvironment as _getEnvironment,
|
|
6
|
+
createContext,
|
|
7
|
+
getSecretVarName,
|
|
8
|
+
} from "@catladder/pipeline";
|
|
9
|
+
|
|
10
|
+
import type { CommandInstance } from "vorpal";
|
|
11
|
+
import { getAllVariables, getVariableValueByRawName } from "../utils/gitlab";
|
|
12
|
+
|
|
13
|
+
import { getGitRoot } from "../utils/projects";
|
|
14
|
+
import { readYaml } from "../utils/files";
|
|
15
|
+
import { watch } from "fs";
|
|
16
|
+
|
|
17
|
+
export { parseChoice } from "./parseChoice";
|
|
18
|
+
|
|
19
|
+
let currentConfig: Config | null = null;
|
|
20
|
+
|
|
21
|
+
// reload the config on change
|
|
22
|
+
const reloadConfigAndObserve = async () => {
|
|
23
|
+
const gitRoot = await getGitRoot();
|
|
24
|
+
const result = readConfigSync(gitRoot);
|
|
25
|
+
if (!result) {
|
|
26
|
+
// can't do anything, there is no config
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const { config, path } = result;
|
|
30
|
+
const watcher = watch(path, () => {
|
|
31
|
+
watcher.close();
|
|
32
|
+
reloadConfigAndObserve();
|
|
33
|
+
});
|
|
34
|
+
currentConfig = config;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const getProjectConfig = async () => {
|
|
38
|
+
if (!currentConfig) {
|
|
39
|
+
// initially
|
|
40
|
+
await reloadConfigAndObserve();
|
|
41
|
+
}
|
|
42
|
+
return currentConfig as Config;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const getGitlabCiFilePath = async () => {
|
|
46
|
+
const gitRoot = await getGitRoot();
|
|
47
|
+
return gitRoot + "/.gitlab-ci.yml";
|
|
48
|
+
};
|
|
49
|
+
export const getGitlabCi = async <T = Record<string, any>>() => {
|
|
50
|
+
try {
|
|
51
|
+
return readYaml(await getGitlabCiFilePath()) as Promise<T>;
|
|
52
|
+
} catch (e) {
|
|
53
|
+
// ignore
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export const getProjectComponents = async () => {
|
|
59
|
+
const config = await getProjectConfig();
|
|
60
|
+
if (!config) return [];
|
|
61
|
+
return Object.keys(config.components);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const getPipelineContextByChoice = async (
|
|
65
|
+
env: string,
|
|
66
|
+
componentName: string
|
|
67
|
+
) => {
|
|
68
|
+
const config = await getProjectConfig();
|
|
69
|
+
return await createContext(config, componentName, env);
|
|
70
|
+
};
|
|
71
|
+
export const getAllComponentsWithAllEnvsFlat = async (): Promise<
|
|
72
|
+
Array<{ env: string; componentName: string }>
|
|
73
|
+
> => {
|
|
74
|
+
const config = await getProjectConfig();
|
|
75
|
+
if (!config) {
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
return Object.keys(config.components).flatMap((componentName) =>
|
|
79
|
+
getAllEnvs(config, componentName).map((env) => ({ env, componentName }))
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const getAllComponentsWithAllEnvsHierarchical = async (): Promise<{
|
|
84
|
+
[componentName: string]: string[];
|
|
85
|
+
}> => {
|
|
86
|
+
const config = await getProjectConfig();
|
|
87
|
+
if (!config) {
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return Object.fromEntries(
|
|
92
|
+
Object.keys(config.components).map((componentName) => [
|
|
93
|
+
componentName,
|
|
94
|
+
getAllEnvs(config, componentName),
|
|
95
|
+
])
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const getAllPipelineContexts = async () => {
|
|
100
|
+
return Promise.all(
|
|
101
|
+
(await getAllComponentsWithAllEnvsFlat())
|
|
102
|
+
.filter((c) => c.env !== "local")
|
|
103
|
+
.map(({ env, componentName }) =>
|
|
104
|
+
getPipelineContextByChoice(env, componentName)
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const getEnvironment = async (env: string, componentName: string) => {
|
|
110
|
+
const config = await getProjectConfig();
|
|
111
|
+
|
|
112
|
+
return _getEnvironment(config, componentName, env);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const getGitlabVar = async (
|
|
116
|
+
vorpal: CommandInstance,
|
|
117
|
+
env: string,
|
|
118
|
+
componentName: string,
|
|
119
|
+
variableName: string
|
|
120
|
+
) => {
|
|
121
|
+
const rawVariableName = getSecretVarName(env, componentName, variableName);
|
|
122
|
+
return await getVariableValueByRawName(vorpal, rawVariableName);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const resolveSecrets = async (
|
|
126
|
+
vorpal: CommandInstance | null,
|
|
127
|
+
varSets: EnvironmentEnvVars[]
|
|
128
|
+
): Promise<Record<string, string>> => {
|
|
129
|
+
const allVariablesInGitlab = await getAllVariables(vorpal);
|
|
130
|
+
|
|
131
|
+
return Object.fromEntries(
|
|
132
|
+
varSets.flatMap((set) =>
|
|
133
|
+
Object.entries(set.envVars)
|
|
134
|
+
.map(([key, value]) => {
|
|
135
|
+
const secretKey = set.secretEnvVarKeys.find((k) => k.key === key);
|
|
136
|
+
|
|
137
|
+
if (secretKey) {
|
|
138
|
+
if (secretKey.hidden) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
for (const variable of allVariablesInGitlab) {
|
|
142
|
+
value = value.replace(
|
|
143
|
+
new RegExp("\\$" + variable.key, "g"),
|
|
144
|
+
variable.value
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
return [key, value];
|
|
148
|
+
}
|
|
149
|
+
return [key, value];
|
|
150
|
+
})
|
|
151
|
+
.filter(Boolean)
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const getEnvVarsResolved = async (
|
|
157
|
+
vorpal: CommandInstance | null,
|
|
158
|
+
env: string,
|
|
159
|
+
componentName: string | null
|
|
160
|
+
) => {
|
|
161
|
+
if (!componentName) {
|
|
162
|
+
return {};
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
const envionment = await getEnvironment(env, componentName);
|
|
166
|
+
|
|
167
|
+
// in the pipeline the secrets alreadyy exists and bash will expand them
|
|
168
|
+
// but here we need to manually load them
|
|
169
|
+
return resolveSecrets(vorpal, [
|
|
170
|
+
{
|
|
171
|
+
envVars: envionment.envVars,
|
|
172
|
+
secretEnvVarKeys: envionment.secretEnvVarKeys,
|
|
173
|
+
},
|
|
174
|
+
]);
|
|
175
|
+
} catch (e) {
|
|
176
|
+
// env is disabled
|
|
177
|
+
return {};
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
*
|
|
183
|
+
* is used to get job only vars that should also be editable locally with catladder.
|
|
184
|
+
*/
|
|
185
|
+
export const getJobOnlyEnvVarsResolved = async (
|
|
186
|
+
vorpal: CommandInstance,
|
|
187
|
+
env: string,
|
|
188
|
+
componentName: string
|
|
189
|
+
) => {
|
|
190
|
+
try {
|
|
191
|
+
const envionment = await getEnvironment(env, componentName);
|
|
192
|
+
return resolveSecrets(vorpal, [
|
|
193
|
+
envionment.jobOnlyVars.build,
|
|
194
|
+
envionment.jobOnlyVars.deploy,
|
|
195
|
+
]);
|
|
196
|
+
} catch (e) {
|
|
197
|
+
// env is disabled
|
|
198
|
+
return {};
|
|
199
|
+
}
|
|
200
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Gcloudregion } from "@catladder/pipeline";
|
|
2
|
+
import { exec } from "child-process-promise";
|
|
3
|
+
|
|
4
|
+
export const upsertGcloudArtifactsRegistry = async (config: {
|
|
5
|
+
projectId: string;
|
|
6
|
+
region: Gcloudregion;
|
|
7
|
+
}) => {
|
|
8
|
+
try {
|
|
9
|
+
await exec(
|
|
10
|
+
`gcloud artifacts repositories create catladder-deploy --project="${config.projectId}" --repository-format=docker --location=${config.region}`
|
|
11
|
+
);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
// probably already exists
|
|
14
|
+
//
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { DeployConfigCloudRun } from "@catladder/pipeline";
|
|
2
|
+
import { exec } from "child-process-promise";
|
|
3
|
+
|
|
4
|
+
const getSuffixFromService = (service: any) => {
|
|
5
|
+
const fullUrl = service.status.url;
|
|
6
|
+
const name = service.metadata.name;
|
|
7
|
+
|
|
8
|
+
return fullUrl.replace("https://" + name + "-", "");
|
|
9
|
+
};
|
|
10
|
+
export const getCloudRunDomainSuffix = async (config: DeployConfigCloudRun) => {
|
|
11
|
+
/* google cloud run domains are partially predictable, they have a fixed suffix that depends on the region and project, but we don't know it beforehand
|
|
12
|
+
|
|
13
|
+
So what we do is either:
|
|
14
|
+
- get one service and extract its suffix
|
|
15
|
+
- create a dummy project, extract the suffix and save that as a gitlab variable
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const dummyServiceName = "cl-dummy-service-delete-me";
|
|
21
|
+
|
|
22
|
+
const existingServices = await exec(
|
|
23
|
+
`gcloud run services list --format=json --project="${config.projectId}" --region=${config.region} --limit=1`
|
|
24
|
+
).then((r) => JSON.parse(r.stdout));
|
|
25
|
+
|
|
26
|
+
if (existingServices.length > 0) {
|
|
27
|
+
return getSuffixFromService(existingServices[0]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const result = await exec(
|
|
31
|
+
`gcloud run deploy ${dummyServiceName} --region=${config.region} --allow-unauthenticated --project ${config.projectId} --image=us-docker.pkg.dev/cloudrun/container/hello --format=json`
|
|
32
|
+
).then((r) => JSON.parse(r.stdout));
|
|
33
|
+
|
|
34
|
+
return await getSuffixFromService(result);
|
|
35
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Context } from "@catladder/pipeline";
|
|
2
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
|
+
import type { CommandInstance } from "vorpal";
|
|
4
|
+
import { openGoogleCloudDashboard } from "../openDashboard";
|
|
5
|
+
|
|
6
|
+
export const openGoogleCloudRunDashboard = async (
|
|
7
|
+
instance: CommandInstance,
|
|
8
|
+
context: Context
|
|
9
|
+
) => {
|
|
10
|
+
if (!isOfDeployType(context.componentConfig.deploy, "google-cloudrun")) {
|
|
11
|
+
throw new Error("deploy type is not google-cloudrun ");
|
|
12
|
+
}
|
|
13
|
+
const { fullName } = context.environment;
|
|
14
|
+
const { region, projectId } = context.componentConfig.deploy;
|
|
15
|
+
await openGoogleCloudDashboard(
|
|
16
|
+
instance,
|
|
17
|
+
`run/detail/${region}/${fullName}/metrics`,
|
|
18
|
+
{
|
|
19
|
+
project: projectId,
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
};
|