fast2dev 1.0.0__py3-none-any.whl

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 (543) hide show
  1. f2dev/__init__.py +1 -0
  2. f2dev/__main__.py +5 -0
  3. f2dev/_bundle/platform/.dockerignore +80 -0
  4. f2dev/_bundle/platform/.gitignore +82 -0
  5. f2dev/_bundle/platform/LICENSE +202 -0
  6. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/template_values.yaml +1731 -0
  7. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/Chart.yaml +9 -0
  8. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-airflow-deploy.yaml +60 -0
  9. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-bi-sync.yaml +46 -0
  10. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-checkout.yaml +49 -0
  11. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-console-sync.yaml +41 -0
  12. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-e2e-label.yaml +48 -0
  13. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-e2e-run.yaml +43 -0
  14. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-e2e-teardown.yaml +47 -0
  15. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-governance.yaml +40 -0
  16. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-lint.yaml +37 -0
  17. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-notify.yaml +32 -0
  18. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-quality.yaml +38 -0
  19. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-refresh.yaml +36 -0
  20. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-supersede.yaml +30 -0
  21. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-tags.yaml +44 -0
  22. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/pipeline-branch.yaml +138 -0
  23. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/pipeline-main.yaml +150 -0
  24. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/pipeline-pr.yaml +184 -0
  25. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/templates/NOTES.txt +18 -0
  26. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/templates/settings-configmap.yaml +14 -0
  27. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/templates/workflowtemplates.yaml +31 -0
  28. f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/values.yaml +41 -0
  29. f2dev/_bundle/platform/charts/data_services_charts/cicd_workload_runner/github/template_github_values.yaml +436 -0
  30. f2dev/_bundle/platform/charts/data_services_charts/cicd_workload_runner/github/template_github_values_extra.yaml +49 -0
  31. f2dev/_bundle/platform/charts/data_services_charts/cicd_workload_runner/gitlab/template_gitlab_values.yaml +551 -0
  32. f2dev/_bundle/platform/charts/data_services_charts/cicd_workload_runner/gitlab/template_gitlab_values_extra.yaml +9 -0
  33. f2dev/_bundle/platform/charts/data_services_charts/data_analysis/lightdash/template_values.yaml +359 -0
  34. f2dev/_bundle/platform/charts/data_services_charts/data_analysis/metabase/template_values.yaml +384 -0
  35. f2dev/_bundle/platform/charts/data_services_charts/data_analysis/superset/template_values.yaml +1562 -0
  36. f2dev/_bundle/platform/charts/data_services_charts/data_analysis/template_values.yaml +269 -0
  37. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/.helmignore +15 -0
  38. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/Chart.yaml +20 -0
  39. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/template_values.yaml.j2 +175 -0
  40. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/NOTES.txt +19 -0
  41. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/_helpers.tpl +50 -0
  42. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/cicd-rbac.yaml +30 -0
  43. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/configmap.yaml +142 -0
  44. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/extras.yaml +14 -0
  45. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/ingress.yaml +69 -0
  46. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/promtail-configmap.yaml +68 -0
  47. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/secret.yaml +31 -0
  48. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/service.yaml +15 -0
  49. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/serviceaccount.yaml +12 -0
  50. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/statefulset.yaml +276 -0
  51. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/valkey.yaml +113 -0
  52. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/warehouse-stats-cronjob.yaml +107 -0
  53. f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/values.yaml +828 -0
  54. f2dev/_bundle/platform/charts/data_services_charts/data_dbt_server/template_values.yaml +385 -0
  55. f2dev/_bundle/platform/charts/data_services_charts/data_governance/template_dh_prerequisites_values.yaml +118 -0
  56. f2dev/_bundle/platform/charts/data_services_charts/data_governance/template_dh_values.yaml +1671 -0
  57. f2dev/_bundle/platform/charts/data_services_charts/data_governance/template_kafka_values.yaml +112 -0
  58. f2dev/_bundle/platform/charts/data_services_charts/data_governance/template_opensearch_values.yaml +662 -0
  59. f2dev/_bundle/platform/charts/data_services_charts/data_governance/template_values.yaml +738 -0
  60. f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/Chart.yaml +6 -0
  61. f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/files/argo-openapi.json +681 -0
  62. f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/templates/_helpers.tpl +17 -0
  63. f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/templates/argo-rbac.yaml +35 -0
  64. f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/templates/backends.yaml +327 -0
  65. f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/templates/gateway.yaml +150 -0
  66. f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/values.yaml +91 -0
  67. f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/template_values.yaml +142 -0
  68. f2dev/_bundle/platform/charts/data_services_charts/data_modeling/template_values.yaml +1167 -0
  69. f2dev/_bundle/platform/charts/data_services_charts/data_modeling/template_values_extra.yaml +99 -0
  70. f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/airflow-cleanup/Dockerfile +10 -0
  71. f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/airflow-cleanup/build.sh +38 -0
  72. f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/airflow-cleanup/cleanup.py +452 -0
  73. f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/airflow-cleanup/requirements.txt +3 -0
  74. f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/docs/keycloak-oidc-setup.md +106 -0
  75. f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/template_values.yaml +5536 -0
  76. f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/template_values_extra.yaml +379 -0
  77. f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/webserver-config/configmap.yaml +459 -0
  78. f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/webserver-config/fast2dev_auth.py +285 -0
  79. f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/webserver-config/fast2dev_mcp_plugin.py +24 -0
  80. f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/webserver-config/webserver_config.py +130 -0
  81. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/Dockerfile +10 -0
  82. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/build.sh +38 -0
  83. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/cleanup.py +749 -0
  84. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/k8s/configmap.yaml +24 -0
  85. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/k8s/cronjob.yaml +137 -0
  86. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/requirements.txt +3 -0
  87. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/.helmignore +26 -0
  88. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/Chart.lock +3 -0
  89. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/Chart.yaml +15 -0
  90. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/README.md +243 -0
  91. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/NOTES.txt +31 -0
  92. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/_helpers.tpl +245 -0
  93. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/_images.tpl +17 -0
  94. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-auth-secret.yaml +35 -0
  95. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-bootloader/bootloader-secrets.yaml +19 -0
  96. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-bootloader/pod.yaml +126 -0
  97. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-connector-rollout-worker/deployment.yaml +171 -0
  98. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-cron/cron-secrets.yaml +19 -0
  99. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-cron/deployment.yaml +149 -0
  100. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-db.yaml +88 -0
  101. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/_helpers.tpl +111 -0
  102. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/deployment.yaml +169 -0
  103. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/hpa.yaml +23 -0
  104. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/pdb.yaml +17 -0
  105. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/service.yaml +25 -0
  106. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/serviceaccount.yaml +10 -0
  107. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-featureflag-server/deployment.yaml +161 -0
  108. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-featureflag-server/service.yaml +25 -0
  109. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-keycloak/service.yaml +62 -0
  110. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-keycloak/statefulset.yaml +182 -0
  111. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-manifest-server/_helpers.tpl +54 -0
  112. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-manifest-server/deployment.yaml +152 -0
  113. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-manifest-server/service.yaml +23 -0
  114. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-manifest-server/serviceaccount.yaml +10 -0
  115. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-metrics/deployment.yaml +124 -0
  116. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-server/deployment.yaml +227 -0
  117. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-server/service.yaml +29 -0
  118. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-stigg-sidecar/deployment.yaml +184 -0
  119. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-stigg-sidecar/service.yaml +21 -0
  120. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-temporal/configmap.yaml +55 -0
  121. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-temporal/deployment.yaml +220 -0
  122. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-temporal/service.yaml +21 -0
  123. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-temporal-ui/deployment.yaml +122 -0
  124. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-temporal-ui/service.yaml +23 -0
  125. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-webapp/deployment.yaml +146 -0
  126. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-webapp/ingress.yaml +63 -0
  127. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-webapp/service.yaml +32 -0
  128. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-worker/deployment.yaml +229 -0
  129. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-workload-api-server/deployment.yaml +191 -0
  130. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-workload-api-server/service.yaml +25 -0
  131. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-workload-launcher/deployment.yaml +232 -0
  132. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-workload-launcher/jobs-secrets.yaml +21 -0
  133. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_auth.tpl +944 -0
  134. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_aws.tpl +109 -0
  135. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_cluster.tpl +82 -0
  136. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_common.tpl +370 -0
  137. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_connector.tpl +58 -0
  138. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_connectorRollout.tpl +141 -0
  139. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_connectorRolloutWorker.tpl +56 -0
  140. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_cron.tpl +62 -0
  141. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_customerio.tpl +56 -0
  142. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_database.tpl +375 -0
  143. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_dataplaneGroups.tpl +38 -0
  144. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_directJobRunner.tpl +122 -0
  145. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_featureFlags.tpl +126 -0
  146. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_java.tpl +38 -0
  147. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_jobs.tpl +422 -0
  148. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_keycloak.tpl +542 -0
  149. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_logging.tpl +38 -0
  150. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_metrics.tpl +214 -0
  151. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_micronaut.tpl +43 -0
  152. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_minio.tpl +64 -0
  153. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_secretsManager.tpl +628 -0
  154. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_server.tpl +533 -0
  155. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_shopify.tpl +83 -0
  156. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_stigg.tpl +157 -0
  157. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_storage.tpl +468 -0
  158. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_temporal.tpl +943 -0
  159. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_topology.tpl +98 -0
  160. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_tracking.tpl +82 -0
  161. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_webapp.tpl +38 -0
  162. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_worker.tpl +366 -0
  163. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_workloadApiServer.tpl +62 -0
  164. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_workloadLauncher.tpl +395 -0
  165. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_workloads.tpl +770 -0
  166. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/env-configmap.yaml +62 -0
  167. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/gcs-log-creds-secret.yaml +19 -0
  168. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/ingress.yaml +69 -0
  169. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/minio.yaml +161 -0
  170. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/secret.yaml +31 -0
  171. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/serviceaccount.yaml +50 -0
  172. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/telemetry-configmap.yaml +32 -0
  173. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/tests/test-webapp.yaml +34 -0
  174. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/values.yaml +3158 -0
  175. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/.helmignore +12 -0
  176. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/Chart.yaml +16 -0
  177. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/README.md +172 -0
  178. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/templates/_helpers.tpl +42 -0
  179. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/templates/deployment.yaml +105 -0
  180. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/templates/externalsecret.yaml +23 -0
  181. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/templates/pdb.yaml +15 -0
  182. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/templates/service.yaml +18 -0
  183. f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/values.yaml +97 -0
  184. f2dev/_bundle/platform/charts/data_services_charts/data_replication/feature-flags-configmap.yaml +16 -0
  185. f2dev/_bundle/platform/charts/data_services_charts/data_replication/template_metrics_values.yaml +13 -0
  186. f2dev/_bundle/platform/charts/data_services_charts/data_replication/template_oauth2proxy_values.yaml +1200 -0
  187. f2dev/_bundle/platform/charts/data_services_charts/data_replication/template_values.yaml +3255 -0
  188. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/Chart.yaml +7 -0
  189. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/hazelcast-client.yaml +27 -0
  190. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/hazelcast-master.yaml +38 -0
  191. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/hazelcast-worker.yaml +29 -0
  192. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/jvm_client_options +24 -0
  193. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/jvm_master_options +6 -0
  194. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/jvm_worker_options +6 -0
  195. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/log4j2.properties +109 -0
  196. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/seatunnel.yaml +36 -0
  197. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/_helpers.tpl +70 -0
  198. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/configmap.yaml +11 -0
  199. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/deployment-master.yaml +120 -0
  200. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/deployment-worker.yaml +118 -0
  201. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/rbac.yaml +32 -0
  202. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/services.yaml +33 -0
  203. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/values.yaml +101 -0
  204. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/template_oauth2proxy_values.yaml +196 -0
  205. f2dev/_bundle/platform/charts/data_services_charts/data_streaming/template_values.yaml +75 -0
  206. f2dev/_bundle/platform/charts/data_services_charts/object_storage_operator/template_values.yaml +506 -0
  207. f2dev/_bundle/platform/charts/infra_services_charts/cert_manager/csi_driver_values.yaml +193 -0
  208. f2dev/_bundle/platform/charts/infra_services_charts/cert_manager/template_pdns_webhook_values.yaml +91 -0
  209. f2dev/_bundle/platform/charts/infra_services_charts/cert_manager/template_values.yaml +1777 -0
  210. f2dev/_bundle/platform/charts/infra_services_charts/cert_manager/template_values_extra.yaml +253 -0
  211. f2dev/_bundle/platform/charts/infra_services_charts/cluster_cleaner/template_values.yaml +57 -0
  212. f2dev/_bundle/platform/charts/infra_services_charts/external_dns/template_values.yaml +476 -0
  213. f2dev/_bundle/platform/charts/infra_services_charts/external_dns/template_values_extra.yaml +131 -0
  214. f2dev/_bundle/platform/charts/infra_services_charts/idp_sso_manager/realm_template.json +4785 -0
  215. f2dev/_bundle/platform/charts/infra_services_charts/idp_sso_manager/template_values.yaml +657 -0
  216. f2dev/_bundle/platform/charts/infra_services_charts/pvc_autoscaller/template_values.yaml +36 -0
  217. f2dev/_bundle/platform/charts/infra_services_charts/pvc_autoscaller/template_values_extra.yaml +352 -0
  218. f2dev/_bundle/platform/charts/infra_services_charts/secret_manager/template_values.yaml +1218 -0
  219. f2dev/_bundle/platform/charts/infra_services_charts/secret_manager/template_values_extra.yaml +845 -0
  220. f2dev/_bundle/platform/charts/infra_services_charts/secret_manager_operator/template_values.yaml +561 -0
  221. f2dev/_bundle/platform/charts/infra_services_charts/secret_manager_operator/template_values_extra.yaml +23 -0
  222. f2dev/_bundle/platform/charts/infra_services_charts/services_logs/template_alloy_events_values.yaml +59 -0
  223. f2dev/_bundle/platform/charts/infra_services_charts/services_logs/template_alloy_values.yaml +185 -0
  224. f2dev/_bundle/platform/charts/infra_services_charts/services_logs/template_loki_values.yaml +108 -0
  225. f2dev/_bundle/platform/charts/infra_services_charts/services_metrics/template_values.yaml +1530 -0
  226. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/00-main/.gitkeep +0 -0
  227. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/00-main/f2d-main.json +2871 -0
  228. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/01-platform/.gitkeep +0 -0
  229. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/01-platform/f2d-k8s-cluster.json +1751 -0
  230. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/01-platform/f2d-microservices.json +1682 -0
  231. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/01-platform/f2d-pvc-storage.json +1320 -0
  232. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/01-platform/f2d-service.json +1193 -0
  233. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/.gitkeep +0 -0
  234. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/f2d-cert-manager.json +755 -0
  235. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/f2d-keycloak.json +746 -0
  236. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/f2d-object-storage.json +881 -0
  237. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/f2d-postgresql.json +1590 -0
  238. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/f2d-traefik.json +1375 -0
  239. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/.gitkeep +0 -0
  240. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-cicd-workflows-trends.json +1916 -0
  241. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-cicd-workflows.json +1330 -0
  242. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-analysis.json +631 -0
  243. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-freshness.json +1362 -0
  244. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-governance.json +1958 -0
  245. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-modeling.json +764 -0
  246. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-orchestration-trends.json +2352 -0
  247. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-orchestration.json +1506 -0
  248. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-quality.json +1549 -0
  249. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-replication-trends.json +2799 -0
  250. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-replication.json +2153 -0
  251. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-streaming-trends.json +1536 -0
  252. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-streaming.json +1209 -0
  253. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/04-data-warehouse/.gitkeep +0 -0
  254. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/04-data-warehouse-bigquery/.gitkeep +0 -0
  255. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/04-data-warehouse-bigquery/f2d-bigquery.json +990 -0
  256. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/05-logs/.gitkeep +0 -0
  257. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/05-logs/f2d-logs.json +630 -0
  258. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/folders.yaml +17 -0
  259. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/requirements.yaml +8 -0
  260. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/template_alerts_cm.yaml +2031 -0
  261. f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/template_values.yaml +1315 -0
  262. f2dev/_bundle/platform/charts/infra_services_charts/stackgres_postgres_db/template_values.yaml +550 -0
  263. f2dev/_bundle/platform/charts/infra_services_charts/stackgres_postgres_db/template_values_extra.yaml +742 -0
  264. f2dev/_bundle/platform/charts/infra_services_charts/traefik_lb/template_values.yaml +1758 -0
  265. f2dev/_bundle/platform/cli/README.md +866 -0
  266. f2dev/_bundle/platform/cli/__init__.py +42 -0
  267. f2dev/_bundle/platform/cli/__main__.py +17 -0
  268. f2dev/_bundle/platform/cli/cert_providers.py +369 -0
  269. f2dev/_bundle/platform/cli/command_record.py +144 -0
  270. f2dev/_bundle/platform/cli/config/data_services_config.json +217 -0
  271. f2dev/_bundle/platform/cli/config/environment_profiles.yaml +183 -0
  272. f2dev/_bundle/platform/cli/config/images.json +129 -0
  273. f2dev/_bundle/platform/cli/config/infrastructure_services_config.json +141 -0
  274. f2dev/_bundle/platform/cli/config.py +252 -0
  275. f2dev/_bundle/platform/cli/deployment_configuration_aws_example.yaml +117 -0
  276. f2dev/_bundle/platform/cli/deployment_configuration_gcp_example.yaml +130 -0
  277. f2dev/_bundle/platform/cli/deployment_configuration_onprem_example.yaml +71 -0
  278. f2dev/_bundle/platform/cli/destroy.py +677 -0
  279. f2dev/_bundle/platform/cli/dns_check.py +27 -0
  280. f2dev/_bundle/platform/cli/dns_providers.py +405 -0
  281. f2dev/_bundle/platform/cli/exit_codes.py +32 -0
  282. f2dev/_bundle/platform/cli/fixers.py +56 -0
  283. f2dev/_bundle/platform/cli/generate_only.py +336 -0
  284. f2dev/_bundle/platform/cli/health_report.py +114 -0
  285. f2dev/_bundle/platform/cli/logging.py +206 -0
  286. f2dev/_bundle/platform/cli/main.py +5293 -0
  287. f2dev/_bundle/platform/cli/precheck.py +1523 -0
  288. f2dev/_bundle/platform/cli/prerequisites/README.md +208 -0
  289. f2dev/_bundle/platform/cli/prerequisites/install-prerequisites.bat +107 -0
  290. f2dev/_bundle/platform/cli/prerequisites/install-prerequisites.ps1 +343 -0
  291. f2dev/_bundle/platform/cli/prerequisites/install-prerequisites.sh +207 -0
  292. f2dev/_bundle/platform/cli/prerequisites/linux/install-linux.sh +775 -0
  293. f2dev/_bundle/platform/cli/prerequisites/macos/install-macos.sh +634 -0
  294. f2dev/_bundle/platform/cli/prerequisites/requirements.txt +41 -0
  295. f2dev/_bundle/platform/cli/prerequisites/verify-prerequisites.ps1 +150 -0
  296. f2dev/_bundle/platform/cli/prerequisites/verify-prerequisites.sh +418 -0
  297. f2dev/_bundle/platform/cli/prerequisites/versions.yaml +43 -0
  298. f2dev/_bundle/platform/cli/prerequisites/windows/install-windows.ps1 +1005 -0
  299. f2dev/_bundle/platform/cli/restore.py +179 -0
  300. f2dev/_bundle/platform/cli/service_gates.py +160 -0
  301. f2dev/_bundle/platform/cli/state.py +332 -0
  302. f2dev/_bundle/platform/cli/wizard.py +782 -0
  303. f2dev/_bundle/platform/cli.py +235 -0
  304. f2dev/_bundle/platform/deployers/__init__.py +4 -0
  305. f2dev/_bundle/platform/deployers/base_deployer.py +8 -0
  306. f2dev/_bundle/platform/deployers/clouds/__init__.py +0 -0
  307. f2dev/_bundle/platform/deployers/clouds/aws_cloud.py +619 -0
  308. f2dev/_bundle/platform/deployers/clouds/azure_cloud.py +0 -0
  309. f2dev/_bundle/platform/deployers/clouds/google_cloud.py +785 -0
  310. f2dev/_bundle/platform/deployers/clouds/terragrunt_progress.py +56 -0
  311. f2dev/_bundle/platform/deployers/services/data_services/1.0_cicd_workload_runner.py +644 -0
  312. f2dev/_bundle/platform/deployers/services/data_services/12.0_control_plane.py +321 -0
  313. f2dev/_bundle/platform/deployers/services/data_services/13.0_data_mcp_hub.py +362 -0
  314. f2dev/_bundle/platform/deployers/services/data_services/2.0_object_storage_operator.py +416 -0
  315. f2dev/_bundle/platform/deployers/services/data_services/2.5_services_logs.py +482 -0
  316. f2dev/_bundle/platform/deployers/services/data_services/3.0_data_cicd_workflows.py +361 -0
  317. f2dev/_bundle/platform/deployers/services/data_services/4.0_data_replication.py +534 -0
  318. f2dev/_bundle/platform/deployers/services/data_services/4.5_data_streaming.py +303 -0
  319. f2dev/_bundle/platform/deployers/services/data_services/5.0_data_orchestration.py +760 -0
  320. f2dev/_bundle/platform/deployers/services/data_services/6.0_data_modeling.py +753 -0
  321. f2dev/_bundle/platform/deployers/services/data_services/7.0_data_governance.py +795 -0
  322. f2dev/_bundle/platform/deployers/services/data_services/8.0_data_analysis.py +587 -0
  323. f2dev/_bundle/platform/deployers/services/infra_services/1.0_secret_operator.py +467 -0
  324. f2dev/_bundle/platform/deployers/services/infra_services/10.0_cluster_pvc_autoscaller.py +500 -0
  325. f2dev/_bundle/platform/deployers/services/infra_services/2.0_cert_manager.py +963 -0
  326. f2dev/_bundle/platform/deployers/services/infra_services/3.0_external_dns.py +823 -0
  327. f2dev/_bundle/platform/deployers/services/infra_services/4.0_traefik_lb.py +604 -0
  328. f2dev/_bundle/platform/deployers/services/infra_services/5.0_stackgres_postgresql.py +652 -0
  329. f2dev/_bundle/platform/deployers/services/infra_services/6.0_services_metrics.py +515 -0
  330. f2dev/_bundle/platform/deployers/services/infra_services/7.0_services_monitoring.py +787 -0
  331. f2dev/_bundle/platform/deployers/services/infra_services/8.0_cluster_cleaner.py +439 -0
  332. f2dev/_bundle/platform/deployers/services/infra_services/9.0_idp_sso_manager.py +790 -0
  333. f2dev/_bundle/platform/readme.md +47 -0
  334. f2dev/_bundle/platform/requirements.txt +14 -0
  335. f2dev/_bundle/platform/terraform/aws_cloud/templates/backend.tf_template +10 -0
  336. f2dev/_bundle/platform/terraform/aws_cloud/templates/defaults.yaml_template +11 -0
  337. f2dev/_bundle/platform/terraform/aws_cloud/templates/env.yaml_template +2 -0
  338. f2dev/_bundle/platform/terraform/aws_cloud/templates/root.hcl_advanced_template +134 -0
  339. f2dev/_bundle/platform/terraform/aws_cloud/templates/root.hcl_basic_template +134 -0
  340. f2dev/_bundle/platform/terraform/aws_cloud/templates/terragrunt.hcl_advanced_template +134 -0
  341. f2dev/_bundle/platform/terraform/aws_cloud/templates/terragrunt.hcl_basic_template +134 -0
  342. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/01-apps-vpc/terragrunt.hcl +26 -0
  343. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/02-create-dns-ns-record/terragrunt.hcl +16 -0
  344. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/03-eks-cluster/terragrunt.hcl +21 -0
  345. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/04-external_dns_sa/terragrunt.hcl +28 -0
  346. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/01-apps-vpc/terragrunt.hcl +25 -0
  347. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/02-eks-cluster/terragrunt.hcl +32 -0
  348. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/03-external-dns-irsa/terragrunt.hcl +34 -0
  349. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/04-cert-manager-irsa/terragrunt.hcl +34 -0
  350. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/05-create-dns-zone/terragrunt.hcl +22 -0
  351. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/06-create-dns-ns-record/terragrunt.hcl +44 -0
  352. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/empty.yaml +1 -0
  353. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/empty.yaml +1 -0
  354. f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/env.hcl +2 -0
  355. f2dev/_bundle/platform/terraform/azure_cloud/README.md +3 -0
  356. f2dev/_bundle/platform/terraform/azure_cloud/templates/_keep_structure.txt +0 -0
  357. f2dev/_bundle/platform/terraform/google_cloud/README.md +20 -0
  358. f2dev/_bundle/platform/terraform/google_cloud/templates/backend.tf_template +7 -0
  359. f2dev/_bundle/platform/terraform/google_cloud/templates/defaults.yaml_template +12 -0
  360. f2dev/_bundle/platform/terraform/google_cloud/templates/env.yaml_template +2 -0
  361. f2dev/_bundle/platform/terraform/google_cloud/templates/root.hcl_advanced_template +114 -0
  362. f2dev/_bundle/platform/terraform/google_cloud/templates/root.hcl_basic_template +116 -0
  363. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/.gitignore +3 -0
  364. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/00-create-ou-folder/terragrunt.hcl +15 -0
  365. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/01-create-project/terragrunt.hcl +30 -0
  366. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/02-enable-apis/terragrunt.hcl +25 -0
  367. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/03-0-apps-vpc/terragrunt.hcl +134 -0
  368. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/04-external-ip-traefik/terragrunt.hcl +29 -0
  369. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/05-create-dns-zone/terragrunt.hcl +25 -0
  370. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/06-create-dns-ns-record/terragrunt.hcl +43 -0
  371. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/07-gke-cluster/terragrunt.hcl +103 -0
  372. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/08-dbt_deploy_sa/terragrunt.hcl +36 -0
  373. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/09-dbt_sa/terragrunt.hcl +40 -0
  374. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/10-cert_manager_sa/terragrunt.hcl +34 -0
  375. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/11-external_dns_sa/terragrunt.hcl +30 -0
  376. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/12-monitoring_sa/terragrunt.hcl +52 -0
  377. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/13-data_replication_sa/terragrunt.hcl +35 -0
  378. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/14-data_orchestration_sa/terragrunt.hcl +35 -0
  379. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/15-bi_data_sa/terragrunt.hcl +43 -0
  380. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/16-whitelist-external-ip-on-common/terragrunt.hcl +30 -0
  381. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/17-kubeconfig/terragrunt.hcl +23 -0
  382. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/18-data_streaming_sa/terragrunt.hcl +24 -0
  383. f2dev/_bundle/platform/terraform/google_cloud/terragrunt/empty.yaml +1 -0
  384. f2dev/_bundle/platform/utils/__init__.py +0 -0
  385. f2dev/_bundle/platform/utils/customer_data_platform_repository_operator.py +1098 -0
  386. f2dev/_bundle/platform/utils/customer_secret_manager_operations.py +1635 -0
  387. f2dev/_bundle/platform/utils/environment_profiles.py +58 -0
  388. f2dev/_bundle/platform/utils/helm_utils.py +215 -0
  389. f2dev/_bundle/platform/utils/infrastructure_deployment_operator.py +1532 -0
  390. f2dev/_bundle/platform/utils/keycloak_realm_reconcile.py +320 -0
  391. f2dev/_bundle/platform/utils/kubeconfig_fixer.py +265 -0
  392. f2dev/_bundle/platform/utils/raw_extras.py +34 -0
  393. f2dev/_bundle/platform/utils/readiness.py +330 -0
  394. f2dev/_bundle/platform/utils/secret_structure_upgrade.py +194 -0
  395. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/.gitignore +7 -0
  396. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/README.md +33 -0
  397. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/analyses/.gitkeep +0 -0
  398. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/dbt_project.yml +52 -0
  399. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/macros/.gitkeep +0 -0
  400. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/macros/fast2dev_bq_time_zones.sql +12 -0
  401. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/macros/fast2dev_monitoring_grain.sql +23 -0
  402. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_daily_spend.sql +19 -0
  403. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_daily_spend.yml +25 -0
  404. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_model_costs_daily.sql +16 -0
  405. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_model_costs_daily.yml +24 -0
  406. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_storage_by_dataset.sql +12 -0
  407. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_storage_by_dataset.yml +21 -0
  408. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_user_costs_daily.sql +14 -0
  409. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_user_costs_daily.yml +22 -0
  410. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_weekly_kpi.sql +52 -0
  411. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_weekly_kpi.yml +42 -0
  412. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_weekly_spend.sql +74 -0
  413. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_weekly_spend.yml +49 -0
  414. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/sources/billing_export.yml +9 -0
  415. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/staging/fast2dev_bq_billing_export.sql +9 -0
  416. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/staging/fast2dev_bq_billing_export.yml +4 -0
  417. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/packages.yml +5 -0
  418. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/profiles.yml +15 -0
  419. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/scripts/run_monitoring.py +201 -0
  420. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/seeds/.gitkeep +0 -0
  421. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/snapshots/.gitkeep +0 -0
  422. f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/tests/.gitkeep +0 -0
  423. f2dev/_bundle/platform/utils/templates/dry_run/gcp_sa.json +12 -0
  424. f2dev/_bundle/platform/utils/templates/dry_run/kubeconfig.yaml +18 -0
  425. f2dev/_bundle/platform/utils/templates/git_repo_templates/data_orchestrator/repository_structure/README.MD +50 -0
  426. f2dev/_bundle/platform/utils/templates/git_repo_templates/data_orchestrator/repository_structure/dags/dbt/README.MD +47 -0
  427. f2dev/_bundle/platform/utils/templates/git_repo_templates/data_orchestrator/repository_structure/dags/fast2dev_healthcheck.py_template_airflow_3.x +158 -0
  428. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/bitbucket/bitbucket-pipelines.yml_template +144 -0
  429. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitea/.gitea/PR_VALIDATION.md +52 -0
  430. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitea/.gitea/pull_request_template.md +48 -0
  431. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitea/.gitea/workflows/argo-workflows.yml_template +143 -0
  432. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitea/.gitea/workflows/pr-agent.yml +30 -0
  433. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitea/.gitea/workflows/validate-pr-description.yml +38 -0
  434. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/github/.github/PR_VALIDATION.md +52 -0
  435. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/github/.github/pull_request_template.md +48 -0
  436. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/github/.github/workflows/argo-workflows.yml_template +143 -0
  437. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/github/.github/workflows/pr-agent.yml +37 -0
  438. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/github/.github/workflows/validate-pr-description.yml +157 -0
  439. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitlab/.gitlab/PR_VALIDATION.md +43 -0
  440. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitlab/.gitlab/merge_request_templates/Default.md +48 -0
  441. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitlab/.gitlab-ci.yml_template +181 -0
  442. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/repository_structure/.gitignore +21 -0
  443. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/repository_structure/.pr_agent.toml +82 -0
  444. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/repository_structure/AGENTS.md +126 -0
  445. f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/repository_structure/README.MD +101 -0
  446. f2dev/_bundle/platform/utils/templates/git_repo_templates/infrastructure_deployment_files/DR.md +341 -0
  447. f2dev/_bundle/platform/utils/templates/git_repo_templates/infrastructure_deployment_files/README.md.j2 +81 -0
  448. f2dev/_bundle/platform/utils/templates/git_repo_templates/infrastructure_deployment_files/decrypt_files.py +331 -0
  449. f2dev/_bundle/platform/utils/templates/git_repo_templates/infrastructure_deployment_files/encrypt_files.py +321 -0
  450. f2dev/_bundle/platform/utils/templates/secret_structure_template/customer_vault_structure.json +502 -0
  451. f2dev/_bundle/platform/utils/vault_structure_sync.py +96 -0
  452. f2dev/_bundle/terraform-modules/README.md +12 -0
  453. f2dev/_bundle/terraform-modules/aws_cloud/README.md +7 -0
  454. f2dev/_bundle/terraform-modules/aws_cloud/eks/addons-roles.tf +298 -0
  455. f2dev/_bundle/terraform-modules/aws_cloud/eks/main.tf +313 -0
  456. f2dev/_bundle/terraform-modules/aws_cloud/eks/outputs.tf +3 -0
  457. f2dev/_bundle/terraform-modules/aws_cloud/eks/policies/lb-controller-policy.json +219 -0
  458. f2dev/_bundle/terraform-modules/aws_cloud/eks/provider.tf +36 -0
  459. f2dev/_bundle/terraform-modules/aws_cloud/eks/variables.tf +107 -0
  460. f2dev/_bundle/terraform-modules/aws_cloud/eks/versions.tf +10 -0
  461. f2dev/_bundle/terraform-modules/aws_cloud/gcp_aws_zone/main.tf +25 -0
  462. f2dev/_bundle/terraform-modules/aws_cloud/gcp_aws_zone/provider.tf +17 -0
  463. f2dev/_bundle/terraform-modules/aws_cloud/gcp_aws_zone/variables.tf +41 -0
  464. f2dev/_bundle/terraform-modules/aws_cloud/vpc/main.tf +34 -0
  465. f2dev/_bundle/terraform-modules/aws_cloud/vpc/outputs.tf +44 -0
  466. f2dev/_bundle/terraform-modules/aws_cloud/vpc/provider.tf +12 -0
  467. f2dev/_bundle/terraform-modules/aws_cloud/vpc/variables.tf +118 -0
  468. f2dev/_bundle/terraform-modules/aws_cloud/vpc/versions.tf +10 -0
  469. f2dev/_bundle/terraform-modules/azure_cloud/README.md +3 -0
  470. f2dev/_bundle/terraform-modules/google_cloud/README.md +17 -0
  471. f2dev/_bundle/terraform-modules/google_cloud/artifact-registry/main.tf +8 -0
  472. f2dev/_bundle/terraform-modules/google_cloud/artifact-registry/providers.tf +6 -0
  473. f2dev/_bundle/terraform-modules/google_cloud/artifact-registry/variables.tf +17 -0
  474. f2dev/_bundle/terraform-modules/google_cloud/artifact-registry/versions.tf +8 -0
  475. f2dev/_bundle/terraform-modules/google_cloud/cloud-dns/main.tf +24 -0
  476. f2dev/_bundle/terraform-modules/google_cloud/cloud-dns/outputs.tf +25 -0
  477. f2dev/_bundle/terraform-modules/google_cloud/cloud-dns/providers.tf +7 -0
  478. f2dev/_bundle/terraform-modules/google_cloud/cloud-dns/variables.tf +17 -0
  479. f2dev/_bundle/terraform-modules/google_cloud/cloud-dns/versions.tf +9 -0
  480. f2dev/_bundle/terraform-modules/google_cloud/cloud-dns-recordset/main.tf +38 -0
  481. f2dev/_bundle/terraform-modules/google_cloud/cloud-dns-recordset/variables.tf +73 -0
  482. f2dev/_bundle/terraform-modules/google_cloud/cloud-dns-recordset/versions.tf +39 -0
  483. f2dev/_bundle/terraform-modules/google_cloud/composer/main.tf +213 -0
  484. f2dev/_bundle/terraform-modules/google_cloud/composer/outputs.tf +31 -0
  485. f2dev/_bundle/terraform-modules/google_cloud/composer/provider.tf +4 -0
  486. f2dev/_bundle/terraform-modules/google_cloud/composer/variables.tf +192 -0
  487. f2dev/_bundle/terraform-modules/google_cloud/create-ou-folder/main.tf +29 -0
  488. f2dev/_bundle/terraform-modules/google_cloud/create-ou-folder/output.tf +4 -0
  489. f2dev/_bundle/terraform-modules/google_cloud/create-ou-folder/providers.tf +6 -0
  490. f2dev/_bundle/terraform-modules/google_cloud/create-ou-folder/variables.tf +40 -0
  491. f2dev/_bundle/terraform-modules/google_cloud/create-ou-folder/versions.tf +8 -0
  492. f2dev/_bundle/terraform-modules/google_cloud/create-project/main.tf +18 -0
  493. f2dev/_bundle/terraform-modules/google_cloud/create-project/output.tf +8 -0
  494. f2dev/_bundle/terraform-modules/google_cloud/create-project/providers.tf +6 -0
  495. f2dev/_bundle/terraform-modules/google_cloud/create-project/variables.tf +27 -0
  496. f2dev/_bundle/terraform-modules/google_cloud/create-project/versions.tf +9 -0
  497. f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/README.md +188 -0
  498. f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/main.tf +135 -0
  499. f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/output.tf +16 -0
  500. f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/providers.tf +6 -0
  501. f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/variables.tf +54 -0
  502. f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/versions.tf +17 -0
  503. f2dev/_bundle/terraform-modules/google_cloud/enable_apis/main.tf +14 -0
  504. f2dev/_bundle/terraform-modules/google_cloud/enable_apis/provider.tf +7 -0
  505. f2dev/_bundle/terraform-modules/google_cloud/enable_apis/variables.tf +13 -0
  506. f2dev/_bundle/terraform-modules/google_cloud/enable_apis/versions.tf +10 -0
  507. f2dev/_bundle/terraform-modules/google_cloud/external-ip/README.md +89 -0
  508. f2dev/_bundle/terraform-modules/google_cloud/external-ip/main.tf +17 -0
  509. f2dev/_bundle/terraform-modules/google_cloud/external-ip/outputs.tf +19 -0
  510. f2dev/_bundle/terraform-modules/google_cloud/external-ip/variables.tf +43 -0
  511. f2dev/_bundle/terraform-modules/google_cloud/fw-add/main.tf +24 -0
  512. f2dev/_bundle/terraform-modules/google_cloud/fw-add/providers.tf +6 -0
  513. f2dev/_bundle/terraform-modules/google_cloud/fw-add/variables.tf +37 -0
  514. f2dev/_bundle/terraform-modules/google_cloud/fw-add/versions.tf +9 -0
  515. f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/README.md +10 -0
  516. f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/main.tf +459 -0
  517. f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/outputs.tf +44 -0
  518. f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/provider.tf +19 -0
  519. f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/variables.tf +354 -0
  520. f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/versions.tf +22 -0
  521. f2dev/_bundle/terraform-modules/google_cloud/kubeconfig/README.md +40 -0
  522. f2dev/_bundle/terraform-modules/google_cloud/kubeconfig/main.tf +54 -0
  523. f2dev/_bundle/terraform-modules/google_cloud/kubeconfig/outputs.tf +10 -0
  524. f2dev/_bundle/terraform-modules/google_cloud/kubeconfig/variables.tf +24 -0
  525. f2dev/_bundle/terraform-modules/google_cloud/kubeconfig/versions.tf +10 -0
  526. f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/README.md +47 -0
  527. f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/main.tf +51 -0
  528. f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/net-address/README.md +103 -0
  529. f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/net-address/main.tf +71 -0
  530. f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/net-address/outputs.tf +71 -0
  531. f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/net-address/variables.tf +82 -0
  532. f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/net-address/versions.tf +27 -0
  533. f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/outputs.tf +35 -0
  534. f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/provider.tf +4 -0
  535. f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/variables.tf +237 -0
  536. f2dev/_bundle/terraform-modules/oracle_cloud/README.md +3 -0
  537. f2dev/launcher.py +153 -0
  538. fast2dev-1.0.0.dist-info/METADATA +201 -0
  539. fast2dev-1.0.0.dist-info/RECORD +543 -0
  540. fast2dev-1.0.0.dist-info/WHEEL +4 -0
  541. fast2dev-1.0.0.dist-info/entry_points.txt +2 -0
  542. fast2dev-1.0.0.dist-info/licenses/LICENSE +202 -0
  543. fast2dev-1.0.0.dist-info/licenses/NOTICE +6 -0
