@tdk-landscape/tdk-cli-core 1.3.15 → 1.3.22
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/Tiltfile +144 -0
- package/discovery/AGENTS.md +362 -0
- package/discovery/TILT_DISCOVERY.star +424 -0
- package/discovery/Tiltfile +58 -0
- package/discovery/config.star +258 -0
- package/discovery/constants.star +127 -0
- package/discovery/deterministic.star +211 -0
- package/discovery/discovery_daemon.star +191 -0
- package/discovery/discovery_orchestrator.star +460 -0
- package/discovery/filtering.star +5 -0
- package/discovery/identity-management-backend/service.yaml +26 -0
- package/discovery/identity-management-frontend/service.yaml +29 -0
- package/discovery/identity-sdk/service.yaml +9 -0
- package/discovery/incremental_discovery.star +213 -0
- package/discovery/indexing.star +7 -0
- package/discovery/json_manifest_scanner.star +51 -0
- package/discovery/libraries.star +46 -0
- package/discovery/loading.star +23 -0
- package/discovery/manifest/constants.star +104 -0
- package/discovery/manifest/loading.star +386 -0
- package/discovery/manifest/normalize.star +281 -0
- package/discovery/manifest/validation.star +108 -0
- package/discovery/normalization.star +11 -0
- package/discovery/registry.star +544 -0
- package/discovery/resource_snapshot.py +382 -0
- package/discovery/resource_snapshot.star +143 -0
- package/discovery/schemas.star +1 -0
- package/discovery/services/platform/cdc/debezium/nats-connector/service.yaml +9 -0
- package/discovery/services/platform/cdc/nats-http-bridge/service.yaml +9 -0
- package/discovery/services/platform/orchestrator/orchestrator-glue-backend/service.yaml +26 -0
- package/discovery/services/platform/synthetic-monitor/service.yaml +9 -0
- package/discovery/test_resource_snapshot.py +251 -0
- package/discovery/validation.star +78 -0
- package/discovery/versioning.star +1 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +11 -0
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +1 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/project.d.ts.map +1 -1
- package/dist/commands/project.js +36 -41
- package/dist/commands/project.js.map +1 -1
- package/dist/commands/resource.d.ts.map +1 -1
- package/dist/commands/resource.js +51 -55
- package/dist/commands/resource.js.map +1 -1
- package/dist/commands/stack.d.ts.map +1 -1
- package/dist/commands/stack.js +22 -24
- package/dist/commands/stack.js.map +1 -1
- package/dist/commands/ui.d.ts.map +1 -1
- package/dist/commands/ui.js +1 -2
- package/dist/commands/ui.js.map +1 -1
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +1 -2
- package/dist/commands/up.js.map +1 -1
- package/dist/commands/upgrade.d.ts +8 -0
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +59 -18
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/generator/extension-fetch.d.ts +19 -0
- package/dist/generator/extension-fetch.d.ts.map +1 -1
- package/dist/generator/extension-fetch.js +71 -5
- package/dist/generator/extension-fetch.js.map +1 -1
- package/dist/generator/template-engine.d.ts +1 -0
- package/dist/generator/template-engine.d.ts.map +1 -1
- package/dist/generator/template-engine.js +50 -6
- package/dist/generator/template-engine.js.map +1 -1
- package/dist/utils/command-helpers.d.ts.map +1 -1
- package/dist/utils/command-helpers.js +7 -9
- package/dist/utils/command-helpers.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +1 -0
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/errors.d.ts +2 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +6 -1
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/project-features.d.ts.map +1 -1
- package/dist/utils/project-features.js +1 -1
- package/dist/utils/project-features.js.map +1 -1
- package/dist/utils/resource-features.d.ts.map +1 -1
- package/dist/utils/resource-features.js +2 -2
- package/dist/utils/resource-features.js.map +1 -1
- package/dist/utils/tar.js +4 -4
- package/dist/utils/tar.js.map +1 -1
- package/dist/utils/validation.d.ts +7 -0
- package/dist/utils/validation.d.ts.map +1 -1
- package/dist/utils/validation.js +9 -0
- package/dist/utils/validation.js.map +1 -1
- package/engine/AGENTS.md +705 -0
- package/engine/README.md +29 -0
- package/engine/REFACTORING_MANIFEST_SYSTEM.md +974 -0
- package/engine/Tiltfile +80 -0
- package/engine/assets/docker/golden-layers.Dockerfile +221 -0
- package/engine/assets/scripts/cleanup-completed-migrator-images.sh +37 -0
- package/engine/assets/scripts/cleanup-tilt-images.sh +120 -0
- package/engine/assets/scripts/mac-m1-resource-monitor.sh +121 -0
- package/engine/config.star +3 -0
- package/engine/docs/AUTODISCOVERY_TEST.md +182 -0
- package/engine/docs/C4-ARCHITECTURE-operations.md +396 -0
- package/engine/docs/C4-ARCHITECTURE-overview.md +284 -0
- package/engine/docs/C4-ARCHITECTURE.md +17 -0
- package/engine/docs/GOLDEN_IMAGE_INTEGRATION.md +349 -0
- package/engine/docs/MANIFEST_DRIVEN_ARCHITECTURE.md +357 -0
- package/engine/docs/README.md +284 -0
- package/engine/entrypoint.star +97 -0
- package/engine/lifecycle/orchestrator.star +260 -0
- package/engine/paths.star +717 -0
- package/engine/schemas/manifest-schema.json +301 -0
- package/engine/schemas/service-schema.json +301 -0
- package/engine/scripts/README.md +89 -0
- package/engine/scripts/build-and-publish-lib.sh +205 -0
- package/engine/scripts/check-lib-publish.sh +85 -0
- package/engine/scripts/debug-container.sh +258 -0
- package/engine/scripts/generate-manifest.sh +197 -0
- package/engine/spec.master +702 -0
- package/engine/spec.master.example +341 -0
- package/engine/topologies/README.md +34 -0
- package/engine/topologies/platform/docker/AGENTS.md +59 -0
- package/engine/topologies/platform/docker/auth/auth.star +167 -0
- package/engine/topologies/platform/docker/build/golden_image.star +37 -0
- package/engine/topologies/platform/docker/build/golden_image_build.star +82 -0
- package/engine/topologies/platform/docker/build/golden_image_constants.star +93 -0
- package/engine/topologies/platform/docker/build/golden_image_dockerfile.star +291 -0
- package/engine/topologies/platform/docker/compose/compose.star +636 -0
- package/engine/topologies/platform/docker/compose/compose_helpers.star +52 -0
- package/engine/topologies/platform/docker/compose/traefik_standalone.star +53 -0
- package/engine/topologies/platform/docker/config/bunignore.star +142 -0
- package/engine/topologies/platform/docker/config/dockerignore.star +150 -0
- package/engine/topologies/platform/docker/constants.star +170 -0
- package/engine/topologies/platform/docker/dockerfile/dockerfile.star +54 -0
- package/engine/topologies/platform/docker/generators/golden_docker_generator_v2.star +73 -0
- package/engine/topologies/platform/docker/index.star +27 -0
- package/engine/topologies/platform/docker/layers/bun_helpers.star +23 -0
- package/engine/topologies/platform/docker/layers/infisical/index.star +40 -0
- package/engine/topologies/platform/docker/layers/infisical/infisical_docker.star +262 -0
- package/engine/topologies/platform/docker/layers/l1_base_layers.star +87 -0
- package/engine/topologies/platform/docker/layers/l2_dependency_layers.star +125 -0
- package/engine/topologies/platform/docker/layers/l3_builder_layers.star +209 -0
- package/engine/topologies/platform/docker/layers/l4_runtime_layers.star +214 -0
- package/engine/topologies/platform/docker/layers/prisma/constants.star +135 -0
- package/engine/topologies/platform/docker/layers/prisma/db_readiness.star +96 -0
- package/engine/topologies/platform/docker/layers/prisma/filesystem_setup.star +109 -0
- package/engine/topologies/platform/docker/layers/prisma/migrate_script.star +98 -0
- package/engine/topologies/platform/docker/layers/prisma/prisma_build.star +126 -0
- package/engine/topologies/platform/docker/layers/prisma/prisma_runtime.star +161 -0
- package/engine/topologies/platform/docker/layers/prisma/secret_resolution.star +119 -0
- package/engine/topologies/platform/docker/networking/api_path_constants.star +230 -0
- package/engine/topologies/platform/docker/networking/sablier_container_cycle.star +27 -0
- package/engine/topologies/platform/docker/networking/traefik.star +232 -0
- package/engine/topologies/platform/docker/networking/traefik_constants.star +146 -0
- package/engine/topologies/platform/docker/networking/traefik_helpers.star +160 -0
- package/engine/topologies/platform/docker/secrets/infisical.star +135 -0
- package/engine/topologies/platform/net/proxy.star +4 -0
- package/engine/topologies/platform/registries/local.star +4 -0
- package/engine/topologies/platform/security/secrets.star +239 -0
- package/engine/topologies/platform/state/relational.star +4 -0
- package/engine/topologies/tilt/common/AGENTS.md +59 -0
- package/engine/topologies/tilt/common/utils.star +364 -0
- package/engine/topologies/tilt/common/utils_debug.star +69 -0
- package/engine/topologies/tilt/common/utils_deterministic.star +168 -0
- package/engine/topologies/tilt/common/utils_docker_networks.star +46 -0
- package/engine/topologies/tilt/common/utils_env.star +43 -0
- package/engine/topologies/tilt/common/utils_output.star +97 -0
- package/engine/topologies/tilt/config/AGENTS.md +68 -0
- package/engine/topologies/tilt/config/defaults.star +3 -0
- package/engine/topologies/tilt/config/feature_flags.star +10 -0
- package/engine/topologies/tilt/config/global.star +55 -0
- package/engine/topologies/tilt/config/profiles.star +382 -0
- package/engine/topologies/tilt/generators/agents_md.star +62 -0
- package/engine/topologies/tilt/generators/api_gateway.star +145 -0
- package/engine/topologies/tilt/generators/index.star +124 -0
- package/engine/topologies/tilt/generators/infisical/README.md +424 -0
- package/engine/topologies/tilt/generators/infisical/examples.star +312 -0
- package/engine/topologies/tilt/generators/infisical/index.star +57 -0
- package/engine/topologies/tilt/generators/infisical/machine_identity.star +420 -0
- package/engine/topologies/tilt/generators/infisical/organization.star +534 -0
- package/engine/topologies/tilt/generators/infisical/path_manager.star +476 -0
- package/engine/topologies/tilt/generators/infisical/secrets_generator.star +420 -0
- package/engine/topologies/tilt/generators/nginx_conf.star +143 -0
- package/engine/topologies/tilt/generators/npmrc.star +111 -0
- package/engine/topologies/tilt/generators/tsconfig.star +23 -0
- package/engine/topologies/tilt/generators/typescript/backend_library_tsconfig.star +71 -0
- package/engine/topologies/tilt/generators/typescript/backend_tsconfig.star +124 -0
- package/engine/topologies/tilt/generators/typescript/common.star +7 -0
- package/engine/topologies/tilt/generators/typescript/frontend_library_tsconfig.star +76 -0
- package/engine/topologies/tilt/generators/typescript/frontend_tsconfig.star +110 -0
- package/engine/topologies/tilt/generators/typescript/include.star +23 -0
- package/engine/topologies/tilt/generators/typescript/playwright_config.star +40 -0
- package/engine/topologies/tilt/generators/typescript/prisma_config.star +49 -0
- package/engine/topologies/tilt/generators/validators.star +853 -0
- package/engine/topologies/tilt/generators/vite/backend.star +78 -0
- package/engine/topologies/tilt/generators/vite/frontend.star +98 -0
- package/engine/topologies/tilt/generators/vite/generators.star +43 -0
- package/engine/topologies/tilt/generators/vite/helpers.star +244 -0
- package/engine/topologies/tilt/generators/vite/library.star +65 -0
- package/engine/topologies/tilt/generators/vite/sdk.star +73 -0
- package/engine/topologies/tilt/generators/vite/templates.star +737 -0
- package/engine/topologies/tilt/generators/vite_config.star +22 -0
- package/engine/topologies/tilt/manifest/AGENTS.md +61 -0
- package/engine/topologies/tilt/manifest/README.md +693 -0
- package/engine/topologies/tilt/manifest/__init__.star +218 -0
- package/engine/topologies/tilt/manifest/constants.star +252 -0
- package/engine/topologies/tilt/manifest/errors.star +266 -0
- package/engine/topologies/tilt/manifest/integration.star +339 -0
- package/engine/topologies/tilt/manifest/json_to_yaml.py +54 -0
- package/engine/topologies/tilt/manifest/loader.star +214 -0
- package/engine/topologies/tilt/manifest/mapper.star +227 -0
- package/engine/topologies/tilt/manifest/parser.star +400 -0
- package/engine/topologies/tilt/manifest/schema.star +462 -0
- package/engine/topologies/tilt/manifest/tests/test_integration.star +276 -0
- package/engine/topologies/tilt/manifest/tests/test_loader_parser.star +397 -0
- package/engine/topologies/tilt/manifest/tests/test_manifest.star +316 -0
- package/engine/topologies/tilt/manifest/tests/test_validator.star +470 -0
- package/engine/topologies/tilt/manifest/validator.star +717 -0
- package/engine/topologies/tilt/manifest/yaml_to_json.py +18 -0
- package/engine/topologies/tilt/resources/AGENTS.md +71 -0
- package/engine/topologies/tilt/resources/conditions.star +3 -0
- package/engine/topologies/tilt/resources/databases.star +244 -0
- package/engine/topologies/tilt/resources/declaration.star +3 -0
- package/engine/topologies/tilt/resources/deps.star +3 -0
- package/engine/topologies/tilt/resources/infra-loader.star +437 -0
- package/engine/topologies/tilt/resources/libs.star +30 -0
- package/engine/topologies/tilt/resources/libs_discovery.star +102 -0
- package/engine/topologies/tilt/resources/libs_paths.star +79 -0
- package/engine/topologies/tilt/resources/libs_resource_definition.star +151 -0
- package/engine/topologies/tilt/resources/libs_setup.star +164 -0
- package/engine/topologies/tilt/resources/libs_tsconfig.star +37 -0
- package/engine/topologies/tilt/resources/orchestrator/apply.star +77 -0
- package/engine/topologies/tilt/resources/orchestrator/apply_compose_resource_registration.star +431 -0
- package/engine/topologies/tilt/resources/orchestrator/apply_manifest_orchestration.star +81 -0
- package/engine/topologies/tilt/resources/orchestrator/apply_migrator_orchestration.star +148 -0
- package/engine/topologies/tilt/resources/orchestrator/apply_resource_validation.star +36 -0
- package/engine/topologies/tilt/resources/orchestrator/apply_runtime_flags.star +44 -0
- package/engine/topologies/tilt/resources/orchestrator/builders/typescript.star +164 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/AGENTS.md +75 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/index.star +21 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/resolver.star +134 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/env.star +258 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/frontend.star +169 -0
- package/engine/topologies/tilt/resources/orchestrator/generators/manifest_resource.star +524 -0
- package/engine/topologies/tilt/resources/orchestrator/helpers.star +33 -0
- package/engine/topologies/tilt/resources/orchestrator.star +54 -0
- package/engine/topologies/tilt/resources/ordering.star +3 -0
- package/engine/topologies/tilt/resources/triggers.star +3 -0
- package/engine/topologies/tilt/resources/watchers.star +299 -0
- package/engine/where-things-live.star +717 -0
- package/ext/Tiltfile +66 -0
- package/ext/ide-components/README.md +219 -0
- package/ext/ide-components/code_executor/server.py +268 -0
- package/ext/ide-components/code_viewer/server.py +206 -0
- package/ext/ide-components/config_inspector/server.py +1050 -0
- package/ext/ide-components/file_browser/server.py +285 -0
- package/ext/ide-components/shared/config_service.py +469 -0
- package/ext/ide-components/shared/file_utils.py +298 -0
- package/ext/ide-components/shared/http_utils.py +232 -0
- package/ext/ide-components/shared/static/styles.css +1334 -0
- package/ext/ide-components/shared/syntax_highlighter.py +140 -0
- package/ext/ide-components/shared/template_engine.py +123 -0
- package/ext/ide-components/shared/templates/base.html +121 -0
- package/ext/ide-components/shared/test_config_service.py +326 -0
- package/ext/ide-components/shared/tilt_integration.py +158 -0
- package/ext/ui-enhancements/cron-status-server.sh +49 -0
- package/ext/ui-enhancements/cron-status-tracker.sh +146 -0
- package/ext/ui-enhancements/extension.yaml +36 -0
- package/ext/ui-enhancements/tiltfile.py +99 -0
- package/ext/ui-enhancements/ui/cron-jobs-tab.css +396 -0
- package/ext/ui-enhancements/ui/help-panel.css +279 -0
- package/ext/ui-enhancements/ui/icons.css +125 -0
- package/ext/ui-enhancements/ui/tooltips.css +114 -0
- package/package.json +13 -9
- package/specs/specs/TILT_SERVICE_DEFAULTS.star +205 -0
- package/specs/specs/TILT_TECH_STACK.star +159 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# 🎯 TILT ENTRYPOINT MODULE (Phase 1 Topologies Migration)
|
|
3
|
+
# =============================================================================
|
|
4
|
+
|
|
5
|
+
# Core
|
|
6
|
+
load("./topologies/tilt/common/utils.star", _Utils = "Utils")
|
|
7
|
+
load("./topologies/tilt/discovery/loading.star", _Manifest = "Manifest")
|
|
8
|
+
load("./topologies/tilt/config/global.star", _Config = "Config")
|
|
9
|
+
|
|
10
|
+
# Discovery Daemon (auto-discovery of new services)
|
|
11
|
+
load("./topologies/tilt/discovery/discovery_daemon.star", "run_discovery_daemon")
|
|
12
|
+
|
|
13
|
+
# Registry (migrated to topologies adapter with autogenerated product outputs)
|
|
14
|
+
load(
|
|
15
|
+
"./topologies/tilt/discovery/resource_registry.star",
|
|
16
|
+
_GLOBAL_CONFIG_EXPORT = "GLOBAL_CONFIG_EXPORT",
|
|
17
|
+
_APP_RESOURCES = "APP_RESOURCES",
|
|
18
|
+
_INFRA_RESOURCES_EXPORT = "INFRA_RESOURCES_EXPORT",
|
|
19
|
+
_DDD_LIBS_EXPORT = "DDD_LIBS_EXPORT",
|
|
20
|
+
_DEFAULTS_EXPORT = "DEFAULTS_EXPORT",
|
|
21
|
+
_RESOURCE_ALIASES = "RESOURCE_ALIASES",
|
|
22
|
+
_RESOURCE_PATH_MAP = "RESOURCE_PATH_MAP",
|
|
23
|
+
_get_platform_libs_export = "get_platform_libs_export",
|
|
24
|
+
_get_product_libs_export = "get_product_libs_export",
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
# Providers
|
|
28
|
+
load("./topologies/tilt/generators/vite_config.star", _Vite = "Vite")
|
|
29
|
+
load("./topologies/tilt/generators/tsconfig.star", _TSConfig = "TSConfig")
|
|
30
|
+
load("./topologies/platform/docker/index.star", _Docker = "Docker")
|
|
31
|
+
load("./topologies/tilt/generators/npmrc.star", _PackageConfig = "PackageConfig")
|
|
32
|
+
|
|
33
|
+
# Lifecycle
|
|
34
|
+
load("./topologies/tilt/resources/deps.star", _Libs = "Libs")
|
|
35
|
+
load("./topologies/tilt/resources/conditions.star", _Database = "Database")
|
|
36
|
+
load("./topologies/tilt/resources/declaration.star", _Orchestrator = "Orchestrator")
|
|
37
|
+
load("./topologies/tilt/resources/ordering.star", _Infra = "Infra")
|
|
38
|
+
load("./topologies/tilt/resources/triggers.star", _Watchers = "Watchers")
|
|
39
|
+
|
|
40
|
+
Utils = _Utils
|
|
41
|
+
Manifest = _Manifest
|
|
42
|
+
Config = _Config
|
|
43
|
+
|
|
44
|
+
GLOBAL_CONFIG_EXPORT = _GLOBAL_CONFIG_EXPORT
|
|
45
|
+
APP_RESOURCES = _APP_RESOURCES
|
|
46
|
+
INFRA_RESOURCES_EXPORT = _INFRA_RESOURCES_EXPORT
|
|
47
|
+
DDD_LIBS_EXPORT = _DDD_LIBS_EXPORT
|
|
48
|
+
DEFAULTS_EXPORT = _DEFAULTS_EXPORT
|
|
49
|
+
RESOURCE_ALIASES = _RESOURCE_ALIASES
|
|
50
|
+
RESOURCE_PATH_MAP = _RESOURCE_PATH_MAP
|
|
51
|
+
|
|
52
|
+
def get_platform_libs_export():
|
|
53
|
+
return _get_platform_libs_export()
|
|
54
|
+
|
|
55
|
+
def get_product_libs_export():
|
|
56
|
+
return _get_product_libs_export()
|
|
57
|
+
|
|
58
|
+
Vite = _Vite
|
|
59
|
+
TSConfig = _TSConfig
|
|
60
|
+
Docker = _Docker
|
|
61
|
+
PackageConfig = _PackageConfig
|
|
62
|
+
|
|
63
|
+
Libs = _Libs
|
|
64
|
+
Database = _Database
|
|
65
|
+
Orchestrator = _Orchestrator
|
|
66
|
+
Infra = _Infra
|
|
67
|
+
Watchers = _Watchers
|
|
68
|
+
|
|
69
|
+
# =============================================================================
|
|
70
|
+
# 🔮 AUTO-DISCOVERY DAEMON
|
|
71
|
+
# =============================================================================
|
|
72
|
+
# Start the service discovery daemon if auto-discovery is enabled
|
|
73
|
+
# This monitors for new service.json files and auto-registers them
|
|
74
|
+
# =============================================================================
|
|
75
|
+
|
|
76
|
+
_AUTO_DISCOVER_ENABLED = os.environ.get("AUTO_DISCOVER", "true").lower() == "true"
|
|
77
|
+
_DISCOVERY_SCAN_INTERVAL = int(os.environ.get("DISCOVERY_SCAN_INTERVAL", "5"))
|
|
78
|
+
|
|
79
|
+
if _AUTO_DISCOVER_ENABLED:
|
|
80
|
+
print("🔮 Auto-discovery enabled (scan interval: {}s)".format(_DISCOVERY_SCAN_INTERVAL))
|
|
81
|
+
# Run daemon in background via local_resource
|
|
82
|
+
# Use unique name to avoid conflicts on reload
|
|
83
|
+
local_resource(
|
|
84
|
+
name="service-discovery-daemon-v2",
|
|
85
|
+
serve_cmd="cd {} && python3 discovery/resource_snapshot.py watch".format(os.getcwd()),
|
|
86
|
+
deps=["services/product"],
|
|
87
|
+
auto_init=True,
|
|
88
|
+
labels=["infra", "discovery"],
|
|
89
|
+
)
|
|
90
|
+
print("👁️ Service discovery daemon running")
|
|
91
|
+
print(" └─ New services will be auto-detected and registered")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# Inlined constant
|
|
95
|
+
DEFAULTS = {}
|
|
96
|
+
|
|
97
|
+
GLOBAL_CONFIG = {}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# =============================================================================
|
|
2
|
+
# 🔄 TILT LIFECYCLE - SERVICE STARTUP ORCHESTRATOR
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# Path: .tilt/lifecycle/orchestrator.star
|
|
5
|
+
# Purpose: Service startup sequencing and grace period management
|
|
6
|
+
# =============================================================================
|
|
7
|
+
#
|
|
8
|
+
# This module implements Story 4 - Fix API Gateway 504 Errors:
|
|
9
|
+
# - Service startup sequencing
|
|
10
|
+
# - 30-second grace period configuration
|
|
11
|
+
# - Proper health check orchestration
|
|
12
|
+
# - Zero 504 errors on startup
|
|
13
|
+
#
|
|
14
|
+
# =============================================================================
|
|
15
|
+
|
|
16
|
+
# === INLINED CONSTANTS for pure extension loading ===
|
|
17
|
+
HEALTH_CHECK_PATH = "/health"
|
|
18
|
+
# === END INLINED CONSTANTS ===
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
load('../topologies/platform/docker/networking/traefik_constants.star',
|
|
22
|
+
'TRAEFIK_STARTUP_GRACE_PERIOD',
|
|
23
|
+
'TRAEFIK_RESOURCE_STARTUP_DELAY',
|
|
24
|
+
'TRAEFIK_HEALTHY_THRESHOLD',
|
|
25
|
+
'TRAEFIK_HEALTHCHECK_INTERVAL',
|
|
26
|
+
'TRAEFIK_HEALTHCHECK_TIMEOUT',
|
|
27
|
+
'TRAEFIK_HEALTHCHECK_RETRIES',
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# =============================================================================
|
|
32
|
+
# 📋 STARTUP SEQUENCING CONFIGURATION
|
|
33
|
+
# =============================================================================
|
|
34
|
+
|
|
35
|
+
# Service startup phases - ensure infrastructure is ready before apps
|
|
36
|
+
STARTUP_PHASES = {
|
|
37
|
+
'infra': [
|
|
38
|
+
'TDK_postgres',
|
|
39
|
+
'TDK_nats',
|
|
40
|
+
'TDK_infisical',
|
|
41
|
+
'verdaccio',
|
|
42
|
+
],
|
|
43
|
+
'proxy': [
|
|
44
|
+
'TDK_traefik',
|
|
45
|
+
'TDK_dashy',
|
|
46
|
+
],
|
|
47
|
+
'migrators': [], # Populated dynamically based on enabled services
|
|
48
|
+
'apps': [], # Populated dynamically based on enabled services
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
# Grace period configuration for each service type
|
|
52
|
+
GRACE_PERIOD_CONFIG = {
|
|
53
|
+
'backend': {
|
|
54
|
+
'start_period': '60s', # Time before health checks begin
|
|
55
|
+
'interval': '10s', # Health check interval
|
|
56
|
+
'timeout': '5s', # Health check timeout
|
|
57
|
+
'retries': 6, # Retries before marking unhealthy
|
|
58
|
+
'startup_delay': '10s', # Delay before service receives traffic
|
|
59
|
+
},
|
|
60
|
+
'frontend': {
|
|
61
|
+
'start_period': '30s',
|
|
62
|
+
'interval': '10s',
|
|
63
|
+
'timeout': '5s',
|
|
64
|
+
'retries': 3,
|
|
65
|
+
'startup_delay': '5s',
|
|
66
|
+
},
|
|
67
|
+
'infra': {
|
|
68
|
+
'start_period': '30s',
|
|
69
|
+
'interval': '5s',
|
|
70
|
+
'timeout': '5s',
|
|
71
|
+
'retries': 10,
|
|
72
|
+
'startup_delay': '5s',
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
# =============================================================================
|
|
77
|
+
# 🚀 STARTUP SEQUENCING FUNCTIONS
|
|
78
|
+
# =============================================================================
|
|
79
|
+
|
|
80
|
+
def get_resource_phase(resource_name, resource_config):
|
|
81
|
+
"""Determine which startup phase a service belongs to."""
|
|
82
|
+
# Check if it's an infrastructure service
|
|
83
|
+
if resource_name in STARTUP_PHASES['infra']:
|
|
84
|
+
return 'infra'
|
|
85
|
+
|
|
86
|
+
# Check if it's a proxy service
|
|
87
|
+
if resource_name in STARTUP_PHASES['proxy']:
|
|
88
|
+
return 'proxy'
|
|
89
|
+
|
|
90
|
+
# Check if service has migrator
|
|
91
|
+
resources = resource_config.get('resources', [])
|
|
92
|
+
for res in resources:
|
|
93
|
+
if 'migrator' in res.get('name', ''):
|
|
94
|
+
return 'migrators'
|
|
95
|
+
|
|
96
|
+
# Default to apps
|
|
97
|
+
return 'apps'
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def get_grace_period_config(resource_type):
|
|
101
|
+
"""Get grace period configuration for a service type."""
|
|
102
|
+
return GRACE_PERIOD_CONFIG.get(resource_type, GRACE_PERIOD_CONFIG['backend'])
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def calculate_total_startup_time(resource_type):
|
|
106
|
+
"""
|
|
107
|
+
Calculate total time for a service to be considered healthy.
|
|
108
|
+
Formula: start_period + (retries * interval) + buffer
|
|
109
|
+
"""
|
|
110
|
+
config = get_grace_period_config(resource_type)
|
|
111
|
+
start_period_seconds = _parse_duration(config['start_period'])
|
|
112
|
+
interval_seconds = _parse_duration(config['interval'])
|
|
113
|
+
retries = config['retries']
|
|
114
|
+
|
|
115
|
+
# Total time = start_period + (retries * interval) + 5s buffer
|
|
116
|
+
total_seconds = start_period_seconds + (retries * interval_seconds) + 5
|
|
117
|
+
return total_seconds
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _parse_duration(duration_str):
|
|
121
|
+
"""Parse duration string (e.g., '60s', '5m') to seconds."""
|
|
122
|
+
if not duration_str:
|
|
123
|
+
return 0
|
|
124
|
+
|
|
125
|
+
duration_str = str(duration_str).strip().lower()
|
|
126
|
+
|
|
127
|
+
if duration_str.endswith('s'):
|
|
128
|
+
return int(duration_str[:-1])
|
|
129
|
+
elif duration_str.endswith('m'):
|
|
130
|
+
return int(duration_str[:-1]) * 60
|
|
131
|
+
elif duration_str.endswith('h'):
|
|
132
|
+
return int(duration_str[:-1]) * 3600
|
|
133
|
+
else:
|
|
134
|
+
# Assume seconds if no unit
|
|
135
|
+
return int(duration_str)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
# =============================================================================
|
|
139
|
+
# 🔍 HEALTH CHECK ORCHESTRATION
|
|
140
|
+
# =============================================================================
|
|
141
|
+
|
|
142
|
+
def get_health_check_config(resource_name, resource_type='backend', port=3000):
|
|
143
|
+
"""
|
|
144
|
+
Generate health check configuration for a service.
|
|
145
|
+
Ensures proper sequencing to prevent 504 errors.
|
|
146
|
+
"""
|
|
147
|
+
config = get_grace_period_config(resource_type)
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
'test': ['CMD', 'curl', '-f', '--max-time', '5',
|
|
151
|
+
'http://localhost:' + str(port) + '/health'],
|
|
152
|
+
'interval': config['interval'],
|
|
153
|
+
'timeout': config['timeout'],
|
|
154
|
+
'retries': config['retries'],
|
|
155
|
+
'start_period': config['start_period'],
|
|
156
|
+
'disable': False,
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def get_traefik_health_check_labels(resource_name, health_path=HEALTH_CHECK_PATH):
|
|
161
|
+
"""
|
|
162
|
+
Generate Traefik health check labels for load balancer.
|
|
163
|
+
These ensure Traefik only routes to healthy services.
|
|
164
|
+
"""
|
|
165
|
+
return {
|
|
166
|
+
'traefik.http.services.{}.loadbalancer.healthcheck.path'.format(resource_name): health_path,
|
|
167
|
+
'traefik.http.services.{}.loadbalancer.healthcheck.interval'.format(resource_name): TRAEFIK_HEALTHCHECK_INTERVAL,
|
|
168
|
+
'traefik.http.services.{}.loadbalancer.healthcheck.timeout'.format(resource_name): TRAEFIK_HEALTHCHECK_TIMEOUT,
|
|
169
|
+
# Disable health check initially during startup grace period
|
|
170
|
+
'traefik.http.services.{}.loadbalancer.healthcheck.disable'.format(resource_name): 'false',
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
# =============================================================================
|
|
175
|
+
# ⏱️ STARTUP DELAY AND SYNCHRONIZATION
|
|
176
|
+
# =============================================================================
|
|
177
|
+
|
|
178
|
+
def get_startup_delay(resource_type='backend'):
|
|
179
|
+
"""Get the startup delay for a service type before it receives traffic."""
|
|
180
|
+
config = get_grace_period_config(resource_type)
|
|
181
|
+
return config['startup_delay']
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def should_wait_for_dependencies(resource_config):
|
|
185
|
+
"""
|
|
186
|
+
Determine if a service should wait for dependencies before starting.
|
|
187
|
+
Returns list of dependencies to wait for.
|
|
188
|
+
"""
|
|
189
|
+
dependencies = []
|
|
190
|
+
|
|
191
|
+
# Check for database dependency
|
|
192
|
+
resources = resource_config.get('resources', [])
|
|
193
|
+
for res in resources:
|
|
194
|
+
manifest = res.get('_manifest', {})
|
|
195
|
+
if manifest.get('databaseName') or manifest.get('features', []).count('prisma') > 0:
|
|
196
|
+
dependencies.append('database-management')
|
|
197
|
+
break
|
|
198
|
+
|
|
199
|
+
# Check for NATS dependency
|
|
200
|
+
for res in resources:
|
|
201
|
+
manifest = res.get('_manifest', {})
|
|
202
|
+
if 'nats' in manifest.get('features', []):
|
|
203
|
+
dependencies.append('messaging')
|
|
204
|
+
break
|
|
205
|
+
|
|
206
|
+
return dependencies
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
# =============================================================================
|
|
210
|
+
# 🎯 SERVICE READINESS CHECKS
|
|
211
|
+
# =============================================================================
|
|
212
|
+
|
|
213
|
+
def is_resource_ready(resource_name, resource_config):
|
|
214
|
+
"""
|
|
215
|
+
Check if a service is ready to receive traffic.
|
|
216
|
+
Used by Tilt resource_deps to sequence service startup.
|
|
217
|
+
"""
|
|
218
|
+
phase = get_resource_phase(resource_name, resource_config)
|
|
219
|
+
|
|
220
|
+
# Infrastructure services must be healthy first
|
|
221
|
+
if phase == 'infra':
|
|
222
|
+
return True # These are handled by docker-compose health checks
|
|
223
|
+
|
|
224
|
+
# Proxy services depend on infra
|
|
225
|
+
if phase == 'proxy':
|
|
226
|
+
return 'infra' # Wait for infra phase
|
|
227
|
+
|
|
228
|
+
# Migrators depend on database
|
|
229
|
+
if phase == 'migrators':
|
|
230
|
+
return 'database-management'
|
|
231
|
+
|
|
232
|
+
# Apps depend on their migrators and infrastructure
|
|
233
|
+
return 'migrators' # Wait for migrators
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
# =============================================================================
|
|
237
|
+
# 📊 ORCHESTRATOR PUBLIC API
|
|
238
|
+
# =============================================================================
|
|
239
|
+
|
|
240
|
+
Orchestrator = struct(
|
|
241
|
+
# Phase detection
|
|
242
|
+
get_resource_phase=get_resource_phase,
|
|
243
|
+
|
|
244
|
+
# Grace period configuration
|
|
245
|
+
get_grace_period_config=get_grace_period_config,
|
|
246
|
+
calculate_total_startup_time=calculate_total_startup_time,
|
|
247
|
+
|
|
248
|
+
# Health check configuration
|
|
249
|
+
get_health_check_config=get_health_check_config,
|
|
250
|
+
get_traefik_health_check_labels=get_traefik_health_check_labels,
|
|
251
|
+
|
|
252
|
+
# Startup synchronization
|
|
253
|
+
get_startup_delay=get_startup_delay,
|
|
254
|
+
should_wait_for_dependencies=should_wait_for_dependencies,
|
|
255
|
+
is_resource_ready=is_resource_ready,
|
|
256
|
+
|
|
257
|
+
# Constants
|
|
258
|
+
STARTUP_PHASES=STARTUP_PHASES,
|
|
259
|
+
GRACE_PERIOD_CONFIG=GRACE_PERIOD_CONFIG,
|
|
260
|
+
)
|