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.
- f2dev/__init__.py +1 -0
- f2dev/__main__.py +5 -0
- f2dev/_bundle/platform/.dockerignore +80 -0
- f2dev/_bundle/platform/.gitignore +82 -0
- f2dev/_bundle/platform/LICENSE +202 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/template_values.yaml +1731 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/Chart.yaml +9 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-airflow-deploy.yaml +60 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-bi-sync.yaml +46 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-checkout.yaml +49 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-console-sync.yaml +41 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-e2e-label.yaml +48 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-e2e-run.yaml +43 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-e2e-teardown.yaml +47 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-governance.yaml +40 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-lint.yaml +37 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-notify.yaml +32 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-quality.yaml +38 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-refresh.yaml +36 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-supersede.yaml +30 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/block-tags.yaml +44 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/pipeline-branch.yaml +138 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/pipeline-main.yaml +150 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/files/pipeline-pr.yaml +184 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/templates/NOTES.txt +18 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/templates/settings-configmap.yaml +14 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/templates/workflowtemplates.yaml +31 -0
- f2dev/_bundle/platform/charts/data_services_charts/argo_workflows/workflow_templates/values.yaml +41 -0
- f2dev/_bundle/platform/charts/data_services_charts/cicd_workload_runner/github/template_github_values.yaml +436 -0
- f2dev/_bundle/platform/charts/data_services_charts/cicd_workload_runner/github/template_github_values_extra.yaml +49 -0
- f2dev/_bundle/platform/charts/data_services_charts/cicd_workload_runner/gitlab/template_gitlab_values.yaml +551 -0
- f2dev/_bundle/platform/charts/data_services_charts/cicd_workload_runner/gitlab/template_gitlab_values_extra.yaml +9 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_analysis/lightdash/template_values.yaml +359 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_analysis/metabase/template_values.yaml +384 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_analysis/superset/template_values.yaml +1562 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_analysis/template_values.yaml +269 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/.helmignore +15 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/Chart.yaml +20 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/template_values.yaml.j2 +175 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/NOTES.txt +19 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/_helpers.tpl +50 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/cicd-rbac.yaml +30 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/configmap.yaml +142 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/extras.yaml +14 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/ingress.yaml +69 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/promtail-configmap.yaml +68 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/secret.yaml +31 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/service.yaml +15 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/serviceaccount.yaml +12 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/statefulset.yaml +276 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/valkey.yaml +113 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/templates/warehouse-stats-cronjob.yaml +107 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_control_plane/values.yaml +828 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_dbt_server/template_values.yaml +385 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_governance/template_dh_prerequisites_values.yaml +118 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_governance/template_dh_values.yaml +1671 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_governance/template_kafka_values.yaml +112 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_governance/template_opensearch_values.yaml +662 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_governance/template_values.yaml +738 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/Chart.yaml +6 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/files/argo-openapi.json +681 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/templates/_helpers.tpl +17 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/templates/argo-rbac.yaml +35 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/templates/backends.yaml +327 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/templates/gateway.yaml +150 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/hub/values.yaml +91 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_mcp_hub/template_values.yaml +142 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_modeling/template_values.yaml +1167 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_modeling/template_values_extra.yaml +99 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/airflow-cleanup/Dockerfile +10 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/airflow-cleanup/build.sh +38 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/airflow-cleanup/cleanup.py +452 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/airflow-cleanup/requirements.txt +3 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/docs/keycloak-oidc-setup.md +106 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/template_values.yaml +5536 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/template_values_extra.yaml +379 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/webserver-config/configmap.yaml +459 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/webserver-config/fast2dev_auth.py +285 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/webserver-config/fast2dev_mcp_plugin.py +24 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_orchestration/webserver-config/webserver_config.py +130 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/Dockerfile +10 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/build.sh +38 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/cleanup.py +749 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/k8s/configmap.yaml +24 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/k8s/cronjob.yaml +137 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte-cleanup/requirements.txt +3 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/.helmignore +26 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/Chart.lock +3 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/Chart.yaml +15 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/README.md +243 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/NOTES.txt +31 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/_helpers.tpl +245 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/_images.tpl +17 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-auth-secret.yaml +35 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-bootloader/bootloader-secrets.yaml +19 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-bootloader/pod.yaml +126 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-connector-rollout-worker/deployment.yaml +171 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-cron/cron-secrets.yaml +19 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-cron/deployment.yaml +149 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-db.yaml +88 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/_helpers.tpl +111 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/deployment.yaml +169 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/hpa.yaml +23 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/pdb.yaml +17 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/service.yaml +25 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-direct-job-runner/serviceaccount.yaml +10 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-featureflag-server/deployment.yaml +161 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-featureflag-server/service.yaml +25 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-keycloak/service.yaml +62 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-keycloak/statefulset.yaml +182 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-manifest-server/_helpers.tpl +54 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-manifest-server/deployment.yaml +152 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-manifest-server/service.yaml +23 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-manifest-server/serviceaccount.yaml +10 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-metrics/deployment.yaml +124 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-server/deployment.yaml +227 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-server/service.yaml +29 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-stigg-sidecar/deployment.yaml +184 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-stigg-sidecar/service.yaml +21 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-temporal/configmap.yaml +55 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-temporal/deployment.yaml +220 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-temporal/service.yaml +21 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-temporal-ui/deployment.yaml +122 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-temporal-ui/service.yaml +23 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-webapp/deployment.yaml +146 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-webapp/ingress.yaml +63 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-webapp/service.yaml +32 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-worker/deployment.yaml +229 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-workload-api-server/deployment.yaml +191 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-workload-api-server/service.yaml +25 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-workload-launcher/deployment.yaml +232 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/airbyte-workload-launcher/jobs-secrets.yaml +21 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_auth.tpl +944 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_aws.tpl +109 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_cluster.tpl +82 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_common.tpl +370 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_connector.tpl +58 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_connectorRollout.tpl +141 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_connectorRolloutWorker.tpl +56 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_cron.tpl +62 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_customerio.tpl +56 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_database.tpl +375 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_dataplaneGroups.tpl +38 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_directJobRunner.tpl +122 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_featureFlags.tpl +126 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_java.tpl +38 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_jobs.tpl +422 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_keycloak.tpl +542 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_logging.tpl +38 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_metrics.tpl +214 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_micronaut.tpl +43 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_minio.tpl +64 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_secretsManager.tpl +628 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_server.tpl +533 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_shopify.tpl +83 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_stigg.tpl +157 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_storage.tpl +468 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_temporal.tpl +943 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_topology.tpl +98 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_tracking.tpl +82 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_webapp.tpl +38 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_worker.tpl +366 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_workloadApiServer.tpl +62 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_workloadLauncher.tpl +395 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/config/_workloads.tpl +770 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/env-configmap.yaml +62 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/gcs-log-creds-secret.yaml +19 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/ingress.yaml +69 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/minio.yaml +161 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/secret.yaml +31 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/serviceaccount.yaml +50 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/telemetry-configmap.yaml +32 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/templates/tests/test-webapp.yaml +34 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte/values.yaml +3158 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/.helmignore +12 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/Chart.yaml +16 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/README.md +172 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/templates/_helpers.tpl +42 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/templates/deployment.yaml +105 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/templates/externalsecret.yaml +23 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/templates/pdb.yaml +15 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/templates/service.yaml +18 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/airbyte_chart/airbyte-metrics-fast2dev-ddp/values.yaml +97 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/feature-flags-configmap.yaml +16 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/template_metrics_values.yaml +13 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/template_oauth2proxy_values.yaml +1200 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_replication/template_values.yaml +3255 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/Chart.yaml +7 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/hazelcast-client.yaml +27 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/hazelcast-master.yaml +38 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/hazelcast-worker.yaml +29 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/jvm_client_options +24 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/jvm_master_options +6 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/jvm_worker_options +6 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/log4j2.properties +109 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/conf/seatunnel.yaml +36 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/_helpers.tpl +70 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/configmap.yaml +11 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/deployment-master.yaml +120 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/deployment-worker.yaml +118 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/rbac.yaml +32 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/templates/services.yaml +33 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/seatunnel/values.yaml +101 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/template_oauth2proxy_values.yaml +196 -0
- f2dev/_bundle/platform/charts/data_services_charts/data_streaming/template_values.yaml +75 -0
- f2dev/_bundle/platform/charts/data_services_charts/object_storage_operator/template_values.yaml +506 -0
- f2dev/_bundle/platform/charts/infra_services_charts/cert_manager/csi_driver_values.yaml +193 -0
- f2dev/_bundle/platform/charts/infra_services_charts/cert_manager/template_pdns_webhook_values.yaml +91 -0
- f2dev/_bundle/platform/charts/infra_services_charts/cert_manager/template_values.yaml +1777 -0
- f2dev/_bundle/platform/charts/infra_services_charts/cert_manager/template_values_extra.yaml +253 -0
- f2dev/_bundle/platform/charts/infra_services_charts/cluster_cleaner/template_values.yaml +57 -0
- f2dev/_bundle/platform/charts/infra_services_charts/external_dns/template_values.yaml +476 -0
- f2dev/_bundle/platform/charts/infra_services_charts/external_dns/template_values_extra.yaml +131 -0
- f2dev/_bundle/platform/charts/infra_services_charts/idp_sso_manager/realm_template.json +4785 -0
- f2dev/_bundle/platform/charts/infra_services_charts/idp_sso_manager/template_values.yaml +657 -0
- f2dev/_bundle/platform/charts/infra_services_charts/pvc_autoscaller/template_values.yaml +36 -0
- f2dev/_bundle/platform/charts/infra_services_charts/pvc_autoscaller/template_values_extra.yaml +352 -0
- f2dev/_bundle/platform/charts/infra_services_charts/secret_manager/template_values.yaml +1218 -0
- f2dev/_bundle/platform/charts/infra_services_charts/secret_manager/template_values_extra.yaml +845 -0
- f2dev/_bundle/platform/charts/infra_services_charts/secret_manager_operator/template_values.yaml +561 -0
- f2dev/_bundle/platform/charts/infra_services_charts/secret_manager_operator/template_values_extra.yaml +23 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_logs/template_alloy_events_values.yaml +59 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_logs/template_alloy_values.yaml +185 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_logs/template_loki_values.yaml +108 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_metrics/template_values.yaml +1530 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/00-main/.gitkeep +0 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/00-main/f2d-main.json +2871 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/01-platform/.gitkeep +0 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/01-platform/f2d-k8s-cluster.json +1751 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/01-platform/f2d-microservices.json +1682 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/01-platform/f2d-pvc-storage.json +1320 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/01-platform/f2d-service.json +1193 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/.gitkeep +0 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/f2d-cert-manager.json +755 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/f2d-keycloak.json +746 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/f2d-object-storage.json +881 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/f2d-postgresql.json +1590 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/02-infrastructure/f2d-traefik.json +1375 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/.gitkeep +0 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-cicd-workflows-trends.json +1916 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-cicd-workflows.json +1330 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-analysis.json +631 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-freshness.json +1362 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-governance.json +1958 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-modeling.json +764 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-orchestration-trends.json +2352 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-orchestration.json +1506 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-quality.json +1549 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-replication-trends.json +2799 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-replication.json +2153 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-streaming-trends.json +1536 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/03-data-services/f2d-data-streaming.json +1209 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/04-data-warehouse/.gitkeep +0 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/04-data-warehouse-bigquery/.gitkeep +0 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/04-data-warehouse-bigquery/f2d-bigquery.json +990 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/05-logs/.gitkeep +0 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/05-logs/f2d-logs.json +630 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/folders.yaml +17 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/dashboards/requirements.yaml +8 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/template_alerts_cm.yaml +2031 -0
- f2dev/_bundle/platform/charts/infra_services_charts/services_monitoring/template_values.yaml +1315 -0
- f2dev/_bundle/platform/charts/infra_services_charts/stackgres_postgres_db/template_values.yaml +550 -0
- f2dev/_bundle/platform/charts/infra_services_charts/stackgres_postgres_db/template_values_extra.yaml +742 -0
- f2dev/_bundle/platform/charts/infra_services_charts/traefik_lb/template_values.yaml +1758 -0
- f2dev/_bundle/platform/cli/README.md +866 -0
- f2dev/_bundle/platform/cli/__init__.py +42 -0
- f2dev/_bundle/platform/cli/__main__.py +17 -0
- f2dev/_bundle/platform/cli/cert_providers.py +369 -0
- f2dev/_bundle/platform/cli/command_record.py +144 -0
- f2dev/_bundle/platform/cli/config/data_services_config.json +217 -0
- f2dev/_bundle/platform/cli/config/environment_profiles.yaml +183 -0
- f2dev/_bundle/platform/cli/config/images.json +129 -0
- f2dev/_bundle/platform/cli/config/infrastructure_services_config.json +141 -0
- f2dev/_bundle/platform/cli/config.py +252 -0
- f2dev/_bundle/platform/cli/deployment_configuration_aws_example.yaml +117 -0
- f2dev/_bundle/platform/cli/deployment_configuration_gcp_example.yaml +130 -0
- f2dev/_bundle/platform/cli/deployment_configuration_onprem_example.yaml +71 -0
- f2dev/_bundle/platform/cli/destroy.py +677 -0
- f2dev/_bundle/platform/cli/dns_check.py +27 -0
- f2dev/_bundle/platform/cli/dns_providers.py +405 -0
- f2dev/_bundle/platform/cli/exit_codes.py +32 -0
- f2dev/_bundle/platform/cli/fixers.py +56 -0
- f2dev/_bundle/platform/cli/generate_only.py +336 -0
- f2dev/_bundle/platform/cli/health_report.py +114 -0
- f2dev/_bundle/platform/cli/logging.py +206 -0
- f2dev/_bundle/platform/cli/main.py +5293 -0
- f2dev/_bundle/platform/cli/precheck.py +1523 -0
- f2dev/_bundle/platform/cli/prerequisites/README.md +208 -0
- f2dev/_bundle/platform/cli/prerequisites/install-prerequisites.bat +107 -0
- f2dev/_bundle/platform/cli/prerequisites/install-prerequisites.ps1 +343 -0
- f2dev/_bundle/platform/cli/prerequisites/install-prerequisites.sh +207 -0
- f2dev/_bundle/platform/cli/prerequisites/linux/install-linux.sh +775 -0
- f2dev/_bundle/platform/cli/prerequisites/macos/install-macos.sh +634 -0
- f2dev/_bundle/platform/cli/prerequisites/requirements.txt +41 -0
- f2dev/_bundle/platform/cli/prerequisites/verify-prerequisites.ps1 +150 -0
- f2dev/_bundle/platform/cli/prerequisites/verify-prerequisites.sh +418 -0
- f2dev/_bundle/platform/cli/prerequisites/versions.yaml +43 -0
- f2dev/_bundle/platform/cli/prerequisites/windows/install-windows.ps1 +1005 -0
- f2dev/_bundle/platform/cli/restore.py +179 -0
- f2dev/_bundle/platform/cli/service_gates.py +160 -0
- f2dev/_bundle/platform/cli/state.py +332 -0
- f2dev/_bundle/platform/cli/wizard.py +782 -0
- f2dev/_bundle/platform/cli.py +235 -0
- f2dev/_bundle/platform/deployers/__init__.py +4 -0
- f2dev/_bundle/platform/deployers/base_deployer.py +8 -0
- f2dev/_bundle/platform/deployers/clouds/__init__.py +0 -0
- f2dev/_bundle/platform/deployers/clouds/aws_cloud.py +619 -0
- f2dev/_bundle/platform/deployers/clouds/azure_cloud.py +0 -0
- f2dev/_bundle/platform/deployers/clouds/google_cloud.py +785 -0
- f2dev/_bundle/platform/deployers/clouds/terragrunt_progress.py +56 -0
- f2dev/_bundle/platform/deployers/services/data_services/1.0_cicd_workload_runner.py +644 -0
- f2dev/_bundle/platform/deployers/services/data_services/12.0_control_plane.py +321 -0
- f2dev/_bundle/platform/deployers/services/data_services/13.0_data_mcp_hub.py +362 -0
- f2dev/_bundle/platform/deployers/services/data_services/2.0_object_storage_operator.py +416 -0
- f2dev/_bundle/platform/deployers/services/data_services/2.5_services_logs.py +482 -0
- f2dev/_bundle/platform/deployers/services/data_services/3.0_data_cicd_workflows.py +361 -0
- f2dev/_bundle/platform/deployers/services/data_services/4.0_data_replication.py +534 -0
- f2dev/_bundle/platform/deployers/services/data_services/4.5_data_streaming.py +303 -0
- f2dev/_bundle/platform/deployers/services/data_services/5.0_data_orchestration.py +760 -0
- f2dev/_bundle/platform/deployers/services/data_services/6.0_data_modeling.py +753 -0
- f2dev/_bundle/platform/deployers/services/data_services/7.0_data_governance.py +795 -0
- f2dev/_bundle/platform/deployers/services/data_services/8.0_data_analysis.py +587 -0
- f2dev/_bundle/platform/deployers/services/infra_services/1.0_secret_operator.py +467 -0
- f2dev/_bundle/platform/deployers/services/infra_services/10.0_cluster_pvc_autoscaller.py +500 -0
- f2dev/_bundle/platform/deployers/services/infra_services/2.0_cert_manager.py +963 -0
- f2dev/_bundle/platform/deployers/services/infra_services/3.0_external_dns.py +823 -0
- f2dev/_bundle/platform/deployers/services/infra_services/4.0_traefik_lb.py +604 -0
- f2dev/_bundle/platform/deployers/services/infra_services/5.0_stackgres_postgresql.py +652 -0
- f2dev/_bundle/platform/deployers/services/infra_services/6.0_services_metrics.py +515 -0
- f2dev/_bundle/platform/deployers/services/infra_services/7.0_services_monitoring.py +787 -0
- f2dev/_bundle/platform/deployers/services/infra_services/8.0_cluster_cleaner.py +439 -0
- f2dev/_bundle/platform/deployers/services/infra_services/9.0_idp_sso_manager.py +790 -0
- f2dev/_bundle/platform/readme.md +47 -0
- f2dev/_bundle/platform/requirements.txt +14 -0
- f2dev/_bundle/platform/terraform/aws_cloud/templates/backend.tf_template +10 -0
- f2dev/_bundle/platform/terraform/aws_cloud/templates/defaults.yaml_template +11 -0
- f2dev/_bundle/platform/terraform/aws_cloud/templates/env.yaml_template +2 -0
- f2dev/_bundle/platform/terraform/aws_cloud/templates/root.hcl_advanced_template +134 -0
- f2dev/_bundle/platform/terraform/aws_cloud/templates/root.hcl_basic_template +134 -0
- f2dev/_bundle/platform/terraform/aws_cloud/templates/terragrunt.hcl_advanced_template +134 -0
- f2dev/_bundle/platform/terraform/aws_cloud/templates/terragrunt.hcl_basic_template +134 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/01-apps-vpc/terragrunt.hcl +26 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/02-create-dns-ns-record/terragrunt.hcl +16 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/03-eks-cluster/terragrunt.hcl +21 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/04-external_dns_sa/terragrunt.hcl +28 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/01-apps-vpc/terragrunt.hcl +25 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/02-eks-cluster/terragrunt.hcl +32 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/03-external-dns-irsa/terragrunt.hcl +34 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/04-cert-manager-irsa/terragrunt.hcl +34 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/05-create-dns-zone/terragrunt.hcl +22 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/06-create-dns-ns-record/terragrunt.hcl +44 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/bi-platform/empty.yaml +1 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/empty.yaml +1 -0
- f2dev/_bundle/platform/terraform/aws_cloud/terragrunt/env.hcl +2 -0
- f2dev/_bundle/platform/terraform/azure_cloud/README.md +3 -0
- f2dev/_bundle/platform/terraform/azure_cloud/templates/_keep_structure.txt +0 -0
- f2dev/_bundle/platform/terraform/google_cloud/README.md +20 -0
- f2dev/_bundle/platform/terraform/google_cloud/templates/backend.tf_template +7 -0
- f2dev/_bundle/platform/terraform/google_cloud/templates/defaults.yaml_template +12 -0
- f2dev/_bundle/platform/terraform/google_cloud/templates/env.yaml_template +2 -0
- f2dev/_bundle/platform/terraform/google_cloud/templates/root.hcl_advanced_template +114 -0
- f2dev/_bundle/platform/terraform/google_cloud/templates/root.hcl_basic_template +116 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/.gitignore +3 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/00-create-ou-folder/terragrunt.hcl +15 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/01-create-project/terragrunt.hcl +30 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/02-enable-apis/terragrunt.hcl +25 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/03-0-apps-vpc/terragrunt.hcl +134 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/04-external-ip-traefik/terragrunt.hcl +29 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/05-create-dns-zone/terragrunt.hcl +25 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/06-create-dns-ns-record/terragrunt.hcl +43 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/07-gke-cluster/terragrunt.hcl +103 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/08-dbt_deploy_sa/terragrunt.hcl +36 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/09-dbt_sa/terragrunt.hcl +40 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/10-cert_manager_sa/terragrunt.hcl +34 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/11-external_dns_sa/terragrunt.hcl +30 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/12-monitoring_sa/terragrunt.hcl +52 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/13-data_replication_sa/terragrunt.hcl +35 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/14-data_orchestration_sa/terragrunt.hcl +35 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/15-bi_data_sa/terragrunt.hcl +43 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/16-whitelist-external-ip-on-common/terragrunt.hcl +30 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/17-kubeconfig/terragrunt.hcl +23 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/bi-platform/18-data_streaming_sa/terragrunt.hcl +24 -0
- f2dev/_bundle/platform/terraform/google_cloud/terragrunt/empty.yaml +1 -0
- f2dev/_bundle/platform/utils/__init__.py +0 -0
- f2dev/_bundle/platform/utils/customer_data_platform_repository_operator.py +1098 -0
- f2dev/_bundle/platform/utils/customer_secret_manager_operations.py +1635 -0
- f2dev/_bundle/platform/utils/environment_profiles.py +58 -0
- f2dev/_bundle/platform/utils/helm_utils.py +215 -0
- f2dev/_bundle/platform/utils/infrastructure_deployment_operator.py +1532 -0
- f2dev/_bundle/platform/utils/keycloak_realm_reconcile.py +320 -0
- f2dev/_bundle/platform/utils/kubeconfig_fixer.py +265 -0
- f2dev/_bundle/platform/utils/raw_extras.py +34 -0
- f2dev/_bundle/platform/utils/readiness.py +330 -0
- f2dev/_bundle/platform/utils/secret_structure_upgrade.py +194 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/.gitignore +7 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/README.md +33 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/analyses/.gitkeep +0 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/dbt_project.yml +52 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/macros/.gitkeep +0 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/macros/fast2dev_bq_time_zones.sql +12 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/macros/fast2dev_monitoring_grain.sql +23 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_daily_spend.sql +19 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_daily_spend.yml +25 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_model_costs_daily.sql +16 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_model_costs_daily.yml +24 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_storage_by_dataset.sql +12 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_storage_by_dataset.yml +21 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_user_costs_daily.sql +14 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_user_costs_daily.yml +22 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_weekly_kpi.sql +52 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_weekly_kpi.yml +42 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_weekly_spend.sql +74 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/marts/fast2dev_bq_weekly_spend.yml +49 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/sources/billing_export.yml +9 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/staging/fast2dev_bq_billing_export.sql +9 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/models/staging/fast2dev_bq_billing_export.yml +4 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/packages.yml +5 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/profiles.yml +15 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/scripts/run_monitoring.py +201 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/seeds/.gitkeep +0 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/snapshots/.gitkeep +0 -0
- f2dev/_bundle/platform/utils/templates/control_plane_warehouse_stats_template/bigquery_usage/tests/.gitkeep +0 -0
- f2dev/_bundle/platform/utils/templates/dry_run/gcp_sa.json +12 -0
- f2dev/_bundle/platform/utils/templates/dry_run/kubeconfig.yaml +18 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/data_orchestrator/repository_structure/README.MD +50 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/data_orchestrator/repository_structure/dags/dbt/README.MD +47 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/data_orchestrator/repository_structure/dags/fast2dev_healthcheck.py_template_airflow_3.x +158 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/bitbucket/bitbucket-pipelines.yml_template +144 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitea/.gitea/PR_VALIDATION.md +52 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitea/.gitea/pull_request_template.md +48 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitea/.gitea/workflows/argo-workflows.yml_template +143 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitea/.gitea/workflows/pr-agent.yml +30 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitea/.gitea/workflows/validate-pr-description.yml +38 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/github/.github/PR_VALIDATION.md +52 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/github/.github/pull_request_template.md +48 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/github/.github/workflows/argo-workflows.yml_template +143 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/github/.github/workflows/pr-agent.yml +37 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/github/.github/workflows/validate-pr-description.yml +157 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitlab/.gitlab/PR_VALIDATION.md +43 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitlab/.gitlab/merge_request_templates/Default.md +48 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/gitlab/.gitlab-ci.yml_template +181 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/repository_structure/.gitignore +21 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/repository_structure/.pr_agent.toml +82 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/repository_structure/AGENTS.md +126 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/dbt_data_model/repository_structure/README.MD +101 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/infrastructure_deployment_files/DR.md +341 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/infrastructure_deployment_files/README.md.j2 +81 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/infrastructure_deployment_files/decrypt_files.py +331 -0
- f2dev/_bundle/platform/utils/templates/git_repo_templates/infrastructure_deployment_files/encrypt_files.py +321 -0
- f2dev/_bundle/platform/utils/templates/secret_structure_template/customer_vault_structure.json +502 -0
- f2dev/_bundle/platform/utils/vault_structure_sync.py +96 -0
- f2dev/_bundle/terraform-modules/README.md +12 -0
- f2dev/_bundle/terraform-modules/aws_cloud/README.md +7 -0
- f2dev/_bundle/terraform-modules/aws_cloud/eks/addons-roles.tf +298 -0
- f2dev/_bundle/terraform-modules/aws_cloud/eks/main.tf +313 -0
- f2dev/_bundle/terraform-modules/aws_cloud/eks/outputs.tf +3 -0
- f2dev/_bundle/terraform-modules/aws_cloud/eks/policies/lb-controller-policy.json +219 -0
- f2dev/_bundle/terraform-modules/aws_cloud/eks/provider.tf +36 -0
- f2dev/_bundle/terraform-modules/aws_cloud/eks/variables.tf +107 -0
- f2dev/_bundle/terraform-modules/aws_cloud/eks/versions.tf +10 -0
- f2dev/_bundle/terraform-modules/aws_cloud/gcp_aws_zone/main.tf +25 -0
- f2dev/_bundle/terraform-modules/aws_cloud/gcp_aws_zone/provider.tf +17 -0
- f2dev/_bundle/terraform-modules/aws_cloud/gcp_aws_zone/variables.tf +41 -0
- f2dev/_bundle/terraform-modules/aws_cloud/vpc/main.tf +34 -0
- f2dev/_bundle/terraform-modules/aws_cloud/vpc/outputs.tf +44 -0
- f2dev/_bundle/terraform-modules/aws_cloud/vpc/provider.tf +12 -0
- f2dev/_bundle/terraform-modules/aws_cloud/vpc/variables.tf +118 -0
- f2dev/_bundle/terraform-modules/aws_cloud/vpc/versions.tf +10 -0
- f2dev/_bundle/terraform-modules/azure_cloud/README.md +3 -0
- f2dev/_bundle/terraform-modules/google_cloud/README.md +17 -0
- f2dev/_bundle/terraform-modules/google_cloud/artifact-registry/main.tf +8 -0
- f2dev/_bundle/terraform-modules/google_cloud/artifact-registry/providers.tf +6 -0
- f2dev/_bundle/terraform-modules/google_cloud/artifact-registry/variables.tf +17 -0
- f2dev/_bundle/terraform-modules/google_cloud/artifact-registry/versions.tf +8 -0
- f2dev/_bundle/terraform-modules/google_cloud/cloud-dns/main.tf +24 -0
- f2dev/_bundle/terraform-modules/google_cloud/cloud-dns/outputs.tf +25 -0
- f2dev/_bundle/terraform-modules/google_cloud/cloud-dns/providers.tf +7 -0
- f2dev/_bundle/terraform-modules/google_cloud/cloud-dns/variables.tf +17 -0
- f2dev/_bundle/terraform-modules/google_cloud/cloud-dns/versions.tf +9 -0
- f2dev/_bundle/terraform-modules/google_cloud/cloud-dns-recordset/main.tf +38 -0
- f2dev/_bundle/terraform-modules/google_cloud/cloud-dns-recordset/variables.tf +73 -0
- f2dev/_bundle/terraform-modules/google_cloud/cloud-dns-recordset/versions.tf +39 -0
- f2dev/_bundle/terraform-modules/google_cloud/composer/main.tf +213 -0
- f2dev/_bundle/terraform-modules/google_cloud/composer/outputs.tf +31 -0
- f2dev/_bundle/terraform-modules/google_cloud/composer/provider.tf +4 -0
- f2dev/_bundle/terraform-modules/google_cloud/composer/variables.tf +192 -0
- f2dev/_bundle/terraform-modules/google_cloud/create-ou-folder/main.tf +29 -0
- f2dev/_bundle/terraform-modules/google_cloud/create-ou-folder/output.tf +4 -0
- f2dev/_bundle/terraform-modules/google_cloud/create-ou-folder/providers.tf +6 -0
- f2dev/_bundle/terraform-modules/google_cloud/create-ou-folder/variables.tf +40 -0
- f2dev/_bundle/terraform-modules/google_cloud/create-ou-folder/versions.tf +8 -0
- f2dev/_bundle/terraform-modules/google_cloud/create-project/main.tf +18 -0
- f2dev/_bundle/terraform-modules/google_cloud/create-project/output.tf +8 -0
- f2dev/_bundle/terraform-modules/google_cloud/create-project/providers.tf +6 -0
- f2dev/_bundle/terraform-modules/google_cloud/create-project/variables.tf +27 -0
- f2dev/_bundle/terraform-modules/google_cloud/create-project/versions.tf +9 -0
- f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/README.md +188 -0
- f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/main.tf +135 -0
- f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/output.tf +16 -0
- f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/providers.tf +6 -0
- f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/variables.tf +54 -0
- f2dev/_bundle/terraform-modules/google_cloud/deploy_sa/versions.tf +17 -0
- f2dev/_bundle/terraform-modules/google_cloud/enable_apis/main.tf +14 -0
- f2dev/_bundle/terraform-modules/google_cloud/enable_apis/provider.tf +7 -0
- f2dev/_bundle/terraform-modules/google_cloud/enable_apis/variables.tf +13 -0
- f2dev/_bundle/terraform-modules/google_cloud/enable_apis/versions.tf +10 -0
- f2dev/_bundle/terraform-modules/google_cloud/external-ip/README.md +89 -0
- f2dev/_bundle/terraform-modules/google_cloud/external-ip/main.tf +17 -0
- f2dev/_bundle/terraform-modules/google_cloud/external-ip/outputs.tf +19 -0
- f2dev/_bundle/terraform-modules/google_cloud/external-ip/variables.tf +43 -0
- f2dev/_bundle/terraform-modules/google_cloud/fw-add/main.tf +24 -0
- f2dev/_bundle/terraform-modules/google_cloud/fw-add/providers.tf +6 -0
- f2dev/_bundle/terraform-modules/google_cloud/fw-add/variables.tf +37 -0
- f2dev/_bundle/terraform-modules/google_cloud/fw-add/versions.tf +9 -0
- f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/README.md +10 -0
- f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/main.tf +459 -0
- f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/outputs.tf +44 -0
- f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/provider.tf +19 -0
- f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/variables.tf +354 -0
- f2dev/_bundle/terraform-modules/google_cloud/gke-cluster/versions.tf +22 -0
- f2dev/_bundle/terraform-modules/google_cloud/kubeconfig/README.md +40 -0
- f2dev/_bundle/terraform-modules/google_cloud/kubeconfig/main.tf +54 -0
- f2dev/_bundle/terraform-modules/google_cloud/kubeconfig/outputs.tf +10 -0
- f2dev/_bundle/terraform-modules/google_cloud/kubeconfig/variables.tf +24 -0
- f2dev/_bundle/terraform-modules/google_cloud/kubeconfig/versions.tf +10 -0
- f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/README.md +47 -0
- f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/main.tf +51 -0
- f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/net-address/README.md +103 -0
- f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/net-address/main.tf +71 -0
- f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/net-address/outputs.tf +71 -0
- f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/net-address/variables.tf +82 -0
- f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/net-address/versions.tf +27 -0
- f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/outputs.tf +35 -0
- f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/provider.tf +4 -0
- f2dev/_bundle/terraform-modules/google_cloud/shared-vpc/variables.tf +237 -0
- f2dev/_bundle/terraform-modules/oracle_cloud/README.md +3 -0
- f2dev/launcher.py +153 -0
- fast2dev-1.0.0.dist-info/METADATA +201 -0
- fast2dev-1.0.0.dist-info/RECORD +543 -0
- fast2dev-1.0.0.dist-info/WHEEL +4 -0
- fast2dev-1.0.0.dist-info/entry_points.txt +2 -0
- fast2dev-1.0.0.dist-info/licenses/LICENSE +202 -0
- fast2dev-1.0.0.dist-info/licenses/NOTICE +6 -0
|
@@ -0,0 +1,1532 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
import logging
|
|
4
|
+
import subprocess
|
|
5
|
+
import json
|
|
6
|
+
import requests
|
|
7
|
+
from cryptography.fernet import Fernet
|
|
8
|
+
import sys
|
|
9
|
+
import base64
|
|
10
|
+
import time
|
|
11
|
+
import tempfile
|
|
12
|
+
from cli.state import secrets_dir, vault_structure_path
|
|
13
|
+
from utils.vault_structure_sync import refresh_from_vault
|
|
14
|
+
|
|
15
|
+
# Configure logging
|
|
16
|
+
logging.basicConfig(
|
|
17
|
+
level=logging.INFO,
|
|
18
|
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
|
19
|
+
handlers=[
|
|
20
|
+
logging.StreamHandler(sys.stdout)
|
|
21
|
+
]
|
|
22
|
+
)
|
|
23
|
+
logger = logging.getLogger('infrastructure_deployment_operator')
|
|
24
|
+
|
|
25
|
+
class InfrastructureDeploymentError(Exception):
|
|
26
|
+
"""Base exception for infrastructure deployment errors"""
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
class VaultError(InfrastructureDeploymentError):
|
|
30
|
+
"""Exception raised for vault-related errors"""
|
|
31
|
+
pass
|
|
32
|
+
|
|
33
|
+
class GitError(InfrastructureDeploymentError):
|
|
34
|
+
"""Exception raised for git-related errors"""
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
class InfrastructureDeploymentOperator:
|
|
38
|
+
"""
|
|
39
|
+
Handles infrastructure deployment file collection, encryption, and storage in Git repositories.
|
|
40
|
+
Supports multiple cloud providers and git providers with flexible credential management.
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
def __init__(self,
|
|
44
|
+
customer: str,
|
|
45
|
+
cloud_provider: str = "gcp",
|
|
46
|
+
terraform_state: str = "remote",
|
|
47
|
+
# Git configuration
|
|
48
|
+
git_provider: str | None = None,
|
|
49
|
+
git_repo_url: str | None = None,
|
|
50
|
+
git_access_token: str | None = None,
|
|
51
|
+
git_private_key: str | None = None,
|
|
52
|
+
git_username: str | None = None,
|
|
53
|
+
git_password: str | None = None,
|
|
54
|
+
# Kubernetes configuration
|
|
55
|
+
kube_config_path: str | None = None,
|
|
56
|
+
namespace: str = "vault",
|
|
57
|
+
# Operation flags
|
|
58
|
+
force_deployment: bool = False,
|
|
59
|
+
cleanup_enabled: bool = True,
|
|
60
|
+
dry_run: bool = False,
|
|
61
|
+
state_file: str | None = None,
|
|
62
|
+
bi_tool: str | None = None):
|
|
63
|
+
"""
|
|
64
|
+
Initialize the InfrastructureDeploymentOperator.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
customer: Customer name
|
|
68
|
+
cloud_provider: Cloud provider ('gcp', 'aws', 'azure', 'self-managed')
|
|
69
|
+
terraform_state: Terraform state storage ('local' or 'remote')
|
|
70
|
+
git_provider: Git provider (auto-detected if not provided)
|
|
71
|
+
git_repo_url: Git repository URL
|
|
72
|
+
git_access_token: Git access token
|
|
73
|
+
git_private_key: Path to Git private key file
|
|
74
|
+
git_username: Git username
|
|
75
|
+
git_password: Git password
|
|
76
|
+
kube_config_path: Path to kubeconfig file
|
|
77
|
+
namespace: Kubernetes namespace for vault
|
|
78
|
+
force_deployment: Force deployment even if no infrastructure files are found
|
|
79
|
+
cleanup_enabled: Enable cleanup of local environment after deployment
|
|
80
|
+
"""
|
|
81
|
+
logger.info(f"Initializing InfrastructureDeploymentOperator for customer: {customer}")
|
|
82
|
+
|
|
83
|
+
# Core configuration
|
|
84
|
+
self.customer = customer
|
|
85
|
+
self.cloud_provider = cloud_provider
|
|
86
|
+
self.terraform_state = terraform_state
|
|
87
|
+
|
|
88
|
+
# Git configuration
|
|
89
|
+
self.git_provider = git_provider
|
|
90
|
+
self.git_repo_url = git_repo_url
|
|
91
|
+
self.git_access_token = git_access_token
|
|
92
|
+
self.git_private_key = git_private_key
|
|
93
|
+
self.git_username = git_username
|
|
94
|
+
self.git_password = git_password
|
|
95
|
+
|
|
96
|
+
# Kubernetes configuration
|
|
97
|
+
self.kube_config_path = kube_config_path
|
|
98
|
+
self.namespace = namespace
|
|
99
|
+
|
|
100
|
+
# Operation flags
|
|
101
|
+
self.force_deployment = force_deployment
|
|
102
|
+
self.cleanup_enabled = cleanup_enabled
|
|
103
|
+
self.dry_run = dry_run
|
|
104
|
+
self.state_file = state_file
|
|
105
|
+
self.bi_tool = bi_tool
|
|
106
|
+
self.written_files: list[str] = []
|
|
107
|
+
self._previous_tree: str | None = None
|
|
108
|
+
self._secrets_refreshed = True
|
|
109
|
+
|
|
110
|
+
# Working directory
|
|
111
|
+
self.working_dir = f"/tmp/{customer}_infrastructure_deployment_files"
|
|
112
|
+
|
|
113
|
+
# Validate configuration
|
|
114
|
+
self._validate_configuration()
|
|
115
|
+
|
|
116
|
+
# Initialize components
|
|
117
|
+
self._initialize_components()
|
|
118
|
+
|
|
119
|
+
def _validate_configuration(self):
|
|
120
|
+
"""Validate the configuration parameters"""
|
|
121
|
+
logger.info("Validating configuration parameters")
|
|
122
|
+
|
|
123
|
+
# Validate customer name
|
|
124
|
+
if not self.customer or not self.customer.strip():
|
|
125
|
+
raise ValueError("Customer name is required and cannot be empty")
|
|
126
|
+
|
|
127
|
+
# Validate cloud provider
|
|
128
|
+
if self.cloud_provider not in ['gcp', 'aws', 'azure', 'self-managed']:
|
|
129
|
+
raise ValueError(f"Unsupported cloud provider: {self.cloud_provider}")
|
|
130
|
+
|
|
131
|
+
# Validate terraform_state
|
|
132
|
+
if self.terraform_state not in ['local', 'remote']:
|
|
133
|
+
raise ValueError(f"Unsupported terraform_state: {self.terraform_state}")
|
|
134
|
+
|
|
135
|
+
# Validate git configuration
|
|
136
|
+
if not self.git_repo_url:
|
|
137
|
+
raise ValueError("git_repo_url is required")
|
|
138
|
+
|
|
139
|
+
logger.info("Configuration validation completed successfully")
|
|
140
|
+
|
|
141
|
+
def _validate_encryption_key(self):
|
|
142
|
+
"""Validate that the encryption key is properly formatted"""
|
|
143
|
+
try:
|
|
144
|
+
# Test the encryption key by creating a Fernet instance
|
|
145
|
+
fernet = Fernet(self.encryption_key.encode('utf-8'))
|
|
146
|
+
# Try to encrypt a small test string
|
|
147
|
+
test_data = b"test"
|
|
148
|
+
encrypted = fernet.encrypt(test_data)
|
|
149
|
+
decrypted = fernet.decrypt(encrypted)
|
|
150
|
+
if decrypted != test_data:
|
|
151
|
+
raise ValueError("Encryption key validation failed - decryption mismatch")
|
|
152
|
+
logger.debug("Encryption key validation successful")
|
|
153
|
+
except Exception as e:
|
|
154
|
+
logger.error(f"Encryption key validation failed: {str(e)}")
|
|
155
|
+
raise InfrastructureDeploymentError(f"Invalid encryption key: {str(e)}")
|
|
156
|
+
|
|
157
|
+
def _initialize_components(self):
|
|
158
|
+
"""Initialize required components based on configuration"""
|
|
159
|
+
logger.info("Initializing components")
|
|
160
|
+
|
|
161
|
+
try:
|
|
162
|
+
# Initialize encryption
|
|
163
|
+
self.encryption_key = Fernet.generate_key().decode('utf-8')
|
|
164
|
+
logger.info("Encryption key generated successfully")
|
|
165
|
+
|
|
166
|
+
# Validate encryption key
|
|
167
|
+
self._validate_encryption_key()
|
|
168
|
+
logger.info("Encryption key validated successfully")
|
|
169
|
+
|
|
170
|
+
# Initialize vault client first
|
|
171
|
+
self.vault_client = self._initialize_vault_client()
|
|
172
|
+
logger.info("Vault client initialized successfully")
|
|
173
|
+
|
|
174
|
+
# Initialize git manager after vault client is ready
|
|
175
|
+
self.git_manager = self._initialize_git_manager()
|
|
176
|
+
logger.info("Git manager initialized successfully")
|
|
177
|
+
|
|
178
|
+
except Exception as e:
|
|
179
|
+
logger.error(f"Failed to initialize components: {str(e)}")
|
|
180
|
+
raise InfrastructureDeploymentError(f"Component initialization failed: {str(e)}")
|
|
181
|
+
|
|
182
|
+
def _initialize_git_manager(self):
|
|
183
|
+
"""Initialize git manager with appropriate authentication"""
|
|
184
|
+
if not self.git_provider:
|
|
185
|
+
self.git_provider = self._detect_git_provider(self.git_repo_url)
|
|
186
|
+
|
|
187
|
+
# If git_access_token is not provided, try to get it from vault
|
|
188
|
+
if not self.git_access_token:
|
|
189
|
+
logger.info(f"No access token provided, attempting to retrieve from vault for {self.git_provider}")
|
|
190
|
+
try:
|
|
191
|
+
self.git_access_token = self._get_git_access_token_from_vault()
|
|
192
|
+
logger.info(f"Retrieved {self.git_provider} access token from vault")
|
|
193
|
+
except Exception as e:
|
|
194
|
+
if not self.dry_run:
|
|
195
|
+
logger.error(f"Failed to get {self.git_provider} access token from vault: {str(e)}")
|
|
196
|
+
raise ValueError(f"{self.git_provider.capitalize()} access token is required. Either provide it directly via --git_access_token parameter or ensure it exists in vault")
|
|
197
|
+
logger.info("[DRY-RUN] No git access token; nothing is cloned or pushed")
|
|
198
|
+
self.git_access_token = "dry-run"
|
|
199
|
+
else:
|
|
200
|
+
logger.info(f"Using provided {self.git_provider} access token")
|
|
201
|
+
|
|
202
|
+
# Validate git credentials based on provider
|
|
203
|
+
self._validate_git_credentials()
|
|
204
|
+
|
|
205
|
+
return GitManager(
|
|
206
|
+
repo_url=self.git_repo_url,
|
|
207
|
+
credentials=self._get_git_credentials(),
|
|
208
|
+
working_dir=self.working_dir
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
def _initialize_vault_client(self):
|
|
212
|
+
"""Initialize the local vault client"""
|
|
213
|
+
self.secret_file = str(vault_structure_path(self.customer))
|
|
214
|
+
logger.info(f"Looking for secret file: {self.secret_file}")
|
|
215
|
+
if not os.path.exists(self.secret_file):
|
|
216
|
+
raise FileNotFoundError(f"Secret file not found: {self.secret_file}")
|
|
217
|
+
logger.info(f"Secret file found: {self.secret_file}")
|
|
218
|
+
return LocalVaultClient(
|
|
219
|
+
customer=self.customer,
|
|
220
|
+
kube_config=self.kube_config_path,
|
|
221
|
+
namespace=self.namespace
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
def _validate_git_credentials(self):
|
|
225
|
+
"""Validate git credentials based on provider"""
|
|
226
|
+
if self.git_provider in ['github', 'gitlab', 'bitbucket']:
|
|
227
|
+
if not (self.git_access_token or (self.git_private_key and self.git_username)):
|
|
228
|
+
raise ValueError(f"Either access token or private key + username required for {self.git_provider}")
|
|
229
|
+
elif self.git_provider == 'gitea':
|
|
230
|
+
if not (self.git_access_token or (self.git_username and self.git_password)):
|
|
231
|
+
raise ValueError("Either access token or username + password required for Gitea")
|
|
232
|
+
else:
|
|
233
|
+
raise ValueError(f"Unsupported git provider: {self.git_provider}")
|
|
234
|
+
|
|
235
|
+
def _get_git_credentials(self) -> dict:
|
|
236
|
+
"""Get git credentials based on provider"""
|
|
237
|
+
credentials = {}
|
|
238
|
+
|
|
239
|
+
if self.git_access_token:
|
|
240
|
+
credentials['access_token'] = self.git_access_token
|
|
241
|
+
elif self.git_private_key:
|
|
242
|
+
credentials['private_key'] = self.git_private_key
|
|
243
|
+
credentials['username'] = self.git_username
|
|
244
|
+
else:
|
|
245
|
+
credentials['username'] = self.git_username
|
|
246
|
+
credentials['password'] = self.git_password
|
|
247
|
+
|
|
248
|
+
return credentials
|
|
249
|
+
|
|
250
|
+
def _detect_git_provider(self, repo_url: str) -> str:
|
|
251
|
+
"""Detect git provider from repository URL"""
|
|
252
|
+
if not repo_url:
|
|
253
|
+
return "gitlab" # Default provider
|
|
254
|
+
|
|
255
|
+
url = repo_url.lower()
|
|
256
|
+
|
|
257
|
+
if "github" in url:
|
|
258
|
+
return "github"
|
|
259
|
+
elif "gitlab" in url:
|
|
260
|
+
return "gitlab"
|
|
261
|
+
elif "gitea" in url:
|
|
262
|
+
return "gitea"
|
|
263
|
+
elif "bitbucket" in url:
|
|
264
|
+
return "bitbucket"
|
|
265
|
+
else:
|
|
266
|
+
return "gitlab" # Default provider
|
|
267
|
+
|
|
268
|
+
ROOT_MAP = {
|
|
269
|
+
'core_infrastructure': 'core-infrastructure-deployment',
|
|
270
|
+
'k8s_core_services': 'k8s-infrastructure-services-deployment',
|
|
271
|
+
'k8s_data_services': 'k8s-data-platform-services-deployment',
|
|
272
|
+
}
|
|
273
|
+
TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), 'templates', 'git_repo_templates',
|
|
274
|
+
'infrastructure_deployment_files')
|
|
275
|
+
COPIED_TEMPLATE_FILES = ('DR.md', 'encrypt_files.py', 'decrypt_files.py')
|
|
276
|
+
REPOSITORY_GITIGNORE = ".env\n*.key\n"
|
|
277
|
+
BI_TOOLS = ('superset', 'lightdash', 'metabase')
|
|
278
|
+
README_SECTIONS = (
|
|
279
|
+
('k8s_core_services', 'Infrastructure services'),
|
|
280
|
+
('k8s_data_services', 'Data services'),
|
|
281
|
+
('other', 'Other'),
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
def _repository_paths(self) -> dict:
|
|
285
|
+
"""Local source path -> path of the same file in this repository."""
|
|
286
|
+
paths = {}
|
|
287
|
+
for mapping_type, mapping in self._get_infrastructure_mappings().items():
|
|
288
|
+
root = self.ROOT_MAP.get(mapping_type, mapping_type)
|
|
289
|
+
for directory, files in mapping.items():
|
|
290
|
+
for name in files:
|
|
291
|
+
source = os.path.normpath(self._get_source_path(directory, name))
|
|
292
|
+
paths[source] = os.path.normpath(os.path.join(root, directory, name))
|
|
293
|
+
return paths
|
|
294
|
+
|
|
295
|
+
@staticmethod
|
|
296
|
+
def _format_command(args: list) -> str:
|
|
297
|
+
import shlex
|
|
298
|
+
lines, current = [], []
|
|
299
|
+
for arg in args:
|
|
300
|
+
if arg.startswith('-') and current:
|
|
301
|
+
lines.append(' '.join(current))
|
|
302
|
+
current = []
|
|
303
|
+
current.append(shlex.quote(arg))
|
|
304
|
+
if current:
|
|
305
|
+
lines.append(' '.join(current))
|
|
306
|
+
return ' \\\n '.join(lines)
|
|
307
|
+
|
|
308
|
+
def _readme_context(self) -> dict:
|
|
309
|
+
from datetime import datetime, timezone
|
|
310
|
+
from cli import command_record
|
|
311
|
+
|
|
312
|
+
repo_paths = self._repository_paths()
|
|
313
|
+
sections = {key: [] for key, _ in self.README_SECTIONS}
|
|
314
|
+
for command in command_record.ordered():
|
|
315
|
+
args = list(command['args'])
|
|
316
|
+
section = 'other'
|
|
317
|
+
for i in range(1, len(args)):
|
|
318
|
+
if args[i - 1] in ('--values', '-f', '--filename'):
|
|
319
|
+
repo_path = repo_paths.get(os.path.normpath(args[i]))
|
|
320
|
+
if repo_path:
|
|
321
|
+
args[i] = repo_path
|
|
322
|
+
for key, root in self.ROOT_MAP.items():
|
|
323
|
+
if repo_path.startswith(root) and key in sections:
|
|
324
|
+
section = key
|
|
325
|
+
sections[section].append(self._format_command(args))
|
|
326
|
+
|
|
327
|
+
domain = ''
|
|
328
|
+
if self.state_file and os.path.exists(self.state_file):
|
|
329
|
+
try:
|
|
330
|
+
with open(self.state_file) as f:
|
|
331
|
+
domain = json.load(f).get('config', {}).get('domain_name', '')
|
|
332
|
+
except (OSError, ValueError):
|
|
333
|
+
domain = ''
|
|
334
|
+
recorded = command_record.RECORD_FILE
|
|
335
|
+
return {
|
|
336
|
+
'customer': self.customer,
|
|
337
|
+
'domain': domain,
|
|
338
|
+
'cloud_provider': self.cloud_provider,
|
|
339
|
+
'terraform_state': self.terraform_state,
|
|
340
|
+
'generated_at': datetime.now(timezone.utc).strftime('%Y-%m-%d %H:%M UTC'),
|
|
341
|
+
'recorded_at': (datetime.fromtimestamp(recorded.stat().st_mtime, timezone.utc).strftime('%Y-%m-%d %H:%M UTC')
|
|
342
|
+
if recorded.exists() else ''),
|
|
343
|
+
'sections': [{'title': title, 'commands': sections[key]}
|
|
344
|
+
for key, title in self.README_SECTIONS if sections[key]],
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
def render_readme(self) -> str:
|
|
348
|
+
from jinja2 import Environment, FileSystemLoader
|
|
349
|
+
env = Environment(loader=FileSystemLoader(self.TEMPLATE_DIR), trim_blocks=True, lstrip_blocks=True,
|
|
350
|
+
keep_trailing_newline=True)
|
|
351
|
+
return env.get_template('README.md.j2').render(**self._readme_context())
|
|
352
|
+
|
|
353
|
+
def _copy_template_files(self):
|
|
354
|
+
"""Write README.md (from the recorded deployment commands) and copy DR.md and the scripts."""
|
|
355
|
+
logger.info("Writing the repository README and copying template files")
|
|
356
|
+
try:
|
|
357
|
+
with open(os.path.join(self.working_dir, 'README.md'), 'w') as f:
|
|
358
|
+
f.write(self.render_readme())
|
|
359
|
+
with open(os.path.join(self.working_dir, '.gitignore'), 'w') as f:
|
|
360
|
+
f.write(self.REPOSITORY_GITIGNORE)
|
|
361
|
+
for name in self.COPIED_TEMPLATE_FILES:
|
|
362
|
+
source_path = os.path.join(self.TEMPLATE_DIR, name)
|
|
363
|
+
if os.path.exists(source_path):
|
|
364
|
+
shutil.copy2(source_path, os.path.join(self.working_dir, name))
|
|
365
|
+
else:
|
|
366
|
+
logger.warning(f"Template file not found: {name}")
|
|
367
|
+
except Exception as e:
|
|
368
|
+
logger.error(f"Failed to write template files: {str(e)}")
|
|
369
|
+
raise InfrastructureDeploymentError(f"Template file copy failed: {str(e)}")
|
|
370
|
+
|
|
371
|
+
RENDERED_CORE_FILES = ('defaults.yaml', 'root.hcl', 'backend.tf', 'env.yaml',
|
|
372
|
+
'sa_key.txt', 'sa_name.txt', 'kubeconfig', 'external_ip_traefik.txt',
|
|
373
|
+
'dns_zone_complete_info.txt', 'dns_zone_nameservers.txt')
|
|
374
|
+
|
|
375
|
+
def collect_and_store_infrastructure(self):
|
|
376
|
+
"""Main method to collect and store infrastructure files"""
|
|
377
|
+
logger.info(f"Starting infrastructure collection for customer: {self.customer}")
|
|
378
|
+
|
|
379
|
+
try:
|
|
380
|
+
# Create working directory
|
|
381
|
+
os.makedirs(self.working_dir, exist_ok=True)
|
|
382
|
+
logger.info(f"Created working directory: {self.working_dir}")
|
|
383
|
+
|
|
384
|
+
# In dry-run mode, skip git clone
|
|
385
|
+
if self.dry_run:
|
|
386
|
+
logger.info("[DRY-RUN] Skipping git clone - using local working directory only")
|
|
387
|
+
print(f"[DRY-RUN] Skipping git clone for repository")
|
|
388
|
+
print(f"[DRY-RUN] Files will be prepared in: {self.working_dir}")
|
|
389
|
+
else:
|
|
390
|
+
# Clone repository
|
|
391
|
+
self.git_manager.clone_repository()
|
|
392
|
+
logger.info("Repository cloned successfully")
|
|
393
|
+
|
|
394
|
+
self._clear_working_tree()
|
|
395
|
+
|
|
396
|
+
# Copy template files
|
|
397
|
+
self._copy_template_files()
|
|
398
|
+
logger.info("Template files copied successfully")
|
|
399
|
+
|
|
400
|
+
# Get infrastructure mappings
|
|
401
|
+
mappings = self._get_infrastructure_mappings()
|
|
402
|
+
logger.info("Retrieved infrastructure mappings")
|
|
403
|
+
|
|
404
|
+
# Check for Terraform state files if terraform_state is local
|
|
405
|
+
if self.terraform_state == "local":
|
|
406
|
+
self._check_terraform_state_files(mappings)
|
|
407
|
+
|
|
408
|
+
# Check what files exist and provide summary
|
|
409
|
+
total_files = 0
|
|
410
|
+
existing_files = 0
|
|
411
|
+
|
|
412
|
+
for mapping_type, mapping in mappings.items():
|
|
413
|
+
for directory, files in mapping.items():
|
|
414
|
+
for file in files:
|
|
415
|
+
total_files += 1
|
|
416
|
+
if os.path.exists(self._get_source_path(directory, file)):
|
|
417
|
+
existing_files += 1
|
|
418
|
+
|
|
419
|
+
logger.info(f"Infrastructure scan complete: {existing_files}/{total_files} files found")
|
|
420
|
+
|
|
421
|
+
if existing_files == 0:
|
|
422
|
+
logger.info("No infrastructure files found - this appears to be a manual deployment")
|
|
423
|
+
else:
|
|
424
|
+
logger.info(f"Found {existing_files} infrastructure files to process")
|
|
425
|
+
if existing_files < total_files:
|
|
426
|
+
logger.info(f"Note: {total_files - existing_files} files are missing from the expected mapping")
|
|
427
|
+
logger.info("This is normal if some Terraform modules haven't been applied yet or some files are optional")
|
|
428
|
+
|
|
429
|
+
# Always proceed with validation and processing - validation is now more flexible
|
|
430
|
+
# Note: We don't need to validate here since we check file existence during processing
|
|
431
|
+
logger.info("Core infrastructure files validation skipped - will validate during processing")
|
|
432
|
+
|
|
433
|
+
self._refresh_secrets_from_vault()
|
|
434
|
+
|
|
435
|
+
# Prepare and encrypt files
|
|
436
|
+
self._prepare_and_encrypt_files(mappings)
|
|
437
|
+
self._prepare_installer_files()
|
|
438
|
+
logger.info("Files prepared and encrypted")
|
|
439
|
+
|
|
440
|
+
# Save encryption key to vault
|
|
441
|
+
self.save_encryption_key()
|
|
442
|
+
self._write_local_key_copy()
|
|
443
|
+
logger.info("Encryption key saved to vault")
|
|
444
|
+
|
|
445
|
+
# Check if we have any encrypted files to commit
|
|
446
|
+
encrypted_files = sorted(set(self.written_files))
|
|
447
|
+
|
|
448
|
+
if not encrypted_files:
|
|
449
|
+
if self.force_deployment:
|
|
450
|
+
logger.warning("No infrastructure files were processed, but force_deployment is enabled - proceeding with empty repository")
|
|
451
|
+
else:
|
|
452
|
+
logger.warning("No infrastructure files were processed - repository will not be updated")
|
|
453
|
+
return self._get_deployment_summary()
|
|
454
|
+
|
|
455
|
+
logger.info(f"Found {len(encrypted_files)} encrypted files to commit")
|
|
456
|
+
|
|
457
|
+
# Commit and push changes
|
|
458
|
+
self._commit_and_push_changes()
|
|
459
|
+
logger.info("Changes committed and pushed")
|
|
460
|
+
|
|
461
|
+
# Clean up local environment after successful deployment
|
|
462
|
+
if self.cleanup_enabled and not self.dry_run:
|
|
463
|
+
self._cleanup_local_environment()
|
|
464
|
+
logger.info("Local environment cleaned up")
|
|
465
|
+
else:
|
|
466
|
+
logger.info("Local environment cleanup skipped (cleanup_enabled=False)")
|
|
467
|
+
|
|
468
|
+
# Cleanup
|
|
469
|
+
self._cleanup()
|
|
470
|
+
logger.info("Cleanup completed")
|
|
471
|
+
|
|
472
|
+
return self._get_deployment_summary()
|
|
473
|
+
|
|
474
|
+
except Exception as e:
|
|
475
|
+
logger.error(f"Failed to collect and store infrastructure: {str(e)}")
|
|
476
|
+
self._cleanup() # Ensure cleanup on failure
|
|
477
|
+
raise InfrastructureDeploymentError(f"Infrastructure collection failed: {str(e)}")
|
|
478
|
+
|
|
479
|
+
def _get_infrastructure_mappings(self) -> dict:
|
|
480
|
+
"""Get infrastructure file mappings based on cloud provider"""
|
|
481
|
+
mappings = {
|
|
482
|
+
'core_infrastructure': self._get_core_infrastructure_mapping(),
|
|
483
|
+
'k8s_core_services': self._get_k8s_core_services_mapping(),
|
|
484
|
+
'k8s_data_services': self._get_k8s_data_services_mapping()
|
|
485
|
+
}
|
|
486
|
+
return mappings
|
|
487
|
+
|
|
488
|
+
def _get_core_infrastructure_mapping(self) -> dict:
|
|
489
|
+
"""Get core infrastructure mapping based on cloud provider"""
|
|
490
|
+
if self.cloud_provider == "gcp":
|
|
491
|
+
mapping = {
|
|
492
|
+
'.': ['.gitignore', 'defaults.yaml', 'empty.yaml'],
|
|
493
|
+
'bi-platform': ['root.hcl', 'backend.tf', 'env.yaml'],
|
|
494
|
+
'bi-platform/00-create-ou-folder': ['terragrunt.hcl'],
|
|
495
|
+
'bi-platform/01-create-project': ['terragrunt.hcl'],
|
|
496
|
+
'bi-platform/02-enable-apis': ['terragrunt.hcl'],
|
|
497
|
+
'bi-platform/03-0-apps-vpc': ['terragrunt.hcl'],
|
|
498
|
+
'bi-platform/04-external-ip-traefik': ['terragrunt.hcl', 'external_ip_traefik.txt'],
|
|
499
|
+
'bi-platform/05-create-dns-zone': ['terragrunt.hcl', 'dns_zone_complete_info.txt', 'dns_zone_nameservers.txt'],
|
|
500
|
+
'bi-platform/06-create-dns-ns-record': ['terragrunt.hcl'],
|
|
501
|
+
'bi-platform/07-gke-cluster': ['terragrunt.hcl'],
|
|
502
|
+
'bi-platform/08-dbt_deploy_sa': ['terragrunt.hcl', 'sa_key.txt', 'sa_name.txt'],
|
|
503
|
+
'bi-platform/09-dbt_sa': ['terragrunt.hcl', 'sa_name.txt'],
|
|
504
|
+
'bi-platform/10-cert_manager_sa': ['terragrunt.hcl', 'sa_name.txt'],
|
|
505
|
+
'bi-platform/11-external_dns_sa': ['terragrunt.hcl', 'sa_name.txt'],
|
|
506
|
+
'bi-platform/12-monitoring_sa': ['terragrunt.hcl', 'sa_name.txt'],
|
|
507
|
+
'bi-platform/13-data_replication_sa': ['terragrunt.hcl', 'sa_name.txt'],
|
|
508
|
+
'bi-platform/14-data_orchestration_sa': ['terragrunt.hcl', 'sa_name.txt'],
|
|
509
|
+
'bi-platform/15-bi_data_sa': ['terragrunt.hcl', 'sa_key.txt', 'sa_name.txt'],
|
|
510
|
+
'bi-platform/16-whitelist-external-ip-on-common': ['terragrunt.hcl'],
|
|
511
|
+
'bi-platform/17-kubeconfig': ['terragrunt.hcl', 'kubeconfig'],
|
|
512
|
+
'bi-platform/18-data_streaming_sa': ['terragrunt.hcl', 'sa_key.txt', 'sa_name.txt']
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
# Add .terraform folders and state files if terraform_state is local
|
|
516
|
+
if self.terraform_state == "local":
|
|
517
|
+
terraform_folders = [
|
|
518
|
+
'bi-platform/00-create-ou-folder',
|
|
519
|
+
'bi-platform/01-create-project',
|
|
520
|
+
'bi-platform/02-enable-apis',
|
|
521
|
+
'bi-platform/03-0-apps-vpc',
|
|
522
|
+
'bi-platform/04-external-ip-traefik',
|
|
523
|
+
'bi-platform/05-create-dns-zone',
|
|
524
|
+
'bi-platform/06-create-dns-ns-record',
|
|
525
|
+
'bi-platform/07-gke-cluster',
|
|
526
|
+
'bi-platform/08-dbt_deploy_sa',
|
|
527
|
+
'bi-platform/09-dbt_sa',
|
|
528
|
+
'bi-platform/10-cert_manager_sa',
|
|
529
|
+
'bi-platform/11-external_dns_sa',
|
|
530
|
+
'bi-platform/12-monitoring_sa',
|
|
531
|
+
'bi-platform/13-data_replication_sa',
|
|
532
|
+
'bi-platform/14-data_orchestration_sa',
|
|
533
|
+
'bi-platform/15-bi_data_sa',
|
|
534
|
+
'bi-platform/16-whitelist-external-ip-on-common',
|
|
535
|
+
'bi-platform/17-kubeconfig',
|
|
536
|
+
'bi-platform/18-data_streaming_sa'
|
|
537
|
+
]
|
|
538
|
+
|
|
539
|
+
for folder in terraform_folders:
|
|
540
|
+
mapping[f'{folder}/.terraform/{self.customer}/{folder.split("/")[-1]}'] = ['terraform.tfstate', 'terraform.tfstate.backup']
|
|
541
|
+
|
|
542
|
+
return mapping
|
|
543
|
+
elif self.cloud_provider == "aws":
|
|
544
|
+
mapping = {
|
|
545
|
+
'.': ['.gitignore', 'defaults.yaml', 'empty.yaml', 'env.hcl'],
|
|
546
|
+
'bi-platform': ['root.hcl', 'backend.tf', 'env.yaml', 'empty.yaml'],
|
|
547
|
+
'bi-platform/01-apps-vpc': ['terragrunt.hcl'],
|
|
548
|
+
'bi-platform/02-eks-cluster': ['terragrunt.hcl'],
|
|
549
|
+
'bi-platform/03-external-dns-irsa': ['terragrunt.hcl'],
|
|
550
|
+
'bi-platform/04-cert-manager-irsa': ['terragrunt.hcl'],
|
|
551
|
+
'bi-platform/05-create-dns-zone': ['terragrunt.hcl'],
|
|
552
|
+
'bi-platform/06-create-dns-ns-record': ['terragrunt.hcl'],
|
|
553
|
+
'bi-platform/kubeconfig': ['kubeconfig']
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
# Add .terraform folders and state files if terraform_state is local
|
|
557
|
+
if self.terraform_state == "local":
|
|
558
|
+
terraform_folders = [
|
|
559
|
+
'bi-platform/01-apps-vpc',
|
|
560
|
+
'bi-platform/02-eks-cluster',
|
|
561
|
+
'bi-platform/03-external-dns-irsa',
|
|
562
|
+
'bi-platform/04-cert-manager-irsa',
|
|
563
|
+
'bi-platform/05-create-dns-zone',
|
|
564
|
+
'bi-platform/06-create-dns-ns-record'
|
|
565
|
+
]
|
|
566
|
+
|
|
567
|
+
for folder in terraform_folders:
|
|
568
|
+
mapping[f'{folder}/.terraform/{self.customer}/{folder.split("/")[-1]}'] = ['terraform.tfstate', 'terraform.tfstate.backup']
|
|
569
|
+
|
|
570
|
+
return mapping
|
|
571
|
+
elif self.cloud_provider == "azure":
|
|
572
|
+
mapping = {
|
|
573
|
+
'.': ['.gitignore', 'defaults.yaml', 'empty.yaml'],
|
|
574
|
+
'bi-platform': ['root.hcl', 'backend.tf', 'env.yaml'],
|
|
575
|
+
'bi-platform/01-enable-apis': ['terragrunt.hcl'],
|
|
576
|
+
'bi-platform/02-apps-vpc': ['terragrunt.hcl'],
|
|
577
|
+
'bi-platform/03-external-ip-traefik': ['terragrunt.hcl'],
|
|
578
|
+
'bi-platform/04-create-dns-zone': ['terragrunt.hcl'],
|
|
579
|
+
'bi-platform/05-create-dns-ns-record': ['terragrunt.hcl'],
|
|
580
|
+
'bi-platform/06-aks-cluster': ['terragrunt.hcl'],
|
|
581
|
+
'bi-platform/07-aks-cluster-artifact-registry-access': ['terragrunt.hcl'],
|
|
582
|
+
'bi-platform/08-whitelist-external-ip-on-common': ['terragrunt.hcl']
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
# Add .terraform folders and state files if terraform_state is local
|
|
586
|
+
if self.terraform_state == "local":
|
|
587
|
+
terraform_folders = [
|
|
588
|
+
'bi-platform/01-enable-apis',
|
|
589
|
+
'bi-platform/02-apps-vpc',
|
|
590
|
+
'bi-platform/03-external-ip-traefik',
|
|
591
|
+
'bi-platform/04-create-dns-zone',
|
|
592
|
+
'bi-platform/05-create-dns-ns-record',
|
|
593
|
+
'bi-platform/06-aks-cluster',
|
|
594
|
+
'bi-platform/07-aks-cluster-artifact-registry-access',
|
|
595
|
+
'bi-platform/08-whitelist-external-ip-on-common'
|
|
596
|
+
]
|
|
597
|
+
|
|
598
|
+
for folder in terraform_folders:
|
|
599
|
+
mapping[f'{folder}/.terraform'] = ['terraform.tfstate', 'terraform.tfstate.backup']
|
|
600
|
+
|
|
601
|
+
return mapping
|
|
602
|
+
else: # self-managed
|
|
603
|
+
return {} # Empty mapping for self-managed as it's built manually
|
|
604
|
+
|
|
605
|
+
def _get_k8s_core_services_mapping(self) -> dict:
|
|
606
|
+
"""Get Kubernetes core services mapping (paths relative to charts/infra_services_charts)"""
|
|
607
|
+
return {
|
|
608
|
+
'secret_manager': ['values.yaml', 'values_extra.yaml'],
|
|
609
|
+
'secret_manager_operator': ['values.yaml', 'values_extra.yaml'],
|
|
610
|
+
'cert_manager': ['values.yaml', 'values_extra.yaml', 'pdns_webhook_values.yaml'],
|
|
611
|
+
'cluster_cleaner': ['values.yaml'],
|
|
612
|
+
'external_dns': ['values.yaml', 'values_extra.yaml'],
|
|
613
|
+
'idp_sso_manager': [f'{self.customer}_realm.json', 'values.yaml'],
|
|
614
|
+
'services_metrics': ['values.yaml'],
|
|
615
|
+
'services_logs': ['loki_values.yaml', 'alloy_values.yaml', 'alloy_events_values.yaml'],
|
|
616
|
+
'pvc_autoscaller': ['values.yaml', 'values_extra.yaml'],
|
|
617
|
+
'services_monitoring': ['alerts_cm.yaml', 'values.yaml'],
|
|
618
|
+
'stackgres_postgres_db': ['values.yaml', 'values_extra.yaml'],
|
|
619
|
+
'traefik_lb': ['values.yaml']
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
def _clear_working_tree(self):
|
|
623
|
+
"""Move everything but .git aside so the push mirrors the files this run produces.
|
|
624
|
+
|
|
625
|
+
The previous copy is kept until the end of the run: an expected file whose source is
|
|
626
|
+
missing or cannot be encrypted is restored from it instead of being deleted from the repository.
|
|
627
|
+
"""
|
|
628
|
+
self.written_files = []
|
|
629
|
+
self._drop_previous_tree()
|
|
630
|
+
if not os.path.isdir(self.working_dir):
|
|
631
|
+
return
|
|
632
|
+
self._previous_tree = tempfile.mkdtemp(prefix="fast2dev-previous-")
|
|
633
|
+
for name in os.listdir(self.working_dir):
|
|
634
|
+
if name == '.git':
|
|
635
|
+
continue
|
|
636
|
+
shutil.move(os.path.join(self.working_dir, name), os.path.join(self._previous_tree, name))
|
|
637
|
+
|
|
638
|
+
def _drop_previous_tree(self):
|
|
639
|
+
if self._previous_tree and os.path.isdir(self._previous_tree):
|
|
640
|
+
shutil.rmtree(self._previous_tree, ignore_errors=True)
|
|
641
|
+
self._previous_tree = None
|
|
642
|
+
|
|
643
|
+
def _keep_previous(self, target_path: str) -> bool:
|
|
644
|
+
"""Restore the repository copy of an expected file this run could not produce."""
|
|
645
|
+
if not self._previous_tree:
|
|
646
|
+
return False
|
|
647
|
+
rel = os.path.relpath(target_path, self.working_dir)
|
|
648
|
+
previous = os.path.join(self._previous_tree, rel)
|
|
649
|
+
if not os.path.isfile(previous):
|
|
650
|
+
return False
|
|
651
|
+
os.makedirs(os.path.dirname(target_path), exist_ok=True)
|
|
652
|
+
shutil.copy2(previous, target_path)
|
|
653
|
+
logger.warning(f"Kept the existing repository copy of {rel}")
|
|
654
|
+
return True
|
|
655
|
+
|
|
656
|
+
def _get_k8s_data_services_mapping(self) -> dict:
|
|
657
|
+
"""Data services mapping with only the BI tool this install deploys."""
|
|
658
|
+
mapping = self._k8s_data_services_mapping()
|
|
659
|
+
if not self.bi_tool:
|
|
660
|
+
return mapping
|
|
661
|
+
selected = self.bi_tool.strip().lower()
|
|
662
|
+
for tool in self.BI_TOOLS:
|
|
663
|
+
if tool != selected:
|
|
664
|
+
mapping.pop(f'data_analysis/{tool}', None)
|
|
665
|
+
return mapping
|
|
666
|
+
|
|
667
|
+
def _k8s_data_services_mapping(self) -> dict:
|
|
668
|
+
"""All data services files (paths relative to charts/data_services_charts)"""
|
|
669
|
+
return {
|
|
670
|
+
'argo_workflows': ['values.yaml'],
|
|
671
|
+
'cicd_workload_runner': ['values.yaml', 'values_extra.yaml'],
|
|
672
|
+
'object_storage_operator': ['values.yaml'],
|
|
673
|
+
'data_analysis': ['values.yaml'],
|
|
674
|
+
'data_analysis/lightdash': ['values.yaml'],
|
|
675
|
+
'data_analysis/superset': ['values.yaml'],
|
|
676
|
+
'data_analysis/metabase': ['values.yaml'],
|
|
677
|
+
'data_control_plane': ['deploy_values.yaml'],
|
|
678
|
+
'data_dbt_server': ['values.yaml'],
|
|
679
|
+
'data_governance': ['values.yaml', 'dh_values.yaml', 'dh_prerequisites_values.yaml',
|
|
680
|
+
'opensearch_values.yaml', 'kafka_values.yaml'],
|
|
681
|
+
'data_modeling': ['values.yaml', 'values_extra.yaml'],
|
|
682
|
+
'data_orchestration': ['values.yaml', 'values_extra.yaml'],
|
|
683
|
+
'data_replication': ['values.yaml', 'metrics_values.yaml',
|
|
684
|
+
'oauth2proxy_values.yaml'],
|
|
685
|
+
'data_streaming': ['values.yaml', 'oauth2proxy_values.yaml'],
|
|
686
|
+
'data_mcp_hub': ['values.yaml'],
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
def _check_terraform_state_files(self, mappings: dict) -> dict:
|
|
690
|
+
"""Check for existence of Terraform state files when terraform_state is local"""
|
|
691
|
+
if self.terraform_state != "local":
|
|
692
|
+
return {}
|
|
693
|
+
|
|
694
|
+
logger.info("Checking for Terraform state files...")
|
|
695
|
+
state_files_found = {}
|
|
696
|
+
|
|
697
|
+
for mapping_type, mapping in mappings.items():
|
|
698
|
+
if mapping_type == 'core_infrastructure':
|
|
699
|
+
for directory, files in mapping.items():
|
|
700
|
+
if '.terraform' in directory:
|
|
701
|
+
existing_files = []
|
|
702
|
+
for file in files:
|
|
703
|
+
source_path = self._get_source_path(directory, file)
|
|
704
|
+
if os.path.exists(source_path):
|
|
705
|
+
existing_files.append(file)
|
|
706
|
+
|
|
707
|
+
if existing_files:
|
|
708
|
+
state_files_found[directory] = existing_files
|
|
709
|
+
logger.info(f"Found Terraform state files in {directory}: {', '.join(existing_files)}")
|
|
710
|
+
else:
|
|
711
|
+
logger.warning(f"No Terraform state files found in {directory}")
|
|
712
|
+
|
|
713
|
+
if state_files_found:
|
|
714
|
+
logger.info(f"Found Terraform state files in {len(state_files_found)} directories")
|
|
715
|
+
else:
|
|
716
|
+
logger.warning("No Terraform state files found - this may indicate that Terraform has not been run yet")
|
|
717
|
+
|
|
718
|
+
return state_files_found
|
|
719
|
+
|
|
720
|
+
def _prepare_and_encrypt_files(self, mappings: dict):
|
|
721
|
+
"""Prepare and encrypt files based on mappings, preserving logical structure under new root folders"""
|
|
722
|
+
logger.info("Preparing and encrypting files")
|
|
723
|
+
|
|
724
|
+
if self.terraform_state == "local":
|
|
725
|
+
logger.info("Terraform state is set to 'local' - will include .terraform folders and state files")
|
|
726
|
+
|
|
727
|
+
root_map = {
|
|
728
|
+
'core_infrastructure': 'core-infrastructure-deployment',
|
|
729
|
+
'k8s_core_services': 'k8s-infrastructure-services-deployment',
|
|
730
|
+
'k8s_data_services': 'k8s-data-platform-services-deployment',
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
total_processed = 0
|
|
734
|
+
total_files_in_mappings = 0
|
|
735
|
+
|
|
736
|
+
for mapping_type, mapping in mappings.items():
|
|
737
|
+
logger.info(f"Processing {mapping_type} mapping")
|
|
738
|
+
root_folder = root_map.get(mapping_type, mapping_type)
|
|
739
|
+
|
|
740
|
+
# Count files for this mapping type
|
|
741
|
+
files_in_mapping = 0
|
|
742
|
+
processed_in_mapping = 0
|
|
743
|
+
missing_files = []
|
|
744
|
+
|
|
745
|
+
for directory, files in mapping.items():
|
|
746
|
+
for file in files:
|
|
747
|
+
files_in_mapping += 1
|
|
748
|
+
total_files_in_mappings += 1
|
|
749
|
+
source_path = self._get_source_path(directory, file)
|
|
750
|
+
if os.path.exists(source_path):
|
|
751
|
+
processed_in_mapping += 1
|
|
752
|
+
total_processed += 1
|
|
753
|
+
|
|
754
|
+
# For services, preserve subfolder structure
|
|
755
|
+
if mapping_type == 'core_infrastructure':
|
|
756
|
+
target_dir = os.path.join(self.working_dir, root_folder, directory)
|
|
757
|
+
else:
|
|
758
|
+
target_dir = os.path.join(self.working_dir, root_folder, directory)
|
|
759
|
+
os.makedirs(target_dir, exist_ok=True)
|
|
760
|
+
target_path = os.path.join(target_dir, file)
|
|
761
|
+
if not self._encrypt_and_copy_file(source_path, target_path):
|
|
762
|
+
self._keep_previous(target_path)
|
|
763
|
+
|
|
764
|
+
# Special logging for Terraform state files
|
|
765
|
+
if '.terraform' in directory and file in ['terraform.tfstate', 'terraform.tfstate.backup']:
|
|
766
|
+
logger.info(f"Processed Terraform state file: {directory}/{file} -> {target_path}")
|
|
767
|
+
else:
|
|
768
|
+
logger.debug(f"Processed file: {directory}/{file} -> {target_path}")
|
|
769
|
+
else:
|
|
770
|
+
self._keep_previous(os.path.join(self.working_dir, root_folder, directory, file))
|
|
771
|
+
missing_files.append(f"{directory}/{file} (expected: {source_path})")
|
|
772
|
+
# Special logging for missing Terraform state files
|
|
773
|
+
if '.terraform' in directory and file in ['terraform.tfstate', 'terraform.tfstate.backup']:
|
|
774
|
+
logger.warning(f"Terraform state file not found: {source_path}")
|
|
775
|
+
else:
|
|
776
|
+
logger.debug(f"Source file not found: {source_path}")
|
|
777
|
+
|
|
778
|
+
if processed_in_mapping > 0:
|
|
779
|
+
logger.info(f"Completed {mapping_type}: {processed_in_mapping}/{files_in_mapping} files processed")
|
|
780
|
+
if missing_files:
|
|
781
|
+
logger.warning(f"Missing {len(missing_files)} files in {mapping_type}: {', '.join(missing_files[:5])}{'...' if len(missing_files) > 5 else ''}")
|
|
782
|
+
else:
|
|
783
|
+
logger.info(f"No files found for {mapping_type} - skipping")
|
|
784
|
+
|
|
785
|
+
logger.info(f"File processing complete: {total_processed}/{total_files_in_mappings} files encrypted and copied")
|
|
786
|
+
logger.info(f"Total files in mappings: {total_files_in_mappings}, Total processed: {total_processed}, Missing: {total_files_in_mappings - total_processed}")
|
|
787
|
+
|
|
788
|
+
# Add a clear summary
|
|
789
|
+
success_rate = (total_processed / total_files_in_mappings * 100) if total_files_in_mappings > 0 else 0
|
|
790
|
+
logger.info(f"File processing summary: {success_rate:.1f}% success rate ({total_processed}/{total_files_in_mappings} files)")
|
|
791
|
+
|
|
792
|
+
if success_rate < 100:
|
|
793
|
+
logger.warning("Some files were not found and could not be processed. This may be normal if:")
|
|
794
|
+
logger.warning("- Some Terraform modules haven't been applied yet")
|
|
795
|
+
logger.warning("- Some files are generated during deployment")
|
|
796
|
+
logger.warning("- Some optional files are missing")
|
|
797
|
+
else:
|
|
798
|
+
logger.info("All expected files were successfully processed!")
|
|
799
|
+
|
|
800
|
+
INSTALLER_FOLDER = "installer"
|
|
801
|
+
STATE_FILE_NAME = "deployment_state.json"
|
|
802
|
+
|
|
803
|
+
def _installer_files(self) -> dict[str, str]:
|
|
804
|
+
"""Installer files backed up under ``installer/``: repository name -> local path."""
|
|
805
|
+
files = {os.path.basename(str(vault_structure_path(self.customer))): str(vault_structure_path(self.customer))}
|
|
806
|
+
if self.state_file:
|
|
807
|
+
files[self.STATE_FILE_NAME] = self.state_file
|
|
808
|
+
from cli.command_record import RECORD_FILE
|
|
809
|
+
if RECORD_FILE.exists():
|
|
810
|
+
files[RECORD_FILE.name] = str(RECORD_FILE)
|
|
811
|
+
return files
|
|
812
|
+
|
|
813
|
+
def _refresh_secrets_from_vault(self):
|
|
814
|
+
"""Vault is the source of truth once the platform runs; refresh the file before it is backed up."""
|
|
815
|
+
if self.dry_run:
|
|
816
|
+
logger.info("[DRY-RUN] Secrets file not refreshed from Vault")
|
|
817
|
+
return
|
|
818
|
+
structure = str(vault_structure_path(self.customer))
|
|
819
|
+
if not os.path.exists(structure):
|
|
820
|
+
return
|
|
821
|
+
try:
|
|
822
|
+
refresh_from_vault(structure, self.kube_config_path, self.namespace)
|
|
823
|
+
self._secrets_refreshed = True
|
|
824
|
+
except Exception as e: # noqa: BLE001
|
|
825
|
+
self._secrets_refreshed = False
|
|
826
|
+
logger.warning(f"Could not refresh the secrets file from Vault ({type(e).__name__}); "
|
|
827
|
+
"the repository keeps its existing copy")
|
|
828
|
+
|
|
829
|
+
def _prepare_installer_files(self):
|
|
830
|
+
"""Encrypt the secrets file and the installer state so the repository can seed a new run."""
|
|
831
|
+
target_dir = os.path.join(self.working_dir, self.INSTALLER_FOLDER)
|
|
832
|
+
structure = str(vault_structure_path(self.customer))
|
|
833
|
+
for name, source in self._installer_files().items():
|
|
834
|
+
target = os.path.join(target_dir, name)
|
|
835
|
+
if source == structure and not self._secrets_refreshed and self._keep_previous(target):
|
|
836
|
+
continue
|
|
837
|
+
if os.path.exists(source):
|
|
838
|
+
if not self._encrypt_and_copy_file(source, target):
|
|
839
|
+
self._keep_previous(target)
|
|
840
|
+
elif not self._keep_previous(target):
|
|
841
|
+
logger.warning(f"Installer file not found, not backed up: {source}")
|
|
842
|
+
|
|
843
|
+
def local_key_path(self) -> str:
|
|
844
|
+
return str(secrets_dir() / f"{self.customer}_deployment_files.key")
|
|
845
|
+
|
|
846
|
+
def _write_local_key_copy(self):
|
|
847
|
+
"""Keep a copy of the key outside the cluster; without it the repository cannot be decrypted."""
|
|
848
|
+
if self.dry_run:
|
|
849
|
+
return
|
|
850
|
+
path = self.local_key_path()
|
|
851
|
+
os.makedirs(os.path.dirname(path), exist_ok=True)
|
|
852
|
+
with open(path, "w") as f:
|
|
853
|
+
f.write(self.encryption_key)
|
|
854
|
+
os.chmod(path, 0o600)
|
|
855
|
+
logger.info(f"Encryption key copy written to {path}")
|
|
856
|
+
|
|
857
|
+
def _get_source_path(self, directory: str, file: str) -> str:
|
|
858
|
+
"""Get source path for a file based on mapping type"""
|
|
859
|
+
# Check if directory is a core service
|
|
860
|
+
if directory in self._get_k8s_core_services_mapping():
|
|
861
|
+
base_path = "charts/infra_services_charts"
|
|
862
|
+
# Check if directory is a data service
|
|
863
|
+
elif directory in self._k8s_data_services_mapping():
|
|
864
|
+
base_path = "charts/data_services_charts"
|
|
865
|
+
else:
|
|
866
|
+
# Default for core infrastructure
|
|
867
|
+
if self.cloud_provider == "gcp":
|
|
868
|
+
base_path = "terraform/google_cloud/terragrunt"
|
|
869
|
+
elif self.cloud_provider == "aws":
|
|
870
|
+
base_path = "terraform/aws_cloud/terragrunt"
|
|
871
|
+
elif self.cloud_provider == "azure":
|
|
872
|
+
base_path = "terraform/azure_cloud/terragrunt"
|
|
873
|
+
else:
|
|
874
|
+
base_path = "terraform/self_managed/terragrunt"
|
|
875
|
+
|
|
876
|
+
# Handle .terraform folders - they have a nested structure
|
|
877
|
+
if '.terraform' in directory:
|
|
878
|
+
# For .terraform folders, we need to handle the nested structure
|
|
879
|
+
# The directory format is: bi-platform/01-create-project/.terraform/{customer}/01-create-project
|
|
880
|
+
# We need to extract the parent directory and the final subdirectory
|
|
881
|
+
parts = directory.split('/')
|
|
882
|
+
if len(parts) >= 4 and parts[-3] == '.terraform' and parts[-2] == self.customer:
|
|
883
|
+
# This is a terraform state file path
|
|
884
|
+
parent_dir = '/'.join(parts[:-3]) # bi-platform/01-create-project
|
|
885
|
+
sub_dir = parts[-1] # 01-create-project
|
|
886
|
+
return os.path.join(base_path, parent_dir, '.terraform', self.customer, sub_dir, file)
|
|
887
|
+
else:
|
|
888
|
+
# Fallback for other .terraform paths
|
|
889
|
+
return os.path.join(base_path, directory, file)
|
|
890
|
+
|
|
891
|
+
return os.path.join(base_path, directory, file)
|
|
892
|
+
|
|
893
|
+
def _encrypt_and_copy_file(self, source_path: str, target_path: str) -> bool:
|
|
894
|
+
"""Encrypt and copy a file. Returns False when the file was not written."""
|
|
895
|
+
try:
|
|
896
|
+
logger.debug(f"Encrypting file: {source_path}")
|
|
897
|
+
|
|
898
|
+
# Check if source file exists
|
|
899
|
+
if not os.path.exists(source_path):
|
|
900
|
+
logger.warning(f"Source file does not exist: {source_path}")
|
|
901
|
+
return False
|
|
902
|
+
|
|
903
|
+
# Check if source file is readable
|
|
904
|
+
if not os.access(source_path, os.R_OK):
|
|
905
|
+
logger.warning(f"Source file is not readable: {source_path}")
|
|
906
|
+
return False
|
|
907
|
+
|
|
908
|
+
# Check file size
|
|
909
|
+
file_size = os.path.getsize(source_path)
|
|
910
|
+
if file_size == 0:
|
|
911
|
+
logger.warning(f"Source file is empty: {source_path}")
|
|
912
|
+
return False
|
|
913
|
+
|
|
914
|
+
with open(source_path, 'rb') as f:
|
|
915
|
+
content = f.read()
|
|
916
|
+
|
|
917
|
+
# Validate content
|
|
918
|
+
if not content:
|
|
919
|
+
logger.warning(f"Source file has no content: {source_path}")
|
|
920
|
+
return False
|
|
921
|
+
|
|
922
|
+
# Encrypt content
|
|
923
|
+
fernet = Fernet(self.encryption_key.encode('utf-8'))
|
|
924
|
+
encrypted_content = fernet.encrypt(content)
|
|
925
|
+
|
|
926
|
+
# Ensure target directory exists
|
|
927
|
+
os.makedirs(os.path.dirname(target_path), exist_ok=True)
|
|
928
|
+
|
|
929
|
+
# Write encrypted content
|
|
930
|
+
with open(target_path, 'wb') as f:
|
|
931
|
+
f.write(encrypted_content)
|
|
932
|
+
self.written_files.append(target_path)
|
|
933
|
+
|
|
934
|
+
logger.debug(f"File encrypted and copied to: {target_path}")
|
|
935
|
+
return True
|
|
936
|
+
except Exception as e:
|
|
937
|
+
logger.error(f"Failed to encrypt and copy file {source_path}: {type(e).__name__}")
|
|
938
|
+
return False
|
|
939
|
+
|
|
940
|
+
def save_encryption_key(self):
|
|
941
|
+
"""Save encryption key to vault and log it"""
|
|
942
|
+
logger.info("Saving encryption key to vault")
|
|
943
|
+
logger.info("Backup encryption key generated")
|
|
944
|
+
|
|
945
|
+
# In dry-run mode, skip saving to vault
|
|
946
|
+
if self.dry_run:
|
|
947
|
+
logger.info("[DRY-RUN] Skipping encryption key save to vault")
|
|
948
|
+
print("[DRY-RUN] Encryption key generated but not saved to Vault; a real deployment stores it there")
|
|
949
|
+
return {"status": "dry-run", "message": "Encryption key not saved in dry-run mode"}
|
|
950
|
+
|
|
951
|
+
try:
|
|
952
|
+
# Setup port forward to vault
|
|
953
|
+
self.vault_client._setup_port_forward()
|
|
954
|
+
|
|
955
|
+
try:
|
|
956
|
+
# Get vault token from Kubernetes secret
|
|
957
|
+
cmd = [
|
|
958
|
+
"kubectl", "get", "secret", "vault-init", "-n", self.vault_client.namespace,
|
|
959
|
+
"-o", "jsonpath={.data.root-token}"
|
|
960
|
+
]
|
|
961
|
+
if self.kube_config_path:
|
|
962
|
+
cmd.extend(["--kubeconfig", self.kube_config_path])
|
|
963
|
+
|
|
964
|
+
result = subprocess.run(cmd, check=True, capture_output=True, text=True)
|
|
965
|
+
root_token = base64.b64decode(result.stdout).decode('utf-8')
|
|
966
|
+
|
|
967
|
+
# Save secret using vault API
|
|
968
|
+
headers = {
|
|
969
|
+
"X-Vault-Token": root_token,
|
|
970
|
+
"Content-Type": "application/json"
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
# Create the secret path
|
|
974
|
+
path = "/v1/secret/data/infrastructure_value_files_encryption_key"
|
|
975
|
+
payload = {
|
|
976
|
+
"data": {
|
|
977
|
+
"value": self.encryption_key
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
response = requests.post(
|
|
982
|
+
f"{self.vault_client.vault_addr}{path}",
|
|
983
|
+
headers=headers,
|
|
984
|
+
json=payload,
|
|
985
|
+
timeout=10
|
|
986
|
+
)
|
|
987
|
+
response.raise_for_status()
|
|
988
|
+
|
|
989
|
+
logger.info("Encryption key saved to vault successfully")
|
|
990
|
+
return response.json()
|
|
991
|
+
|
|
992
|
+
finally:
|
|
993
|
+
self.vault_client._cleanup_port_forward()
|
|
994
|
+
|
|
995
|
+
except Exception as e:
|
|
996
|
+
logger.error(f"Failed to save encryption key: {str(e)}")
|
|
997
|
+
raise VaultError(f"Failed to save encryption key: {str(e)}")
|
|
998
|
+
|
|
999
|
+
def _commit_and_push_changes(self):
|
|
1000
|
+
"""Commit and push changes to git repository"""
|
|
1001
|
+
try:
|
|
1002
|
+
# In dry-run mode, skip git commit and push
|
|
1003
|
+
if self.dry_run:
|
|
1004
|
+
logger.info("[DRY-RUN] Skipping git commit and push")
|
|
1005
|
+
print("[DRY-RUN] Would commit and push changes to repository")
|
|
1006
|
+
print(f"[DRY-RUN] Files remain in: {self.working_dir}")
|
|
1007
|
+
return
|
|
1008
|
+
|
|
1009
|
+
self.git_manager.commit_and_push("Update infrastructure files")
|
|
1010
|
+
except Exception as e:
|
|
1011
|
+
logger.error(f"Failed to commit and push changes: {str(e)}")
|
|
1012
|
+
raise
|
|
1013
|
+
|
|
1014
|
+
def _cleanup(self):
|
|
1015
|
+
"""Clean up temporary files and directories"""
|
|
1016
|
+
self._drop_previous_tree()
|
|
1017
|
+
try:
|
|
1018
|
+
# In dry-run mode, keep the files for review
|
|
1019
|
+
if self.dry_run:
|
|
1020
|
+
logger.info("[DRY-RUN] Skipping cleanup - files kept for review")
|
|
1021
|
+
print(f"[DRY-RUN] Infrastructure files available for review at: {self.working_dir}")
|
|
1022
|
+
return
|
|
1023
|
+
|
|
1024
|
+
if os.path.exists(self.working_dir):
|
|
1025
|
+
logger.info(f"Cleaning up working directory: {self.working_dir}")
|
|
1026
|
+
shutil.rmtree(self.working_dir)
|
|
1027
|
+
logger.info("Cleanup completed successfully")
|
|
1028
|
+
except Exception as e:
|
|
1029
|
+
logger.warning(f"Failed to cleanup working directory: {str(e)}")
|
|
1030
|
+
# Don't raise here as this is cleanup
|
|
1031
|
+
|
|
1032
|
+
def _cleanup_local_environment(self):
|
|
1033
|
+
"""Clean up local environment after successful deployment"""
|
|
1034
|
+
logger.info("Starting local environment cleanup...")
|
|
1035
|
+
|
|
1036
|
+
try:
|
|
1037
|
+
# Clean up Terraform state files and sensitive data
|
|
1038
|
+
self._cleanup_terraform_files()
|
|
1039
|
+
|
|
1040
|
+
# Clean up service account keys and sensitive files
|
|
1041
|
+
self._cleanup_sensitive_files()
|
|
1042
|
+
|
|
1043
|
+
# Clean up temporary files
|
|
1044
|
+
self._cleanup_temp_files()
|
|
1045
|
+
|
|
1046
|
+
# Clean up secret files
|
|
1047
|
+
self._cleanup_secret_files()
|
|
1048
|
+
|
|
1049
|
+
# Clean up rendered values and terraform config (kept encrypted in git)
|
|
1050
|
+
self._cleanup_rendered_files()
|
|
1051
|
+
|
|
1052
|
+
logger.info("Local environment cleanup completed successfully")
|
|
1053
|
+
|
|
1054
|
+
except Exception as e:
|
|
1055
|
+
logger.warning(f"Some cleanup operations failed: {str(e)}")
|
|
1056
|
+
# Don't raise here as this is cleanup
|
|
1057
|
+
|
|
1058
|
+
def _cleanup_rendered_files(self):
|
|
1059
|
+
"""Remove plain-text rendered files that were encrypted and pushed to the customer repository"""
|
|
1060
|
+
logger.info("Cleaning up rendered values and terraform config files...")
|
|
1061
|
+
removed = 0
|
|
1062
|
+
for mapping_type, mapping in self._get_infrastructure_mappings().items():
|
|
1063
|
+
for directory, files in mapping.items():
|
|
1064
|
+
if mapping_type == 'core_infrastructure' and '.terraform' in directory:
|
|
1065
|
+
continue
|
|
1066
|
+
for file in files:
|
|
1067
|
+
if mapping_type == 'core_infrastructure' and file not in self.RENDERED_CORE_FILES:
|
|
1068
|
+
continue
|
|
1069
|
+
path = self._get_source_path(directory, file)
|
|
1070
|
+
if os.path.isfile(path):
|
|
1071
|
+
try:
|
|
1072
|
+
os.remove(path)
|
|
1073
|
+
removed += 1
|
|
1074
|
+
except Exception as e:
|
|
1075
|
+
logger.warning(f"Failed to remove rendered file {path}: {str(e)}")
|
|
1076
|
+
logger.info(f"Removed {removed} rendered files")
|
|
1077
|
+
|
|
1078
|
+
def _cleanup_terraform_files(self):
|
|
1079
|
+
"""Clean up Terraform state files and .terraform directories"""
|
|
1080
|
+
logger.info("Cleaning up Terraform files...")
|
|
1081
|
+
|
|
1082
|
+
terraform_dirs_to_clean = [
|
|
1083
|
+
"terraform/google_cloud/terragrunt/bi-platform",
|
|
1084
|
+
"terraform/aws_cloud/terragrunt/bi-platform",
|
|
1085
|
+
"terraform/azure_cloud/terragrunt/bi-platform"
|
|
1086
|
+
]
|
|
1087
|
+
|
|
1088
|
+
for base_dir in terraform_dirs_to_clean:
|
|
1089
|
+
if not os.path.exists(base_dir):
|
|
1090
|
+
continue
|
|
1091
|
+
|
|
1092
|
+
for root, dirs, files in os.walk(base_dir):
|
|
1093
|
+
# Clean up .terraform directories
|
|
1094
|
+
if '.terraform' in dirs:
|
|
1095
|
+
terraform_dir = os.path.join(root, '.terraform')
|
|
1096
|
+
try:
|
|
1097
|
+
shutil.rmtree(terraform_dir)
|
|
1098
|
+
logger.debug(f"Removed .terraform directory: {terraform_dir}")
|
|
1099
|
+
except Exception as e:
|
|
1100
|
+
logger.warning(f"Failed to remove .terraform directory {terraform_dir}: {str(e)}")
|
|
1101
|
+
|
|
1102
|
+
# Clean up terraform.tfstate files
|
|
1103
|
+
for file in files:
|
|
1104
|
+
if file in ['terraform.tfstate', 'terraform.tfstate.backup']:
|
|
1105
|
+
file_path = os.path.join(root, file)
|
|
1106
|
+
try:
|
|
1107
|
+
os.remove(file_path)
|
|
1108
|
+
logger.debug(f"Removed terraform state file: {file_path}")
|
|
1109
|
+
except Exception as e:
|
|
1110
|
+
logger.warning(f"Failed to remove terraform state file {file_path}: {str(e)}")
|
|
1111
|
+
|
|
1112
|
+
def _cleanup_sensitive_files(self):
|
|
1113
|
+
"""Clean up sensitive files like service account keys"""
|
|
1114
|
+
logger.info("Cleaning up sensitive files...")
|
|
1115
|
+
|
|
1116
|
+
terraform_dirs_to_clean = [
|
|
1117
|
+
"terraform/google_cloud/terragrunt/bi-platform",
|
|
1118
|
+
"terraform/aws_cloud/terragrunt/bi-platform",
|
|
1119
|
+
"terraform/azure_cloud/terragrunt/bi-platform"
|
|
1120
|
+
]
|
|
1121
|
+
|
|
1122
|
+
sensitive_files = [
|
|
1123
|
+
'sa_key.txt',
|
|
1124
|
+
'sa_name.txt',
|
|
1125
|
+
'kubeconfig',
|
|
1126
|
+
'external_ip_traefik.txt',
|
|
1127
|
+
'dns_zone_complete_info.txt',
|
|
1128
|
+
'dns_zone_nameservers.txt'
|
|
1129
|
+
]
|
|
1130
|
+
|
|
1131
|
+
for base_dir in terraform_dirs_to_clean:
|
|
1132
|
+
if not os.path.exists(base_dir):
|
|
1133
|
+
continue
|
|
1134
|
+
|
|
1135
|
+
for root, dirs, files in os.walk(base_dir):
|
|
1136
|
+
for file in files:
|
|
1137
|
+
if file in sensitive_files:
|
|
1138
|
+
file_path = os.path.join(root, file)
|
|
1139
|
+
try:
|
|
1140
|
+
os.remove(file_path)
|
|
1141
|
+
logger.debug(f"Removed sensitive file: {file_path}")
|
|
1142
|
+
except Exception as e:
|
|
1143
|
+
logger.warning(f"Failed to remove sensitive file {file_path}: {str(e)}")
|
|
1144
|
+
|
|
1145
|
+
def _cleanup_temp_files(self):
|
|
1146
|
+
"""Clean up temporary files created during deployment"""
|
|
1147
|
+
logger.info("Cleaning up temporary files...")
|
|
1148
|
+
|
|
1149
|
+
temp_files = [
|
|
1150
|
+
f"/tmp/{self.customer}_infrastructure_deployment_files",
|
|
1151
|
+
str(vault_structure_path(self.customer)),
|
|
1152
|
+
]
|
|
1153
|
+
|
|
1154
|
+
for temp_file in temp_files:
|
|
1155
|
+
if os.path.exists(temp_file):
|
|
1156
|
+
try:
|
|
1157
|
+
if os.path.isdir(temp_file):
|
|
1158
|
+
shutil.rmtree(temp_file)
|
|
1159
|
+
else:
|
|
1160
|
+
os.remove(temp_file)
|
|
1161
|
+
logger.debug(f"Removed temporary file/directory: {temp_file}")
|
|
1162
|
+
except Exception as e:
|
|
1163
|
+
logger.warning(f"Failed to remove temporary file {temp_file}: {str(e)}")
|
|
1164
|
+
|
|
1165
|
+
def _cleanup_secret_files(self):
|
|
1166
|
+
"""Clean up secret files and sensitive configuration"""
|
|
1167
|
+
logger.info("Cleaning up secret files...")
|
|
1168
|
+
|
|
1169
|
+
# Clean up any remaining secret files
|
|
1170
|
+
secret_patterns = [
|
|
1171
|
+
"*.key",
|
|
1172
|
+
"*.pem",
|
|
1173
|
+
"*.crt",
|
|
1174
|
+
"*.p12",
|
|
1175
|
+
"*.pfx"
|
|
1176
|
+
]
|
|
1177
|
+
|
|
1178
|
+
terraform_dirs_to_clean = [
|
|
1179
|
+
"terraform/google_cloud/terragrunt",
|
|
1180
|
+
"terraform/aws_cloud/terragrunt",
|
|
1181
|
+
"terraform/azure_cloud/terragrunt"
|
|
1182
|
+
]
|
|
1183
|
+
|
|
1184
|
+
for base_dir in terraform_dirs_to_clean:
|
|
1185
|
+
if not os.path.exists(base_dir):
|
|
1186
|
+
continue
|
|
1187
|
+
|
|
1188
|
+
for root, dirs, files in os.walk(base_dir):
|
|
1189
|
+
for file in files:
|
|
1190
|
+
for pattern in secret_patterns:
|
|
1191
|
+
if file.endswith(pattern.replace('*', '')):
|
|
1192
|
+
file_path = os.path.join(root, file)
|
|
1193
|
+
try:
|
|
1194
|
+
os.remove(file_path)
|
|
1195
|
+
logger.debug(f"Removed secret file: {file_path}")
|
|
1196
|
+
except Exception as e:
|
|
1197
|
+
logger.warning(f"Failed to remove secret file {file_path}: {str(e)}")
|
|
1198
|
+
|
|
1199
|
+
def _get_deployment_summary(self) -> dict:
|
|
1200
|
+
"""Get deployment summary"""
|
|
1201
|
+
summary = {
|
|
1202
|
+
"customer": self.customer,
|
|
1203
|
+
"cloud_provider": self.cloud_provider,
|
|
1204
|
+
"terraform_state": self.terraform_state,
|
|
1205
|
+
"git_provider": self.git_provider,
|
|
1206
|
+
"git_repo_url": self.git_repo_url,
|
|
1207
|
+
"status": "success",
|
|
1208
|
+
"encryption_key": self.encryption_key # Include encryption key in summary
|
|
1209
|
+
}
|
|
1210
|
+
logger.info("Deployment summary generated")
|
|
1211
|
+
return summary
|
|
1212
|
+
|
|
1213
|
+
def _get_git_access_token_from_vault(self) -> str:
|
|
1214
|
+
"""Get git access token from vault based on provider"""
|
|
1215
|
+
try:
|
|
1216
|
+
# Get vault path from environment or use default based on provider
|
|
1217
|
+
if self.git_provider == "github":
|
|
1218
|
+
vault_path = os.getenv('GITHUB_TOKEN_VAULT_PATH', '/data-platform-runner/ci-access-tokens/')
|
|
1219
|
+
secret_name = "GITHUB-TOKEN"
|
|
1220
|
+
elif self.git_provider == "gitlab":
|
|
1221
|
+
vault_path = os.getenv('GITLAB_TOKEN_VAULT_PATH', '/data-platform-runner/ci-access-tokens/')
|
|
1222
|
+
secret_name = "PRIVATE-TOKEN"
|
|
1223
|
+
elif self.git_provider == "bitbucket":
|
|
1224
|
+
vault_path = os.getenv('BITBUCKET_TOKEN_VAULT_PATH', '/data-platform-runner/ci-access-tokens/')
|
|
1225
|
+
secret_name = "BITBUCKET-TOKEN"
|
|
1226
|
+
elif self.git_provider == "gitea":
|
|
1227
|
+
vault_path = os.getenv('GITEA_TOKEN_VAULT_PATH', '/data-platform-runner/ci-access-tokens/')
|
|
1228
|
+
secret_name = "GITEA-TOKEN"
|
|
1229
|
+
else:
|
|
1230
|
+
# Default to GitLab for backward compatibility
|
|
1231
|
+
vault_path = os.getenv('GITLAB_TOKEN_VAULT_PATH', '/data-platform-runner/ci-access-tokens/')
|
|
1232
|
+
secret_name = "PRIVATE-TOKEN"
|
|
1233
|
+
|
|
1234
|
+
logger.info(f"Attempting to retrieve {secret_name} from vault path: {vault_path}")
|
|
1235
|
+
token = self.vault_client.get_secret(
|
|
1236
|
+
secret_name=secret_name,
|
|
1237
|
+
secret_path=vault_path
|
|
1238
|
+
)
|
|
1239
|
+
logger.info(f"Successfully retrieved {self.git_provider} token from vault")
|
|
1240
|
+
return token
|
|
1241
|
+
except Exception as e:
|
|
1242
|
+
logger.error(f"Failed to get {self.git_provider} access token from vault: {str(e)}")
|
|
1243
|
+
raise ValueError(f"{self.git_provider.capitalize()} access token is required. Either provide it directly via --git_access_token parameter or ensure it exists in vault at the configured path")
|
|
1244
|
+
|
|
1245
|
+
class GitManager:
|
|
1246
|
+
"""Handles Git operations with different authentication methods"""
|
|
1247
|
+
|
|
1248
|
+
def __init__(self, repo_url: str, credentials: dict, working_dir: str):
|
|
1249
|
+
self.repo_url = repo_url
|
|
1250
|
+
self.credentials = credentials
|
|
1251
|
+
self.working_dir = working_dir
|
|
1252
|
+
|
|
1253
|
+
def clone_repository(self):
|
|
1254
|
+
"""Clone repository with appropriate authentication"""
|
|
1255
|
+
if os.path.exists(self.working_dir):
|
|
1256
|
+
shutil.rmtree(self.working_dir)
|
|
1257
|
+
|
|
1258
|
+
if self.credentials.get('access_token'):
|
|
1259
|
+
# Use token-based authentication
|
|
1260
|
+
repo_url_with_token = self._add_token_to_url(self.repo_url, self.credentials['access_token'])
|
|
1261
|
+
self._git_clone(repo_url_with_token)
|
|
1262
|
+
elif self.credentials.get('private_key'):
|
|
1263
|
+
# Use SSH-based authentication
|
|
1264
|
+
self._setup_ssh_key()
|
|
1265
|
+
self._git_clone(self.repo_url)
|
|
1266
|
+
else:
|
|
1267
|
+
# Use basic authentication
|
|
1268
|
+
self._git_clone_with_basic_auth(self.repo_url,
|
|
1269
|
+
self.credentials['username'],
|
|
1270
|
+
self.credentials['password'])
|
|
1271
|
+
|
|
1272
|
+
def _add_token_to_url(self, url: str, token: str) -> str:
|
|
1273
|
+
"""Add access token to repository URL"""
|
|
1274
|
+
if "https://" in url:
|
|
1275
|
+
# GitHub uses a different format: https://username:token@github.com/...
|
|
1276
|
+
# For GitHub, we'll use 'oauth2' as username for consistency
|
|
1277
|
+
return url.replace("https://", f"https://oauth2:{token}@")
|
|
1278
|
+
return url
|
|
1279
|
+
|
|
1280
|
+
def _setup_ssh_key(self):
|
|
1281
|
+
"""Setup SSH key for authentication"""
|
|
1282
|
+
ssh_dir = os.path.expanduser("~/.ssh")
|
|
1283
|
+
os.makedirs(ssh_dir, exist_ok=True)
|
|
1284
|
+
|
|
1285
|
+
# Write private key
|
|
1286
|
+
with open(os.path.join(ssh_dir, "id_rsa"), "w") as f:
|
|
1287
|
+
f.write(self.credentials['private_key'])
|
|
1288
|
+
|
|
1289
|
+
# Set permissions
|
|
1290
|
+
os.chmod(os.path.join(ssh_dir, "id_rsa"), 0o600)
|
|
1291
|
+
|
|
1292
|
+
def _git_clone(self, repo_url: str):
|
|
1293
|
+
"""Execute git clone command"""
|
|
1294
|
+
try:
|
|
1295
|
+
subprocess.run(['git', 'clone', repo_url, self.working_dir],
|
|
1296
|
+
check=True, capture_output=True)
|
|
1297
|
+
except subprocess.CalledProcessError as e:
|
|
1298
|
+
raise GitError(f"Failed to clone repository: {e.stderr.decode()}")
|
|
1299
|
+
|
|
1300
|
+
def _git_clone_with_basic_auth(self, repo_url: str, username: str, password: str):
|
|
1301
|
+
"""Execute git clone with basic authentication"""
|
|
1302
|
+
try:
|
|
1303
|
+
# Create credentials file
|
|
1304
|
+
credentials_file = os.path.join(self.working_dir, ".git-credentials")
|
|
1305
|
+
with open(credentials_file, "w") as f:
|
|
1306
|
+
f.write(f"{repo_url}\n")
|
|
1307
|
+
|
|
1308
|
+
# Configure git to use credentials
|
|
1309
|
+
subprocess.run(['git', 'config', '--global', 'credential.helper', 'store'],
|
|
1310
|
+
check=True, capture_output=True)
|
|
1311
|
+
|
|
1312
|
+
# Clone repository
|
|
1313
|
+
self._git_clone(repo_url)
|
|
1314
|
+
|
|
1315
|
+
except Exception as e:
|
|
1316
|
+
raise GitError(f"Failed to clone repository with basic auth: {str(e)}")
|
|
1317
|
+
|
|
1318
|
+
def commit_and_push(self, message: str):
|
|
1319
|
+
"""Commit and push changes"""
|
|
1320
|
+
try:
|
|
1321
|
+
subprocess.run(['git', 'add', '-A'],
|
|
1322
|
+
cwd=self.working_dir,
|
|
1323
|
+
check=True, capture_output=True)
|
|
1324
|
+
status = subprocess.run(['git', 'status', '--porcelain'],
|
|
1325
|
+
cwd=self.working_dir,
|
|
1326
|
+
check=True, capture_output=True)
|
|
1327
|
+
if not status.stdout.strip():
|
|
1328
|
+
logger.info("Deployment repository already up to date - nothing to commit")
|
|
1329
|
+
return False
|
|
1330
|
+
|
|
1331
|
+
# Commit changes
|
|
1332
|
+
subprocess.run(['git', 'commit', '-m', message],
|
|
1333
|
+
cwd=self.working_dir,
|
|
1334
|
+
check=True, capture_output=True)
|
|
1335
|
+
|
|
1336
|
+
# Push changes
|
|
1337
|
+
subprocess.run(['git', 'push'],
|
|
1338
|
+
cwd=self.working_dir,
|
|
1339
|
+
check=True, capture_output=True)
|
|
1340
|
+
return True
|
|
1341
|
+
except subprocess.CalledProcessError as e:
|
|
1342
|
+
raise GitError(f"Failed to commit and push changes: {e.stderr.decode()}")
|
|
1343
|
+
|
|
1344
|
+
class LocalVaultClient:
|
|
1345
|
+
"""Client for local vault"""
|
|
1346
|
+
|
|
1347
|
+
def __init__(self, customer: str, kube_config: str | None, namespace: str):
|
|
1348
|
+
self.customer = customer
|
|
1349
|
+
self.kube_config = kube_config
|
|
1350
|
+
self.namespace = namespace
|
|
1351
|
+
self.secret_file = str(vault_structure_path(customer))
|
|
1352
|
+
self.port_forward_process = None
|
|
1353
|
+
self.vault_addr = "http://127.0.0.1:8200"
|
|
1354
|
+
|
|
1355
|
+
def _setup_port_forward(self):
|
|
1356
|
+
"""Setup port forward to vault"""
|
|
1357
|
+
try:
|
|
1358
|
+
cmd = [
|
|
1359
|
+
"kubectl", "port-forward", "vault-0", "-n", self.namespace,
|
|
1360
|
+
"8200:8200"
|
|
1361
|
+
]
|
|
1362
|
+
|
|
1363
|
+
if self.kube_config:
|
|
1364
|
+
cmd.extend(["--kubeconfig", self.kube_config])
|
|
1365
|
+
|
|
1366
|
+
# Start port-forward in background
|
|
1367
|
+
self.port_forward_process = subprocess.Popen(
|
|
1368
|
+
cmd,
|
|
1369
|
+
stdout=subprocess.PIPE,
|
|
1370
|
+
stderr=subprocess.PIPE
|
|
1371
|
+
)
|
|
1372
|
+
|
|
1373
|
+
# Wait for port-forward to be ready
|
|
1374
|
+
time.sleep(2)
|
|
1375
|
+
|
|
1376
|
+
except Exception as e:
|
|
1377
|
+
if self.port_forward_process:
|
|
1378
|
+
self.port_forward_process.terminate()
|
|
1379
|
+
raise Exception(f"Failed to setup port forward: {str(e)}")
|
|
1380
|
+
|
|
1381
|
+
def _cleanup_port_forward(self):
|
|
1382
|
+
"""Cleanup port forward"""
|
|
1383
|
+
if self.port_forward_process:
|
|
1384
|
+
try:
|
|
1385
|
+
self.port_forward_process.terminate()
|
|
1386
|
+
self.port_forward_process.wait(timeout=5)
|
|
1387
|
+
except subprocess.TimeoutExpired:
|
|
1388
|
+
self.port_forward_process.kill()
|
|
1389
|
+
finally:
|
|
1390
|
+
self.port_forward_process = None
|
|
1391
|
+
|
|
1392
|
+
def save_secret(self, secret_name: str, secret_value: str, secret_path: str) -> dict:
|
|
1393
|
+
"""Save secret to local vault using port-forwarding"""
|
|
1394
|
+
try:
|
|
1395
|
+
# Setup port forward
|
|
1396
|
+
self._setup_port_forward()
|
|
1397
|
+
|
|
1398
|
+
# Get vault token from Kubernetes secret
|
|
1399
|
+
cmd = [
|
|
1400
|
+
"kubectl", "get", "secret", "vault-init", "-n", self.namespace,
|
|
1401
|
+
"-o", "jsonpath={.data.root-token}"
|
|
1402
|
+
]
|
|
1403
|
+
if self.kube_config:
|
|
1404
|
+
cmd.extend(["--kubeconfig", self.kube_config])
|
|
1405
|
+
|
|
1406
|
+
result = subprocess.run(cmd, check=True, capture_output=True, text=True)
|
|
1407
|
+
root_token = base64.b64decode(result.stdout).decode('utf-8')
|
|
1408
|
+
|
|
1409
|
+
# Save secret using vault API
|
|
1410
|
+
headers = {
|
|
1411
|
+
"X-Vault-Token": root_token,
|
|
1412
|
+
"Content-Type": "application/json"
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
# Create the secret path if it doesn't exist
|
|
1416
|
+
path = f"/v1/secret/data/{secret_path.lstrip('/')}/{secret_name}"
|
|
1417
|
+
payload = {
|
|
1418
|
+
"data": {
|
|
1419
|
+
"value": secret_value
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
response = requests.post(
|
|
1424
|
+
f"{self.vault_addr}{path}",
|
|
1425
|
+
headers=headers,
|
|
1426
|
+
json=payload,
|
|
1427
|
+
timeout=10
|
|
1428
|
+
)
|
|
1429
|
+
response.raise_for_status()
|
|
1430
|
+
|
|
1431
|
+
return response.json()
|
|
1432
|
+
|
|
1433
|
+
except Exception as e:
|
|
1434
|
+
logger.error(f"Failed to save secret to local vault: {str(e)}")
|
|
1435
|
+
raise
|
|
1436
|
+
finally:
|
|
1437
|
+
self._cleanup_port_forward()
|
|
1438
|
+
|
|
1439
|
+
def get_secret(self, secret_name: str, secret_path: str) -> str:
|
|
1440
|
+
"""Retrieve the secret from the local vault JSON file."""
|
|
1441
|
+
try:
|
|
1442
|
+
logger.info(f"Attempting to get secret '{secret_name}' from path '{secret_path}' in file '{self.secret_file}'")
|
|
1443
|
+
if not os.path.exists(self.secret_file):
|
|
1444
|
+
raise FileNotFoundError(f"Secret file not found: {self.secret_file}")
|
|
1445
|
+
|
|
1446
|
+
with open(self.secret_file, 'r') as f:
|
|
1447
|
+
vault_data = json.load(f)
|
|
1448
|
+
|
|
1449
|
+
# Navigate through the JSON structure based on the secret path
|
|
1450
|
+
current = vault_data
|
|
1451
|
+
for part in secret_path.strip('/').split('/'):
|
|
1452
|
+
if part not in current:
|
|
1453
|
+
raise KeyError(f"Path {secret_path} not found in vault structure")
|
|
1454
|
+
current = current[part]
|
|
1455
|
+
|
|
1456
|
+
if secret_name not in current:
|
|
1457
|
+
raise KeyError(f"Secret {secret_name} not found at path {secret_path}")
|
|
1458
|
+
|
|
1459
|
+
logger.info(f"Successfully retrieved secret '{secret_name}' from vault")
|
|
1460
|
+
return current[secret_name]
|
|
1461
|
+
|
|
1462
|
+
except Exception as e:
|
|
1463
|
+
logger.error(f"Failed to get secret from local vault: {str(e)}")
|
|
1464
|
+
raise
|
|
1465
|
+
|
|
1466
|
+
def main():
|
|
1467
|
+
"""Main entry point for CLI usage"""
|
|
1468
|
+
import argparse
|
|
1469
|
+
|
|
1470
|
+
parser = argparse.ArgumentParser(description="Infrastructure Deployment Operator")
|
|
1471
|
+
|
|
1472
|
+
# Core arguments
|
|
1473
|
+
parser.add_argument('--customer', required=True, help='Customer name')
|
|
1474
|
+
parser.add_argument('--cloud_provider', choices=['gcp', 'aws', 'azure', 'self-managed'],
|
|
1475
|
+
required=True, help='Cloud provider')
|
|
1476
|
+
parser.add_argument('--terraform_state', choices=['local', 'remote'],
|
|
1477
|
+
default='remote', help='Terraform state storage method')
|
|
1478
|
+
|
|
1479
|
+
# Git configuration
|
|
1480
|
+
git_group = parser.add_argument_group('git configuration')
|
|
1481
|
+
git_group.add_argument('--git_repo_url', required=True, help='Git repository URL')
|
|
1482
|
+
git_group.add_argument('--git_provider', help='Git provider (auto-detected if not provided)')
|
|
1483
|
+
|
|
1484
|
+
# Git authentication
|
|
1485
|
+
git_auth_group = parser.add_argument_group('git authentication')
|
|
1486
|
+
git_auth_group.add_argument('--git_access_token', help='Git access token')
|
|
1487
|
+
git_auth_group.add_argument('--git_private_key', help='Path to Git private key file')
|
|
1488
|
+
git_auth_group.add_argument('--git_username', help='Git username')
|
|
1489
|
+
git_auth_group.add_argument('--git_password', help='Git password')
|
|
1490
|
+
|
|
1491
|
+
# Kubernetes configuration
|
|
1492
|
+
k8s_group = parser.add_argument_group('kubernetes configuration')
|
|
1493
|
+
k8s_group.add_argument('--kube_config_path', help='Path to kubeconfig file')
|
|
1494
|
+
k8s_group.add_argument('--namespace', default='vault', help='Kubernetes namespace')
|
|
1495
|
+
|
|
1496
|
+
# Operation flags
|
|
1497
|
+
operation_group = parser.add_argument_group('operation flags')
|
|
1498
|
+
operation_group.add_argument('--force_deployment', action='store_true',
|
|
1499
|
+
help='Force deployment even if no infrastructure files are found')
|
|
1500
|
+
operation_group.add_argument('--no-cleanup', action='store_true',
|
|
1501
|
+
help='Skip cleanup of local environment after deployment')
|
|
1502
|
+
|
|
1503
|
+
args = parser.parse_args()
|
|
1504
|
+
|
|
1505
|
+
try:
|
|
1506
|
+
# Initialize operator
|
|
1507
|
+
operator = InfrastructureDeploymentOperator(
|
|
1508
|
+
customer=args.customer,
|
|
1509
|
+
cloud_provider=args.cloud_provider,
|
|
1510
|
+
terraform_state=args.terraform_state,
|
|
1511
|
+
git_provider=args.git_provider,
|
|
1512
|
+
git_repo_url=args.git_repo_url,
|
|
1513
|
+
git_access_token=args.git_access_token,
|
|
1514
|
+
git_private_key=args.git_private_key,
|
|
1515
|
+
git_username=args.git_username,
|
|
1516
|
+
git_password=args.git_password,
|
|
1517
|
+
kube_config_path=args.kube_config_path,
|
|
1518
|
+
namespace=args.namespace,
|
|
1519
|
+
force_deployment=args.force_deployment,
|
|
1520
|
+
cleanup_enabled=not args.no_cleanup
|
|
1521
|
+
)
|
|
1522
|
+
|
|
1523
|
+
# Collect and store infrastructure
|
|
1524
|
+
result = operator.collect_and_store_infrastructure()
|
|
1525
|
+
print(json.dumps(result, indent=2))
|
|
1526
|
+
|
|
1527
|
+
except Exception as e:
|
|
1528
|
+
logger.error(f"Operation failed: {str(e)}")
|
|
1529
|
+
sys.exit(1)
|
|
1530
|
+
|
|
1531
|
+
if __name__ == "__main__":
|
|
1532
|
+
main()
|