@@ -0,0 +1,1523 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ fast2.dev — Host Preparation Utility
5
+ =====================================
6
+
7
+ Pure-Python, cross-platform precheck orchestrator for the fast2.dev
8
+ deployment CLI. Replaces the previous "run install-prerequisites.{sh,ps1}
9
+ manually before invoking cli.py" workflow.
10
+
11
+ Responsibilities
12
+ ----------------
13
+ 1. Detect the host platform (Linux / macOS / Windows, WSL2, container, CI).
14
+ 2. Ensure a project-local virtualenv exists; if not, create one and
15
+ re-exec the current script inside it (PEP 668 friendly — no
16
+ ``--break-system-packages`` required).
17
+ 3. Verify the Python interpreter itself meets the minimum version.
18
+ 4. Verify every required Python package (from
19
+ ``platform/requirements.txt`` and
20
+ ``platform/cli/prerequisites/requirements.txt``) is importable.
21
+ Missing packages are installed automatically with ``pip``.
22
+ 5. Verify every required external tool (``kubectl``, ``gcloud``,
23
+ ``terraform``, ``terragrunt``, ``helm``, ``git``, ``jq``, ``curl``,
24
+ ``docker``) is on ``PATH`` and meets the pinned minimum version.
25
+ Missing tools are reported; the user is asked before any
26
+ non-pip install is attempted.
27
+ 6. Render a single human-readable status table at the end of every
28
+ run so the operator knows whether deployment can proceed.
29
+
30
+ Designed to be imported (the CLI calls :func:`run_precheck`) or
31
+ executed as a module::
32
+
33
+ python -m platform.utils.host_prep check
34
+ python -m platform.utils.host_prep install
35
+ python -m platform.utils.host_prep install --only kubectl,helm
36
+ python -m platform.utils.host_prep install --dry-run
37
+ python -m platform.utils.host_prep ensure-venv
38
+ python -m platform.utils.host_prep --json check
39
+
40
+ All operations are idempotent and re-runnable. The precheck is invoked
41
+ on every ``python cli.py`` launch; on a fully prepared host it takes
42
+ the fast path (one ``shutil.which`` per tool, <100 ms).
43
+ """
44
+
45
+ from __future__ import annotations
46
+
47
+ import json
48
+ import os
49
+ import platform as _platform_mod
50
+ import re
51
+ import shutil
52
+ import subprocess
53
+ import sys
54
+ import venv
55
+ from dataclasses import asdict, dataclass, field
56
+ from pathlib import Path
57
+ from typing import Iterable
58
+
59
+ __all__ = [
60
+ "PrereqStatus",
61
+ "PlatformInfo",
62
+ "PrecheckResult",
63
+ "ToolSpec",
64
+ "REQUIRED_TOOLS",
65
+ "REQUIRED_PYTHON_MAJOR",
66
+ "REQUIRED_PYTHON_MINOR",
67
+ "VENV_DIR",
68
+ "detect_platform",
69
+ "check_python_runtime",
70
+ "check_python_packages",
71
+ "install_python_packages",
72
+ "check_external_tools",
73
+ "install_external_tool",
74
+ "ensure_venv",
75
+ "is_in_venv",
76
+ "in_throwaway_env",
77
+ "run_precheck",
78
+ ]
79
+
80
+
81
+ # ---------------------------------------------------------------------------
82
+ # Constants
83
+ # ---------------------------------------------------------------------------
84
+
85
+ REQUIRED_PYTHON_MAJOR = 3
86
+ REQUIRED_PYTHON_MINOR = 10
87
+
88
+ # Project-local venv path, resolved relative to the platform/ root (the
89
+ # directory holding cli.py). This is the same convention used by the
90
+ # existing `platform/.local_run.sh` helper and ignored by .gitignore
91
+ # (".venv/" is listed at the repo root).
92
+ VENV_DIR_NAME = ".venv"
93
+
94
+ # Resolve platform/ root from this file:
95
+ # this file: platform/cli/precheck.py
96
+ # platform/: platform/cli/../ -> platform/
97
+ PLATFORM_ROOT = Path(__file__).resolve().parent.parent
98
+ VENV_DIR = PLATFORM_ROOT / VENV_DIR_NAME
99
+
100
+ # Python requirements files the host_prep step must satisfy. Order is
101
+ # preserved when installing.
102
+ REQUIREMENTS_FILES: tuple[Path, ...] = (
103
+ PLATFORM_ROOT / "requirements.txt",
104
+ PLATFORM_ROOT / "cli" / "prerequisites" / "requirements.txt",
105
+ )
106
+
107
+ # Subprocess timeout (seconds) for any external probe. Keep short —
108
+ # a stuck `gcloud --version` should never hang the wizard.
109
+ PROBE_TIMEOUT_S = 15
110
+ # Longer timeout for actual installs (apt / brew can take a while).
111
+ INSTALL_TIMEOUT_S = 600
112
+
113
+
114
+ # ---------------------------------------------------------------------------
115
+ # Data classes
116
+ # ---------------------------------------------------------------------------
117
+
118
+
119
+ @dataclass
120
+ class PlatformInfo:
121
+ """Snapshot of the host's OS/arch/distribution context."""
122
+
123
+ os: str # "linux" | "darwin" | "windows" | "other"
124
+ arch: str # "amd64" | "arm64" | ...
125
+ is_wsl: bool
126
+ is_windows: bool
127
+ is_macos: bool
128
+ is_linux: bool
129
+ distro_id: str # e.g. "ubuntu", "debian", "centos", "fedora", "amzn", "arch", "linux"
130
+ has_sudo: bool
131
+ has_brew: bool
132
+ has_choco: bool
133
+ has_winget: bool
134
+ has_apt: bool
135
+ has_dnf: bool
136
+ has_yum: bool
137
+ in_container: bool
138
+ in_ci: bool
139
+
140
+ @property
141
+ def short_label(self) -> str:
142
+ bits = [self.os, self.arch]
143
+ if self.is_wsl:
144
+ bits.append("wsl")
145
+ if self.in_container:
146
+ bits.append("container")
147
+ if self.in_ci:
148
+ bits.append("ci")
149
+ return "-".join(b for b in bits if b)
150
+
151
+
152
+ @dataclass
153
+ class PrereqStatus:
154
+ """One row in the precheck status table."""
155
+
156
+ tool: str
157
+ category: str # "runtime" | "python-package" | "tool"
158
+ installed: bool
159
+ version_ok: bool
160
+ detected_version: str | None = None
161
+ required_version: str | None = None
162
+ path: str | None = None
163
+ error: str | None = None
164
+ install_hint: str | None = None # human-readable manual command if applicable
165
+
166
+ @property
167
+ def ok(self) -> bool:
168
+ """A status is "ok" if installed AND version meets requirement."""
169
+ return self.installed and self.version_ok
170
+
171
+ def to_row(self) -> str:
172
+ """Format as a single status-table line."""
173
+ if self.installed and self.version_ok:
174
+ mark = "✅"
175
+ elif self.installed and not self.version_ok:
176
+ mark = "⚠️ "
177
+ else:
178
+ mark = "❌"
179
+ ver = self.detected_version or "not found"
180
+ req = f" (need {self.required_version})" if self.required_version else ""
181
+ where = f" [{self.path}]" if self.path else ""
182
+ return f" {mark} {self.tool:<18} {ver}{req}{where}"
183
+
184
+
185
+ @dataclass
186
+ class PrecheckResult:
187
+ """Aggregate result of a full precheck run."""
188
+
189
+ ready: bool
190
+ statuses: list[PrereqStatus] = field(default_factory=list)
191
+ actions_taken: list[str] = field(default_factory=list)
192
+ missing_actionable: list[str] = field(default_factory=list)
193
+ platform: PlatformInfo | None = None
194
+
195
+ def missing(self) -> list[PrereqStatus]:
196
+ return [s for s in self.statuses if not s.ok]
197
+
198
+ def render_table(self) -> str:
199
+ """Render the result as a multi-line status table."""
200
+ lines = []
201
+ by_cat: dict[str, list[PrereqStatus]] = {}
202
+ for s in self.statuses:
203
+ by_cat.setdefault(s.category, []).append(s)
204
+ order = ("runtime", "python-package", "tool")
205
+ for cat in order:
206
+ if cat in by_cat:
207
+ lines.append(f" [{cat}]")
208
+ for s in by_cat[cat]:
209
+ lines.append(s.to_row())
210
+ if self.actions_taken:
211
+ lines.append("")
212
+ lines.append(" Actions taken:")
213
+ for a in self.actions_taken:
214
+ lines.append(f" - {a}")
215
+ if self.missing_actionable:
216
+ lines.append("")
217
+ lines.append(" Manual install hints:")
218
+ for h in self.missing_actionable:
219
+ lines.append(f" - {h}")
220
+ return "\n".join(lines)
221
+
222
+
223
+ # ---------------------------------------------------------------------------
224
+ # Tool registry
225
+ # ---------------------------------------------------------------------------
226
+
227
+
228
+ @dataclass(frozen=True)
229
+ class ToolSpec:
230
+ """One external tool the platform needs."""
231
+
232
+ name: str
233
+ min_version: str | None # None = presence only
234
+ # Apt package name on Debian/Ubuntu (may be None for tools installed
235
+ # from official scripts, e.g. kubectl, helm, terragrunt).
236
+ apt_package: str | None = None
237
+ # Brew formula/cask name on macOS.
238
+ brew_package: str | None = None
239
+ # Windows package manager name (choco or winget).
240
+ choco_package: str | None = None
241
+ winget_package: str | None = None
242
+ # Direct download URL template (Python format placeholders:
243
+ # {version}, {os}, {arch}). Used for tools that aren't in OS
244
+ # package managers (terragrunt, helm as a fallback).
245
+ download_url: str | None = None
246
+ # Format of the download (None = single binary, "zip", "tar.gz").
247
+ download_format: str | None = None
248
+ # Path of the binary inside the archive. Defaults to ``name``.
249
+ download_member: str | None = None
250
+ # Pinned version for download_url templating. Used when the tool
251
+ # has no package-manager version (e.g. terragrunt pins to 0.84.x).
252
+ download_version: str | None = None
253
+ # If True, the installer prefers direct download over package
254
+ # managers even when an apt/brew/choco package exists. Set for
255
+ # tools whose vendor sources are more reliable than the package
256
+ # repos (HashiCorp, Google, Kubernetes all ship faster + have
257
+ # fewer moving parts than their third-party apt repos).
258
+ prefer_download: bool = False
259
+ # Shell command used to extract version output. Default: "<name> --version".
260
+ version_cmd: tuple[str, ...] = ()
261
+ # Manual install hint shown to the user.
262
+ install_hint: str = ""
263
+
264
+
265
+ # A single source of truth for the required-tool set. The Python-side
266
+ # installer consults this; the registry determines what the wizard checks.
267
+ REQUIRED_TOOLS: tuple[ToolSpec, ...] = (
268
+ ToolSpec(
269
+ name="kubectl",
270
+ min_version=None,
271
+ # Direct download from kubernetes.io (more reliable than the
272
+ # third-party apt repo, which is missing on most distros).
273
+ download_url=(
274
+ "https://dl.k8s.io/release/v{version}/bin/{os}/{arch}/kubectl"
275
+ ),
276
+ download_version="1.30.0",
277
+ prefer_download=True,
278
+ install_hint="https://kubernetes.io/docs/tasks/tools/",
279
+ ),
280
+ ToolSpec(
281
+ name="gcloud",
282
+ min_version=None,
283
+ # gcloud ships a single ~100MB tarball from dl.google.com.
284
+ # The apt repo is well-known but slow; direct is faster and
285
+ # doesn't need a third-party repo configured.
286
+ download_url=(
287
+ "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/"
288
+ "google-cloud-cli-{version}-{os}-{arch}.{ext}"
289
+ ),
290
+ download_version="509.0.0",
291
+ download_format="tar.gz",
292
+ download_member="google-cloud-sdk/bin/gcloud",
293
+ prefer_download=True,
294
+ install_hint="On Windows, run inside WSL2 or "
295
+ "https://cloud.google.com/sdk/docs/install",
296
+ ),
297
+ ToolSpec(
298
+ name="terraform",
299
+ min_version=None,
300
+ # Direct zip from HashiCorp (apt repo for HashiCorp is not
301
+ # always configured; this works on every distro).
302
+ download_url=(
303
+ "https://releases.hashicorp.com/terraform/{version}/"
304
+ "terraform_{version}_{os}_{arch}.zip"
305
+ ),
306
+ download_version="1.9.8",
307
+ download_format="zip",
308
+ download_member="terraform",
309
+ prefer_download=True,
310
+ install_hint="https://developer.hashicorp.com/terraform/install",
311
+ ),
312
+ ToolSpec(
313
+ name="terragrunt",
314
+ min_version="0.84.0",
315
+ download_url=(
316
+ "https://github.com/gruntwork-io/terragrunt/releases/download/"
317
+ "v{version}/terragrunt_{os}_{arch}"
318
+ ),
319
+ download_version="0.84.6",
320
+ prefer_download=True,
321
+ install_hint=(
322
+ "https://terragrunt.gruntwork.io/docs/getting-started/install/"
323
+ ),
324
+ ),
325
+ ToolSpec(
326
+ name="helm",
327
+ min_version=None,
328
+ # Official tarball from get.helm.sh — single binary, works on
329
+ # every distro. The get-helm-3 curl script also works but
330
+ # piping curl | bash is harder to audit.
331
+ download_url=(
332
+ "https://get.helm.sh/helm-v{version}-{os}-{arch}.tar.gz"
333
+ ),
334
+ download_version="3.16.2",
335
+ download_format="tar.gz",
336
+ download_member="helm",
337
+ prefer_download=True,
338
+ install_hint="https://helm.sh/docs/intro/install/",
339
+ ),
340
+ ToolSpec(
341
+ name="git",
342
+ min_version=None,
343
+ apt_package="git",
344
+ brew_package="git",
345
+ choco_package="git",
346
+ install_hint="Install Git for Windows or use WSL2.",
347
+ ),
348
+ ToolSpec(
349
+ name="jq",
350
+ min_version=None,
351
+ apt_package="jq",
352
+ brew_package="jq",
353
+ choco_package="jq",
354
+ install_hint="https://jqlang.github.io/jq/download/",
355
+ ),
356
+ ToolSpec(
357
+ name="curl",
358
+ min_version=None,
359
+ apt_package="curl",
360
+ brew_package="curl",
361
+ install_hint="Built-in to Windows 10+ and most Linux distros.",
362
+ ),
363
+ ToolSpec(
364
+ name="docker",
365
+ min_version=None,
366
+ # On Debian/Ubuntu, prefer the official Docker repo; we still try
367
+ # the distro package as a fallback path.
368
+ apt_package="docker.io",
369
+ brew_package="docker",
370
+ choco_package="docker-desktop",
371
+ install_hint="https://docs.docker.com/engine/install/",
372
+ ),
373
+ )
374
+
375
+
376
+ # ---------------------------------------------------------------------------
377
+ # Platform detection
378
+ # ---------------------------------------------------------------------------
379
+
380
+
381
+ def _read_os_release() -> dict[str, str]:
382
+ """Best-effort /etc/os-release reader; returns {} on Windows/macOS."""
383
+ p = Path("/etc/os-release")
384
+ if not p.is_file():
385
+ return {}
386
+ out: dict[str, str] = {}
387
+ try:
388
+ for line in p.read_text(encoding="utf-8", errors="replace").splitlines():
389
+ if "=" in line:
390
+ k, v = line.split("=", 1)
391
+ out[k.strip()] = v.strip().strip('"').strip("'")
392
+ except OSError:
393
+ return {}
394
+ return out
395
+
396
+
397
+ def _is_wsl() -> bool:
398
+ """Detect Windows Subsystem for Linux from inside the WSL guest."""
399
+ if _platform_mod.system().lower() != "linux":
400
+ return False
401
+ if os.environ.get("WSL_DISTRO_NAME") or os.environ.get("WSLENV"):
402
+ return True
403
+ try:
404
+ release = Path("/proc/sys/kernel/osrelease").read_text().lower()
405
+ return "microsoft" in release or "wsl" in release
406
+ except OSError:
407
+ return False
408
+
409
+
410
+ def _in_container() -> bool:
411
+ """Detect common container markers."""
412
+ if Path("/.dockerenv").exists():
413
+ return True
414
+ if Path("/run/.containerenv").exists():
415
+ return True
416
+ try:
417
+ cgroup = Path("/proc/1/cgroup").read_text(errors="replace").lower()
418
+ except OSError:
419
+ cgroup = ""
420
+ if any(tok in cgroup for tok in ("docker", "kubepods", "containerd")):
421
+ return True
422
+ return False
423
+
424
+
425
+ def _in_ci() -> bool:
426
+ """Detect common CI environment variables."""
427
+ return any(
428
+ v in os.environ
429
+ for v in (
430
+ "CI",
431
+ "GITHUB_ACTIONS",
432
+ "GITLAB_CI",
433
+ "CIRCLECI",
434
+ "JENKINS_URL",
435
+ "BUILDKITE",
436
+ "TF_BUILD",
437
+ )
438
+ )
439
+
440
+
441
+ def detect_platform() -> PlatformInfo:
442
+ """Inspect the host and return a :class:`PlatformInfo` snapshot."""
443
+ sysname = _platform_mod.system().lower()
444
+ is_windows = sysname == "windows"
445
+ is_macos = sysname == "darwin"
446
+ is_linux = sysname == "linux"
447
+ is_wsl = _is_wsl() and is_linux
448
+ arch = _platform_mod.machine().lower() or "unknown"
449
+ osrel = _read_os_release()
450
+ distro_id = osrel.get("ID", "linux" if is_linux else sysname)
451
+
452
+ def _have(cmd: str) -> bool:
453
+ return shutil.which(cmd) is not None
454
+
455
+ # is_wsl Linux shells can use sudo; native Windows cannot use sudo.
456
+ has_sudo = is_linux and _have("sudo")
457
+ return PlatformInfo(
458
+ os="windows" if is_windows else ("darwin" if is_macos else ("linux" if is_linux else "other")),
459
+ arch=arch,
460
+ is_wsl=is_wsl,
461
+ is_windows=is_windows,
462
+ is_macos=is_macos,
463
+ is_linux=is_linux,
464
+ distro_id=distro_id,
465
+ has_sudo=has_sudo,
466
+ has_brew=is_macos and _have("brew"),
467
+ has_choco=is_windows and _have("choco"),
468
+ has_winget=is_windows and _have("winget"),
469
+ has_apt=is_linux and _have("apt-get"),
470
+ has_dnf=is_linux and _have("dnf"),
471
+ has_yum=is_linux and _have("yum"),
472
+ in_container=_in_container(),
473
+ in_ci=_in_ci(),
474
+ )
475
+
476
+
477
+ # ---------------------------------------------------------------------------
478
+ # Version parsing
479
+ # ---------------------------------------------------------------------------
480
+
481
+
482
+ _SEMVER_RE = re.compile(r"v?(\d+)\.(\d+)(?:\.(\d+))?")
483
+
484
+
485
+ def _parse_version(text: str) -> str | None:
486
+ """Extract the first X.Y.Z-ish version from arbitrary text."""
487
+ if not text:
488
+ return None
489
+ m = _SEMVER_RE.search(text)
490
+ if not m:
491
+ return None
492
+ major, minor, patch = m.group(1), m.group(2), m.group(3) or "0"
493
+ return f"{major}.{minor}.{patch}"
494
+
495
+
496
+ def _version_ge(actual: str | None, required: str) -> bool:
497
+ """Return True if ``actual >= required``. Both are X.Y.Z-ish."""
498
+ if not actual:
499
+ return False
500
+ a = [int(x) for x in actual.split(".")]
501
+ r = [int(x) for x in required.split(".")]
502
+ while len(a) < 3:
503
+ a.append(0)
504
+ while len(r) < 3:
505
+ r.append(0)
506
+ return a[:3] >= r[:3]
507
+
508
+
509
+ # ---------------------------------------------------------------------------
510
+ # Venv helpers
511
+ # ---------------------------------------------------------------------------
512
+
513
+
514
+ def is_in_venv() -> bool:
515
+ """True if the current Python is running inside *any* virtualenv.
516
+
517
+ Detects both stdlib ``venv`` (sys.real_prefix set) and the
518
+ ``virtualenv`` package (sys.base_prefix != sys.prefix)."""
519
+ return getattr(sys, "real_prefix", None) is not None or (
520
+ sys.base_prefix != sys.prefix
521
+ )
522
+
523
+
524
+ def in_throwaway_env(info: PlatformInfo | None = None) -> bool:
525
+ """True when a venv is not required (Docker, CI, throwaway VM).
526
+
527
+ Inside a container or CI runner the system Python is already
528
+ throwaway, so we skip the auto-create flow and just install
529
+ packages directly with ``pip``.
530
+ """
531
+ info = info or detect_platform()
532
+ return info.in_container or info.in_ci
533
+
534
+
535
+ def _venv_python(venv_dir: Path) -> Path:
536
+ """Resolve the python executable inside ``venv_dir``."""
537
+ if _platform_mod.system().lower() == "windows":
538
+ return venv_dir / "Scripts" / "python.exe"
539
+ return venv_dir / "bin" / "python"
540
+
541
+
542
+ def _run_venv_builder(venv_dir: Path) -> None:
543
+ """Create a venv at ``venv_dir`` using the stdlib ``venv`` module."""
544
+ builder = venv.EnvBuilder(
545
+ system_site_packages=False,
546
+ clear=False,
547
+ symlinks=True,
548
+ upgrade=False,
549
+ with_pip=True,
550
+ prompt="fast2dev",
551
+ )
552
+ builder.create(str(venv_dir))
553
+
554
+
555
+ def ensure_venv(venv_dir: Path | None = None, *, force: bool = False) -> Path | None:
556
+ """Ensure a project venv exists; return its Python interpreter.
557
+
558
+ If we are already inside a venv, return ``None`` (the caller should
559
+ use the running interpreter). If we are outside a venv and the
560
+ host is a throwaway environment (Docker, CI), also return ``None``
561
+ — the caller should just ``pip install`` into the system Python.
562
+ Otherwise create the venv at ``venv_dir`` (default:
563
+ ``platform/.venv``) and return its Python path.
564
+ """
565
+ if is_in_venv():
566
+ return None
567
+ info = detect_platform()
568
+ if in_throwaway_env(info):
569
+ return None
570
+ target = Path(venv_dir) if venv_dir else VENV_DIR
571
+ if target.exists() and not force:
572
+ py = _venv_python(target)
573
+ if py.is_file():
574
+ return py
575
+ target.parent.mkdir(parents=True, exist_ok=True)
576
+ print(f"[fast2dev] Creating virtualenv at {target} ...")
577
+ _run_venv_builder(target)
578
+ py = _venv_python(target)
579
+ if not py.is_file():
580
+ raise RuntimeError(
581
+ f"venv was created at {target} but python executable not found at {py}"
582
+ )
583
+ return py
584
+
585
+
586
+ def reexec_in_venv(venv_python: Path, argv: list[str]) -> int:
587
+ """Re-exec the current process inside the venv Python. Does not return.
588
+
589
+ ``argv[0]`` is conventionally the script path the Python
590
+ interpreter is running. We need to build a fresh argv for the
591
+ child that follows the standard CPython layout::
592
+
593
+ [python_executable, script_path, *script_args]
594
+
595
+ ``os.execv`` replaces the process image so the call does not
596
+ return on the happy path.
597
+ """
598
+ # Build the new argv: [python, script, ...args]
599
+ script = argv[0] if argv else "python"
600
+ rest = list(argv[1:])
601
+ new_argv = [str(venv_python), script, *rest]
602
+ print(f"[fast2dev] Re-launching inside venv: {' '.join(new_argv)}")
603
+ flush = getattr(sys.stdout, "flush", None)
604
+ if callable(flush):
605
+ flush()
606
+ os.execv(str(venv_python), new_argv)
607
+ # Unreachable: os.execv replaces the process image. Returning a
608
+ # sentinel keeps the type-checker happy.
609
+ return 0 # pragma: no cover
610
+
611
+
612
+ def maybe_reexec_in_venv(argv: list[str] | None = None) -> None:
613
+ """Ensure we're running inside the project venv.
614
+
615
+ Behavior:
616
+ - If already in any venv: return (no-op).
617
+ - If in a throwaway env (Docker/CI): return (no-op).
618
+ - If ``platform/.venv`` exists and contains a working Python: re-exec into it.
619
+ - Otherwise: create ``platform/.venv`` and re-exec into it.
620
+
621
+ Re-exec replaces the current process image via ``os.execv`` so this
622
+ function does not return on the happy path. If something goes wrong
623
+ (e.g. venv can't be created), it raises ``RuntimeError`` so the
624
+ caller can show a useful error.
625
+ """
626
+ if is_in_venv():
627
+ return
628
+ info = detect_platform()
629
+ if in_throwaway_env(info):
630
+ return
631
+ argv = argv if argv is not None else sys.argv
632
+ venv_py = ensure_venv(force=False)
633
+ if venv_py is None:
634
+ # ensure_venv returned None even though we're not in a venv
635
+ # and not in a throwaway env. That means the venv was
636
+ # already in place. Re-derive the python.
637
+ venv_py = _venv_python(VENV_DIR)
638
+ if not venv_py.is_file():
639
+ raise RuntimeError(
640
+ f"Project venv directory exists at {VENV_DIR} but no python "
641
+ f"executable was found at {venv_py}. Re-create it with: "
642
+ f"`python -m venv {VENV_DIR}`."
643
+ )
644
+ reexec_in_venv(venv_py, argv)
645
+
646
+
647
+ # ---------------------------------------------------------------------------
648
+ # Python runtime + package checks
649
+ # ---------------------------------------------------------------------------
650
+
651
+
652
+ def check_python_runtime() -> PrereqStatus:
653
+ """Check the current Python interpreter meets the minimum version."""
654
+ vi = sys.version_info
655
+ actual = f"{vi.major}.{vi.minor}.{vi.micro}"
656
+ required = f"{REQUIRED_PYTHON_MAJOR}.{REQUIRED_PYTHON_MINOR}.0"
657
+ ok = (vi.major, vi.minor) >= (REQUIRED_PYTHON_MAJOR, REQUIRED_PYTHON_MINOR)
658
+ return PrereqStatus(
659
+ tool="python",
660
+ category="runtime",
661
+ installed=True,
662
+ version_ok=ok,
663
+ detected_version=actual,
664
+ required_version=f">={REQUIRED_PYTHON_MAJOR}.{REQUIRED_PYTHON_MINOR}",
665
+ path=sys.executable,
666
+ error=None if ok else f"Python {REQUIRED_PYTHON_MAJOR}.{REQUIRED_PYTHON_MINOR}+ required",
667
+ )
668
+
669
+
670
+ def _pip_show(pkg: str) -> tuple[bool, str | None]:
671
+ """Return (installed, version) for a single distribution name."""
672
+ try:
673
+ from importlib import metadata # py3.8+
674
+ except ImportError: # pragma: no cover
675
+ import importlib_metadata as metadata # type: ignore
676
+ try:
677
+ dist = metadata.distribution(pkg)
678
+ except metadata.PackageNotFoundError:
679
+ return False, None
680
+ return True, dist.version
681
+
682
+
683
+ def _req_names(path: Path) -> list[str]:
684
+ """Parse a requirements file, returning a list of distribution names.
685
+
686
+ Strips version specifiers, comments, and `-r` / `--hash` lines.
687
+ """
688
+ if not path.is_file():
689
+ return []
690
+ out: list[str] = []
691
+ for raw in path.read_text(encoding="utf-8", errors="replace").splitlines():
692
+ line = raw.strip()
693
+ if not line or line.startswith("#") or line.startswith("-"):
694
+ continue
695
+ if line.startswith("--"):
696
+ continue
697
+ # Drop inline comments and extras extras[foo]==1.0 -> extras
698
+ name = re.split(r"[#\s>=<~!\[]", line, 1)[0].strip()
699
+ if name:
700
+ out.append(name)
701
+ return out
702
+
703
+
704
+ def check_python_packages(
705
+ requirements_files: Iterable[Path] = REQUIREMENTS_FILES,
706
+ ) -> list[PrereqStatus]:
707
+ """Check every package listed in ``requirements_files`` is importable."""
708
+ results: list[PrereqStatus] = []
709
+ seen: set[str] = set()
710
+ files = list(requirements_files)
711
+ if not any(p.is_file() for p in files):
712
+ return results
713
+ for fpath in files:
714
+ if not fpath.is_file():
715
+ continue
716
+ for name in _req_names(fpath):
717
+ key = name.lower().replace("_", "-")
718
+ if key in seen:
719
+ continue
720
+ seen.add(key)
721
+ ok, ver = _pip_show(name)
722
+ results.append(
723
+ PrereqStatus(
724
+ tool=name,
725
+ category="python-package",
726
+ installed=ok,
727
+ version_ok=ok, # we don't enforce a version; presence is enough
728
+ detected_version=ver,
729
+ required_version=None,
730
+ path=None,
731
+ error=None if ok else f"{name} not installed in {sys.prefix}",
732
+ install_hint=f"{sys.executable} -m pip install {name}",
733
+ )
734
+ )
735
+ return results
736
+
737
+
738
+ def install_python_packages(
739
+ requirements_files: Iterable[Path] = REQUIREMENTS_FILES,
740
+ ) -> list[str]:
741
+ """Install every package in the given requirements files. Returns actions taken."""
742
+ actions: list[str] = []
743
+ files = [p for p in requirements_files if p.is_file()]
744
+ if not files:
745
+ return actions
746
+ # Upgrade pip + setuptools + wheel first to avoid PEP 517 issues.
747
+ base = [sys.executable, "-m", "pip", "install", "--upgrade",
748
+ "pip", "setuptools", "wheel"]
749
+ print(f"[fast2dev] Upgrading pip/setuptools/wheel ...")
750
+ subprocess.run(base, check=True, timeout=INSTALL_TIMEOUT_S,
751
+ stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
752
+ actions.append("upgraded pip/setuptools/wheel")
753
+ for fpath in files:
754
+ try:
755
+ rel = fpath.relative_to(PLATFORM_ROOT)
756
+ except ValueError:
757
+ # Path lives outside the platform/ root (e.g. a test fixture
758
+ # in /tmp). Fall back to the bare filename for logging.
759
+ rel = Path(fpath.name)
760
+ print(f"[fast2dev] Installing Python packages from {rel} ...")
761
+ cmd = [sys.executable, "-m", "pip", "install",
762
+ "--progress-bar", "off", "-r", str(fpath)]
763
+ # Stream pip output live so long resolves/builds don't look hung,
764
+ # while keeping the tail for the error message.
765
+ proc = subprocess.Popen(
766
+ cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True,
767
+ )
768
+ lines: list[str] = []
769
+ try:
770
+ assert proc.stdout is not None
771
+ for line in proc.stdout:
772
+ print(f" {line.rstrip()}", flush=True)
773
+ lines.append(line.rstrip())
774
+ returncode = proc.wait(timeout=INSTALL_TIMEOUT_S)
775
+ except subprocess.TimeoutExpired:
776
+ proc.kill()
777
+ raise
778
+ if returncode != 0:
779
+ # Surface the last 20 lines of pip output so the user can
780
+ # see the real error (missing system libs, version conflict,
781
+ # etc.) instead of an opaque CalledProcessError.
782
+ tail = "\n".join(lines[-20:])
783
+ raise RuntimeError(
784
+ f"pip install -r {rel} failed (exit {returncode}).\n"
785
+ f"Last output:\n{tail}"
786
+ )
787
+ actions.append(f"pip install -r {rel}")
788
+ return actions
789
+
790
+
791
+ # ---------------------------------------------------------------------------
792
+ # External tool checks + install
793
+ # ---------------------------------------------------------------------------
794
+
795
+
796
+ def _run(cmd: list[str], timeout: int = PROBE_TIMEOUT_S) -> subprocess.CompletedProcess:
797
+ """Run a short probe, swallowing output. Never raises."""
798
+ try:
799
+ return subprocess.run(
800
+ cmd,
801
+ check=False,
802
+ capture_output=True,
803
+ text=True,
804
+ timeout=timeout,
805
+ )
806
+ except (subprocess.SubprocessError, OSError) as exc:
807
+ return subprocess.CompletedProcess(cmd, returncode=-1, stdout="", stderr=str(exc))
808
+
809
+
810
+ def _detect_os_token(info: PlatformInfo) -> str:
811
+ """Map our PlatformInfo into the tokens our download URLs expect."""
812
+ if info.is_macos:
813
+ return "darwin"
814
+ if info.is_windows and not info.is_wsl:
815
+ return "windows"
816
+ return "linux"
817
+
818
+
819
+ def _detect_arch_token(info: PlatformInfo) -> str:
820
+ a = info.arch
821
+ if a in ("x86_64", "amd64"):
822
+ return "amd64"
823
+ if a in ("aarch64", "arm64"):
824
+ return "arm64"
825
+ return a
826
+
827
+
828
+ # Directories we additionally probe for tool binaries. The installer
829
+ # falls back to ``~/.local/bin`` when ``/usr/local/bin`` isn't writable
830
+ # (e.g. when not running as root), and several common tools (gcloud,
831
+ # brew, snap, choco) install to other well-known locations that may
832
+ # not be on $PATH for the current shell. Probing them here means the
833
+ # precheck sees tools the user can already run in their terminal even
834
+ # though the bootstrap process inherited a shorter PATH.
835
+ _EXTRA_TOOL_SEARCH_PATHS: tuple[str, ...] = (
836
+ str(Path.home() / ".local" / "bin"),
837
+ str(Path.home() / "bin"),
838
+ "/opt/google-cloud-sdk/bin",
839
+ "/opt/homebrew/bin",
840
+ "/usr/local/bin",
841
+ "/snap/bin",
842
+ r"C:\Program Files\Google\Cloud SDK\google-cloud-sdk\bin",
843
+ r"C:\ProgramData\chocolatey\bin",
844
+ r"C:\Program Files\Git\cmd",
845
+ )
846
+
847
+
848
+ def _which_with_extra_paths(name: str) -> str | None:
849
+ """``shutil.which`` plus an explicit probe of common install locations.
850
+
851
+ On a fresh host the precheck will often install a tool to
852
+ ``~/.local/bin`` (because the user isn't root) or to a vendor
853
+ location like ``/opt/google-cloud-sdk/bin`` (because that's
854
+ where the gcloud installer puts it). Neither is always on $PATH
855
+ for the current shell, which would otherwise make the post-install
856
+ re-check spuriously report the tool as missing.
857
+ """
858
+ # 1) the canonical $PATH lookup
859
+ found = shutil.which(name)
860
+ if found:
861
+ return found
862
+ # 2) probe known extra locations
863
+ for directory in _EXTRA_TOOL_SEARCH_PATHS:
864
+ candidate = Path(directory) / (name + (".exe" if os.name == "nt" else ""))
865
+ if candidate.is_file() and os.access(candidate, os.X_OK):
866
+ return str(candidate)
867
+ return None
868
+
869
+
870
+ def _extend_path_for_current_process(directory: str) -> None:
871
+ """Prepend ``directory`` to ``$PATH`` so the current process sees it.
872
+
873
+ The installer uses this after writing a binary so that the
874
+ re-check (and any subsequent in-process subprocess calls) find
875
+ the newly-installed tool without needing a shell restart.
876
+ """
877
+ if not directory:
878
+ return
879
+ current = os.environ.get("PATH", "")
880
+ parts = current.split(os.pathsep) if current else []
881
+ if directory in parts:
882
+ return
883
+ os.environ["PATH"] = directory + (os.pathsep + current if current else "")
884
+
885
+
886
+ def check_external_tools(
887
+ tools: Iterable[ToolSpec] = REQUIRED_TOOLS,
888
+ ) -> list[PrereqStatus]:
889
+ """Probe every required external tool for presence + minimum version."""
890
+ results: list[PrereqStatus] = []
891
+ for spec in tools:
892
+ path = _which_with_extra_paths(spec.name)
893
+ if not path:
894
+ results.append(
895
+ PrereqStatus(
896
+ tool=spec.name,
897
+ category="tool",
898
+ installed=False,
899
+ version_ok=False,
900
+ detected_version=None,
901
+ required_version=spec.min_version,
902
+ path=None,
903
+ error=f"{spec.name} not found on PATH or common install locations",
904
+ install_hint=spec.install_hint or f"Install {spec.name}",
905
+ )
906
+ )
907
+ continue
908
+ cmd = list(spec.version_cmd) if spec.version_cmd else [spec.name, "--version"]
909
+ proc = _run(cmd)
910
+ out = (proc.stdout or "") + "\n" + (proc.stderr or "")
911
+ detected = _parse_version(out)
912
+ if spec.min_version is None:
913
+ ok = True
914
+ else:
915
+ ok = _version_ge(detected, spec.min_version)
916
+ results.append(
917
+ PrereqStatus(
918
+ tool=spec.name,
919
+ category="tool",
920
+ installed=True,
921
+ version_ok=ok,
922
+ detected_version=detected or out.splitlines()[0][:40] if out else None,
923
+ required_version=spec.min_version,
924
+ path=path,
925
+ error=None if ok else (
926
+ f"{spec.name} {detected} < required {spec.min_version}"
927
+ if detected else f"could not parse {spec.name} version from output"
928
+ ),
929
+ install_hint=None,
930
+ )
931
+ )
932
+ return results
933
+
934
+
935
+ _GKE_PLUGIN = "gke-gcloud-auth-plugin"
936
+
937
+
938
+ def _gcloud_sdk_bin_dirs() -> list[Path]:
939
+ """Directories where the gcloud SDK keeps its bundled binaries.
940
+
941
+ Resolves the real location of `gcloud` (following Homebrew/snap
942
+ symlinks) plus well-known SDK install roots.
943
+ """
944
+ dirs: list[Path] = []
945
+ gcloud = _which_with_extra_paths("gcloud")
946
+ if gcloud:
947
+ dirs.append(Path(os.path.realpath(gcloud)).parent)
948
+ proc = _run(["gcloud", "info", "--format=value(installation.sdk_root)"]) if gcloud else None
949
+ if proc is not None and proc.returncode == 0 and proc.stdout.strip():
950
+ dirs.append(Path(proc.stdout.strip()) / "bin")
951
+ home = Path.home()
952
+ dirs += [
953
+ Path("/opt/homebrew/share/google-cloud-sdk/bin"),
954
+ Path("/usr/local/share/google-cloud-sdk/bin"),
955
+ Path("/opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin"),
956
+ Path("/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/bin"),
957
+ home / "google-cloud-sdk" / "bin",
958
+ Path("/opt/google-cloud-sdk/bin"),
959
+ Path("/usr/lib/google-cloud-sdk/bin"),
960
+ Path("/snap/google-cloud-cli/current/bin"),
961
+ ]
962
+ seen: set[str] = set()
963
+ out: list[Path] = []
964
+ for d in dirs:
965
+ if str(d) not in seen:
966
+ seen.add(str(d))
967
+ out.append(d)
968
+ return out
969
+
970
+
971
+ def _find_gke_plugin() -> str | None:
972
+ found = shutil.which(_GKE_PLUGIN)
973
+ if found:
974
+ return found
975
+ exe = _GKE_PLUGIN + (".exe" if os.name == "nt" else "")
976
+ for d in _gcloud_sdk_bin_dirs():
977
+ cand = d / exe
978
+ if cand.is_file() and os.access(cand, os.X_OK):
979
+ return str(cand)
980
+ return None
981
+
982
+
983
+ def _link_onto_path(target: str) -> str | None:
984
+ """Symlink ``target`` into a directory that is on the user's PATH.
985
+
986
+ Prefers the directory where `gcloud` itself is linked (e.g.
987
+ /opt/homebrew/bin), falling back to ~/.local/bin. Returns the link
988
+ path, or None if no writable PATH directory was found.
989
+ """
990
+ if os.name == "nt":
991
+ return None
992
+ # Must be called BEFORE the plugin dir is added to this process's PATH,
993
+ # otherwise `which gcloud` may resolve inside the SDK dir itself.
994
+ target_real = os.path.realpath(target)
995
+ target_dir = os.path.realpath(os.path.dirname(target))
996
+ path_dirs = os.environ.get("PATH", "").split(os.pathsep)
997
+ candidates: list[Path] = []
998
+ gcloud_link = shutil.which("gcloud")
999
+ if gcloud_link:
1000
+ candidates.append(Path(gcloud_link).parent)
1001
+ candidates.append(Path.home() / ".local" / "bin")
1002
+ for d in candidates:
1003
+ if str(d) not in path_dirs or os.path.realpath(d) == target_dir:
1004
+ continue # not on PATH, or the plugin's own dir (would self-link)
1005
+ link = d / _GKE_PLUGIN
1006
+ try:
1007
+ if link.is_symlink():
1008
+ if os.path.realpath(link) == target_real:
1009
+ return str(link) # already correct
1010
+ link.unlink() # stale/broken symlink only
1011
+ elif link.exists():
1012
+ continue # a real file: never overwrite
1013
+ d.mkdir(parents=True, exist_ok=True)
1014
+ link.symlink_to(target_real)
1015
+ return str(link)
1016
+ except OSError:
1017
+ continue
1018
+ return None
1019
+
1020
+
1021
+ def ensure_gke_auth_plugin(actions: list[str], *, dry_run: bool = False) -> PrereqStatus:
1022
+ """Make sure ``gke-gcloud-auth-plugin`` is installed and callable.
1023
+
1024
+ 1. Look on PATH and inside the gcloud SDK bin directories.
1025
+ 2. If missing, install it via ``gcloud components install``
1026
+ (falls back to a hint for apt/snap-managed SDKs).
1027
+ 3. If found outside PATH, prepend its directory to this process's
1028
+ PATH (so kubectl/helm subprocesses work immediately) and symlink
1029
+ it into a PATH directory so the user's shell works too.
1030
+ """
1031
+ def status(ok: bool, path: str | None, error: str | None, hint: str | None) -> PrereqStatus:
1032
+ return PrereqStatus(
1033
+ tool=_GKE_PLUGIN, category="tool", installed=path is not None,
1034
+ version_ok=ok, detected_version=None, required_version=None,
1035
+ path=path, error=error, install_hint=hint,
1036
+ )
1037
+
1038
+ manual_hint = (
1039
+ "gcloud components install gke-gcloud-auth-plugin "
1040
+ "(apt: sudo apt-get install google-cloud-cli-gke-gcloud-auth-plugin)"
1041
+ )
1042
+ plugin = _find_gke_plugin()
1043
+ if plugin is None:
1044
+ if not _which_with_extra_paths("gcloud"):
1045
+ return status(False, None, "gcloud not installed", manual_hint)
1046
+ if dry_run:
1047
+ actions.append(f"[dry-run] would install {_GKE_PLUGIN}")
1048
+ return status(False, None, f"{_GKE_PLUGIN} not installed", manual_hint)
1049
+ print(f"[fast2dev] Installing {_GKE_PLUGIN} via gcloud components ...")
1050
+ proc = _run(
1051
+ ["gcloud", "components", "install", _GKE_PLUGIN, "--quiet"],
1052
+ timeout=INSTALL_TIMEOUT_S,
1053
+ )
1054
+ if proc.returncode != 0:
1055
+ tail = ((proc.stdout or "") + (proc.stderr or "")).strip().splitlines()[-3:]
1056
+ return status(False, None, " / ".join(tail) or "install failed", manual_hint)
1057
+ actions.append(f"installed {_GKE_PLUGIN}")
1058
+ plugin = _find_gke_plugin()
1059
+ if plugin is None:
1060
+ return status(False, None, f"{_GKE_PLUGIN} installed but not found", manual_hint)
1061
+
1062
+ if shutil.which(_GKE_PLUGIN) is None:
1063
+ plugin_dir = str(Path(plugin).parent)
1064
+ link = None if dry_run else _link_onto_path(plugin)
1065
+ # Always expose it to this process (kubectl/helm subprocesses).
1066
+ _extend_path_for_current_process(plugin_dir)
1067
+ if not dry_run:
1068
+ if link:
1069
+ actions.append(f"linked {_GKE_PLUGIN} -> {link}")
1070
+ print(f"[fast2dev] Linked {_GKE_PLUGIN} into {Path(link).parent} (it was not on PATH)")
1071
+ else:
1072
+ print(
1073
+ f"[fast2dev] {_GKE_PLUGIN} found at {plugin} but not on your PATH. "
1074
+ f'Add to your shell profile: export PATH="{plugin_dir}:$PATH"'
1075
+ )
1076
+ return status(True, plugin, None, None)
1077
+
1078
+
1079
+ def _resolve_download_url(spec: ToolSpec, os_token: str, arch_token: str) -> str | None:
1080
+ """Build the concrete download URL for a tool on this host.
1081
+
1082
+ Returns None if the tool has no ``download_url`` template. The
1083
+ placeholders substituted are ``{version}``, ``{os}``, ``{arch}``,
1084
+ and ``{ext}`` (set to ``"tar.gz"`` on Unix, ``"zip"`` on Windows).
1085
+ """
1086
+ if not spec.download_url:
1087
+ return None
1088
+ version = spec.download_version or spec.min_version or "latest"
1089
+ ext = "zip" if os_token == "windows" else "tar.gz"
1090
+ return spec.download_url.format(
1091
+ version=version, os=os_token, arch=arch_token, ext=ext,
1092
+ )
1093
+
1094
+
1095
+ def install_external_tool(
1096
+ spec: ToolSpec,
1097
+ info: PlatformInfo | None = None,
1098
+ *,
1099
+ dry_run: bool = False,
1100
+ ) -> bool:
1101
+ """Install a single external tool. Returns True on success.
1102
+
1103
+ Strategy (in order, depending on platform and ``spec.prefer_download``):
1104
+ - Tools with ``prefer_download=True`` (terraform, kubectl, gcloud,
1105
+ helm, terragrunt): try direct download from the vendor's
1106
+ official URL first, then fall back to the OS package manager.
1107
+ - Tools without ``prefer_download`` (git, jq, curl, docker): try
1108
+ the OS package manager first (apt / brew / choco / winget),
1109
+ since these are always in the distro's core repos and don't
1110
+ need a third-party repo to be configured.
1111
+ - Windows: package manager (choco/winget) is always tried first;
1112
+ the user is told to use WSL2 if the tool has no Windows story.
1113
+ """
1114
+ info = info or detect_platform()
1115
+ os_token = _detect_os_token(info)
1116
+ arch_token = _detect_arch_token(info)
1117
+
1118
+ def _run_privileged(cmd: list[str]) -> bool:
1119
+ if dry_run:
1120
+ print(f"[dry-run] would run: {' '.join(cmd)}")
1121
+ return True
1122
+ print(f"[fast2dev] Running: {' '.join(cmd)}")
1123
+ try:
1124
+ proc = subprocess.run(cmd, check=False, timeout=INSTALL_TIMEOUT_S)
1125
+ return proc.returncode == 0
1126
+ except (subprocess.SubprocessError, OSError) as exc:
1127
+ print(f"[fast2dev] install failed: {exc}")
1128
+ return False
1129
+
1130
+ def _try_download() -> bool:
1131
+ url = _resolve_download_url(spec, os_token, arch_token)
1132
+ if not url:
1133
+ return False
1134
+ return _download_and_install_binary(
1135
+ spec.name, url,
1136
+ dry_run=dry_run,
1137
+ archive=spec.download_format,
1138
+ archive_member=spec.download_member,
1139
+ )
1140
+
1141
+ # Linux / WSL ------------------------------------------------------------
1142
+ if info.is_linux:
1143
+ if spec.prefer_download:
1144
+ if _try_download():
1145
+ return True
1146
+ # fall through to apt
1147
+ if spec.apt_package and info.has_apt:
1148
+ sudo = [] if os.geteuid() == 0 else ["sudo"]
1149
+ cmd = [*sudo, "apt-get", "install", "-y", spec.apt_package]
1150
+ if _run_privileged(cmd):
1151
+ return True
1152
+ if _try_download():
1153
+ return True
1154
+ return False
1155
+
1156
+ # macOS ------------------------------------------------------------------
1157
+ if info.is_macos:
1158
+ if spec.prefer_download:
1159
+ if _try_download():
1160
+ return True
1161
+ if spec.brew_package and info.has_brew:
1162
+ if _run_privileged(["brew", "install", spec.brew_package]):
1163
+ return True
1164
+ if _try_download():
1165
+ return True
1166
+ return False
1167
+
1168
+ # Windows (non-WSL) ------------------------------------------------------
1169
+ if info.is_windows:
1170
+ if spec.choco_package and info.has_choco:
1171
+ if _run_privileged(["choco", "install", "-y", spec.choco_package]):
1172
+ return True
1173
+ if spec.winget_package and info.has_winget:
1174
+ if _run_privileged([
1175
+ "winget", "install", "--id", spec.winget_package, "-e",
1176
+ "--accept-package-agreements", "--accept-source-agreements",
1177
+ ]):
1178
+ return True
1179
+ # gcloud, terragrunt, kubectl have no clean Windows story; tell the user.
1180
+ print(
1181
+ f"[fast2dev] {spec.name} is best installed inside WSL2 on Windows. "
1182
+ f"Hint: {spec.install_hint}"
1183
+ )
1184
+ return False
1185
+
1186
+ print(f"[fast2dev] Unsupported OS for {spec.name}: {info.os}")
1187
+ return False
1188
+
1189
+
1190
+ def _download_and_install_binary(
1191
+ name: str, url: str, *, dry_run: bool = False,
1192
+ archive: str | None = None,
1193
+ archive_member: str | None = None,
1194
+ ) -> bool:
1195
+ """Download a tool from ``url`` and install it to /usr/local/bin
1196
+ (or ``~/.local/bin`` if not running as root).
1197
+
1198
+ Parameters
1199
+ ----------
1200
+ name : str
1201
+ Final name to install the binary as (e.g. ``kubectl``).
1202
+ url : str
1203
+ Direct download URL.
1204
+ archive : str, optional
1205
+ Set to ``"zip"`` or ``"tar.gz"`` if the URL serves an archive
1206
+ rather than a single binary. The archive will be downloaded,
1207
+ the member that contains the binary will be extracted.
1208
+ archive_member : str, optional
1209
+ The path of the binary inside the archive (e.g. ``terraform``).
1210
+ If not given, defaults to ``name``.
1211
+
1212
+ Why this exists: apt repos for HashiCorp, Google, and Kubernetes
1213
+ are not always configured on a clean host, leading to
1214
+ ``E: Unable to locate package terraform`` style failures. Direct
1215
+ downloads from the official sources are distro-agnostic, don't
1216
+ need sudo for the network step, and install to the same path
1217
+ apt would have.
1218
+ """
1219
+ if dry_run:
1220
+ kind = f" (extract {archive_member or name} from {archive})" if archive else ""
1221
+ print(f"[dry-run] would download {url} and install as {name}{kind}")
1222
+ return True
1223
+
1224
+ import tempfile
1225
+ import urllib.request
1226
+ import zipfile
1227
+
1228
+ with tempfile.TemporaryDirectory() as td:
1229
+ work = Path(td)
1230
+ print(f"[fast2dev] Downloading {url} ...")
1231
+ try:
1232
+ with urllib.request.urlopen(url, timeout=INSTALL_TIMEOUT_S) as resp:
1233
+ payload = resp.read()
1234
+ except (OSError, urllib.error.URLError) as exc:
1235
+ print(f"[fast2dev] download failed: {exc}")
1236
+ return False
1237
+
1238
+ if archive == "zip":
1239
+ archive_path = work / "archive.zip"
1240
+ archive_path.write_bytes(payload)
1241
+ member = archive_member or name
1242
+ try:
1243
+ with zipfile.ZipFile(archive_path) as zf:
1244
+ binary_bytes = zf.read(member)
1245
+ except (zipfile.BadZipFile, KeyError) as exc:
1246
+ print(f"[fast2dev] zip extract failed: {exc}")
1247
+ return False
1248
+ elif archive == "tar.gz":
1249
+ import tarfile
1250
+ archive_path = work / "archive.tar.gz"
1251
+ archive_path.write_bytes(payload)
1252
+ member = archive_member or name
1253
+ try:
1254
+ with tarfile.open(archive_path, "r:gz") as tf:
1255
+ found = None
1256
+ for m in tf.getmembers():
1257
+ if m.name.endswith(member) and m.isfile():
1258
+ found = m
1259
+ break
1260
+ if found is None:
1261
+ print(f"[fast2dev] could not find {member!r} in tarball")
1262
+ return False
1263
+ binary_bytes = tf.extractfile(found).read()
1264
+ except (tarfile.TarError, KeyError) as exc:
1265
+ print(f"[fast2dev] tar.gz extract failed: {exc}")
1266
+ return False
1267
+ else:
1268
+ # Single binary download (e.g. terragrunt, kubectl, helm).
1269
+ binary_bytes = payload
1270
+
1271
+ if os.geteuid() == 0:
1272
+ dest = Path("/usr/local/bin") / name
1273
+ dest.write_bytes(binary_bytes)
1274
+ dest.chmod(0o755)
1275
+ print(f"[fast2dev] installed to {dest}")
1276
+ else:
1277
+ user_bin = Path.home() / ".local" / "bin"
1278
+ user_bin.mkdir(parents=True, exist_ok=True)
1279
+ dest = user_bin / name
1280
+ dest.write_bytes(binary_bytes)
1281
+ dest.chmod(0o755)
1282
+ print(f"[fast2dev] installed to {dest} (add {user_bin} to PATH if not already)")
1283
+ # Expose the new location to the current process so the
1284
+ # post-install re-check (and any in-process subprocess) sees
1285
+ # the tool without requiring a shell restart.
1286
+ _extend_path_for_current_process(str(user_bin))
1287
+ return True
1288
+
1289
+
1290
+ # ---------------------------------------------------------------------------
1291
+ # Top-level precheck orchestrator
1292
+ # ---------------------------------------------------------------------------
1293
+
1294
+
1295
+ def run_precheck(
1296
+ *,
1297
+ interactive: bool = True,
1298
+ auto_install_python: bool = True,
1299
+ auto_install_tools: bool = False,
1300
+ only: Iterable[str] | None = None,
1301
+ dry_run: bool = False,
1302
+ ) -> PrecheckResult:
1303
+ """Run the full precheck: venv -> python runtime -> pip pkgs -> external tools.
1304
+
1305
+ On a fully prepared host this takes the fast path: <100 ms, no
1306
+ prompts, no installs. On a missing-prereq host it installs Python
1307
+ packages silently (if ``auto_install_python``) and prompts for
1308
+ external tools (if ``interactive``), or auto-installs them if
1309
+ ``auto_install_tools`` is set.
1310
+
1311
+ Returns a :class:`PrecheckResult` so the caller can decide what
1312
+ to do next (e.g. the CLI proceeds to Phase 1 if ``ready``).
1313
+ """
1314
+ info = detect_platform()
1315
+ actions: list[str] = []
1316
+ statuses: list[PrereqStatus] = []
1317
+
1318
+ # Runtime check first — if Python itself is too old, nothing else matters.
1319
+ py_status = check_python_runtime()
1320
+ statuses.append(py_status)
1321
+ if not py_status.ok:
1322
+ return PrecheckResult(
1323
+ ready=False,
1324
+ statuses=statuses,
1325
+ actions_taken=actions,
1326
+ missing_actionable=[
1327
+ f"Python {REQUIRED_PYTHON_MAJOR}.{REQUIRED_PYTHON_MINOR}+ is required "
1328
+ f"(found {py_status.detected_version}). Install from https://python.org"
1329
+ ],
1330
+ platform=info,
1331
+ )
1332
+
1333
+ # Python packages.
1334
+ py_pkg_statuses = check_python_packages()
1335
+ missing_py = [s for s in py_pkg_statuses if not s.ok]
1336
+ if missing_py and auto_install_python:
1337
+ actions.extend(install_python_packages())
1338
+ # Re-check after install.
1339
+ py_pkg_statuses = check_python_packages()
1340
+ statuses.extend(py_pkg_statuses)
1341
+
1342
+ # External tools.
1343
+ tool_statuses = check_external_tools()
1344
+ only_set = {x.strip() for x in only} if only else None
1345
+ targets = [
1346
+ s for s in tool_statuses
1347
+ if (only_set is None or s.tool in only_set) and not s.ok
1348
+ ]
1349
+ if targets and (auto_install_tools or interactive):
1350
+ # Build the install list from the registry.
1351
+ specs_by_name = {t.name: t for t in REQUIRED_TOOLS}
1352
+ for s in targets:
1353
+ spec = specs_by_name.get(s.tool)
1354
+ if not spec:
1355
+ continue
1356
+ proceed = True
1357
+ if interactive and not auto_install_tools:
1358
+ ans = _prompt_yes_no(
1359
+ f"Install {s.tool}? [Y/n] (or 'm' to see the manual command)"
1360
+ )
1361
+ if ans == "no":
1362
+ proceed = False
1363
+ elif ans == "manual":
1364
+ print(f" {s.install_hint or f'install {s.tool} manually'}")
1365
+ proceed = False
1366
+ if not proceed:
1367
+ continue
1368
+ if install_external_tool(spec, info=info, dry_run=dry_run):
1369
+ actions.append(f"installed {s.tool}")
1370
+ # Re-check after installs.
1371
+ tool_statuses = check_external_tools()
1372
+ statuses.extend(tool_statuses)
1373
+
1374
+ # kubectl needs gke-gcloud-auth-plugin for GKE kubeconfigs. It ships
1375
+ # inside the gcloud SDK but is often not on PATH (e.g. Homebrew only
1376
+ # links `gcloud`), so locate/install it and expose it automatically.
1377
+ if only_set is None or "gke-gcloud-auth-plugin" in only_set:
1378
+ statuses.append(ensure_gke_auth_plugin(actions, dry_run=dry_run))
1379
+
1380
+ missing = [s for s in statuses if not s.ok]
1381
+ hints = [s.install_hint for s in missing if s.install_hint]
1382
+ return PrecheckResult(
1383
+ ready=not missing,
1384
+ statuses=statuses,
1385
+ actions_taken=actions,
1386
+ missing_actionable=hints,
1387
+ platform=info,
1388
+ )
1389
+
1390
+
1391
+ # ---------------------------------------------------------------------------
1392
+ # User prompt helper
1393
+ # ---------------------------------------------------------------------------
1394
+
1395
+
1396
+ def _prompt_yes_no(question: str) -> str:
1397
+ """Prompt yes/no/manual in a way that works in any terminal.
1398
+
1399
+ Returns one of: "yes", "no", "manual". Falls back to "no" on EOF.
1400
+ Uses stdin.readline so the import of readline is lazy and doesn't
1401
+ require a TTY in tests.
1402
+ """
1403
+ try:
1404
+ print(f"[fast2dev] {question}")
1405
+ sys.stdout.flush()
1406
+ line = sys.stdin.readline()
1407
+ except (EOFError, KeyboardInterrupt):
1408
+ return "no"
1409
+ if not line:
1410
+ return "no"
1411
+ s = line.strip().lower()
1412
+ if s in ("", "y", "yes"):
1413
+ return "yes"
1414
+ if s == "m":
1415
+ return "manual"
1416
+ return "no"
1417
+
1418
+
1419
+ # ---------------------------------------------------------------------------
1420
+ # JSON serialization helper
1421
+ # ---------------------------------------------------------------------------
1422
+
1423
+
1424
+ def result_to_json(result: PrecheckResult) -> str:
1425
+ """Render a :class:`PrecheckResult` as JSON. Excludes non-serializable fields."""
1426
+ payload = {
1427
+ "ready": result.ready,
1428
+ "actions_taken": result.actions_taken,
1429
+ "missing_actionable": result.missing_actionable,
1430
+ "platform": asdict(result.platform) if result.platform else None,
1431
+ "statuses": [asdict(s) for s in result.statuses],
1432
+ }
1433
+ return json.dumps(payload, indent=2, default=str)
1434
+
1435
+
1436
+ # ---------------------------------------------------------------------------
1437
+ # Module CLI
1438
+ # ---------------------------------------------------------------------------
1439
+
1440
+
1441
+ def _print_table(result: PrecheckResult) -> None:
1442
+ """Render the result to stdout in the standard text form."""
1443
+ print(f"[fast2dev] Host precheck ({result.platform.short_label if result.platform else 'unknown'}):")
1444
+ print(result.render_table())
1445
+ if result.ready:
1446
+ print("[fast2dev] ✅ host ready. You can proceed with platform deployment.")
1447
+ else:
1448
+ print("[fast2dev] ❌ host NOT ready. Install the items above, or re-run with --auto-install-prereqs.")
1449
+
1450
+
1451
+ def _module_main(argv: list[str] | None = None) -> int:
1452
+ """Entry point for ``python -m platform.utils.host_prep``."""
1453
+ import argparse
1454
+
1455
+ # Common args shared with the ``install`` subparser (subparsers
1456
+ # don't inherit parent args in argparse without ``parents=``).
1457
+ _common = argparse.ArgumentParser(add_help=False)
1458
+ _common.add_argument("--json", action="store_true",
1459
+ help="emit result as JSON instead of a status table")
1460
+ _common.add_argument("--auto-install-python", action="store_true", default=True,
1461
+ help="auto-install missing Python packages (default: true)")
1462
+ _common.add_argument("--no-auto-install-python", dest="auto_install_python",
1463
+ action="store_false")
1464
+ _common.add_argument("--auto-install-prereqs", action="store_true",
1465
+ help="auto-install external tools as well (no prompts)")
1466
+ _common.add_argument("--dry-run", action="store_true",
1467
+ help="print install commands but don't change the host")
1468
+ _common.add_argument("--only", default=None,
1469
+ help="comma-separated tool names to restrict install to "
1470
+ "(e.g. kubectl,helm)")
1471
+
1472
+ parser = argparse.ArgumentParser(
1473
+ prog="python -m platform.utils.host_prep",
1474
+ description="fast2.dev host precheck (Python runtime, pip packages, external tools).",
1475
+ )
1476
+ sub = parser.add_subparsers(dest="cmd", required=True)
1477
+ sub.add_parser("check", parents=[_common],
1478
+ help="run the precheck and print status (no install)")
1479
+ sub.add_parser("install", parents=[_common],
1480
+ help="run the precheck and install missing items")
1481
+ sub.add_parser("ensure-venv",
1482
+ help="create the project venv if missing and print its python path")
1483
+ args = parser.parse_args(argv)
1484
+
1485
+ if args.cmd == "ensure-venv":
1486
+ py = ensure_venv(force=False)
1487
+ if py:
1488
+ print(str(py))
1489
+ return 0
1490
+ if is_in_venv():
1491
+ print(f"already in venv: {sys.executable}", file=sys.stderr)
1492
+ return 0
1493
+ info = detect_platform()
1494
+ if in_throwaway_env(info):
1495
+ print(f"throwaway env ({info.short_label}); system python OK: {sys.executable}")
1496
+ return 0
1497
+ print("could not create venv; see errors above", file=sys.stderr)
1498
+ return 1
1499
+
1500
+ if args.cmd == "check":
1501
+ result = run_precheck(
1502
+ interactive=False,
1503
+ auto_install_python=False,
1504
+ auto_install_tools=False,
1505
+ )
1506
+ else: # install
1507
+ result = run_precheck(
1508
+ interactive=sys.stdin.isatty(),
1509
+ auto_install_python=args.auto_install_python,
1510
+ auto_install_tools=args.auto_install_prereqs,
1511
+ only=args.only.split(",") if args.only else None,
1512
+ dry_run=args.dry_run,
1513
+ )
1514
+
1515
+ if args.json:
1516
+ print(result_to_json(result))
1517
+ else:
1518
+ _print_table(result)
1519
+ return 0 if result.ready else 1
1520
+
1521
+
1522
+ if __name__ == "__main__":
1523
+ sys.exit(_module_main())