@tdk-landscape/tdk-cli-core 1.3.14 → 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.
Files changed (277) hide show
  1. package/README.md +3 -3
  2. package/Tiltfile +144 -0
  3. package/discovery/AGENTS.md +362 -0
  4. package/discovery/TILT_DISCOVERY.star +424 -0
  5. package/discovery/Tiltfile +58 -0
  6. package/discovery/config.star +258 -0
  7. package/discovery/constants.star +127 -0
  8. package/discovery/deterministic.star +211 -0
  9. package/discovery/discovery_daemon.star +191 -0
  10. package/discovery/discovery_orchestrator.star +460 -0
  11. package/discovery/filtering.star +5 -0
  12. package/discovery/identity-management-backend/service.yaml +26 -0
  13. package/discovery/identity-management-frontend/service.yaml +29 -0
  14. package/discovery/identity-sdk/service.yaml +9 -0
  15. package/discovery/incremental_discovery.star +213 -0
  16. package/discovery/indexing.star +7 -0
  17. package/discovery/json_manifest_scanner.star +51 -0
  18. package/discovery/libraries.star +46 -0
  19. package/discovery/loading.star +23 -0
  20. package/discovery/manifest/constants.star +104 -0
  21. package/discovery/manifest/loading.star +386 -0
  22. package/discovery/manifest/normalize.star +281 -0
  23. package/discovery/manifest/validation.star +108 -0
  24. package/discovery/normalization.star +11 -0
  25. package/discovery/registry.star +544 -0
  26. package/discovery/resource_snapshot.py +382 -0
  27. package/discovery/resource_snapshot.star +143 -0
  28. package/discovery/schemas.star +1 -0
  29. package/discovery/services/platform/cdc/debezium/nats-connector/service.yaml +9 -0
  30. package/discovery/services/platform/cdc/nats-http-bridge/service.yaml +9 -0
  31. package/discovery/services/platform/orchestrator/orchestrator-glue-backend/service.yaml +26 -0
  32. package/discovery/services/platform/synthetic-monitor/service.yaml +9 -0
  33. package/discovery/test_resource_snapshot.py +251 -0
  34. package/discovery/validation.star +78 -0
  35. package/discovery/versioning.star +1 -0
  36. package/dist/commands/config.d.ts.map +1 -1
  37. package/dist/commands/config.js +11 -0
  38. package/dist/commands/config.js.map +1 -1
  39. package/dist/commands/doctor.d.ts.map +1 -1
  40. package/dist/commands/doctor.js +1 -2
  41. package/dist/commands/doctor.js.map +1 -1
  42. package/dist/commands/project.d.ts.map +1 -1
  43. package/dist/commands/project.js +36 -41
  44. package/dist/commands/project.js.map +1 -1
  45. package/dist/commands/resource.d.ts.map +1 -1
  46. package/dist/commands/resource.js +51 -55
  47. package/dist/commands/resource.js.map +1 -1
  48. package/dist/commands/stack.d.ts.map +1 -1
  49. package/dist/commands/stack.js +22 -24
  50. package/dist/commands/stack.js.map +1 -1
  51. package/dist/commands/ui.d.ts.map +1 -1
  52. package/dist/commands/ui.js +1 -2
  53. package/dist/commands/ui.js.map +1 -1
  54. package/dist/commands/up.d.ts.map +1 -1
  55. package/dist/commands/up.js +1 -2
  56. package/dist/commands/up.js.map +1 -1
  57. package/dist/commands/upgrade.d.ts +8 -0
  58. package/dist/commands/upgrade.d.ts.map +1 -1
  59. package/dist/commands/upgrade.js +62 -21
  60. package/dist/commands/upgrade.js.map +1 -1
  61. package/dist/generator/extension-fetch.d.ts +19 -0
  62. package/dist/generator/extension-fetch.d.ts.map +1 -1
  63. package/dist/generator/extension-fetch.js +71 -5
  64. package/dist/generator/extension-fetch.js.map +1 -1
  65. package/dist/generator/template-engine.d.ts +1 -0
  66. package/dist/generator/template-engine.d.ts.map +1 -1
  67. package/dist/generator/template-engine.js +50 -6
  68. package/dist/generator/template-engine.js.map +1 -1
  69. package/dist/utils/command-helpers.d.ts.map +1 -1
  70. package/dist/utils/command-helpers.js +7 -9
  71. package/dist/utils/command-helpers.js.map +1 -1
  72. package/dist/utils/constants.d.ts +1 -0
  73. package/dist/utils/constants.d.ts.map +1 -1
  74. package/dist/utils/constants.js +1 -0
  75. package/dist/utils/constants.js.map +1 -1
  76. package/dist/utils/errors.d.ts +2 -0
  77. package/dist/utils/errors.d.ts.map +1 -1
  78. package/dist/utils/errors.js +6 -1
  79. package/dist/utils/errors.js.map +1 -1
  80. package/dist/utils/paths.js +1 -1
  81. package/dist/utils/paths.js.map +1 -1
  82. package/dist/utils/project-features.d.ts.map +1 -1
  83. package/dist/utils/project-features.js +1 -1
  84. package/dist/utils/project-features.js.map +1 -1
  85. package/dist/utils/resource-features.d.ts.map +1 -1
  86. package/dist/utils/resource-features.js +2 -2
  87. package/dist/utils/resource-features.js.map +1 -1
  88. package/dist/utils/tar.js +4 -4
  89. package/dist/utils/tar.js.map +1 -1
  90. package/dist/utils/validation.d.ts +7 -0
  91. package/dist/utils/validation.d.ts.map +1 -1
  92. package/dist/utils/validation.js +9 -0
  93. package/dist/utils/validation.js.map +1 -1
  94. package/engine/AGENTS.md +705 -0
  95. package/engine/README.md +29 -0
  96. package/engine/REFACTORING_MANIFEST_SYSTEM.md +974 -0
  97. package/engine/Tiltfile +80 -0
  98. package/engine/assets/docker/golden-layers.Dockerfile +221 -0
  99. package/engine/assets/scripts/cleanup-completed-migrator-images.sh +37 -0
  100. package/engine/assets/scripts/cleanup-tilt-images.sh +120 -0
  101. package/engine/assets/scripts/mac-m1-resource-monitor.sh +121 -0
  102. package/engine/config.star +3 -0
  103. package/engine/docs/AUTODISCOVERY_TEST.md +182 -0
  104. package/engine/docs/C4-ARCHITECTURE-operations.md +396 -0
  105. package/engine/docs/C4-ARCHITECTURE-overview.md +284 -0
  106. package/engine/docs/C4-ARCHITECTURE.md +17 -0
  107. package/engine/docs/GOLDEN_IMAGE_INTEGRATION.md +349 -0
  108. package/engine/docs/MANIFEST_DRIVEN_ARCHITECTURE.md +357 -0
  109. package/engine/docs/README.md +284 -0
  110. package/engine/entrypoint.star +97 -0
  111. package/engine/lifecycle/orchestrator.star +260 -0
  112. package/engine/paths.star +717 -0
  113. package/engine/schemas/manifest-schema.json +301 -0
  114. package/engine/schemas/service-schema.json +301 -0
  115. package/engine/scripts/README.md +89 -0
  116. package/engine/scripts/build-and-publish-lib.sh +205 -0
  117. package/engine/scripts/check-lib-publish.sh +85 -0
  118. package/engine/scripts/debug-container.sh +258 -0
  119. package/engine/scripts/generate-manifest.sh +197 -0
  120. package/engine/spec.master +702 -0
  121. package/engine/spec.master.example +341 -0
  122. package/engine/topologies/README.md +34 -0
  123. package/engine/topologies/platform/docker/AGENTS.md +59 -0
  124. package/engine/topologies/platform/docker/auth/auth.star +167 -0
  125. package/engine/topologies/platform/docker/build/golden_image.star +37 -0
  126. package/engine/topologies/platform/docker/build/golden_image_build.star +82 -0
  127. package/engine/topologies/platform/docker/build/golden_image_constants.star +93 -0
  128. package/engine/topologies/platform/docker/build/golden_image_dockerfile.star +291 -0
  129. package/engine/topologies/platform/docker/compose/compose.star +636 -0
  130. package/engine/topologies/platform/docker/compose/compose_helpers.star +52 -0
  131. package/engine/topologies/platform/docker/compose/traefik_standalone.star +53 -0
  132. package/engine/topologies/platform/docker/config/bunignore.star +142 -0
  133. package/engine/topologies/platform/docker/config/dockerignore.star +150 -0
  134. package/engine/topologies/platform/docker/constants.star +170 -0
  135. package/engine/topologies/platform/docker/dockerfile/dockerfile.star +54 -0
  136. package/engine/topologies/platform/docker/generators/golden_docker_generator_v2.star +73 -0
  137. package/engine/topologies/platform/docker/index.star +27 -0
  138. package/engine/topologies/platform/docker/layers/bun_helpers.star +23 -0
  139. package/engine/topologies/platform/docker/layers/infisical/index.star +40 -0
  140. package/engine/topologies/platform/docker/layers/infisical/infisical_docker.star +262 -0
  141. package/engine/topologies/platform/docker/layers/l1_base_layers.star +87 -0
  142. package/engine/topologies/platform/docker/layers/l2_dependency_layers.star +125 -0
  143. package/engine/topologies/platform/docker/layers/l3_builder_layers.star +209 -0
  144. package/engine/topologies/platform/docker/layers/l4_runtime_layers.star +214 -0
  145. package/engine/topologies/platform/docker/layers/prisma/constants.star +135 -0
  146. package/engine/topologies/platform/docker/layers/prisma/db_readiness.star +96 -0
  147. package/engine/topologies/platform/docker/layers/prisma/filesystem_setup.star +109 -0
  148. package/engine/topologies/platform/docker/layers/prisma/migrate_script.star +98 -0
  149. package/engine/topologies/platform/docker/layers/prisma/prisma_build.star +126 -0
  150. package/engine/topologies/platform/docker/layers/prisma/prisma_runtime.star +161 -0
  151. package/engine/topologies/platform/docker/layers/prisma/secret_resolution.star +119 -0
  152. package/engine/topologies/platform/docker/networking/api_path_constants.star +230 -0
  153. package/engine/topologies/platform/docker/networking/sablier_container_cycle.star +27 -0
  154. package/engine/topologies/platform/docker/networking/traefik.star +232 -0
  155. package/engine/topologies/platform/docker/networking/traefik_constants.star +146 -0
  156. package/engine/topologies/platform/docker/networking/traefik_helpers.star +160 -0
  157. package/engine/topologies/platform/docker/secrets/infisical.star +135 -0
  158. package/engine/topologies/platform/net/proxy.star +4 -0
  159. package/engine/topologies/platform/registries/local.star +4 -0
  160. package/engine/topologies/platform/security/secrets.star +239 -0
  161. package/engine/topologies/platform/state/relational.star +4 -0
  162. package/engine/topologies/tilt/common/AGENTS.md +59 -0
  163. package/engine/topologies/tilt/common/utils.star +364 -0
  164. package/engine/topologies/tilt/common/utils_debug.star +69 -0
  165. package/engine/topologies/tilt/common/utils_deterministic.star +168 -0
  166. package/engine/topologies/tilt/common/utils_docker_networks.star +46 -0
  167. package/engine/topologies/tilt/common/utils_env.star +43 -0
  168. package/engine/topologies/tilt/common/utils_output.star +97 -0
  169. package/engine/topologies/tilt/config/AGENTS.md +68 -0
  170. package/engine/topologies/tilt/config/defaults.star +3 -0
  171. package/engine/topologies/tilt/config/feature_flags.star +10 -0
  172. package/engine/topologies/tilt/config/global.star +55 -0
  173. package/engine/topologies/tilt/config/profiles.star +382 -0
  174. package/engine/topologies/tilt/generators/agents_md.star +62 -0
  175. package/engine/topologies/tilt/generators/api_gateway.star +145 -0
  176. package/engine/topologies/tilt/generators/index.star +124 -0
  177. package/engine/topologies/tilt/generators/infisical/README.md +424 -0
  178. package/engine/topologies/tilt/generators/infisical/examples.star +312 -0
  179. package/engine/topologies/tilt/generators/infisical/index.star +57 -0
  180. package/engine/topologies/tilt/generators/infisical/machine_identity.star +420 -0
  181. package/engine/topologies/tilt/generators/infisical/organization.star +534 -0
  182. package/engine/topologies/tilt/generators/infisical/path_manager.star +476 -0
  183. package/engine/topologies/tilt/generators/infisical/secrets_generator.star +420 -0
  184. package/engine/topologies/tilt/generators/nginx_conf.star +143 -0
  185. package/engine/topologies/tilt/generators/npmrc.star +111 -0
  186. package/engine/topologies/tilt/generators/tsconfig.star +23 -0
  187. package/engine/topologies/tilt/generators/typescript/backend_library_tsconfig.star +71 -0
  188. package/engine/topologies/tilt/generators/typescript/backend_tsconfig.star +124 -0
  189. package/engine/topologies/tilt/generators/typescript/common.star +7 -0
  190. package/engine/topologies/tilt/generators/typescript/frontend_library_tsconfig.star +76 -0
  191. package/engine/topologies/tilt/generators/typescript/frontend_tsconfig.star +110 -0
  192. package/engine/topologies/tilt/generators/typescript/include.star +23 -0
  193. package/engine/topologies/tilt/generators/typescript/playwright_config.star +40 -0
  194. package/engine/topologies/tilt/generators/typescript/prisma_config.star +49 -0
  195. package/engine/topologies/tilt/generators/validators.star +853 -0
  196. package/engine/topologies/tilt/generators/vite/backend.star +78 -0
  197. package/engine/topologies/tilt/generators/vite/frontend.star +98 -0
  198. package/engine/topologies/tilt/generators/vite/generators.star +43 -0
  199. package/engine/topologies/tilt/generators/vite/helpers.star +244 -0
  200. package/engine/topologies/tilt/generators/vite/library.star +65 -0
  201. package/engine/topologies/tilt/generators/vite/sdk.star +73 -0
  202. package/engine/topologies/tilt/generators/vite/templates.star +737 -0
  203. package/engine/topologies/tilt/generators/vite_config.star +22 -0
  204. package/engine/topologies/tilt/manifest/AGENTS.md +61 -0
  205. package/engine/topologies/tilt/manifest/README.md +693 -0
  206. package/engine/topologies/tilt/manifest/__init__.star +218 -0
  207. package/engine/topologies/tilt/manifest/constants.star +252 -0
  208. package/engine/topologies/tilt/manifest/errors.star +266 -0
  209. package/engine/topologies/tilt/manifest/integration.star +339 -0
  210. package/engine/topologies/tilt/manifest/json_to_yaml.py +54 -0
  211. package/engine/topologies/tilt/manifest/loader.star +214 -0
  212. package/engine/topologies/tilt/manifest/mapper.star +227 -0
  213. package/engine/topologies/tilt/manifest/parser.star +400 -0
  214. package/engine/topologies/tilt/manifest/schema.star +462 -0
  215. package/engine/topologies/tilt/manifest/tests/test_integration.star +276 -0
  216. package/engine/topologies/tilt/manifest/tests/test_loader_parser.star +397 -0
  217. package/engine/topologies/tilt/manifest/tests/test_manifest.star +316 -0
  218. package/engine/topologies/tilt/manifest/tests/test_validator.star +470 -0
  219. package/engine/topologies/tilt/manifest/validator.star +717 -0
  220. package/engine/topologies/tilt/manifest/yaml_to_json.py +18 -0
  221. package/engine/topologies/tilt/resources/AGENTS.md +71 -0
  222. package/engine/topologies/tilt/resources/conditions.star +3 -0
  223. package/engine/topologies/tilt/resources/databases.star +244 -0
  224. package/engine/topologies/tilt/resources/declaration.star +3 -0
  225. package/engine/topologies/tilt/resources/deps.star +3 -0
  226. package/engine/topologies/tilt/resources/infra-loader.star +437 -0
  227. package/engine/topologies/tilt/resources/libs.star +30 -0
  228. package/engine/topologies/tilt/resources/libs_discovery.star +102 -0
  229. package/engine/topologies/tilt/resources/libs_paths.star +79 -0
  230. package/engine/topologies/tilt/resources/libs_resource_definition.star +151 -0
  231. package/engine/topologies/tilt/resources/libs_setup.star +164 -0
  232. package/engine/topologies/tilt/resources/libs_tsconfig.star +37 -0
  233. package/engine/topologies/tilt/resources/orchestrator/apply.star +77 -0
  234. package/engine/topologies/tilt/resources/orchestrator/apply_compose_resource_registration.star +431 -0
  235. package/engine/topologies/tilt/resources/orchestrator/apply_manifest_orchestration.star +81 -0
  236. package/engine/topologies/tilt/resources/orchestrator/apply_migrator_orchestration.star +148 -0
  237. package/engine/topologies/tilt/resources/orchestrator/apply_resource_validation.star +36 -0
  238. package/engine/topologies/tilt/resources/orchestrator/apply_runtime_flags.star +44 -0
  239. package/engine/topologies/tilt/resources/orchestrator/builders/typescript.star +164 -0
  240. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/AGENTS.md +75 -0
  241. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/index.star +21 -0
  242. package/engine/topologies/tilt/resources/orchestrator/generators/dependencies/resolver.star +134 -0
  243. package/engine/topologies/tilt/resources/orchestrator/generators/env.star +258 -0
  244. package/engine/topologies/tilt/resources/orchestrator/generators/frontend.star +169 -0
  245. package/engine/topologies/tilt/resources/orchestrator/generators/manifest_resource.star +524 -0
  246. package/engine/topologies/tilt/resources/orchestrator/helpers.star +33 -0
  247. package/engine/topologies/tilt/resources/orchestrator.star +54 -0
  248. package/engine/topologies/tilt/resources/ordering.star +3 -0
  249. package/engine/topologies/tilt/resources/triggers.star +3 -0
  250. package/engine/topologies/tilt/resources/watchers.star +299 -0
  251. package/engine/where-things-live.star +717 -0
  252. package/ext/Tiltfile +66 -0
  253. package/ext/ide-components/README.md +219 -0
  254. package/ext/ide-components/code_executor/server.py +268 -0
  255. package/ext/ide-components/code_viewer/server.py +206 -0
  256. package/ext/ide-components/config_inspector/server.py +1050 -0
  257. package/ext/ide-components/file_browser/server.py +285 -0
  258. package/ext/ide-components/shared/config_service.py +469 -0
  259. package/ext/ide-components/shared/file_utils.py +298 -0
  260. package/ext/ide-components/shared/http_utils.py +232 -0
  261. package/ext/ide-components/shared/static/styles.css +1334 -0
  262. package/ext/ide-components/shared/syntax_highlighter.py +140 -0
  263. package/ext/ide-components/shared/template_engine.py +123 -0
  264. package/ext/ide-components/shared/templates/base.html +121 -0
  265. package/ext/ide-components/shared/test_config_service.py +326 -0
  266. package/ext/ide-components/shared/tilt_integration.py +158 -0
  267. package/ext/ui-enhancements/cron-status-server.sh +49 -0
  268. package/ext/ui-enhancements/cron-status-tracker.sh +146 -0
  269. package/ext/ui-enhancements/extension.yaml +36 -0
  270. package/ext/ui-enhancements/tiltfile.py +99 -0
  271. package/ext/ui-enhancements/ui/cron-jobs-tab.css +396 -0
  272. package/ext/ui-enhancements/ui/help-panel.css +279 -0
  273. package/ext/ui-enhancements/ui/icons.css +125 -0
  274. package/ext/ui-enhancements/ui/tooltips.css +114 -0
  275. package/package.json +13 -9
  276. package/specs/specs/TILT_SERVICE_DEFAULTS.star +205 -0
  277. package/specs/specs/TILT_TECH_STACK.star +159 -0
