@vaharoni/devops 1.0.47
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/README.md +51 -0
- package/dist/app-support/crypto/index.d.ts +15 -0
- package/dist/app-support/crypto/index.d.ts.map +1 -0
- package/dist/app-support/crypto/index.js +30 -0
- package/dist/app-support/crypto/internal-token.d.ts +20 -0
- package/dist/app-support/crypto/internal-token.d.ts.map +1 -0
- package/dist/app-support/crypto/internal-token.js +42 -0
- package/dist/app-support/crypto/internal-token.spec.d.ts +2 -0
- package/dist/app-support/crypto/internal-token.spec.d.ts.map +1 -0
- package/dist/app-support/crypto/internal-token.spec.js +45 -0
- package/dist/app-support/crypto/secret.d.ts +3 -0
- package/dist/app-support/crypto/secret.d.ts.map +1 -0
- package/dist/app-support/crypto/secret.js +12 -0
- package/dist/app-support/crypto/secret.spec.d.ts +2 -0
- package/dist/app-support/crypto/secret.spec.d.ts.map +1 -0
- package/dist/app-support/crypto/secret.spec.js +15 -0
- package/dist/app-support/discovery/dev-discovery-loader.d.ts +2 -0
- package/dist/app-support/discovery/dev-discovery-loader.d.ts.map +1 -0
- package/dist/app-support/discovery/dev-discovery-loader.js +30 -0
- package/dist/app-support/discovery/service-endpoint.d.ts +2 -0
- package/dist/app-support/discovery/service-endpoint.d.ts.map +1 -0
- package/dist/app-support/discovery/service-endpoint.js +10 -0
- package/dist/cli/affected.d.ts +11 -0
- package/dist/cli/affected.d.ts.map +1 -0
- package/dist/cli/affected.js +103 -0
- package/dist/cli/common.d.ts +89 -0
- package/dist/cli/common.d.ts.map +1 -0
- package/dist/cli/common.js +236 -0
- package/dist/cli/common.spec.d.ts +2 -0
- package/dist/cli/common.spec.d.ts.map +1 -0
- package/dist/cli/common.spec.js +64 -0
- package/dist/cli/console.d.ts +11 -0
- package/dist/cli/console.d.ts.map +1 -0
- package/dist/cli/console.js +35 -0
- package/dist/cli/constant.d.ts +11 -0
- package/dist/cli/constant.d.ts.map +1 -0
- package/dist/cli/constant.js +22 -0
- package/dist/cli/db.d.ts +11 -0
- package/dist/cli/db.d.ts.map +1 -0
- package/dist/cli/db.js +119 -0
- package/dist/cli/dml.d.ts +11 -0
- package/dist/cli/dml.d.ts.map +1 -0
- package/dist/cli/dml.js +116 -0
- package/dist/cli/env.d.ts +11 -0
- package/dist/cli/env.d.ts.map +1 -0
- package/dist/cli/env.js +67 -0
- package/dist/cli/exec.d.ts +11 -0
- package/dist/cli/exec.d.ts.map +1 -0
- package/dist/cli/exec.js +50 -0
- package/dist/cli/image.d.ts +11 -0
- package/dist/cli/image.d.ts.map +1 -0
- package/dist/cli/image.js +140 -0
- package/dist/cli/init.d.ts +11 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +66 -0
- package/dist/cli/internal-curl.d.ts +11 -0
- package/dist/cli/internal-curl.d.ts.map +1 -0
- package/dist/cli/internal-curl.js +43 -0
- package/dist/cli/job.d.ts +11 -0
- package/dist/cli/job.d.ts.map +1 -0
- package/dist/cli/job.js +67 -0
- package/dist/cli/jwt.d.ts +11 -0
- package/dist/cli/jwt.d.ts.map +1 -0
- package/dist/cli/jwt.js +27 -0
- package/dist/cli/namespace.d.ts +11 -0
- package/dist/cli/namespace.d.ts.map +1 -0
- package/dist/cli/namespace.js +70 -0
- package/dist/cli/prep-build.d.ts +11 -0
- package/dist/cli/prep-build.d.ts.map +1 -0
- package/dist/cli/prep-build.js +82 -0
- package/dist/cli/prisma.d.ts +11 -0
- package/dist/cli/prisma.d.ts.map +1 -0
- package/dist/cli/prisma.js +25 -0
- package/dist/cli/redis.d.ts +11 -0
- package/dist/cli/redis.d.ts.map +1 -0
- package/dist/cli/redis.js +76 -0
- package/dist/cli/registry.d.ts +11 -0
- package/dist/cli/registry.d.ts.map +1 -0
- package/dist/cli/registry.js +58 -0
- package/dist/cli/run-many.d.ts +11 -0
- package/dist/cli/run-many.d.ts.map +1 -0
- package/dist/cli/run-many.js +50 -0
- package/dist/cli/run.d.ts +11 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +37 -0
- package/dist/cli/template.d.ts +11 -0
- package/dist/cli/template.d.ts.map +1 -0
- package/dist/cli/template.js +123 -0
- package/dist/cli/test.d.ts +11 -0
- package/dist/cli/test.d.ts.map +1 -0
- package/dist/cli/test.js +28 -0
- package/dist/devops.d.ts +3 -0
- package/dist/devops.d.ts.map +1 -0
- package/dist/devops.js +103 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/libs/affected-entities.d.ts +15 -0
- package/dist/libs/affected-entities.d.ts.map +1 -0
- package/dist/libs/affected-entities.js +52 -0
- package/dist/libs/config.d.ts +6 -0
- package/dist/libs/config.d.ts.map +1 -0
- package/dist/libs/config.js +98 -0
- package/dist/libs/dependencies.d.ts +19 -0
- package/dist/libs/dependencies.d.ts.map +1 -0
- package/dist/libs/dependencies.js +62 -0
- package/dist/libs/dependencies.spec.d.ts +2 -0
- package/dist/libs/dependencies.spec.d.ts.map +1 -0
- package/dist/libs/dependencies.spec.js +21 -0
- package/dist/libs/digital-ocean/container-reg.d.ts +6 -0
- package/dist/libs/digital-ocean/container-reg.d.ts.map +1 -0
- package/dist/libs/digital-ocean/container-reg.js +69 -0
- package/dist/libs/discovery/dependencies.d.ts +19 -0
- package/dist/libs/discovery/dependencies.d.ts.map +1 -0
- package/dist/libs/discovery/dependencies.js +62 -0
- package/dist/libs/discovery/dependencies.spec.d.ts +2 -0
- package/dist/libs/discovery/dependencies.spec.d.ts.map +1 -0
- package/dist/libs/discovery/dependencies.spec.js +21 -0
- package/dist/libs/discovery/images.d.ts +5 -0
- package/dist/libs/discovery/images.d.ts.map +1 -0
- package/dist/libs/discovery/images.js +45 -0
- package/dist/libs/discovery/index.d.ts +5 -0
- package/dist/libs/discovery/index.d.ts.map +1 -0
- package/dist/libs/discovery/index.js +55 -0
- package/dist/libs/discovery/package-json-processor.d.ts +3 -0
- package/dist/libs/discovery/package-json-processor.d.ts.map +1 -0
- package/dist/libs/discovery/package-json-processor.js +34 -0
- package/dist/libs/discovery/process-common.d.ts +25 -0
- package/dist/libs/discovery/process-common.d.ts.map +1 -0
- package/dist/libs/discovery/process-common.js +40 -0
- package/dist/libs/discovery/process-package-json.d.ts +3 -0
- package/dist/libs/discovery/process-package-json.d.ts.map +1 -0
- package/dist/libs/discovery/process-package-json.js +34 -0
- package/dist/libs/discovery/process-pyproject-toml.d.ts +3 -0
- package/dist/libs/discovery/process-pyproject-toml.d.ts.map +1 -0
- package/dist/libs/discovery/process-pyproject-toml.js +36 -0
- package/dist/libs/discovery/pyproject-toml-processor.d.ts +3 -0
- package/dist/libs/discovery/pyproject-toml-processor.d.ts.map +1 -0
- package/dist/libs/discovery/pyproject-toml-processor.js +39 -0
- package/dist/libs/git-helpers.d.ts +8 -0
- package/dist/libs/git-helpers.d.ts.map +1 -0
- package/dist/libs/git-helpers.js +20 -0
- package/dist/libs/hetzner/reg-secret.d.ts +3 -0
- package/dist/libs/hetzner/reg-secret.d.ts.map +1 -0
- package/dist/libs/hetzner/reg-secret.js +39 -0
- package/dist/libs/k8s-constants.d.ts +12 -0
- package/dist/libs/k8s-constants.d.ts.map +1 -0
- package/dist/libs/k8s-constants.js +66 -0
- package/dist/libs/k8s-db.d.ts +18 -0
- package/dist/libs/k8s-db.d.ts.map +1 -0
- package/dist/libs/k8s-db.js +73 -0
- package/dist/libs/k8s-generate.d.ts +17 -0
- package/dist/libs/k8s-generate.d.ts.map +1 -0
- package/dist/libs/k8s-generate.js +179 -0
- package/dist/libs/k8s-helpers.d.ts +11 -0
- package/dist/libs/k8s-helpers.d.ts.map +1 -0
- package/dist/libs/k8s-helpers.js +42 -0
- package/dist/libs/k8s-image-config.d.ts +8 -0
- package/dist/libs/k8s-image-config.d.ts.map +1 -0
- package/dist/libs/k8s-image-config.js +113 -0
- package/dist/libs/k8s-job-waiter.d.ts +8 -0
- package/dist/libs/k8s-job-waiter.d.ts.map +1 -0
- package/dist/libs/k8s-job-waiter.js +84 -0
- package/dist/libs/k8s-namespace.d.ts +7 -0
- package/dist/libs/k8s-namespace.d.ts.map +1 -0
- package/dist/libs/k8s-namespace.js +27 -0
- package/dist/libs/k8s-redis.d.ts +6 -0
- package/dist/libs/k8s-redis.d.ts.map +1 -0
- package/dist/libs/k8s-redis.js +31 -0
- package/dist/libs/k8s-secrets-manager.d.ts +5 -0
- package/dist/libs/k8s-secrets-manager.d.ts.map +1 -0
- package/dist/libs/k8s-secrets-manager.js +61 -0
- package/dist/libs/validate-env.d.ts +56 -0
- package/dist/libs/validate-env.d.ts.map +1 -0
- package/dist/libs/validate-env.js +214 -0
- package/dist/libs/validate-env.spec.d.ts +2 -0
- package/dist/libs/validate-env.spec.d.ts.map +1 -0
- package/dist/libs/validate-env.spec.js +168 -0
- package/dist/libs/workspace-discovery.d.ts +2 -0
- package/dist/libs/workspace-discovery.d.ts.map +1 -0
- package/dist/libs/workspace-discovery.js +75 -0
- package/dist/test.d.ts +2 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +1 -0
- package/dist/types/index.d.ts +925 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +79 -0
- package/package.json +55 -0
- package/src/app-support/crypto/index.ts +31 -0
- package/src/app-support/crypto/internal-token.spec.ts +53 -0
- package/src/app-support/crypto/internal-token.ts +82 -0
- package/src/app-support/crypto/secret.spec.ts +18 -0
- package/src/app-support/crypto/secret.ts +13 -0
- package/src/app-support/discovery/dev-discovery-loader.ts +35 -0
- package/src/app-support/discovery/service-endpoint.ts +12 -0
- package/src/cli/affected.ts +116 -0
- package/src/cli/common.spec.ts +78 -0
- package/src/cli/common.ts +323 -0
- package/src/cli/console.ts +46 -0
- package/src/cli/constant.ts +25 -0
- package/src/cli/db.ts +133 -0
- package/src/cli/dml.ts +126 -0
- package/src/cli/env.ts +87 -0
- package/src/cli/exec.sh +21 -0
- package/src/cli/exec.ts +57 -0
- package/src/cli/image.ts +197 -0
- package/src/cli/init.ts +75 -0
- package/src/cli/internal-curl.ts +48 -0
- package/src/cli/job.ts +80 -0
- package/src/cli/jwt.ts +32 -0
- package/src/cli/namespace.ts +78 -0
- package/src/cli/prep-build.ts +96 -0
- package/src/cli/prisma.ts +33 -0
- package/src/cli/redis.ts +83 -0
- package/src/cli/registry.ts +76 -0
- package/src/cli/run-many.ts +61 -0
- package/src/cli/run.ts +46 -0
- package/src/cli/template.ts +169 -0
- package/src/cli/test.ts +30 -0
- package/src/devops.ts +119 -0
- package/src/index.ts +3 -0
- package/src/libs/affected-entities.ts +71 -0
- package/src/libs/config.ts +117 -0
- package/src/libs/digital-ocean/container-reg.ts +81 -0
- package/src/libs/discovery/dependencies.spec.ts +25 -0
- package/src/libs/discovery/dependencies.ts +73 -0
- package/src/libs/discovery/images.ts +57 -0
- package/src/libs/discovery/index.ts +60 -0
- package/src/libs/discovery/process-common.ts +55 -0
- package/src/libs/discovery/process-package-json.ts +47 -0
- package/src/libs/discovery/process-pyproject-toml.ts +43 -0
- package/src/libs/git-helpers.ts +32 -0
- package/src/libs/hetzner/reg-secret.ts +54 -0
- package/src/libs/k8s-constants.ts +83 -0
- package/src/libs/k8s-db.ts +83 -0
- package/src/libs/k8s-generate.ts +211 -0
- package/src/libs/k8s-helpers.ts +59 -0
- package/src/libs/k8s-image-config.ts +165 -0
- package/src/libs/k8s-job-waiter.ts +124 -0
- package/src/libs/k8s-namespace.ts +41 -0
- package/src/libs/k8s-redis.ts +31 -0
- package/src/libs/k8s-secrets-manager.ts +79 -0
- package/src/libs/validate-env.spec.ts +223 -0
- package/src/libs/validate-env.ts +266 -0
- package/src/target-templates/.devops/config/constants.yaml +17 -0
- package/src/target-templates/.devops/config/images.yaml +88 -0
- package/src/target-templates/.devops/docker-images/common/docker-common.sh +23 -0
- package/src/target-templates/.devops/docker-images/node-services/node-exec.sh +8 -0
- package/src/target-templates/.devops/docker-images/node-services/node-run.sh +8 -0
- package/src/target-templates/.devops/docker-images/node-services.Dockerfile +34 -0
- package/src/target-templates/.devops/docker-images/python-services/python-exec.sh +8 -0
- package/src/target-templates/.devops/docker-images/python-services/python-run.sh +8 -0
- package/src/target-templates/.devops/docker-images/python-services.Dockerfile +29 -0
- package/src/target-templates/.devops/env.example.yaml +23 -0
- package/src/target-templates/.devops/infra/hetzner/abandoned/harbor-values.yaml +30 -0
- package/src/target-templates/.devops/infra/hetzner/abandoned/hcloud-config.yaml +134 -0
- package/src/target-templates/.devops/infra/hetzner/cert-manager.yaml +25 -0
- package/src/target-templates/.devops/infra/hetzner/harbor-cert.yaml +13 -0
- package/src/target-templates/.devops/infra/hetzner/harbor-values.yaml +76 -0
- package/src/target-templates/.devops/infra/hetzner/hcloud-config.yaml +113 -0
- package/src/target-templates/.devops/infra/hetzner/ingress-nginx-annotations.yaml +49 -0
- package/src/target-templates/.devops/infra/hetzner/ingress-nginx-configmap.yaml +8 -0
- package/src/target-templates/.devops/infra/hetzner/retain-storage-class.yaml +8 -0
- package/src/target-templates/.devops/infra/monitoring-ingress.yaml +62 -0
- package/src/target-templates/.devops/infra/stackgres-ui-ingress.yaml +35 -0
- package/src/target-templates/.devops/infra/test.yaml +60 -0
- package/src/target-templates/.devops/manifests/_index.yaml +21 -0
- package/src/target-templates/.devops/manifests/cron-jobs.yaml.hb +55 -0
- package/src/target-templates/.devops/manifests/db-migrate-job.yaml.hb +42 -0
- package/src/target-templates/.devops/manifests/deployment-debug.yaml.hb +44 -0
- package/src/target-templates/.devops/manifests/deployment-process.yaml.hb +47 -0
- package/src/target-templates/.devops/manifests/deployment-web.yaml.hb +53 -0
- package/src/target-templates/.devops/manifests/ingress.yaml.hb +21 -0
- package/src/target-templates/.devops/manifests/prefect.yaml.hb +62 -0
- package/src/target-templates/.devops/manifests/service.yaml.hb +15 -0
- package/src/target-templates/.devops/milvus/production/milvus-values.yaml +2 -0
- package/src/target-templates/.devops/milvus/staging/milvus-values.yaml +2 -0
- package/src/target-templates/.devops/postgres/DailyOperatorRestart.yaml +54 -0
- package/src/target-templates/.devops/postgres/production/cluster/PodDisruptionBudget.yaml +27 -0
- package/src/target-templates/.devops/postgres/production/cluster/SGCluster.yaml +47 -0
- package/src/target-templates/.devops/postgres/production/cluster/StackGres-alerts.yaml +191 -0
- package/src/target-templates/.devops/postgres/production/configurations/06-SGDistributedLogs.yaml +11 -0
- package/src/target-templates/.devops/postgres/production/configurations/07-SGObjectStorage.yaml +18 -0
- package/src/target-templates/.devops/postgres/production/configurations/08-SGScript.yaml +12 -0
- package/src/target-templates/.devops/postgres/staging/cluster/SGCluster.yaml +42 -0
- package/src/target-templates/.devops/postgres/staging/configurations/07-SGObjectStorage.yaml +18 -0
- package/src/target-templates/.devops/postgres/staging/configurations/08-SGScript.yaml +12 -0
- package/src/target-templates/.devops/prefect/production/prefect-values.yaml +14 -0
- package/src/target-templates/.devops/prefect/staging/prefect-values.yaml +14 -0
- package/src/target-templates/.devops/redis/production/redis-values.yaml +20 -0
- package/src/target-templates/.devops/redis/staging/redis-values.yaml +8 -0
- package/src/target-templates/.envrc +5 -0
- package/src/target-templates/.github/actions/build-image@v1/action.yaml +86 -0
- package/src/target-templates/.github/actions/connect-to-digital-ocean@v1/action.yaml +29 -0
- package/src/target-templates/.github/actions/connect-to-hetzner@v1/action.yaml +31 -0
- package/src/target-templates/.github/actions/connect-to-infra@v1/action.yaml +46 -0
- package/src/target-templates/.github/actions/db-migrate@v1/action.yaml +23 -0
- package/src/target-templates/.github/actions/deploy-image@v1/action.yaml +33 -0
- package/src/target-templates/.github/actions/setup-prereq@v1/action.yaml +29 -0
- package/src/target-templates/.github/workflows/k8s-build.yaml +84 -0
- package/src/target-templates/applications/example-data-pipeline/pyproject.toml +14 -0
- package/src/target-templates/applications/example-data-pipeline/src/example_data_pipeline/main.py +38 -0
- package/src/target-templates/applications/example-node/index.ts +30 -0
- package/src/target-templates/applications/example-node/package.json +26 -0
- package/src/target-templates/applications/example-node/tsconfig.json +3 -0
- package/src/target-templates/applications/example-python/pyproject.toml +20 -0
- package/src/target-templates/applications/example-python/src/example_python/__init__.py +0 -0
- package/src/target-templates/applications/example-python/src/example_python/main.py +13 -0
- package/src/target-templates/applications/example-python/src/example_python/scripts.py +17 -0
- package/src/target-templates/applications/example-python/tests/__init__.py +0 -0
- package/src/target-templates/applications/jobs/README.md +68 -0
- package/src/target-templates/applications/jobs/index.ts +1 -0
- package/src/target-templates/applications/jobs/package.json +30 -0
- package/src/target-templates/applications/jobs/tsconfig.json +3 -0
- package/src/target-templates/config/.env.development +1 -0
- package/src/target-templates/config/.env.global +4 -0
- package/src/target-templates/config/.env.test +1 -0
- package/src/target-templates/db/db/__init__.py +0 -0
- package/src/target-templates/db/db/db_client_test.py +46 -0
- package/src/target-templates/db/db-client-test.ts +140 -0
- package/src/target-templates/db/db-client.ts +19 -0
- package/src/target-templates/db/env.yaml +4 -0
- package/src/target-templates/db/package.json +17 -0
- package/src/target-templates/db/prisma/schema.prisma +24 -0
- package/src/target-templates/db/prisma-setup-vitest.ts +27 -0
- package/src/target-templates/db/pyproject.toml +14 -0
- package/src/target-templates/db/tsconfig.json +3 -0
- package/src/target-templates/devops +3 -0
- package/src/target-templates/devopspy +3 -0
- package/src/target-templates/dml/package.json +7 -0
- package/src/target-templates/dml/tsconfig.json +3 -0
- package/src/target-templates/libs/example-node-lib/bun.lock +27 -0
- package/src/target-templates/libs/example-node-lib/index.ts +3 -0
- package/src/target-templates/libs/example-node-lib/package.json +12 -0
- package/src/target-templates/libs/example-node-lib/tsconfig.json +3 -0
- package/src/target-templates/libs/example-python-lib/pyproject.toml +11 -0
- package/src/target-templates/libs/example-python-lib/src/example_python_lib/__init__.py +2 -0
- package/src/target-templates/pyproject.toml +19 -0
- package/src/target-templates/tmp/.gitkeep +0 -0
- package/src/target-templates/tsconfig.json +27 -0
- package/src/test.ts +0 -0
- package/src/types/index.ts +173 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
import { getWorkspace, workspaceDirectoryForLanguage } from ".";
|
2
|
+
import { getImageData, getImageNames } from "../config";
|
3
|
+
import { WorkspaceDependencies } from "./dependencies";
|
4
|
+
// = From images to workspaces
|
5
|
+
const _imageDescendents = {};
|
6
|
+
let _imageDescendentsLoaded = false;
|
7
|
+
function imageDescendents() {
|
8
|
+
if (!_imageDescendentsLoaded) {
|
9
|
+
for (const imageName of getImageNames()) {
|
10
|
+
const descendents = new Set();
|
11
|
+
const imageData = getImageData(imageName);
|
12
|
+
const workspaces = workspaceDirectoryForLanguage(imageData.language);
|
13
|
+
const dependencyResolver = new WorkspaceDependencies(() => workspaces);
|
14
|
+
imageData.applications.forEach((workspace) => {
|
15
|
+
dependencyResolver.getDependents(workspace).forEach((name) => descendents.add(name));
|
16
|
+
});
|
17
|
+
_imageDescendents[imageName] = Array.from(descendents).map(name => workspaces[name]);
|
18
|
+
}
|
19
|
+
_imageDescendentsLoaded = true;
|
20
|
+
}
|
21
|
+
return _imageDescendents;
|
22
|
+
}
|
23
|
+
/** The dependent workspaces are specified in config/images.yaml */
|
24
|
+
export function getImageDescendentData(imageName) {
|
25
|
+
return (imageDescendents()[imageName] ?? []);
|
26
|
+
}
|
27
|
+
// = From workspace to images
|
28
|
+
const _workspaceImages = {};
|
29
|
+
let _workspaceImagesLoaded = false;
|
30
|
+
function workspaceImages() {
|
31
|
+
if (!_workspaceImagesLoaded) {
|
32
|
+
for (const [imageName, descendents] of Object.entries(imageDescendents())) {
|
33
|
+
for (const packageData of descendents) {
|
34
|
+
_workspaceImages[packageData.name] ??= [];
|
35
|
+
_workspaceImages[packageData.name].push(imageName);
|
36
|
+
}
|
37
|
+
}
|
38
|
+
_workspaceImagesLoaded = true;
|
39
|
+
}
|
40
|
+
return _workspaceImages;
|
41
|
+
}
|
42
|
+
export function getWorkspaceImages(workspaceName) {
|
43
|
+
const _verifyPresence = getWorkspace(workspaceName);
|
44
|
+
return workspaceImages()[workspaceName] ?? [];
|
45
|
+
}
|
@@ -0,0 +1,5 @@
|
|
1
|
+
import type { SupportedLanguages, WorkspaceIndex } from "../../types";
|
2
|
+
export declare function workspaces(): WorkspaceIndex;
|
3
|
+
export declare function workspaceDirectoryForLanguage(language: SupportedLanguages): Record<string, import("../..").PackageData>;
|
4
|
+
export declare function getWorkspace(workspaceName: string): import("../..").WorkspaceIndexEntry;
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKtE,wBAAgB,UAAU,mBA8BzB;AAED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,kBAAkB,+CASzE;AAED,wBAAgB,YAAY,CAAC,aAAa,EAAE,MAAM,uCAQjD"}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import chalk from "chalk";
|
2
|
+
import { nodeWorkspaces } from "./process-package-json";
|
3
|
+
import { pythonWorkspaces } from "./process-pyproject-toml";
|
4
|
+
const _workspaces = {};
|
5
|
+
let _workspacesLoaded = false;
|
6
|
+
export function workspaces() {
|
7
|
+
if (_workspacesLoaded)
|
8
|
+
return _workspaces;
|
9
|
+
const nodeWorkspacesData = nodeWorkspaces();
|
10
|
+
const pythonWorkspacesData = pythonWorkspaces();
|
11
|
+
Object.values(nodeWorkspacesData).forEach(data => {
|
12
|
+
_workspaces[data.name] = {
|
13
|
+
rootPath: data.rootPath,
|
14
|
+
packageDataEntries: [data]
|
15
|
+
};
|
16
|
+
});
|
17
|
+
Object.values(pythonWorkspacesData).forEach(data => {
|
18
|
+
const existing = _workspaces[data.name];
|
19
|
+
if (existing) {
|
20
|
+
if (existing.rootPath !== data.rootPath) {
|
21
|
+
// prettier-ignore
|
22
|
+
console.error(chalk.red(`\nWorkspace ${data.name} has conflicting root paths:\n\t${existing.rootPath}\n\t${data.rootPath}\n`));
|
23
|
+
process.exit(1);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
_workspaces[data.name] = {
|
28
|
+
rootPath: data.rootPath,
|
29
|
+
packageDataEntries: []
|
30
|
+
};
|
31
|
+
}
|
32
|
+
_workspaces[data.name].packageDataEntries.push(data);
|
33
|
+
});
|
34
|
+
_workspacesLoaded = true;
|
35
|
+
return _workspaces;
|
36
|
+
}
|
37
|
+
export function workspaceDirectoryForLanguage(language) {
|
38
|
+
switch (language) {
|
39
|
+
case "node":
|
40
|
+
return nodeWorkspaces();
|
41
|
+
case "python":
|
42
|
+
return pythonWorkspaces();
|
43
|
+
default:
|
44
|
+
throw new Error(`Unsupported language: ${language}`);
|
45
|
+
}
|
46
|
+
}
|
47
|
+
export function getWorkspace(workspaceName) {
|
48
|
+
const workspace = workspaces()[workspaceName];
|
49
|
+
if (!workspace) {
|
50
|
+
console.error(chalk.red(`\nWorkspace ${workspaceName} not found\n`));
|
51
|
+
// The gha relies on the 13 exit code for "not found"
|
52
|
+
process.exit(13);
|
53
|
+
}
|
54
|
+
return workspace;
|
55
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"package-json-processor.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/package-json-processor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAUlE,wBAAgB,cAAc,gCAgC7B"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import chalk from "chalk";
|
2
|
+
import fs from "fs";
|
3
|
+
import { globSync } from "glob";
|
4
|
+
import path from "path";
|
5
|
+
import { packageJsonSchema } from "../../types";
|
6
|
+
const rootPkgJsonPath = path.join(process.cwd(), "package.json");
|
7
|
+
const rootPkgJson = JSON.parse(fs.readFileSync(rootPkgJsonPath, "utf8"));
|
8
|
+
const _workspaces = {};
|
9
|
+
let _workspacesLoaded = false;
|
10
|
+
export function nodeWorkspaces() {
|
11
|
+
if (!_workspacesLoaded) {
|
12
|
+
for (const workspaceGlob of (rootPkgJson.workspaces ?? [])) {
|
13
|
+
globSync(path.join(workspaceGlob, "package.json")).forEach((packageJsonPath) => {
|
14
|
+
// Skip packages under node_modules directories in case hoisting did not work
|
15
|
+
if (packageJsonPath.includes("node_modules"))
|
16
|
+
return;
|
17
|
+
const unsafeData = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
18
|
+
const parsedRes = packageJsonSchema.safeParse(unsafeData);
|
19
|
+
if (parsedRes.error) {
|
20
|
+
console.error(`Error parsing ${packageJsonPath}: ${parsedRes.error}`);
|
21
|
+
process.exit(1);
|
22
|
+
}
|
23
|
+
const { dependencies, ...rest } = parsedRes.data;
|
24
|
+
const dependencyNames = Object.keys(dependencies ?? []);
|
25
|
+
const pkgName = rest.name;
|
26
|
+
const rootPath = path.dirname(packageJsonPath);
|
27
|
+
_workspaces[pkgName] = { data: { ...rest, dependencyNames }, rootPath };
|
28
|
+
});
|
29
|
+
}
|
30
|
+
console.warn(chalk.yellow(`Node workspace discovery initialized. Workspaces found: ${Object.keys(_workspaces).join(", ")}`));
|
31
|
+
_workspacesLoaded = true;
|
32
|
+
}
|
33
|
+
return _workspaces;
|
34
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { ZodSchema } from "zod";
|
2
|
+
import type { PackageData, SupportedLanguages } from "../../types";
|
3
|
+
export declare const IGNORED_PATHS: string[];
|
4
|
+
type PackageDataProcessorConfig<T> = {
|
5
|
+
language: SupportedLanguages;
|
6
|
+
pathList: string[];
|
7
|
+
zodSchema: ZodSchema<T>;
|
8
|
+
fileParser: (fileStringData: string) => unknown;
|
9
|
+
nameExtractor: (data: T) => string;
|
10
|
+
};
|
11
|
+
export declare class PackageDataProcessor<T> {
|
12
|
+
workspaceNames: Set<string>;
|
13
|
+
loadedFiles: Record<string, {
|
14
|
+
name: string;
|
15
|
+
data: T;
|
16
|
+
}>;
|
17
|
+
language: SupportedLanguages;
|
18
|
+
nameExtractor: (data: T) => string;
|
19
|
+
constructor(config: PackageDataProcessorConfig<T>);
|
20
|
+
_runFirstPass(pathList: string[], zodSchema: ZodSchema<T>, fileParser: (fileStringData: string) => unknown): void;
|
21
|
+
filterDependencies(dependencyNames: string[]): string[];
|
22
|
+
convert(iterator: (data: T) => Omit<PackageData, 'rootPath' | 'language' | 'name'>): PackageData[];
|
23
|
+
}
|
24
|
+
export {};
|
25
|
+
//# sourceMappingURL=process-common.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"process-common.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/process-common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAInE,eAAO,MAAM,aAAa,UAA6B,CAAC;AAExD,KAAK,0BAA0B,CAAC,CAAC,IAAI;IACnC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IACxB,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC;IAChD,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;CACpC,CAAA;AAED,qBAAa,oBAAoB,CAAC,CAAC;IACjC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IACxC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAM;IAC5D,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,aAAa,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC;gBAEvB,MAAM,EAAE,0BAA0B,CAAC,CAAC,CAAC;IAMjD,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO;IAiB1G,kBAAkB,CAAC,eAAe,EAAE,MAAM,EAAE;IAI5C,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,WAAW,EAAE,UAAU,GAAG,UAAU,GAAG,MAAM,CAAC,GAAG,WAAW,EAAE;CAMnG"}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import fs from "fs";
|
2
|
+
import path from "path";
|
3
|
+
export const IGNORED_PATHS = ["node_modules/", "venv/"];
|
4
|
+
export class PackageDataProcessor {
|
5
|
+
workspaceNames = new Set();
|
6
|
+
loadedFiles = {};
|
7
|
+
language;
|
8
|
+
nameExtractor;
|
9
|
+
constructor(config) {
|
10
|
+
this.language = config.language;
|
11
|
+
this.nameExtractor = config.nameExtractor;
|
12
|
+
this._runFirstPass(config.pathList, config.zodSchema, config.fileParser);
|
13
|
+
}
|
14
|
+
_runFirstPass(pathList, zodSchema, fileParser) {
|
15
|
+
pathList.forEach((packageFilePath) => {
|
16
|
+
if (IGNORED_PATHS.find(path => packageFilePath.includes(path)))
|
17
|
+
return;
|
18
|
+
const unsafeData = fileParser(fs.readFileSync(packageFilePath, "utf8"));
|
19
|
+
const parsedRes = zodSchema.safeParse(unsafeData);
|
20
|
+
if (parsedRes.error) {
|
21
|
+
console.error(`Error parsing ${packageFilePath}: ${parsedRes.error}`);
|
22
|
+
process.exit(1);
|
23
|
+
}
|
24
|
+
const rootDir = path.dirname(packageFilePath);
|
25
|
+
const name = this.nameExtractor(parsedRes.data);
|
26
|
+
this.workspaceNames.add(name);
|
27
|
+
this.loadedFiles[rootDir] = { name, data: parsedRes.data };
|
28
|
+
});
|
29
|
+
}
|
30
|
+
// Should be used by the iterator sent to convert in order to filter out dependencies that are not workspaces
|
31
|
+
filterDependencies(dependencyNames) {
|
32
|
+
return dependencyNames.filter((name) => this.workspaceNames.has(name));
|
33
|
+
}
|
34
|
+
convert(iterator) {
|
35
|
+
return Object.entries(this.loadedFiles).map(([rootPath, { name, data }]) => {
|
36
|
+
const res = iterator(data);
|
37
|
+
return { rootPath, language: this.language, name, ...res };
|
38
|
+
});
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"process-package-json.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/process-package-json.ts"],"names":[],"mappings":"AAIA,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAWtE,wBAAgB,cAAc,gCA+B7B"}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import chalk from "chalk";
|
2
|
+
import fs from "fs";
|
3
|
+
import { globSync } from "glob";
|
4
|
+
import path from "path";
|
5
|
+
import { packageFileNodeSchema } from "../../types";
|
6
|
+
import { PackageDataProcessor } from "./process-common";
|
7
|
+
const rootPkgJsonPath = path.join(process.cwd(), "package.json");
|
8
|
+
const rootPkgJson = JSON.parse(fs.readFileSync(rootPkgJsonPath, "utf8"));
|
9
|
+
const _workspaces = {};
|
10
|
+
let _workspacesLoaded = false;
|
11
|
+
export function nodeWorkspaces() {
|
12
|
+
if (!_workspacesLoaded) {
|
13
|
+
const allPackageJsons = (rootPkgJson.workspaces ?? []).flatMap((workspaceGlob) => globSync(path.join(workspaceGlob, "package.json")));
|
14
|
+
const processor = new PackageDataProcessor({
|
15
|
+
language: "node",
|
16
|
+
pathList: allPackageJsons,
|
17
|
+
zodSchema: packageFileNodeSchema,
|
18
|
+
fileParser: JSON.parse,
|
19
|
+
nameExtractor: (data) => data.name,
|
20
|
+
});
|
21
|
+
processor.convert((data) => {
|
22
|
+
const { dependencies, ...rest } = data;
|
23
|
+
const dependencyNames = Object.keys(dependencies ?? []);
|
24
|
+
return { ...rest, dependencyNames: processor.filterDependencies(dependencyNames) };
|
25
|
+
}).forEach(pkgData => {
|
26
|
+
_workspaces[pkgData.name] = pkgData;
|
27
|
+
});
|
28
|
+
console.warn(chalk.yellow(
|
29
|
+
// prettier-ignore
|
30
|
+
`Node workspace discovery initialized. Workspaces found: ${Object.keys(_workspaces).join(", ")}`));
|
31
|
+
_workspacesLoaded = true;
|
32
|
+
}
|
33
|
+
return _workspaces;
|
34
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"process-pyproject-toml.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/process-pyproject-toml.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAOxE,wBAAgB,gBAAgB,gCAiC/B"}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import chalk from "chalk";
|
2
|
+
import { globSync } from "glob";
|
3
|
+
import { packageFilePythonSchema } from "../../types";
|
4
|
+
import { PackageDataProcessor } from "./process-common";
|
5
|
+
import TOML from '@iarna/toml';
|
6
|
+
const _workspaces = {};
|
7
|
+
let _workspacesLoaded = false;
|
8
|
+
export function pythonWorkspaces() {
|
9
|
+
if (!_workspacesLoaded) {
|
10
|
+
const allPyprojectTomls = globSync("**/*/pyproject.toml");
|
11
|
+
const processor = new PackageDataProcessor({
|
12
|
+
language: "python",
|
13
|
+
pathList: allPyprojectTomls,
|
14
|
+
zodSchema: packageFilePythonSchema,
|
15
|
+
fileParser: TOML.parse,
|
16
|
+
nameExtractor: (data) => data.project.name,
|
17
|
+
});
|
18
|
+
processor.convert((data) => {
|
19
|
+
const deployment = data.tool?.devops?.deployment;
|
20
|
+
const scripts = data.tool?.devops?.scripts;
|
21
|
+
const dependencyNames = data.project.dependencies ?? [];
|
22
|
+
return {
|
23
|
+
scripts,
|
24
|
+
deployment,
|
25
|
+
dependencyNames: processor.filterDependencies(dependencyNames)
|
26
|
+
};
|
27
|
+
}).forEach(pkgData => {
|
28
|
+
_workspaces[pkgData.name] = pkgData;
|
29
|
+
});
|
30
|
+
console.warn(chalk.yellow(
|
31
|
+
// prettier-ignore
|
32
|
+
`Python workspace discovery initialized. Workspaces found: ${Object.keys(_workspaces).join(", ")}`));
|
33
|
+
_workspacesLoaded = true;
|
34
|
+
}
|
35
|
+
return _workspaces;
|
36
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pyproject-toml-processor.d.ts","sourceRoot":"","sources":["../../../src/libs/discovery/pyproject-toml-processor.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAMhE,wBAAgB,gBAAgB,gCAsC/B"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import chalk from "chalk";
|
2
|
+
import fs from "fs";
|
3
|
+
import { globSync } from "glob";
|
4
|
+
import path from "path";
|
5
|
+
import { pyProjectSchema } from "../../types";
|
6
|
+
import TOML from '@iarna/toml';
|
7
|
+
const _workspaces = {};
|
8
|
+
let _workspacesLoaded = false;
|
9
|
+
export function pythonWorkspaces() {
|
10
|
+
if (!_workspacesLoaded) {
|
11
|
+
globSync(path.join(process.cwd(), "**/*/pyproject.toml")).forEach((pyProjectPath) => {
|
12
|
+
// Skip packages under venv just in case
|
13
|
+
if (pyProjectPath.includes("venv"))
|
14
|
+
return;
|
15
|
+
const unsafeData = TOML.parse(fs.readFileSync(pyProjectPath, "utf8"));
|
16
|
+
const parsedRes = pyProjectSchema.safeParse(unsafeData);
|
17
|
+
if (parsedRes.error) {
|
18
|
+
console.error(`Error parsing ${pyProjectPath}: ${parsedRes.error}`);
|
19
|
+
process.exit(1);
|
20
|
+
}
|
21
|
+
const data = parsedRes.data;
|
22
|
+
const pkgName = data.project.name;
|
23
|
+
const deployment = data.tool?.devops?.deployment;
|
24
|
+
const rootPath = path.dirname(pyProjectPath);
|
25
|
+
_workspaces[pkgName] = {
|
26
|
+
rootPath,
|
27
|
+
data: {
|
28
|
+
name: pkgName,
|
29
|
+
scripts: data.tool?.poetry?.scripts,
|
30
|
+
dependencyNames: Object.keys(data.tool?.poetry?.dependencies ?? []),
|
31
|
+
deployment,
|
32
|
+
}
|
33
|
+
};
|
34
|
+
});
|
35
|
+
console.warn(chalk.yellow(`Python workspace discovery initialized. Workspaces found: ${Object.keys(_workspaces).join(", ")}`));
|
36
|
+
_workspacesLoaded = true;
|
37
|
+
}
|
38
|
+
return _workspaces;
|
39
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export declare function commitExists(sha: string): boolean;
|
2
|
+
export declare function firstCommit(): string;
|
3
|
+
export declare function isAffected(path: string, opts?: {
|
4
|
+
baseSha?: string;
|
5
|
+
headSha?: string;
|
6
|
+
skipCheck?: boolean;
|
7
|
+
}): boolean;
|
8
|
+
//# sourceMappingURL=git-helpers.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"git-helpers.d.ts","sourceRoot":"","sources":["../../src/libs/git-helpers.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,WAKvC;AAED,wBAAgB,WAAW,WAK1B;AAED,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,WAavE"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { CommandExecutor } from "../cli/common";
|
2
|
+
export function commitExists(sha) {
|
3
|
+
const statusCode = new CommandExecutor(`git merge-base --is-ancestor "${sha}" HEAD`).exec({ onlyStatusCode: true });
|
4
|
+
return statusCode === 0;
|
5
|
+
}
|
6
|
+
export function firstCommit() {
|
7
|
+
const res = new CommandExecutor(`git rev-list --max-parents=0 HEAD`, {
|
8
|
+
quiet: true,
|
9
|
+
}).exec();
|
10
|
+
return res?.trim();
|
11
|
+
}
|
12
|
+
export function isAffected(path, opts = {}) {
|
13
|
+
const baseSha = opts.baseSha || "HEAD^";
|
14
|
+
const headSha = opts.headSha || "HEAD";
|
15
|
+
// When in doubt, assume it's affected
|
16
|
+
if (!opts.skipCheck && (!commitExists(baseSha) || !commitExists(headSha)))
|
17
|
+
return true;
|
18
|
+
const statusCode = new CommandExecutor(`git diff --quiet ${baseSha} ${headSha} -- ${path}`, { quiet: true }).exec({ onlyStatusCode: true });
|
19
|
+
return statusCode !== 0;
|
20
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"reg-secret.d.ts","sourceRoot":"","sources":["../../../src/libs/hetzner/reg-secret.ts"],"names":[],"mappings":"AAgBA,wBAAgB,2BAA2B,CAAC,WAAW,EAAE,MAAM,QA2B9D;AAED,wBAAgB,kCAAkC,CAAC,WAAW,EAAE,MAAM,QAQrE"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { CommandExecutor } from "../../cli/common";
|
2
|
+
import { getConst } from "../config";
|
3
|
+
import { envToNamespace } from "../k8s-constants";
|
4
|
+
import { kubectlCommand } from "../k8s-helpers";
|
5
|
+
function isApplicable() {
|
6
|
+
const infra = getConst("infra");
|
7
|
+
if (infra !== "hetzner") {
|
8
|
+
console.warn("Setting up registry permissions is only needed for Harbor in a Hetzner setup");
|
9
|
+
return false;
|
10
|
+
}
|
11
|
+
return true;
|
12
|
+
}
|
13
|
+
export function copySecretHarborToNamespace(monorepoEnv) {
|
14
|
+
if (!isApplicable())
|
15
|
+
return;
|
16
|
+
const cmd = kubectlCommand("get secret harbor-registry-secret -o json", {
|
17
|
+
monorepoEnv,
|
18
|
+
namespace: "harbor",
|
19
|
+
});
|
20
|
+
const secretStr = new CommandExecutor(cmd, { quiet: true }).exec();
|
21
|
+
const secretJson = JSON.parse(secretStr);
|
22
|
+
const { apiVersion, data, kind, metadata: { name }, type, } = secretJson;
|
23
|
+
const relevantParts = {
|
24
|
+
apiVersion,
|
25
|
+
data,
|
26
|
+
kind,
|
27
|
+
metadata: { name, namespace: envToNamespace(monorepoEnv) },
|
28
|
+
type,
|
29
|
+
};
|
30
|
+
// prettier-ignore
|
31
|
+
const copyCmd = `echo '${JSON.stringify(relevantParts)}' | kubectl apply -f -`;
|
32
|
+
new CommandExecutor(copyCmd, { quiet: true }).exec();
|
33
|
+
}
|
34
|
+
export function patchServiceAccountImagePullSecret(monorepoEnv) {
|
35
|
+
if (!isApplicable())
|
36
|
+
return;
|
37
|
+
const cmd = kubectlCommand(`patch serviceaccount default -p '{"imagePullSecrets": [{"name": "harbor-registry-secret"}]}'`, { monorepoEnv });
|
38
|
+
new CommandExecutor(cmd, { quiet: true }).exec();
|
39
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
export declare const MISSING_DOMAIN_KEY_ERROR = "$$$MISSING_DOMAIN_KEY$$$";
|
2
|
+
export declare function allSupportedEnvs(): string[];
|
3
|
+
export declare function envToNamespace(monorepoEnv?: string): string;
|
4
|
+
export declare function secretName(): string;
|
5
|
+
export declare function imageDebugName(image: string): string;
|
6
|
+
export declare function imageConfigMap(image: string): string;
|
7
|
+
export declare function containerRegistryRepoName(image: string, monorepoEnv: string): string;
|
8
|
+
export declare function containerRegistryPath(): string;
|
9
|
+
export declare function containerRegistryRepoPath(image: string, monorepoEnv: string, gitSha: string): string;
|
10
|
+
export declare function domainNameForEnv(image: string, monorepoEnv: string): string;
|
11
|
+
export declare function dbMigrateJobName(gitSha: string): string;
|
12
|
+
//# sourceMappingURL=k8s-constants.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"k8s-constants.d.ts","sourceRoot":"","sources":["../../src/libs/k8s-constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB,6BAA6B,CAAA;AAoBlE,wBAAgB,gBAAgB,aAE/B;AAYD,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,UAGlD;AAED,wBAAgB,UAAU,WAEzB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,UAE3C;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,UAE3C;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAG3E;AAED,wBAAgB,qBAAqB,WAEpC;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,UAOf;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,UAIlE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,UAE9C"}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { getConst, getImageData } from "./config";
|
2
|
+
export const MISSING_DOMAIN_KEY_ERROR = "$$$MISSING_DOMAIN_KEY$$$";
|
3
|
+
const DEFAULT_REMOTE_ENVS = ["staging", "production"];
|
4
|
+
const DEFAULT_LOCAL_ENVS = ["development", "test"];
|
5
|
+
let _remoteSupportedEnvs;
|
6
|
+
function remoteSupportedEnvs() {
|
7
|
+
if (_remoteSupportedEnvs)
|
8
|
+
return _remoteSupportedEnvs;
|
9
|
+
const extra = getConst("extra-remote-environments", { ignoreIfInvalid: true }) ?? [];
|
10
|
+
_remoteSupportedEnvs = [...DEFAULT_REMOTE_ENVS, ...extra];
|
11
|
+
return _remoteSupportedEnvs;
|
12
|
+
}
|
13
|
+
let _localSupportedEnvs;
|
14
|
+
function localSupportedEnvs() {
|
15
|
+
if (_localSupportedEnvs)
|
16
|
+
return _localSupportedEnvs;
|
17
|
+
const extra = getConst("extra-local-environments", { ignoreIfInvalid: true }) ?? [];
|
18
|
+
_localSupportedEnvs = [...DEFAULT_LOCAL_ENVS, ...extra];
|
19
|
+
return _localSupportedEnvs;
|
20
|
+
}
|
21
|
+
export function allSupportedEnvs() {
|
22
|
+
return [...remoteSupportedEnvs(), ...localSupportedEnvs()];
|
23
|
+
}
|
24
|
+
function validateEnv(monorepoEnv) {
|
25
|
+
if (!monorepoEnv)
|
26
|
+
throw new Error("MONOREPO_ENV cannot be empty");
|
27
|
+
if (!remoteSupportedEnvs().includes(monorepoEnv)) {
|
28
|
+
console.error(`MONOREPO_ENV must be one of: ${remoteSupportedEnvs().join(", ")}. Can be set using --env flag.`);
|
29
|
+
process.exit(1);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
export function envToNamespace(monorepoEnv) {
|
33
|
+
validateEnv(monorepoEnv);
|
34
|
+
return `${getConst("project-name")}-${monorepoEnv}`;
|
35
|
+
}
|
36
|
+
export function secretName() {
|
37
|
+
return `${getConst("project-name")}-secret`;
|
38
|
+
}
|
39
|
+
export function imageDebugName(image) {
|
40
|
+
return `${image}-debug`;
|
41
|
+
}
|
42
|
+
export function imageConfigMap(image) {
|
43
|
+
return `image-config-${image}`;
|
44
|
+
}
|
45
|
+
export function containerRegistryRepoName(image, monorepoEnv) {
|
46
|
+
validateEnv(monorepoEnv);
|
47
|
+
return `${getConst("project-name")}-${monorepoEnv}-${image}`;
|
48
|
+
}
|
49
|
+
export function containerRegistryPath() {
|
50
|
+
return [getConst("registry-base-url"), getConst("registry-name")].join("/");
|
51
|
+
}
|
52
|
+
export function containerRegistryRepoPath(image, monorepoEnv, gitSha) {
|
53
|
+
return [
|
54
|
+
getConst("registry-base-url"),
|
55
|
+
getConst("registry-name"),
|
56
|
+
[containerRegistryRepoName(image, monorepoEnv), gitSha].join(":"),
|
57
|
+
].join("/");
|
58
|
+
}
|
59
|
+
export function domainNameForEnv(image, monorepoEnv) {
|
60
|
+
const imageData = getImageData(image);
|
61
|
+
const value = imageData["domains"]?.[monorepoEnv] ?? MISSING_DOMAIN_KEY_ERROR;
|
62
|
+
return value;
|
63
|
+
}
|
64
|
+
export function dbMigrateJobName(gitSha) {
|
65
|
+
return `db-migrate-job-${gitSha.slice(0, 8)}`;
|
66
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
export declare function getDbList(): string | null;
|
2
|
+
export declare function getDbBackups(): string | null;
|
3
|
+
export declare function getDbAdminPassword(): {
|
4
|
+
user: string;
|
5
|
+
password: string;
|
6
|
+
} | null;
|
7
|
+
export declare function getDbPasswords(namespace: string): {
|
8
|
+
superUser: string;
|
9
|
+
superPassword: string;
|
10
|
+
authenticatorUser: string;
|
11
|
+
authenticatorPassword: string;
|
12
|
+
replicationUser: string;
|
13
|
+
replicationPassword: string;
|
14
|
+
} | null;
|
15
|
+
export declare function connectToPatroni(namespace: string): void;
|
16
|
+
export declare function connectToPsql(namespace: string): void;
|
17
|
+
export declare function establishTunnel(namespace: string, port: string): void;
|
18
|
+
//# sourceMappingURL=k8s-db.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"k8s-db.d.ts","sourceRoot":"","sources":["../../src/libs/k8s-db.ts"],"names":[],"mappings":"AAGA,wBAAgB,SAAS,kBAKxB;AAED,wBAAgB,YAAY,kBAK3B;AAED,wBAAgB,kBAAkB;;;SAejC;AAED,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM;;;;;;;SAyB/C;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,QAMjD;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,QAM9C;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAK9D"}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { CommandExecutor } from "../cli/common";
|
2
|
+
import { kubectlCommand } from "./k8s-helpers";
|
3
|
+
export function getDbList() {
|
4
|
+
const cmd = kubectlCommand(`get sgcluster -A`);
|
5
|
+
const res = new CommandExecutor(cmd, { quiet: true }).exec();
|
6
|
+
if (!res)
|
7
|
+
return null;
|
8
|
+
return res;
|
9
|
+
}
|
10
|
+
export function getDbBackups() {
|
11
|
+
const cmd = kubectlCommand(`get sgbkp -A`);
|
12
|
+
const res = new CommandExecutor(cmd, { quiet: true }).exec();
|
13
|
+
if (!res)
|
14
|
+
return null;
|
15
|
+
return res;
|
16
|
+
}
|
17
|
+
export function getDbAdminPassword() {
|
18
|
+
const cmd = kubectlCommand(`get secrets/stackgres-restapi-admin -o jsonpath="{.data}"`, { namespace: "stackgres" });
|
19
|
+
const res = new CommandExecutor(cmd, { quiet: true }).exec();
|
20
|
+
if (!res)
|
21
|
+
return null;
|
22
|
+
try {
|
23
|
+
const resJson = JSON.parse(res);
|
24
|
+
const password = atob(resJson["clearPassword"]);
|
25
|
+
const user = atob(resJson["k8sUsername"]);
|
26
|
+
return { user, password };
|
27
|
+
}
|
28
|
+
catch {
|
29
|
+
return null;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
export function getDbPasswords(namespace) {
|
33
|
+
const cmd = kubectlCommand(`get secrets/${namespace} -o jsonpath="{.data}"`, {
|
34
|
+
namespace,
|
35
|
+
});
|
36
|
+
const res = new CommandExecutor(cmd, { quiet: true }).exec();
|
37
|
+
if (!res)
|
38
|
+
return null;
|
39
|
+
try {
|
40
|
+
const resJson = JSON.parse(res);
|
41
|
+
const superUser = atob(resJson["superuser-username"]);
|
42
|
+
const superPassword = atob(resJson["superuser-password"]);
|
43
|
+
const authenticatorUser = atob(resJson["authenticator-username"]);
|
44
|
+
const authenticatorPassword = atob(resJson["authenticator-password"]);
|
45
|
+
const replicationUser = atob(resJson["replication-username"]);
|
46
|
+
const replicationPassword = atob(resJson["replication-password"]);
|
47
|
+
return {
|
48
|
+
superUser,
|
49
|
+
superPassword,
|
50
|
+
authenticatorUser,
|
51
|
+
authenticatorPassword,
|
52
|
+
replicationUser,
|
53
|
+
replicationPassword,
|
54
|
+
};
|
55
|
+
}
|
56
|
+
catch {
|
57
|
+
return null;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
export function connectToPatroni(namespace) {
|
61
|
+
const cmd = kubectlCommand(`exec -it ${namespace}-0 -c patroni -- /bin/bash`, { namespace });
|
62
|
+
new CommandExecutor(cmd).spawn();
|
63
|
+
}
|
64
|
+
export function connectToPsql(namespace) {
|
65
|
+
const cmd = kubectlCommand(`exec -it ${namespace}-0 -c postgres-util -- psql`, { namespace });
|
66
|
+
new CommandExecutor(cmd).spawn();
|
67
|
+
}
|
68
|
+
export function establishTunnel(namespace, port) {
|
69
|
+
const cmd = kubectlCommand(`port-forward pod/${namespace}-0 ${port}:5432`, {
|
70
|
+
namespace,
|
71
|
+
});
|
72
|
+
new CommandExecutor(cmd).spawn();
|
73
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { PackageData, TemplateDbMigrateObject, TemplateDebugObject, TemplateDeploymentObject, TemplateSharedContext } from "../types";
|
2
|
+
export declare function generateImageDeployments(monorepoEnv: string, image: string, gitSha: string): string;
|
3
|
+
export declare function generateWorkspaceDeployment(packageData: PackageData, monorepoEnv: string, image: string, gitSha: string): string;
|
4
|
+
export declare function generateDebugDeployment(monorepoEnv: string, image: string, gitSha: string): string;
|
5
|
+
export declare function generateDbMigrateJob(monorepoEnv: string, image: string, gitSha: string): string;
|
6
|
+
export declare class ImageContextGenerator {
|
7
|
+
monorepoEnv: string;
|
8
|
+
image: string;
|
9
|
+
gitSha: string;
|
10
|
+
replicaMap: Record<string, number>;
|
11
|
+
imageContext: Omit<TemplateSharedContext, 'project_name'>;
|
12
|
+
constructor(monorepoEnv: string, image: string, gitSha: string);
|
13
|
+
getDeployment(pkgData: PackageData): TemplateDeploymentObject;
|
14
|
+
getDbMigrate(): TemplateDbMigrateObject;
|
15
|
+
getDebug(): TemplateDebugObject;
|
16
|
+
}
|
17
|
+
//# sourceMappingURL=k8s-generate.d.ts.map
|