@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,74 @@
|
|
|
1
|
+
import { spawn } from "child-process-promise";
|
|
2
|
+
import commandExists from "command-exists-promise";
|
|
3
|
+
|
|
4
|
+
export const ERROR_NOT_INSTALLED = "cloud-sql-proxy not installed";
|
|
5
|
+
|
|
6
|
+
export type CloudSqlBackgroundProxy = {
|
|
7
|
+
stop: () => void;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type CloudSqlProxyOptions = {
|
|
11
|
+
instanceName: string;
|
|
12
|
+
localPort: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const getProxyCommandSpawnArgs = async ({
|
|
16
|
+
localPort,
|
|
17
|
+
instanceName,
|
|
18
|
+
}: CloudSqlProxyOptions) => {
|
|
19
|
+
const commandString = (await commandExists("cloud-sql-proxy"))
|
|
20
|
+
? `cloud-sql-proxy --port ${localPort} ${instanceName}`
|
|
21
|
+
: (await commandExists(
|
|
22
|
+
"cloud_sql_proxy" // v1
|
|
23
|
+
))
|
|
24
|
+
? `cloud_sql_proxy -instances ${instanceName}=tcp:${localPort}`
|
|
25
|
+
: null;
|
|
26
|
+
if (!commandString) {
|
|
27
|
+
throw new Error(ERROR_NOT_INSTALLED);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const [cmd, ...args] = commandString.split(" ");
|
|
31
|
+
return { cmd, args };
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const startCloudSqlProxyInCurrentShell = async (
|
|
35
|
+
opts: CloudSqlProxyOptions
|
|
36
|
+
) => {
|
|
37
|
+
const { cmd, args } = await getProxyCommandSpawnArgs(opts);
|
|
38
|
+
|
|
39
|
+
await spawn(cmd, args, {
|
|
40
|
+
stdio: "inherit",
|
|
41
|
+
shell: true,
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const startCloudSqlProxyInBackground = async (
|
|
46
|
+
opts: CloudSqlProxyOptions
|
|
47
|
+
): Promise<CloudSqlBackgroundProxy> => {
|
|
48
|
+
const { cmd, args } = await getProxyCommandSpawnArgs(opts);
|
|
49
|
+
|
|
50
|
+
const proxyPromise = spawn(cmd, args, { shell: "bash" });
|
|
51
|
+
|
|
52
|
+
// wait until it starts
|
|
53
|
+
await spawn(
|
|
54
|
+
`echo -n "Waiting for proxy"
|
|
55
|
+
until echo > /dev/tcp/localhost/${opts.localPort}; do
|
|
56
|
+
sleep 0.2
|
|
57
|
+
echo -n "."
|
|
58
|
+
done 2>/dev/null`,
|
|
59
|
+
[],
|
|
60
|
+
{ shell: "bash" }
|
|
61
|
+
);
|
|
62
|
+
const stop = () => {
|
|
63
|
+
proxyPromise.catch(() => {
|
|
64
|
+
// ignore
|
|
65
|
+
});
|
|
66
|
+
proxyPromise.childProcess.kill();
|
|
67
|
+
};
|
|
68
|
+
// stop if catladder i stopped
|
|
69
|
+
process.on("beforeExit", stop);
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
stop,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { exec } from "child-process-promise";
|
|
2
|
+
|
|
3
|
+
export const enableGCloudServices = async (
|
|
4
|
+
services: string[],
|
|
5
|
+
config: {
|
|
6
|
+
projectId: string;
|
|
7
|
+
}
|
|
8
|
+
) => {
|
|
9
|
+
for (const service of services) {
|
|
10
|
+
await exec(
|
|
11
|
+
`gcloud services enable ${service} --project=${config.projectId}`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CommandInstance } from "vorpal";
|
|
2
|
+
import { getGoogleAuthUserNumber } from "../apps/cli/utils/getGoogleAuthUserNumber";
|
|
3
|
+
import open from "open";
|
|
4
|
+
export const openGoogleCloudDashboard = async (
|
|
5
|
+
instance: CommandInstance,
|
|
6
|
+
path: string,
|
|
7
|
+
params: Record<string, string>
|
|
8
|
+
) => {
|
|
9
|
+
const url = new URL("https://console.cloud.google.com/");
|
|
10
|
+
url.pathname = path;
|
|
11
|
+
for (const [key, value] of Object.entries(params)) {
|
|
12
|
+
url.searchParams.set(key, value);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const googleAuthUserNumber = await getGoogleAuthUserNumber.call(instance);
|
|
16
|
+
url.searchParams.set("authuser", googleAuthUserNumber);
|
|
17
|
+
|
|
18
|
+
open(url.toString());
|
|
19
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Context } from "@catladder/pipeline";
|
|
2
|
+
|
|
3
|
+
import { exec } from "child-process-promise";
|
|
4
|
+
import { createHmac } from "crypto";
|
|
5
|
+
import type { CommandInstance } from "vorpal";
|
|
6
|
+
import { upsertAllVariables } from "../utils/gitlab";
|
|
7
|
+
|
|
8
|
+
export const accountExists = async (fullIdentifier: string) => {
|
|
9
|
+
try {
|
|
10
|
+
await exec(`gcloud iam service-accounts describe ${fullIdentifier}`);
|
|
11
|
+
return true;
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type ServiceAccount = {
|
|
18
|
+
projectId: string;
|
|
19
|
+
name: string;
|
|
20
|
+
displayName: string;
|
|
21
|
+
roles: string[];
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
const upsertGcloudServiceAccount = async (
|
|
25
|
+
context: Context,
|
|
26
|
+
account: ServiceAccount
|
|
27
|
+
): Promise<string> => {
|
|
28
|
+
const { projectId, name, displayName, roles, description } = account;
|
|
29
|
+
|
|
30
|
+
// name has limit of 30
|
|
31
|
+
const namePrefix = `${name}-`;
|
|
32
|
+
const nameSuffix = `-${context.environment.shortName}-${context.componentName}`;
|
|
33
|
+
const nameMiddleLength = 30 - namePrefix.length - nameSuffix.length;
|
|
34
|
+
const nameMiddle = `${context.fullConfig.customerName}-${context.fullConfig.appName}`;
|
|
35
|
+
|
|
36
|
+
const middle = hashIfNessecary(nameMiddle, nameMiddleLength);
|
|
37
|
+
|
|
38
|
+
const fullName = `${namePrefix}${middle}${nameSuffix}`;
|
|
39
|
+
|
|
40
|
+
const fullDisplayName = `${context.fullConfig.customerName}-${context.fullConfig.appName} ${context.environment.shortName}:${context.componentName} | ${displayName}`;
|
|
41
|
+
|
|
42
|
+
const fullIdentifier = `${fullName}@${projectId}.iam.gserviceaccount.com`;
|
|
43
|
+
|
|
44
|
+
const existing = await accountExists(fullIdentifier);
|
|
45
|
+
|
|
46
|
+
if (!existing) {
|
|
47
|
+
await exec(
|
|
48
|
+
`gcloud iam service-accounts create ${fullName} --display-name="${fullDisplayName}" --project="${projectId}" --description="${description}"`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
const memberName = `serviceAccount:${fullIdentifier}`;
|
|
52
|
+
for (const role of roles) {
|
|
53
|
+
await exec(
|
|
54
|
+
`gcloud projects add-iam-policy-binding ${projectId} --member=${memberName} --role=${role} `
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// create key
|
|
59
|
+
|
|
60
|
+
// delete first all keys
|
|
61
|
+
const keys = await exec(
|
|
62
|
+
`gcloud iam service-accounts keys list --iam-account=${fullIdentifier} --managed-by=user --format=json`
|
|
63
|
+
).then((o) => JSON.parse(o.stdout));
|
|
64
|
+
|
|
65
|
+
for (const key of keys) {
|
|
66
|
+
await exec(
|
|
67
|
+
`gcloud iam service-accounts keys delete ${key.name} --quiet --iam-account=${fullIdentifier}`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return await exec(
|
|
72
|
+
`gcloud iam service-accounts keys create /dev/stdout --iam-account=${fullIdentifier}`
|
|
73
|
+
).then((o) => o.stdout);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const upsertGcloudServiceAccountAndSaveSecret = async (
|
|
77
|
+
instance: CommandInstance,
|
|
78
|
+
context: Context,
|
|
79
|
+
account: ServiceAccount,
|
|
80
|
+
secretName: string
|
|
81
|
+
): Promise<void> => {
|
|
82
|
+
instance.log("upserting service account " + account.name + "...");
|
|
83
|
+
const key = await upsertGcloudServiceAccount(context, account);
|
|
84
|
+
|
|
85
|
+
await upsertAllVariables(
|
|
86
|
+
instance,
|
|
87
|
+
{
|
|
88
|
+
[secretName]: key,
|
|
89
|
+
},
|
|
90
|
+
context.environment.shortName,
|
|
91
|
+
context.componentName
|
|
92
|
+
);
|
|
93
|
+
instance.log("done!");
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const hashIfNessecary = (str: string, maxLength: number) =>
|
|
97
|
+
str.length > maxLength ? hash(str, maxLength) : str;
|
|
98
|
+
|
|
99
|
+
const hash = (str: string, length: number) => {
|
|
100
|
+
return createHmac("sha256", str).digest("hex").substring(0, length);
|
|
101
|
+
};
|
package/src/k8sApi/index.ts
CHANGED
|
@@ -5,13 +5,29 @@ import {
|
|
|
5
5
|
BatchV1beta1Api,
|
|
6
6
|
} from "@kubernetes/client-node";
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const getKubeConfig = () => {
|
|
9
|
+
const kc = new KubeConfig();
|
|
10
|
+
kc.loadFromDefault();
|
|
11
|
+
return kc;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* get kubernetes client. avoid reusing the instance when context get changed
|
|
15
|
+
* @returns kuberenetes client
|
|
16
|
+
*/
|
|
17
|
+
export const getk8sApi = () => {
|
|
18
|
+
const kc = getKubeConfig();
|
|
9
19
|
|
|
10
|
-
kc.
|
|
20
|
+
return kc.makeApiClient(CoreV1Api);
|
|
21
|
+
};
|
|
11
22
|
|
|
12
|
-
const
|
|
23
|
+
export const getk8sApiBatch = () => {
|
|
24
|
+
const kc = getKubeConfig();
|
|
13
25
|
|
|
14
|
-
|
|
15
|
-
|
|
26
|
+
return kc.makeApiClient(BatchV1Api);
|
|
27
|
+
};
|
|
16
28
|
|
|
17
|
-
export
|
|
29
|
+
export const getk8sApiBatchBeta = () => {
|
|
30
|
+
const kc = getKubeConfig();
|
|
31
|
+
|
|
32
|
+
return kc.makeApiClient(BatchV1beta1Api);
|
|
33
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { parseChoice } from "../config/parseChoice";
|
|
2
|
+
import { getk8sApi } from "../k8sApi";
|
|
3
|
+
import { getProjectNamespace } from "../utils/projects";
|
|
4
|
+
|
|
5
|
+
export const getProjectPods = async (envComponent: string) => {
|
|
6
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
7
|
+
const k8sApi = getk8sApi();
|
|
8
|
+
const res = await k8sApi.listNamespacedPod(namespace);
|
|
9
|
+
|
|
10
|
+
const { componentName } = parseChoice(envComponent);
|
|
11
|
+
return res.body.items.filter((item) =>
|
|
12
|
+
componentName ? item.metadata?.name?.includes(componentName + "-") : true
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const getProjectPvcs = async (envComponent: string) => {
|
|
17
|
+
const namespace = await getProjectNamespace(envComponent);
|
|
18
|
+
const k8sApi = getk8sApi();
|
|
19
|
+
const res = await k8sApi.listNamespacedPersistentVolumeClaim(namespace);
|
|
20
|
+
|
|
21
|
+
return res.body.items;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const getProjectPodNames = async (envComponent: string) => {
|
|
25
|
+
const pods = await getProjectPods(envComponent);
|
|
26
|
+
return pods.map((n) => n.metadata.name);
|
|
27
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Context } from "@catladder/pipeline";
|
|
2
|
+
import { isOfDeployType } from "@catladder/pipeline";
|
|
3
|
+
import type { CommandInstance } from "vorpal";
|
|
4
|
+
import { openGoogleCloudDashboard } from "../gcloud/openDashboard";
|
|
5
|
+
|
|
6
|
+
export const openGoogleCloudLogs = async (
|
|
7
|
+
instance: CommandInstance,
|
|
8
|
+
context: Context
|
|
9
|
+
) => {
|
|
10
|
+
const deployConfig = context.componentConfig.deploy;
|
|
11
|
+
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
12
|
+
throw new Error("context is not of type kubernetes");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!deployConfig.cluster || deployConfig.cluster.type !== "gcloud") {
|
|
16
|
+
throw new Error("no gcloud custer configured");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const namespace = context.environment.envVars.KUBE_NAMESPACE;
|
|
20
|
+
const cluster = deployConfig.cluster;
|
|
21
|
+
|
|
22
|
+
const resource = `k8s_container/cluster_name/${cluster.name}${
|
|
23
|
+
namespace ? `/namespace_name/${namespace}` : ""
|
|
24
|
+
}`;
|
|
25
|
+
|
|
26
|
+
await openGoogleCloudDashboard(instance, "logs/viewer", {
|
|
27
|
+
project: cluster.projectId,
|
|
28
|
+
resource: resource,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const openGoogleCloudKubernetesDashboard = async (
|
|
33
|
+
instance: CommandInstance,
|
|
34
|
+
context: Context
|
|
35
|
+
) => {
|
|
36
|
+
const deployConfig = context.componentConfig.deploy;
|
|
37
|
+
if (!isOfDeployType(deployConfig, "kubernetes")) {
|
|
38
|
+
throw new Error("context is not of type kubernetes");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!deployConfig.cluster || deployConfig.cluster.type !== "gcloud") {
|
|
42
|
+
throw new Error("no gcloud custer configured");
|
|
43
|
+
}
|
|
44
|
+
const namespace = context.environment.envVars.KUBE_NAMESPACE;
|
|
45
|
+
const cluster = deployConfig.cluster;
|
|
46
|
+
const pageState = `("savedViews":("c":["gke/${cluster.region}/${cluster.name}"],"n":["${namespace}"],"i":"4e42e0b9cd6147f8a4fba7516752ec48"))`;
|
|
47
|
+
|
|
48
|
+
await openGoogleCloudDashboard(instance, "kubernetes/workload", {
|
|
49
|
+
project: cluster.projectId,
|
|
50
|
+
pageState: pageState,
|
|
51
|
+
});
|
|
52
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { startPortForwardCommand } from "../utils/portForwards";
|
|
2
|
+
|
|
3
|
+
export const startKubePortForward = async (
|
|
4
|
+
podname: string,
|
|
5
|
+
localPort: number,
|
|
6
|
+
remotePort: number,
|
|
7
|
+
namespace: string
|
|
8
|
+
) => {
|
|
9
|
+
const name = `kube/${namespace}/${podname}/${localPort}:${remotePort}`;
|
|
10
|
+
|
|
11
|
+
await startPortForwardCommand(
|
|
12
|
+
name,
|
|
13
|
+
`kubectl port-forward ${podname} ${localPort}:${remotePort} -n ${namespace}`
|
|
14
|
+
);
|
|
15
|
+
};
|
|
@@ -1 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ReadStream } from "fs-extra";
|
|
2
|
+
|
|
3
|
+
declare module "child-process-promise" {
|
|
4
|
+
function exec(
|
|
5
|
+
cmd: string,
|
|
6
|
+
options?: {
|
|
7
|
+
env?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
): Promise<{
|
|
10
|
+
stdout: string;
|
|
11
|
+
}>;
|
|
12
|
+
|
|
13
|
+
type Stdio = "inherit" | "pipe";
|
|
14
|
+
type SpawnOptions = {
|
|
15
|
+
stdio?: Stdio | Stdio[];
|
|
16
|
+
shell?: boolean | string;
|
|
17
|
+
env?: Record<string, string>;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function spawn(
|
|
21
|
+
cmd: string,
|
|
22
|
+
options?: SpawnOptions
|
|
23
|
+
): Promise<{
|
|
24
|
+
stdout: string;
|
|
25
|
+
}>;
|
|
26
|
+
|
|
27
|
+
function spawn(
|
|
28
|
+
cmd: string,
|
|
29
|
+
args: string[],
|
|
30
|
+
options?: SpawnOptions
|
|
31
|
+
): Promise<unknown> & {
|
|
32
|
+
childProcess: {
|
|
33
|
+
stdout: ReadStream;
|
|
34
|
+
kill: () => void;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
package/src/types/types.ts
CHANGED
package/src/utils/cluster.ts
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
1
|
import { exec } from "child-process-promise";
|
|
2
|
-
|
|
3
|
-
import clusters from "../config/clusters";
|
|
2
|
+
|
|
4
3
|
export const getCurrentContext = async () =>
|
|
5
|
-
(await exec(
|
|
4
|
+
(await exec(`kubectl config current-context`)).stdout.trim();
|
|
6
5
|
|
|
7
6
|
export const getCurrentConnectedClusterName = async () => {
|
|
8
|
-
|
|
9
|
-
return findKey(clusters, { fullName: currentContext });
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export const getClusterByName = (name: string) => {
|
|
13
|
-
return clusters[name];
|
|
7
|
+
return await getCurrentContext();
|
|
14
8
|
};
|
|
15
9
|
|
|
16
|
-
export const
|
|
17
|
-
|
|
18
|
-
export const connectToCluster = async (clusterName: string) => {
|
|
19
|
-
const { connect } = getClusterByName(clusterName);
|
|
20
|
-
await connect();
|
|
10
|
+
export const connectToCluster = async (fullname: string) => {
|
|
11
|
+
await exec(`kubectl config use-context ${fullname}`);
|
|
21
12
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { withFile } from "tmp-promise";
|
|
2
|
+
import { dump, load } from "js-yaml";
|
|
3
|
+
|
|
4
|
+
import { readFile, writeFile } from "fs-extra";
|
|
5
|
+
import getEditor from "./getEditor";
|
|
6
|
+
|
|
7
|
+
export const editAsFile = async <T>(
|
|
8
|
+
inObject: T,
|
|
9
|
+
preamble?: string
|
|
10
|
+
): Promise<T> => {
|
|
11
|
+
const fullPreamble = preamble
|
|
12
|
+
? `#
|
|
13
|
+
# ${preamble.split("\n").join("\n# ")}
|
|
14
|
+
#
|
|
15
|
+
|
|
16
|
+
`
|
|
17
|
+
: "\n";
|
|
18
|
+
const asString = fullPreamble + dump(inObject, { noRefs: true });
|
|
19
|
+
let newContent: T;
|
|
20
|
+
|
|
21
|
+
await withFile(
|
|
22
|
+
async ({ path: tmpFilePath }) => {
|
|
23
|
+
await writeFile(tmpFilePath, asString);
|
|
24
|
+
await (await getEditor()).open(tmpFilePath);
|
|
25
|
+
newContent = load((await readFile(tmpFilePath)).toString("utf-8")) as T;
|
|
26
|
+
},
|
|
27
|
+
{ postfix: ".yml" }
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return newContent;
|
|
31
|
+
};
|
package/src/utils/files.ts
CHANGED
|
@@ -13,6 +13,10 @@ export const readFileOrError = async (filePath: string) => {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
export const readYaml = async (filename: string) => {
|
|
17
|
-
|
|
16
|
+
export const readYaml = async <T = Record<string, any>>(filename: string) => {
|
|
17
|
+
try {
|
|
18
|
+
return yaml.load(await readFile(filename)) as T;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
18
22
|
};
|