@@ -0,0 +1,420 @@
1
+ # =============================================================================
2
+ # 🤖 INFISICAL MACHINE IDENTITY MANAGER
3
+ # =============================================================================
4
+ # Manages Infisical Machine Identity configuration and authentication
5
+ # Replaces: Shell scripts for machine identity setup
6
+ # =============================================================================
7
+ #
8
+ # This module provides:
9
+ # - Machine Identity configuration generation
10
+ # - Authentication method definitions (Universal Auth, OIDC, etc.)
11
+ # - Client ID/Secret management patterns
12
+ # - Token lifecycle management
13
+ #
14
+ # Usage:
15
+ # load("./infisical/machine_identity.star", "MachineIdentity")
16
+ # config = MachineIdentity.generate_universal_auth("my-machine", "/services/user")
17
+ # =============================================================================
18
+
19
+ def _get_timestamp():
20
+ """Get current timestamp string"""
21
+ return str(local("date +%Y-%m-%dT%H:%M:%S", quiet=True)).strip()
22
+
23
+ # =============================================================================
24
+ # Machine Identity Types
25
+ # =============================================================================
26
+
27
+ AUTH_METHODS = {
28
+ "universal-auth": {
29
+ "name": "Universal Auth",
30
+ "description": "Client ID and Client Secret authentication",
31
+ "env_vars": ["INFISICAL_CLIENT_ID", "INFISICAL_CLIENT_SECRET"],
32
+ "supported": True,
33
+ "recommended": True,
34
+ },
35
+ "oidc-auth": {
36
+ "name": "OIDC Auth",
37
+ "description": "OpenID Connect authentication for cloud providers",
38
+ "env_vars": ["INFISICAL_OIDC_TOKEN"],
39
+ "supported": True,
40
+ "recommended": False,
41
+ },
42
+ "token-auth": {
43
+ "name": "Token Auth",
44
+ "description": "Service Token authentication (legacy)",
45
+ "env_vars": ["INFISICAL_TOKEN"],
46
+ "supported": True,
47
+ "recommended": False,
48
+ "deprecated": True,
49
+ },
50
+ "kubernetes-auth": {
51
+ "name": "Kubernetes Auth",
52
+ "description": "Kubernetes service account authentication",
53
+ "env_vars": ["INFISICAL_KUBERNETES_TOKEN"],
54
+ "supported": False,
55
+ "recommended": False,
56
+ },
57
+ "aws-auth": {
58
+ "name": "AWS IAM Auth",
59
+ "description": "AWS IAM role authentication",
60
+ "env_vars": ["AWS_ROLE_ARN", "AWS_WEB_IDENTITY_TOKEN_FILE"],
61
+ "supported": False,
62
+ "recommended": False,
63
+ },
64
+ }
65
+
66
+ # =============================================================================
67
+ # Default Configuration
68
+ # =============================================================================
69
+
70
+ DEFAULT_MACHINE_CONFIG = {
71
+ "auth_method": "universal-auth",
72
+ "token_ttl_seconds": 3600, # 1 hour
73
+ "max_uses": 0, # Unlimited
74
+ "access_level": "service", # service, project, organization
75
+ }
76
+
77
+ # =============================================================================
78
+ # Universal Auth Configuration
79
+ # =============================================================================
80
+
81
+ def _generate_universal_auth_config(identity_name, access_paths=None, project_id=None, environment="dev"):
82
+ """
83
+ Generate Universal Auth (Client ID + Client Secret) configuration.
84
+
85
+ This is the recommended authentication method for services.
86
+
87
+ Args:
88
+ identity_name: Name of the machine identity (e.g., "machine1")
89
+ access_paths: List of Infisical paths this identity can access
90
+ project_id: Project ID for access
91
+ environment: Environment (dev, staging, prod)
92
+
93
+ Returns:
94
+ Dict with Universal Auth configuration
95
+ """
96
+ if not access_paths:
97
+ access_paths = ["/services/*"]
98
+
99
+ # Normalize paths
100
+ normalized_paths = []
101
+ for path in access_paths:
102
+ if not path.startswith("/"):
103
+ path = "/" + path
104
+ normalized_paths.append(path)
105
+
106
+ return {
107
+ "identity_name": identity_name,
108
+ "auth_method": "universal-auth",
109
+ "method_info": AUTH_METHODS["universal-auth"],
110
+ "environment_variables": {
111
+ "INFISICAL_CLIENT_ID": "${INFISICAL_CLIENT_ID}",
112
+ "INFISICAL_CLIENT_SECRET": "${INFISICAL_CLIENT_SECRET}",
113
+ },
114
+ "config": {
115
+ "project_id": project_id or "${INFISICAL_PROJECT_ID}",
116
+ "environment": environment,
117
+ "access_paths": normalized_paths,
118
+ "token_ttl_seconds": DEFAULT_MACHINE_CONFIG["token_ttl_seconds"],
119
+ "max_uses": DEFAULT_MACHINE_CONFIG["max_uses"],
120
+ },
121
+ "cli_command": "infisical login --method universal-auth --client-id <id> --client-secret <secret>",
122
+ "docker_compose": {
123
+ "INFISICAL_CLIENT_ID": "${INFISICAL_CLIENT_ID}",
124
+ "INFISICAL_CLIENT_SECRET": "${INFISICAL_CLIENT_SECRET}",
125
+ "INFISICAL_PROJECT_ID": project_id or "${INFISICAL_PROJECT_ID}",
126
+ "INFISICAL_ENVIRONMENT": environment,
127
+ },
128
+ }
129
+
130
+ def _generate_oidc_auth_config(identity_name, oidc_issuer=None, allowed_audiences=None):
131
+ """
132
+ Generate OIDC Auth configuration.
133
+
134
+ For cloud provider authentication (AWS, GCP, Azure).
135
+
136
+ Args:
137
+ identity_name: Name of the machine identity
138
+ oidc_issuer: OIDC issuer URL
139
+ allowed_audiences: List of allowed audience claims
140
+
141
+ Returns:
142
+ Dict with OIDC Auth configuration
143
+ """
144
+ return {
145
+ "identity_name": identity_name,
146
+ "auth_method": "oidc-auth",
147
+ "method_info": AUTH_METHODS["oidc-auth"],
148
+ "environment_variables": {
149
+ "INFISICAL_OIDC_TOKEN": "${INFISICAL_OIDC_TOKEN}",
150
+ },
151
+ "config": {
152
+ "oidc_issuer": oidc_issuer or "${OIDC_ISSUER}",
153
+ "allowed_audiences": allowed_audiences or [],
154
+ },
155
+ "cli_command": "infisical login --method oidc-auth --oidc-token <token>",
156
+ "docker_compose": {
157
+ "INFISICAL_OIDC_TOKEN": "${INFISICAL_OIDC_TOKEN}",
158
+ },
159
+ }
160
+
161
+ def _generate_token_auth_config(identity_name, token=None):
162
+ """
163
+ Generate Token Auth configuration (legacy).
164
+
165
+ Args:
166
+ identity_name: Name of the machine identity
167
+ token: Service token (or env var reference)
168
+
169
+ Returns:
170
+ Dict with Token Auth configuration
171
+ """
172
+ return {
173
+ "identity_name": identity_name,
174
+ "auth_method": "token-auth",
175
+ "method_info": AUTH_METHODS["token-auth"],
176
+ "deprecated": True,
177
+ "environment_variables": {
178
+ "INFISICAL_TOKEN": token or "${INFISICAL_TOKEN}",
179
+ },
180
+ "config": {},
181
+ "cli_command": "infisical login --method token --token <token>",
182
+ "docker_compose": {
183
+ "INFISICAL_TOKEN": token or "${INFISICAL_TOKEN}",
184
+ },
185
+ }
186
+
187
+ # =============================================================================
188
+ # Machine Identity Templates
189
+ # =============================================================================
190
+
191
+ def _generate_development_machine(identity_name="dev-machine", project_id=None):
192
+ """Generate a development machine identity with broad access."""
193
+ return _generate_universal_auth_config(
194
+ identity_name=identity_name,
195
+ access_paths=[
196
+ "/services/*",
197
+ "/platform/*",
198
+ "/shared/*",
199
+ ],
200
+ project_id=project_id,
201
+ environment="dev",
202
+ )
203
+
204
+ def _generate_production_machine(identity_name="prod-machine", project_id=None, resource_paths=None):
205
+ """Generate a production machine identity with restricted access."""
206
+ if not resource_paths:
207
+ resource_paths = ["/services/${RESOURCE_NAME}"]
208
+
209
+ return _generate_universal_auth_config(
210
+ identity_name=identity_name,
211
+ access_paths=resource_paths,
212
+ project_id=project_id,
213
+ environment="prod",
214
+ )
215
+
216
+ def _generate_ci_machine(identity_name="ci-machine", project_id=None):
217
+ """Generate a CI/CD machine identity for GitHub Actions."""
218
+ return _generate_universal_auth_config(
219
+ identity_name=identity_name,
220
+ access_paths=[
221
+ "/services/*",
222
+ "/platform/*",
223
+ ],
224
+ project_id=project_id,
225
+ environment="dev",
226
+ )
227
+
228
+ def _generate_resource_specific_machine(resource_name, project_id=None):
229
+ """Generate a machine identity for a specific service only."""
230
+ path = "/services/{}".format(resource_name)
231
+
232
+ return _generate_universal_auth_config(
233
+ identity_name="{}-machine".format(resource_name),
234
+ access_paths=[path, "{}/*".format(path)],
235
+ project_id=project_id,
236
+ environment="dev",
237
+ )
238
+
239
+ # =============================================================================
240
+ # Machine Identity Registry
241
+ # =============================================================================
242
+
243
+ # Predefined machine identity configurations
244
+ PREDEFINED_MACHINES = {
245
+ "machine1": {
246
+ "name": "machine1",
247
+ "display_name": "Machine Identity 1",
248
+ "description": "Primary machine identity for local development",
249
+ "auth_method": "universal-auth",
250
+ "access_level": "project",
251
+ "environments": ["dev", "staging"],
252
+ "access_paths": ["/services/*", "/platform/*"],
253
+ },
254
+ "tilt-local": {
255
+ "name": "tilt-local",
256
+ "display_name": "Tilt Local Development",
257
+ "description": "Machine identity for Tilt local development",
258
+ "auth_method": "universal-auth",
259
+ "access_level": "project",
260
+ "environments": ["dev"],
261
+ "access_paths": ["/services/*"],
262
+ },
263
+ "github-actions": {
264
+ "name": "github-actions",
265
+ "display_name": "GitHub Actions CI/CD",
266
+ "description": "Machine identity for GitHub Actions workflows",
267
+ "auth_method": "universal-auth",
268
+ "access_level": "project",
269
+ "environments": ["dev", "staging", "prod"],
270
+ "access_paths": ["/services/*", "/platform/*"],
271
+ },
272
+ "production-deployer": {
273
+ "name": "production-deployer",
274
+ "display_name": "Production Deployment",
275
+ "description": "Machine identity for production deployments",
276
+ "auth_method": "universal-auth",
277
+ "access_level": "project",
278
+ "environments": ["prod"],
279
+ "access_paths": ["/services/*"],
280
+ },
281
+ }
282
+
283
+ def _get_predefined_machine(machine_name):
284
+ """Get predefined machine configuration."""
285
+ return PREDEFINED_MACHINES.get(machine_name)
286
+
287
+ def _register_machine(machine_name, config):
288
+ """Register a new machine identity configuration."""
289
+ PREDEFINED_MACHINES[machine_name] = config
290
+ return config
291
+
292
+ # =============================================================================
293
+ # Environment Variable Generation
294
+ # =============================================================================
295
+
296
+ def _generate_env_file_content(machine_config, include_secrets=False):
297
+ """
298
+ Generate .env file content for a machine identity.
299
+
300
+ Args:
301
+ machine_config: Machine identity configuration
302
+ include_secrets: If True, includes placeholder secret values
303
+
304
+ Returns:
305
+ String content for .env file
306
+ """
307
+ lines = [
308
+ "# Infisical Machine Identity Configuration",
309
+ "# Identity: {}".format(machine_config.get("identity_name", "unknown")),
310
+ "# Generated: {}".format(_get_timestamp()),
311
+ "#",
312
+ "# ⚠️ SECURITY WARNING: Do not commit this file to Git!",
313
+ "",
314
+ "# Authentication Method",
315
+ "INFISICAL_AUTH_METHOD={}".format(machine_config.get("auth_method", "universal-auth")),
316
+ "",
317
+ ]
318
+
319
+ # Add method-specific variables
320
+ env_vars = machine_config.get("environment_variables", {})
321
+ for key, value in env_vars.items():
322
+ if include_secrets:
323
+ lines.append("{}={}".format(key, value))
324
+ else:
325
+ lines.append("{}=__replace_with_actual_value__".format(key))
326
+
327
+ # Add config variables
328
+ config = machine_config.get("config", {})
329
+ if "project_id" in config:
330
+ lines.append("INFISICAL_PROJECT_ID={}".format(config["project_id"]))
331
+ if "environment" in config:
332
+ lines.append("INFISICAL_ENVIRONMENT={}".format(config["environment"]))
333
+
334
+ lines.extend([
335
+ "",
336
+ "# API Configuration",
337
+ "INFISICAL_API_URL=http://localhost:8089",
338
+ ])
339
+
340
+ return "\n".join(lines)
341
+
342
+ # =============================================================================
343
+ # Validation
344
+ # =============================================================================
345
+
346
+ def _validate_auth_method(method):
347
+ """Validate authentication method."""
348
+ if method in AUTH_METHODS:
349
+ info = AUTH_METHODS[method]
350
+ return {
351
+ "valid": True,
352
+ "supported": info["supported"],
353
+ "deprecated": info.get("deprecated", False),
354
+ "message": None,
355
+ }
356
+
357
+ return {
358
+ "valid": False,
359
+ "supported": False,
360
+ "deprecated": False,
361
+ "message": "Unknown auth method: {}".format(method),
362
+ }
363
+
364
+ def _validate_machine_config(config):
365
+ """Validate machine identity configuration."""
366
+ errors = []
367
+ warnings = []
368
+
369
+ # Check required fields
370
+ if not config.get("identity_name"):
371
+ errors.append("Missing identity_name")
372
+
373
+ auth_method = config.get("auth_method", "universal-auth")
374
+ method_validation = _validate_auth_method(auth_method)
375
+
376
+ if not method_validation["valid"]:
377
+ errors.append(method_validation["message"])
378
+ elif method_validation.get("deprecated"):
379
+ warnings.append("Auth method '{}' is deprecated".format(auth_method))
380
+ elif not method_validation["supported"]:
381
+ warnings.append("Auth method '{}' not yet supported".format(auth_method))
382
+
383
+ return {
384
+ "valid": len(errors) == 0,
385
+ "errors": errors,
386
+ "warnings": warnings,
387
+ }
388
+
389
+ # =============================================================================
390
+ # Main API
391
+ # =============================================================================
392
+
393
+ MachineIdentity = struct(
394
+ # Configuration generators
395
+ generate_universal_auth=_generate_universal_auth_config,
396
+ generate_oidc_auth=_generate_oidc_auth_config,
397
+ generate_token_auth=_generate_token_auth_config,
398
+
399
+ # Templates
400
+ generate_development_machine=_generate_development_machine,
401
+ generate_production_machine=_generate_production_machine,
402
+ generate_ci_machine=_generate_ci_machine,
403
+ generate_resource_specific_machine=_generate_resource_specific_machine,
404
+
405
+ # Registry
406
+ get_predefined_machine=_get_predefined_machine,
407
+ register_machine=_register_machine,
408
+ predefined_machines=PREDEFINED_MACHINES,
409
+
410
+ # Environment
411
+ generate_env_file_content=_generate_env_file_content,
412
+
413
+ # Validation
414
+ validate_auth_method=_validate_auth_method,
415
+ validate_machine_config=_validate_machine_config,
416
+
417
+ # Constants
418
+ AUTH_METHODS=AUTH_METHODS,
419
+ DEFAULT_MACHINE_CONFIG=DEFAULT_MACHINE_CONFIG,
420
+ )