├── .gitattributes ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── pull_request_template.md └── workflows │ ├── benchmark.yml │ ├── ci-experimental.yml │ ├── ci-sync-deployment.yml │ ├── ci-sync-preview.yml │ ├── interop-tests.yml │ └── release.yml ├── .gitignore ├── .gitlab-ci.yml ├── .golangci.toml ├── .goreleaser.yaml ├── .tmtriggers ├── cloud │ └── changed-a9fe0083-ed01-4ee7-b407-b367413071d1.tm.hcl └── e2etests │ └── core │ └── changed-e1311e1d-8a43-4224-9209-a2c59fa727b3.tm.hcl ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── ThirdPartyNotice.txt ├── VERSION ├── _test_mock.tf ├── benchmarks └── changed │ ├── _test_mock.tf │ ├── changed_bench_test.go │ ├── doc.go │ └── stack.tm.hcl ├── bin └── .gitkeep ├── bitbucket-pipelines.yml ├── ci ├── _test_mock.tf ├── ci.go ├── ci_test.go ├── doc.go └── stack.tm.hcl ├── cloud ├── _test_mock.tf ├── api │ ├── deployment │ │ ├── _test_mock.tf │ │ ├── stack.tm.hcl │ │ ├── status.go │ │ └── status_test.go │ ├── drift │ │ ├── _test_mock.tf │ │ ├── stack.tm.hcl │ │ ├── status.go │ │ └── status_test.go │ ├── metadata │ │ ├── _test_mock.tf │ │ ├── bitbucket.go │ │ ├── bitbucket_test.go │ │ ├── github.go │ │ ├── github_test.go │ │ ├── gitlab.go │ │ ├── gitlab_test.go │ │ ├── metadata.go │ │ ├── stack.tm.hcl │ │ └── testdata │ │ │ ├── bitbucket_pr.json │ │ │ ├── github_commit.json │ │ │ ├── github_pr.json │ │ │ ├── github_pr_reviews.json │ │ │ ├── gitlab_mr.json │ │ │ ├── gitlab_mr_participants.json │ │ │ └── gitlab_mr_reviewers.json │ ├── preview │ │ ├── _test_mock.tf │ │ ├── doc.go │ │ ├── preview.go │ │ ├── preview_test.go │ │ └── stack.tm.hcl │ ├── resources │ │ ├── _test_mock.tf │ │ ├── resources.go │ │ └── stack.tm.hcl │ ├── stack │ │ ├── _test_mock.tf │ │ ├── stack.tm.hcl │ │ ├── status.go │ │ └── status_test.go │ └── status │ │ ├── _test_mock.tf │ │ ├── stack.tm.hcl │ │ └── status.go ├── client.go ├── client_preview.go ├── client_preview_test.go ├── client_test.go ├── cloud.go ├── doc.go ├── integrations │ ├── bitbucket │ │ ├── _test_mock.tf │ │ ├── bitbucket.go │ │ ├── doc.go │ │ └── stack.tm.hcl │ ├── github │ │ ├── _test_mock.tf │ │ ├── client.go │ │ ├── event.go │ │ ├── event_test.go │ │ ├── stack.tm.hcl │ │ └── testdata │ │ │ └── event_pull_request.json │ └── gitlab │ │ ├── _test_mock.tf │ │ ├── doc.go │ │ ├── mr.go │ │ ├── mr_smoke_test.go │ │ ├── mr_test.go │ │ └── stack.tm.hcl ├── log_syncer.go ├── log_syncer_bench_test.go ├── log_syncer_test.go ├── stack.tm.hcl └── testserver │ ├── _test_mock.tf │ ├── apikey.go │ ├── cloudstore │ ├── _test_mock.tf │ ├── doc.go │ ├── stack.tm.hcl │ ├── store.go │ └── store_test.go │ ├── cmd │ └── testserver │ │ ├── README.md │ │ ├── _test_mock.tf │ │ ├── main.go │ │ └── stack.tm.hcl │ ├── deployments.go │ ├── drifts.go │ ├── github.go │ ├── helpers.go │ ├── memberships.go │ ├── metadata.go │ ├── previews.go │ ├── previews_test.go │ ├── router.go │ ├── stack.tm.hcl │ ├── stacks.go │ ├── store.go │ ├── users.go │ └── well-known.go ├── cloudsync ├── _test_mock.tf ├── cloud_hooks.go ├── create_deployment.go ├── create_drift.go ├── create_preview.go ├── doc.go ├── metadata.go ├── stack.tm.hcl ├── state.go └── terraform_planfile.go ├── cmd ├── terramate-ls │ ├── _test_mock.tf │ ├── main.go │ └── stack.tm.hcl ├── terramate │ ├── _test_mock.tf │ ├── main.go │ └── stack.tm.hcl └── tgdeps │ ├── README.md │ ├── _test_mock.tf │ ├── main.go │ └── stack.tm.hcl ├── commands ├── _test_mock.tf ├── clone │ ├── _test_mock.tf │ ├── clone.go │ └── stack.tm.hcl ├── cloud │ ├── drift │ │ └── show │ │ │ ├── _test_mock.tf │ │ │ ├── show.go │ │ │ └── stack.tm.hcl │ ├── info │ │ ├── _test_mock.tf │ │ ├── info.go │ │ └── stack.tm.hcl │ └── login │ │ ├── _test_mock.tf │ │ ├── doc.go │ │ ├── github.go │ │ ├── google.go │ │ ├── sso.go │ │ └── stack.tm.hcl ├── commands.go ├── completions │ ├── _test_mock.tf │ ├── completions.go │ └── stack.tm.hcl ├── debug │ └── show │ │ ├── generate_origins │ │ ├── _test_mock.tf │ │ ├── generate_origins.go │ │ └── stack.tm.hcl │ │ ├── globals │ │ ├── _test_mock.tf │ │ ├── globals.go │ │ └── stack.tm.hcl │ │ ├── metadata │ │ ├── _test_mock.tf │ │ ├── metadata.go │ │ └── stack.tm.hcl │ │ └── runtime_env │ │ ├── _test_mock.tf │ │ ├── runtime_env.go │ │ └── stack.tm.hcl ├── doc.go ├── experimental │ ├── eval │ │ ├── _test_mock.tf │ │ ├── eval.go │ │ ├── get_config_value.go │ │ ├── partial.go │ │ └── stack.tm.hcl │ ├── rungraph │ │ ├── _test_mock.tf │ │ ├── rungraph.go │ │ └── stack.tm.hcl │ └── vendordownload │ │ ├── _test_mock.tf │ │ ├── stack.tm.hcl │ │ └── vendordownload.go ├── fmt │ ├── _test_mock.tf │ ├── fmt.go │ └── stack.tm.hcl ├── generate │ ├── _test_mock.tf │ ├── generate.go │ └── stack.tm.hcl ├── requiredversion │ ├── _test_mock.tf │ ├── requiredversion.go │ └── stack.tm.hcl ├── run │ ├── _test_mock.tf │ ├── cloud.go │ ├── git.go │ ├── outdatedcode.go │ ├── run.go │ └── stack.tm.hcl ├── script │ ├── _test_mock.tf │ ├── info │ │ ├── _test_mock.tf │ │ ├── info.go │ │ └── stack.tm.hcl │ ├── list │ │ ├── _test_mock.tf │ │ ├── list.go │ │ └── stack.tm.hcl │ ├── run │ │ ├── _test_mock.tf │ │ ├── run.go │ │ └── stack.tm.hcl │ ├── script.go │ ├── stack.tm.hcl │ └── tree │ │ ├── _test_mock.tf │ │ ├── stack.tm.hcl │ │ └── tree.go ├── stack.tm.hcl ├── stack │ ├── create │ │ ├── _test_mock.tf │ │ ├── create.go │ │ └── stack.tm.hcl │ └── list │ │ ├── _test_mock.tf │ │ ├── list.go │ │ └── stack.tm.hcl ├── trigger │ ├── _test_mock.tf │ ├── filter.go │ ├── stack.go │ └── stack.tm.hcl └── version │ ├── _test_mock.tf │ ├── stack.tm.hcl │ └── version.go ├── config ├── _test_mock.tf ├── assert.go ├── assert_test.go ├── config.go ├── config_test.go ├── doc.go ├── eval.go ├── filter │ ├── _test_mock.tf │ ├── filter.go │ ├── filter_test.go │ └── stack.tm.hcl ├── script.go ├── script_lets_test.go ├── script_test.go ├── sharing_backend.go ├── sharing_backend_test.go ├── stack.go ├── stack.tm.hcl └── tag │ ├── _test_mock.tf │ ├── stack.tm.hcl │ └── tag.go ├── constants.go ├── containers └── test │ └── Dockerfile ├── doc.go ├── e2etests ├── cloud │ ├── _test_mock.tf │ ├── cloud_helpers_test.go │ ├── cloud_status_test.go │ ├── exp_trigger_cloud_test.go │ ├── generate-e2e-testserver.tm │ ├── interop │ │ ├── interoperability_test.go │ │ ├── main_test.go │ │ └── testdata │ │ │ ├── event_pull_request.json │ │ │ └── interop-stacks │ │ │ ├── basic-drift-uppercase-id │ │ │ ├── main.tf │ │ │ └── stack.tm.hcl │ │ │ ├── basic-drift │ │ │ ├── main.tf │ │ │ └── stack.tm.hcl │ │ │ ├── empty-uppercase-id │ │ │ └── stack.tm.hcl │ │ │ └── empty │ │ │ └── stack.tm.hcl │ ├── loglevel_test.go │ ├── main_test.go │ ├── run_cloud_config_test.go │ ├── run_cloud_deployment_test.go │ ├── run_cloud_drift_test.go │ ├── run_cloud_signal_test.go │ ├── run_cloud_sync_preview_test.go │ ├── run_cloud_uimode_test.go │ ├── run_script_cloud_deployment_test.go │ ├── run_script_cloud_drift_test.go │ ├── run_script_cloud_preview_test.go │ ├── stack.tm.hcl │ └── testdata │ │ ├── cloud-sync-drift-plan-file │ │ ├── main.tf │ │ └── sanitized.plan.json │ │ ├── cloud.data.json │ │ └── github │ │ ├── get_commit_response.json │ │ └── get_pull_request_response.json ├── cmd │ └── helper │ │ ├── _test_mock.tf │ │ ├── main.go │ │ ├── stack.tm.hcl │ │ └── terragrunt.go ├── core │ ├── _test_mock.tf │ ├── change_detection_test.go │ ├── cli_args_env_test.go │ ├── cli_args_test.go │ ├── create_all_terraform_test.go │ ├── create_all_terragrunt_test.go │ ├── create_test.go │ ├── debug_show_generate_test.go │ ├── debug_show_globals_test.go │ ├── debug_show_metadata_test.go │ ├── disable_loglevel_test.go │ ├── exp_clone_test.go │ ├── exp_eval_test.go │ ├── exp_run_graph_test.go │ ├── exp_trigger_test.go │ ├── exp_vendor_test.go │ ├── fmt_test.go │ ├── general_test.go │ ├── generate_test.go │ ├── imports_test.go │ ├── list_git_test.go │ ├── list_nongit_test.go │ ├── list_run_order_test.go │ ├── list_test.go │ ├── list_watch_test.go │ ├── logging_test.go │ ├── main_test.go │ ├── run_env_test.go │ ├── run_eval_test.go │ ├── run_parallel_test.go │ ├── run_sharing_test.go │ ├── run_signal_test.go │ ├── run_test.go │ ├── run_unix_test.go │ ├── safeguard_test.go │ ├── script_info_test.go │ ├── script_list_test.go │ ├── script_run_test.go │ ├── stack.tm.hcl │ └── version_check_test.go └── internal │ └── runner │ ├── _test_mock.tf │ ├── builders.go │ ├── doc.go │ ├── installers.go │ ├── runner.go │ ├── runner_signal_fixture.go │ ├── runner_unix.go │ ├── runner_windows.go │ ├── setup.go │ └── stack.tm.hcl ├── engine ├── _test_mock.tf ├── cloud.go ├── engine.go ├── project.go ├── run.go ├── stack.tm.hcl └── vendor.go ├── errors ├── _test_mock.tf ├── detailed.go ├── detailed_test.go ├── errlog │ ├── _test_mock.tf │ ├── errlog.go │ └── stack.tm.hcl ├── error.go ├── error_test.go ├── list.go ├── list_test.go ├── stack.tm.hcl └── verbosity │ ├── _test_mock.tf │ ├── stack.tm.hcl │ └── verbosity.go ├── event ├── _test_mock.tf ├── event.go ├── event_test.go └── stack.tm.hcl ├── exit ├── _test_mock.tf ├── stack.tm.hcl └── status.go ├── fs ├── _test_mock.tf ├── copy.go ├── copy_test.go ├── doc.go ├── fs.go ├── fs_bench_test.go ├── fs_test.go └── stack.tm.hcl ├── generate ├── _test_mock.tf ├── assert_test.go ├── doc.go ├── generate.go ├── generate_bench_test.go ├── generate_hcl_test.go ├── generate_list_test.go ├── generate_root_file_test.go ├── generate_sharing_test.go ├── generate_stack_file_test.go ├── generate_test.go ├── genfile │ ├── _test_mock.tf │ ├── assert_test.go │ ├── genfile.go │ ├── genfile_lets_map_test.go │ ├── genfile_test.go │ ├── range_test.go │ └── stack.tm.hcl ├── genhcl │ ├── _test_mock.tf │ ├── assert_test.go │ ├── dynamic_test.go │ ├── genhcl.go │ ├── genhcl_lets_map_test.go │ ├── genhcl_test.go │ ├── partial_eval_test.go │ ├── range_test.go │ └── stack.tm.hcl ├── hcl_expr_func_test.go ├── load_test.go ├── outdated_detection_test.go ├── report │ ├── _test_mock.tf │ ├── report.go │ ├── report_test.go │ └── stack.tm.hcl ├── sharing │ ├── _test_mock.tf │ ├── sharing_backend.go │ └── stack.tm.hcl ├── stack.tm.hcl └── vendor_test.go ├── generate_mkconfig.tm ├── generate_preview.tm ├── git ├── _test_mock.tf ├── doc.go ├── git.go ├── git_test.go ├── options.go ├── stack.tm.hcl ├── url.go └── url_test.go ├── globals.tm ├── globals ├── _test_mock.tf ├── doc.go ├── eval_report.go ├── globals.go ├── globals_map_test.go ├── globals_test.go ├── stack.go └── stack.tm.hcl ├── go.mod ├── go.sum ├── golangci.tm ├── hack ├── check-stacks.sh ├── create-stacks.sh ├── mod-check ├── packages.sh └── release │ └── Dockerfile ├── hcl ├── _test_mock.tf ├── ast │ ├── _test_mock.tf │ ├── attribute.go │ ├── block.go │ ├── doc.go │ ├── expr.go │ ├── expr_clone.go │ ├── expression_bench_test.go │ ├── expression_fuzz_test.go │ ├── expression_test.go │ ├── merged_block.go │ ├── stack.tm.hcl │ ├── testdata │ │ └── fuzz │ │ │ └── FuzzTokensForExpression │ │ │ ├── 010578835b50a79309fe70085f46efcd59284f210ad194823ffefba424058b0d │ │ │ ├── 12a3fe542db50e192063f08fd4e4207a5443ec3521aa9f3612a13a9cba5c9e32 │ │ │ ├── 1fcf672895a6aaf1a9198808b0646dcef752ce7dfc8a4cf619ff4ea06c1a2d54 │ │ │ ├── 5e120b34ce5796e88cb4494d53518c38b57423a01419e0aec54d165e375c5657 │ │ │ ├── 7cf036dc71594d4cba7f183714f8df0d19ffc2067322ca91c7f86ebabe91278e │ │ │ ├── 9fef42767833b9fdb00dd49fc23e98e6d8b8cd3317ca141cdb824ab22a83b7b0 │ │ │ ├── a8be8b6f51e88c73d9f86d93a521a60f165fb0f719f74250dd217358f1f2a723 │ │ │ ├── c5577449902c7edf06fb16fee8b89f9be441f4eceec211229977f7bdccade886 │ │ │ ├── d4e108ec8fee06e52f6873dd1c1d0b5aee38d813f16284573bfd04bfc19513e2 │ │ │ └── dca90936cda3d1bc030018a2b545f93134f5f9be179aab8cea59925b4d8de982 │ └── value.go ├── block_assert_parser.go ├── block_generate_file_parser.go ├── block_generate_hcl_parser.go ├── block_globals_parser.go ├── block_input_parser.go ├── block_output_parser.go ├── block_script_parser.go ├── block_sharing_backend_parser.go ├── block_stack_parser.go ├── block_terramate_parser.go ├── block_vendor_parser.go ├── default_merged_labels_parser_handlers.go ├── default_merged_parser_handlers.go ├── default_unique_parser_handlers.go ├── default_unmerged_parser_handlers.go ├── doc.go ├── eval │ ├── _test_mock.tf │ ├── doc.go │ ├── eval.go │ ├── eval_test.go │ ├── eval_unix_test.go │ ├── eval_windows_test.go │ ├── object.go │ ├── object_test.go │ ├── partial_eval.go │ ├── partial_eval_bench_test.go │ ├── partial_eval_test.go │ ├── partial_fuzz_test.go │ ├── stack.tm.hcl │ └── testdata │ │ └── fuzz │ │ └── FuzzPartialEval │ │ ├── 01de7839a265cdedc41688453bd566fdb7a784e3c6a0260238929babe4de0302 │ │ ├── 02c59bc3f77fdf54917f481e7c63b3d26fda5193d1a5234523271a16885a60c4 │ │ ├── 02f2acb4a8480066727cb0dd0a26d61cacd2715f64c86365e8ef57946b3d6db1 │ │ ├── 051295172fc7e0c375a1d90b85494d2edff3db45ad2a2623b22ea79cdd50104a │ │ ├── 08263e5fb6a0cdaaf6c96afecdc401b0e570b1a125766be7b390b979c71479b2 │ │ ├── 12852db0cb9a3196aac5b6aa905c22c9145c5fcb34d60baa23166d35bd3da752 │ │ ├── 14d273f38dd63e2aab39c4c27cf374a080ee5f91b871355802e5120a65cc388f │ │ ├── 161e01b482687e0930627a1a2f15d3d934d9d5c5a15833ce75813f951f537244 │ │ ├── 1b13b660ee2301b86c7a478c5f35abc2ae4181c05d25f6d150312f4c667679f4 │ │ ├── 1b875b548b4fc6239308e2b7cb36fdb41589d9c81cbb8f14dae17c283f917584 │ │ ├── 21087e7998911f681f9fa6596056b6a989f667b740eae59074d23db4643d7a2a │ │ ├── 250522a540ed87d52892c6e2e9c8f1d31615809de7029b17b21aa0ff98880795 │ │ ├── 259fcccf3465bab0cfae6afaec8d65545f6f3f4eb9dfeec0f4539b6e58d1c11e │ │ ├── 27488d0a2a7122553f8ccbb00cbfe958dd21104e43ff2afdceacb5cfd22ba3b6 │ │ ├── 27686927c7dc0f8c0ff73b62d86fc5694f47a584961548219da9b6c94d3795d7 │ │ ├── 2ce9b4ebf5bb89d805de856854c28fff610304a0b103791c57fc6fe01feca38d │ │ ├── 2dfd1644de95558d7425cf7ccf34d0a05ed68a7176f5cff1cdd1005561582ddb │ │ ├── 2fafa4c82fbf8b7c71d785b7098919d1e2f73e7e236d9599bf08abdc294fef0b │ │ ├── 3471291e39bff1e88f5e49a623b524e45c016658431237fa6eedfb9e21bbec4c │ │ ├── 373b91ace300794a0f36f4e2569d1673fea0a77c43bbd49eb6c780af070c60e4 │ │ ├── 3ad43f72e75dbcf0ed9b0e3ea0851bbf3e40d830b0a04ab2ff143b5b5e87d787 │ │ ├── 411bc38234cbedc868def78340b8b0a116b78d69b31cd8222c309dc80ce8b802 │ │ ├── 44ce3eb7799d791289f3ada1f8efccfd6de6680459caf8b65726629db6cee518 │ │ ├── 58ab79ba15f14a8026f92fa0b015ec7e6cd79c3bdaa83be19b6a249b176cd094 │ │ ├── 5a94c7dbdff6650d02e9192dce3edd12d1806f97f179f4aaf79807d3b161f7aa │ │ ├── 5d4cfa69ef70b79348455abb388eb336cb5b5b436631ab160e44bae7d5cb2565 │ │ ├── 5d91efac5dbf3f033af2de9695a55daa7b99b588bca77a809526b9e9ebe49c6c │ │ ├── 5ec4d4d7565f91b659549d9ba481fb7b651a24419a7a29fad31040dc4ef43908 │ │ ├── 6333fbe0857777c7a858b18528e5a6640b2ff5bf1d8b2d680281996845551dd0 │ │ ├── 6ee4e742723e5c20ec5a9c856d93410cf14cb3fbe54a599c73e28c8b0d335b82 │ │ ├── 7025521623a4a662c3b973db8a8e68aded034570f1a777bf671c2d2eba89781e │ │ ├── 8584c99035a75fceeba6ee9bf7d526a2b5f4f8a05227c706c9e41b008a97fe8e │ │ ├── 85a518a4f8e2a5fe09d702b5fd98ac14ff8500c8bb7427e3c57d527774883602 │ │ ├── 9331b4097d6a4ed39356b17afcb0a5f8e01359f1425707d950f6a653fc59cd75 │ │ ├── 93cbb0905135e8197e3886fff96488ff203b7d8864f240a4c770731ea3c49b82 │ │ ├── 94c8f22dea083f8c72e23cecdf51cd065c84976d84d38f9b0e7d7a97f1152332 │ │ ├── 95eb0979a9f372be57c55b99ffe699ddd6dd6a4ddc6e2e373717c6c547084188 │ │ ├── a1424f5183d4bfb5f43c936f672ed6ba25fc9cc9382c04073a06190828334c99 │ │ ├── a3ff88fc332fa7995655066ad0823ebdeab4791bd759c569c4160d1ca1dcf97a │ │ ├── a71c9c7a611b0f4ed435ad38608bd5daf951f003a44d7219cdefe064e79cb546 │ │ ├── a9a51251fd0e42eb9f03a4e5e59db84e69131deb17a5275b23bf78341f915527 │ │ ├── abd518431b8ab731b7e2ecfaea09fb25f8c7a9c246fb57ea1ec47a9cdfb7c685 │ │ ├── adfadc9a0835ffb53cc906ea281dd91486510688b43dd47713057ad7bde208cb │ │ ├── af0977e984bd55c8e48f13af6ecf722b73b8eec6259e44dfd1d85d46fde46526 │ │ ├── b116e89887aa9e3f5b846b8e943d40fb59bce0415d4277639e307b3c4d680c4b │ │ ├── b8e7b37e86a6bc6d692ad2fd6cd0b3ebb1a94305dfe7ce5b0488de4a27caa6de │ │ ├── ba6edc08e0d40d285f5a74474f6fb94563365b4d88dbf1be18d54cdc40545d69 │ │ ├── c832672669ea3aa88a312b9521927abb062921923c382b96072120ece09bfd88 │ │ ├── cb0065cb8b038e7901d0a48e766c28156c2665f67023ac2e7d72ad7adb35b417 │ │ ├── cb70dbc367f763f274137ac8f7577b67ebbee60d63476d4926fa141a24d79eb9 │ │ ├── cbe8142af83846f8115da94dad768d5b1b7a0693de7a9171a6983afd6c1ea289 │ │ ├── d2eeeb93a3870300e91cb65a28c2bb11fd8411a7229d877ae95cf31eff9302e9 │ │ ├── d850794f83b5d526a143774d6b1ad13bf2a977eb54bfa2476cde9e2aa188711d │ │ ├── de40bb3543f566ed458f6279839aec6538c52adc1371bc3be2bb2d2a669d66df │ │ ├── dfd06bbbba504bb8aa49b5ea028115d1cd07b5ad1cf872509f125286c214829c │ │ ├── e2310bcada3b30d3f888b840c48fb3155570aaae42236506c576f8a6390c012d │ │ ├── e39a09eed20cb1705e0ce3c5a70c7e40793a744452ee3c552b5e04cbbde095ba │ │ ├── e3adebbdcfffce18e6b0856cbcde644a4b2437d88563611edab4052eb271d50b │ │ ├── e712387d8cce6a47bbd0e232d7adf8a359a1f0ef9fe47dbc4bb76df4622f1f48 │ │ ├── e91d62292a45ed966b6e30aba6aeeaeb6d00e1ee496e5639bc250c06b8e42211 │ │ ├── ec6dd781b44ca8bf7d12059640c37558e1606302cef4e90b49c837d538ba9c04 │ │ └── f27fa2cd3f65cea1caf13686a7d913e56e6fab9c6deba33b9d8696c35d540718 ├── fmt │ ├── _test_mock.tf │ ├── fmt.go │ ├── fmt_fuzz_test.go │ ├── fmt_test.go │ ├── formatter.go │ ├── formatter_test.go │ └── stack.tm.hcl ├── generate_test.go ├── hcl.go ├── hcl_assert_test.go ├── hcl_cfg_run_test.go ├── hcl_import_test.go ├── hcl_options.go ├── hcl_script_test.go ├── hcl_stack_test.go ├── hcl_test.go ├── hcl_vendor_test.go ├── info │ ├── _test_mock.tf │ ├── doc.go │ ├── range.go │ ├── range_test.go │ └── stack.tm.hcl ├── printer.go ├── raw_config.go ├── sharing_backend.go ├── sharing_backend_test.go ├── stack.tm.hcl └── testdata │ └── fuzz │ └── FuzzFormatMultiline │ ├── 03e108ccb2adca4afc9d6ccafc885ff00e2b281215f1ad995b0dfb4ba6dabf77 │ ├── 1968484d4c23b26974561db7524f1d8562293b53ca9d767ce179e627c041b777 │ ├── 3012dfcb01972a1f3a5101be3df9ba9e54ff7c58493aaa5b14546068511c63ae │ ├── 57786df2fa66eddc5a9f77c1d3ec3d08194d2780a9b01894738f611abe939a36 │ ├── 6c08602dd987861b76591e0c5181b101ea1a76ed55ac573f885973722758a505 │ ├── 76d21ab7a1739feca98d5cf0a43090286669c47538bbe2379b1467fd44993190 │ ├── 7f89f2cf1a2eb758cba76dca15e2265a507383e9ad270371ffa66582ffee4407 │ ├── 87c917a6fb6807a9ae20fea1da8b2a88c71f78353ed57d5d365cc10b096d76a1 │ ├── 8a3f7a02b84109cee96011556e5185d2ae11c627066e8f719e69d6bfd23b576a │ ├── 94d618c9ccb5beac5954f686324b7f23e05fd8122baa8d78245e487d0fbbaa78 │ ├── 9e8326443fdb02f7b334e7af4811c7a57b5cba251f5b017808bc2ed97e8ecc33 │ ├── b2ccdcc012eec170761e719bb8b221f1582ac39c3bc85a95a1ec08d6aab7543d │ ├── b648d6815bd68a4850bcbb278f4e2a83e0c8d0be2cb1fa9c0c78cfc39c5bb37c │ ├── c88bc237a0f4c470aa4a604d9a7b1cf29dd227548e5dd121b590e970213cbcdc │ ├── cf78b653d8c21607ba1ed07a81819634127c7bdb1a678c39dde2414d9a52b42d │ ├── e577e66149de2ebd33d2f99426df19ef1621a47797f69ac8e38a027b461f3f1f │ ├── eb1e096e56bdc2efd7fe0a3dbe6d76b398a3e8423cc3653ebcd84b7efffb30a6 │ ├── eec8d9318ce8e086269fef2cb20ff7b64abc6f00ca7986ba2dbf40be483ffb22 │ └── ff558e0adb4a52c6d5dfe62491c9c265eebd19681c9990d76de3712c565ceb66 ├── http ├── _test_mock.tf ├── http.go └── stack.tm.hcl ├── lets ├── _test_mock.tf ├── lets.go └── stack.tm.hcl ├── loglevel_test.go ├── ls ├── _test_mock.tf ├── commands.go ├── commands_test.go ├── ls.go ├── ls_test.go └── stack.tm.hcl ├── makefiles ├── _mkconfig.mk ├── common.mk ├── unix.mk └── windows.mk ├── mapexpr ├── _test_mock.tf ├── doc.go ├── map.go ├── stack.tm.hcl └── test │ ├── _test_mock.tf │ ├── stack.tm.hcl │ └── testcases.go ├── modvendor ├── _test_mock.tf ├── download │ ├── _test_mock.tf │ ├── download.go │ ├── download_test.go │ ├── event.go │ ├── event_test.go │ ├── manifest_test.go │ ├── report.go │ ├── report_test.go │ └── stack.tm.hcl ├── manifest │ ├── _test_mock.tf │ ├── manifest.go │ └── stack.tm.hcl ├── modvendor.go ├── modvendor_common.go ├── modvendor_windows.go └── stack.tm.hcl ├── printer ├── _test_mock.tf ├── doc.go ├── printer.go ├── printer_test.go └── stack.tm.hcl ├── project ├── _test_mock.tf ├── doc.go ├── project.go ├── project_test.go └── stack.tm.hcl ├── run ├── _test_mock.tf ├── dag │ ├── _test_mock.tf │ ├── dag.go │ ├── dag_test.go │ └── stack.tm.hcl ├── doc.go ├── env.go ├── env_test.go ├── lookpath_unix.go ├── lookpath_windows.go ├── oncemap.go ├── oncemap_test.go ├── order.go ├── order_test.go └── stack.tm.hcl ├── safeguard ├── _test_mock.tf ├── doc.go ├── safeguard.go └── stack.tm.hcl ├── scheduler ├── _test_mock.tf ├── doc.go ├── parallel.go ├── resource │ ├── _test_mock.tf │ ├── bounded.go │ ├── doc.go │ ├── resource.go │ ├── stack.tm.hcl │ └── throttled.go ├── scheduler.go ├── scheduler_test.go ├── sequential.go └── stack.tm.hcl ├── scripts.tm ├── stack.tm.hcl ├── stack ├── _test_mock.tf ├── clone.go ├── clone_test.go ├── create.go ├── create_test.go ├── doc.go ├── eval.go ├── load_test.go ├── loglevel_test.go ├── manager.go ├── manager_test.go ├── stack.go ├── stack.tm.hcl ├── stack_test.go └── trigger │ ├── _test_mock.tf │ ├── stack.tm.hcl │ ├── trigger.go │ └── trigger_test.go ├── stdlib ├── _test_mock.tf ├── doc.go ├── funcs.go ├── funcs_bench_test.go ├── funcs_test.go ├── hcl.go ├── hcl_test.go ├── stack.tm.hcl ├── ternary.go ├── toml.go ├── toml_test.go ├── try.go └── try_test.go ├── strconv ├── _test_mock.tf ├── doc.go ├── format.go └── stack.tm.hcl ├── terramate.tm ├── terramate_platform_overview_dark.png ├── terramate_platform_overview_light.png ├── test ├── _test_mock.tf ├── assert.go ├── cloud │ ├── _test_mock.tf │ ├── client.go │ ├── doc.go │ └── stack.tm.hcl ├── config.go ├── doc.go ├── errors │ ├── _test_mock.tf │ ├── errors.go │ └── stack.tm.hcl ├── exec.go ├── fs.go ├── fs_js.go ├── fs_unix.go ├── fs_windows.go ├── git.go ├── git_test.go ├── hcl.go ├── hclutils │ ├── _test_mock.tf │ ├── info │ │ ├── _test_mock.tf │ │ ├── info.go │ │ └── stack.tm.hcl │ ├── stack.tm.hcl │ └── utils.go ├── hclwrite │ ├── _test_mock.tf │ ├── hclutils │ │ ├── _test_mock.tf │ │ ├── doc.go │ │ ├── stack.tm.hcl │ │ └── utils.go │ ├── hclwrite.go │ ├── hclwrite_test.go │ └── stack.tm.hcl ├── ls │ ├── _test_mock.tf │ ├── doc.go │ ├── editor.go │ ├── fixture.go │ └── stack.tm.hcl ├── os.go ├── sandbox │ ├── _test_mock.tf │ ├── git.go │ ├── git_test.go │ ├── sandbox.go │ ├── sandbox_test.go │ └── stack.tm.hcl ├── stack.go ├── stack.tm.hcl └── tf.go ├── testdata ├── example-stack │ └── stack.tm.hcl └── testserver │ ├── cloud.data.json │ ├── generate-testserver-data.tm │ ├── stack.tm.hcl │ ├── test-cloud-apikeys.tm │ ├── test-cloud-orgs.tm │ ├── test-cloud-stacks.tm │ └── test-cloud-users.tm ├── tf ├── _test_mock.tf ├── doc.go ├── mod_source_parse.go ├── mod_source_parse_test.go ├── stack.tm.hcl ├── terraform.go └── terraform_test.go ├── tg ├── _test_mock.tf ├── doc.go ├── funcs.go ├── logging_level_test.go ├── stack.tm.hcl ├── tg_config_scanner.go ├── tg_library_sanity_test.go ├── tg_module.go ├── tg_module_bench_test.go └── tg_module_test.go ├── ui └── tui │ ├── _test_mock.tf │ ├── checkpoint_localhost.go │ ├── checkpoint_mineiros.go │ ├── cli.go │ ├── cli_default_help_printer.go │ ├── cli_guesswidth.go │ ├── cli_guesswidth_unix.go │ ├── cli_handler.go │ ├── cli_help.txt │ ├── cli_noprofiling.go │ ├── cli_options.go │ ├── cli_profiling.go │ ├── cli_spec.go │ ├── cli_unix.go │ ├── cli_windows.go │ ├── cliauth │ ├── _test_mock.tf │ ├── cli_cloud.go │ ├── cloud_credential.go │ ├── cloud_credential_apikey.go │ ├── cloud_credential_github.go │ ├── cloud_credential_github_oidc.go │ ├── cloud_credential_gitlab_oidc.go │ ├── cloud_credential_google.go │ ├── cloud_credential_sso.go │ ├── credential.go │ ├── doc.go │ ├── oidc_audience_default.go │ ├── oidc_audience_terramate.go │ └── stack.tm.hcl │ ├── cliconfig │ ├── _test_mock.tf │ ├── cliconfig.go │ ├── cliconfig_test.go │ ├── cliconfig_unix.go │ ├── cliconfig_windows.go │ ├── doc.go │ └── stack.tm.hcl │ ├── clitest │ ├── _test_mock.tf │ ├── doc.go │ ├── messages.go │ └── stack.tm.hcl │ ├── doc.go │ ├── out │ ├── _test_mock.tf │ ├── out.go │ ├── out_test.go │ └── stack.tm.hcl │ ├── stack.tm.hcl │ └── telemetry │ ├── _test_mock.tf │ ├── doc.go │ ├── endpoint.go │ ├── endpoint_localhost.go │ ├── record.go │ ├── record_test.go │ ├── stack.tm.hcl │ ├── telemetry.go │ └── telemetry_test.go ├── version.go └── versions ├── _test_mock.tf ├── doc.go ├── stack.tm.hcl ├── versions.go └── versions_test.go /.gitattributes: -------------------------------------------------------------------------------- 1 | *.tm linguist-language=HCL 2 | * text=auto 3 | _*.tf text eol=lf 4 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @terramate-io/cli-tooling 2 | /cloud @terramate-io/cli-tooling @terramate-io/tmc-backend 3 | /docs 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | 15 | Steps to reproduce the behavior: 16 | 1. Given context '...' 17 | 2. Run command '....' 18 | 3. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Log Output** 24 | Add logs from Terramate to help debug your problem. 25 | 26 | **Environment (please complete the following information):** 27 | - OS: [e.g. Linux] 28 | - OS Version [e.g. Ubuntu 20.04] 29 | - Git Version [e.g. 2.35.1] (git --version) 30 | - Terramate Version [e.g. 0.1.0] (terramate --version) 31 | 32 | **Additional context** 33 | Add any other context about the problem here. 34 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FEATURE]" 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | bin/* 2 | coverage.txt 3 | .terraform 4 | .terraform.lock.hcl 5 | /cmd/terramate/terramate 6 | /testdata/testserver/my-user.tm 7 | 8 | # Profiling artifacts 9 | cpu.prof 10 | mem.prof 11 | *.test 12 | *.tfplan 13 | *.plan 14 | 15 | # Go Workspaces artifacts 16 | /go.work 17 | 18 | # VSCode artifacts 19 | .vscode/ 20 | 21 | # Go releaser artifacts 22 | dist/ 23 | 24 | # MacOS 25 | .DS_Store 26 | cosign.pub 27 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Terramate GmbH 2 | # SPDX-License-Identifier: MPL-2.0 3 | 4 | image: "golang:1.21" 5 | 6 | ci: 7 | stage: test 8 | script: 9 | - apt-get update && apt-get install -y unzip 10 | - curl --proto '=https' --tlsv1.2 -fsSL https://get.opentofu.org/install-opentofu.sh -o install-opentofu.sh 11 | - chmod +x install-opentofu.sh 12 | - ./install-opentofu.sh --install-method standalone && rm install-opentofu.sh 13 | - tofu version 14 | - go test -v -count=1 -tags gitlabci ./cmd/terramate/cli/gitlab/... 15 | - make test 16 | -------------------------------------------------------------------------------- /.golangci.toml: -------------------------------------------------------------------------------- 1 | [issues] 2 | exclude-use-default = false 3 | 4 | [[issues.exclude-rules]] 5 | linters = ['revive'] 6 | path = '(.+)_test\.go' 7 | text = 'dot-imports:' 8 | 9 | [linters] 10 | enable = ['revive', 'misspell', 'gofmt', 'bodyclose'] 11 | 12 | [run] 13 | timeout = '15m' 14 | -------------------------------------------------------------------------------- /.tmtriggers/cloud/changed-a9fe0083-ed01-4ee7-b407-b367413071d1.tm.hcl: -------------------------------------------------------------------------------- 1 | trigger { 2 | ctime = 1743164969 3 | reason = "Created using Terramate CLI without setting specific reason." 4 | type = changed 5 | context = stack 6 | } 7 | -------------------------------------------------------------------------------- /.tmtriggers/e2etests/core/changed-e1311e1d-8a43-4224-9209-a2c59fa727b3.tm.hcl: -------------------------------------------------------------------------------- 1 | trigger { 2 | ctime = 1743119640 3 | reason = "Created using Terramate CLI without setting specific reason." 4 | type = changed 5 | context = stack 6 | } 7 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: default 2 | default: help 3 | 4 | ifeq ($(OS),Windows_NT) 5 | -include makefiles/windows.mk 6 | else 7 | -include makefiles/unix.mk 8 | endif 9 | 10 | -include makefiles/common.mk 11 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 0.13.2 2 | -------------------------------------------------------------------------------- /_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "terramate" { 4 | content = <<-EOT 5 | package terramate // import "github.com/terramate-io/terramate" 6 | 7 | Package terramate provides functions for managing terraform stacks. A stack is a 8 | unit of independent runnable terraform modules. 9 | 10 | func Version() string 11 | EOT 12 | 13 | filename = "${path.module}/mock-terramate.ignore" 14 | } 15 | -------------------------------------------------------------------------------- /benchmarks/changed/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "changed" { 4 | content = <<-EOT 5 | package changed // import "github.com/terramate-io/terramate/benchmarks/changed" 6 | 7 | Package changed contains benchmarks to the change detection system. 8 | EOT 9 | 10 | filename = "${path.module}/mock-changed.ignore" 11 | } 12 | -------------------------------------------------------------------------------- /benchmarks/changed/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package changed contains benchmarks to the change detection system. 5 | package changed 6 | -------------------------------------------------------------------------------- /benchmarks/changed/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package changed // import \"github.com/terramate-io/terramate/benchmarks/changed\"" 6 | description = "package changed // import \"github.com/terramate-io/terramate/benchmarks/changed\"\n\nPackage changed contains benchmarks to the change detection system." 7 | tags = ["benchmarks", "changed", "golang"] 8 | id = "68c9593d-aabe-4d20-9b4c-8dbc9c5d2417" 9 | } 10 | -------------------------------------------------------------------------------- /bin/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/terramate-io/terramate/e89f1f44d6637ff39c04ab9c199e8a2919dc933c/bin/.gitkeep -------------------------------------------------------------------------------- /ci/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "ci" { 4 | content = <<-EOT 5 | package ci // import "github.com/terramate-io/terramate/ci" 6 | 7 | type PlatformType int 8 | const PlatformLocal PlatformType = iota ... 9 | func DetectPlatformFromEnv(repo *git.Repository) PlatformType 10 | EOT 11 | 12 | filename = "${path.module}/mock-ci.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /ci/ci_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package ci_test 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/madlambda/spells/assert" 10 | "github.com/terramate-io/terramate/ci" 11 | ) 12 | 13 | func TestDetectPlatformFromEnv(t *testing.T) { 14 | tests := map[string]ci.PlatformType{ 15 | "GITHUB_ACTIONS": ci.PlatformGithub, 16 | "GITLAB_CI": ci.PlatformGitlab, 17 | "BITBUCKET_BUILD_NUMBER": ci.PlatformBitBucket, 18 | "TF_BUILD": ci.PlatformAzureDevops, 19 | "CI": ci.PlatformGenericCI, 20 | } 21 | 22 | for k, want := range tests { 23 | t.Run(k, func(t *testing.T) { 24 | for k2 := range tests { 25 | if k == k2 { 26 | t.Setenv(k, "1") 27 | } else { 28 | t.Setenv(k2, "") 29 | } 30 | } 31 | platform := ci.DetectPlatformFromEnv() 32 | assert.EqualInts(t, int(want), int(platform)) 33 | }) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ci/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package ci provides helper functions to detect the CI/CD platform. 5 | package ci 6 | -------------------------------------------------------------------------------- /ci/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package ci // import \"github.com/terramate-io/terramate/ci\"" 6 | description = "package ci // import \"github.com/terramate-io/terramate/ci\"\n\ntype PlatformType int\n const PlatformLocal PlatformType = iota ...\n func DetectPlatformFromEnv(repo *git.Repository) PlatformType" 7 | tags = ["ci", "golang"] 8 | id = "d359d542-f3be-4114-af77-24d51721011d" 9 | } 10 | -------------------------------------------------------------------------------- /cloud/api/deployment/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "deployment" { 4 | content = <<-EOT 5 | package deployment // import "github.com/terramate-io/terramate/cloud/deployment" 6 | 7 | Package deployment provides types and helpers for cloud deployments. 8 | 9 | const ErrInvalidStatus errors.Kind = "invalid deployment status" ... 10 | type FilterStatus Status 11 | const UnhealthyFilter FilterStatus = FilterStatus(^OK) ... 12 | func NewStatusFilter(str string) (FilterStatus, error) 13 | type Status uint8 14 | const OK Status = 1 << iota ... 15 | func NewStatus(str string) Status 16 | EOT 17 | 18 | filename = "${path.module}/mock-deployment.ignore" 19 | } 20 | -------------------------------------------------------------------------------- /cloud/api/deployment/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package deployment // import \"github.com/terramate-io/terramate/cloud/deployment\"" 6 | description = "package deployment // import \"github.com/terramate-io/terramate/cloud/deployment\"\n\nPackage deployment provides types and helpers for cloud deployments.\n\nconst ErrInvalidStatus errors.Kind = \"invalid deployment status\" ...\ntype FilterStatus Status\n const UnhealthyFilter FilterStatus = FilterStatus(^OK) ...\n func NewStatusFilter(str string) (FilterStatus, error)\ntype Status uint8\n const OK Status = 1 << iota ...\n func NewStatus(str string) Status" 7 | tags = ["cloud", "deployment", "golang"] 8 | id = "fcad074d-7f0e-491d-a72a-02939b4bb9be" 9 | } 10 | -------------------------------------------------------------------------------- /cloud/api/drift/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "drift" { 4 | content = <<-EOT 5 | package drift // import "github.com/terramate-io/terramate/cloud/drift" 6 | 7 | Package drift provides types and helpers for cloud drifts. 8 | 9 | const ErrInvalidStatus errors.Kind = "invalid drift status" ... 10 | type FilterStatus Status 11 | const UnhealthyFilter FilterStatus = FilterStatus(^OK) ... 12 | func NewStatusFilter(str string) (FilterStatus, error) 13 | type Status uint8 14 | const OK Status = 1 << iota ... 15 | func NewStatus(str string) Status 16 | EOT 17 | 18 | filename = "${path.module}/mock-drift.ignore" 19 | } 20 | -------------------------------------------------------------------------------- /cloud/api/drift/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package drift // import \"github.com/terramate-io/terramate/cloud/drift\"" 6 | description = "package drift // import \"github.com/terramate-io/terramate/cloud/drift\"\n\nPackage drift provides types and helpers for cloud drifts.\n\nconst ErrInvalidStatus errors.Kind = \"invalid drift status\" ...\ntype FilterStatus Status\n const UnhealthyFilter FilterStatus = FilterStatus(^OK) ...\n func NewStatusFilter(str string) (FilterStatus, error)\ntype Status uint8\n const OK Status = 1 << iota ...\n func NewStatus(str string) Status" 7 | tags = ["cloud", "drift", "golang"] 8 | id = "e4f72263-bee0-4dee-82d2-28ad9dd8516f" 9 | } 10 | -------------------------------------------------------------------------------- /cloud/api/metadata/testdata/gitlab_mr_participants.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": 1, 4 | "username": "bob", 5 | "name": "Bob", 6 | "state": "active", 7 | "locked": false, 8 | "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/1/avatar.png", 9 | "web_url": "https://gitlab.com/bob" 10 | } 11 | ] -------------------------------------------------------------------------------- /cloud/api/metadata/testdata/gitlab_mr_reviewers.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "user": { 4 | "id": 1, 5 | "username": "bob", 6 | "name": "Bob", 7 | "state": "active", 8 | "locked": false, 9 | "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/1/avatar.png", 10 | "web_url": "https://gitlab.com/bob" 11 | }, 12 | "state": "reviewed", 13 | "created_at": "2025-02-06T13:14:36.626Z" 14 | } 15 | ] -------------------------------------------------------------------------------- /cloud/api/preview/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "preview" { 4 | content = <<-EOT 5 | package preview // import "github.com/terramate-io/terramate/cloud/preview" 6 | 7 | Package preview contains functionality for the preview feature in Terramate 8 | Cloud. 9 | 10 | const ErrInvalidStackStatus = errors.Kind("invalid stack status") 11 | type Layer string 12 | type StackStatus string 13 | const StackStatusAffected StackStatus = "affected" ... 14 | func DerivePreviewStatus(exitCode int) StackStatus 15 | EOT 16 | 17 | filename = "${path.module}/mock-preview.ignore" 18 | } 19 | -------------------------------------------------------------------------------- /cloud/api/preview/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package preview contains functionality for the preview feature in Terramate 5 | // Cloud. 6 | package preview 7 | -------------------------------------------------------------------------------- /cloud/api/preview/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package preview // import \"github.com/terramate-io/terramate/cloud/preview\"" 6 | description = "package preview // import \"github.com/terramate-io/terramate/cloud/preview\"\n\nPackage preview contains functionality for the preview feature in Terramate\nCloud.\n\nconst ErrInvalidStackStatus = errors.Kind(\"invalid stack status\")\ntype Layer string\ntype StackStatus string\n const StackStatusAffected StackStatus = \"affected\" ...\n func DerivePreviewStatus(exitCode int) StackStatus" 7 | tags = ["cloud", "golang", "preview"] 8 | id = "de7aef4e-bf44-440b-833e-aebc5e8d2606" 9 | } 10 | -------------------------------------------------------------------------------- /cloud/api/stack/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "stack" { 4 | content = <<-EOT 5 | package stack // import "github.com/terramate-io/terramate/cloud/stack" 6 | 7 | Package stack provides types and helpers for cloud stacks. 8 | 9 | const ErrInvalidStatus errors.Kind = "invalid stack status" ... 10 | const AnyTarget = "" 11 | type FilterStatus Status 12 | const UnhealthyFilter FilterStatus = FilterStatus(Drifted | Failed) ... 13 | func NewStatusFilter(str string) (FilterStatus, error) 14 | type Status uint8 15 | const OK Status = 1 << iota ... 16 | func NewStatus(str string) Status 17 | EOT 18 | 19 | filename = "${path.module}/mock-stack.ignore" 20 | } 21 | -------------------------------------------------------------------------------- /cloud/api/stack/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package stack // import \"github.com/terramate-io/terramate/cloud/stack\"" 6 | description = "package stack // import \"github.com/terramate-io/terramate/cloud/stack\"\n\nPackage stack provides types and helpers for cloud stacks.\n\nconst ErrInvalidStatus errors.Kind = \"invalid stack status\" ...\nconst AnyTarget = \"\"\ntype FilterStatus Status\n const UnhealthyFilter FilterStatus = FilterStatus(Drifted | Failed) ...\n func NewStatusFilter(str string) (FilterStatus, error)\ntype Status uint8\n const OK Status = 1 << iota ...\n func NewStatus(str string) Status" 7 | tags = ["cloud", "golang", "stack"] 8 | id = "6f8698d5-9e2b-47ea-b795-9a98b868fbe6" 9 | } 10 | -------------------------------------------------------------------------------- /cloud/api/status/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "status" { 4 | content = <<-EOT 5 | package status // import "github.com/terramate-io/terramate/cloud/api/status" 6 | 7 | func ParseFilters(stackStatus, deploymentStatus, driftStatus string) (resources.StatusFilters, error) 8 | EOT 9 | 10 | filename = "${path.module}/mock-status.ignore" 11 | } 12 | -------------------------------------------------------------------------------- /cloud/api/status/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package status // import \"github.com/terramate-io/terramate/cloud/api/status\"" 6 | description = "package status // import \"github.com/terramate-io/terramate/cloud/api/status\"\n\nfunc ParseFilters(stackStatus, deploymentStatus, driftStatus string) (resources.StatusFilters, error)" 7 | tags = ["api", "cloud", "golang", "status"] 8 | id = "b2be660f-b75c-4ea7-b208-61b17e7c58af" 9 | } 10 | -------------------------------------------------------------------------------- /cloud/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package cloud implements the SDK for communicating with the Terramate Cloud. 5 | package cloud 6 | -------------------------------------------------------------------------------- /cloud/integrations/bitbucket/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "bitbucket" { 4 | content = <<-EOT 5 | package bitbucket // import "github.com/terramate-io/terramate/cmd/terramate/cli/bitbucket" 6 | 7 | Package bitbucket implements the client for Bitbucket Cloud. 8 | 9 | type Actor struct{ ... } 10 | type Branch struct{ ... } 11 | type Client struct{ ... } 12 | type Commit struct{ ... } 13 | type PR struct{ ... } 14 | type PRs []PR 15 | type PullRequestResponse struct{ ... } 16 | type Rendered struct{ ... } 17 | type RenderedContent struct{ ... } 18 | type Summary RenderedContent 19 | type TargetBranch struct{ ... } 20 | EOT 21 | 22 | filename = "${path.module}/mock-bitbucket.ignore" 23 | } 24 | -------------------------------------------------------------------------------- /cloud/integrations/bitbucket/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package bitbucket implements the client for Bitbucket Cloud. 5 | package bitbucket 6 | -------------------------------------------------------------------------------- /cloud/integrations/bitbucket/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package bitbucket // import \"github.com/terramate-io/terramate/cmd/terramate/cli/bitbucket\"" 6 | description = "package bitbucket // import \"github.com/terramate-io/terramate/cmd/terramate/cli/bitbucket\"\n\nPackage bitbucket implements the client for Bitbucket Cloud.\n\ntype Actor struct{ ... }\ntype Branch struct{ ... }\ntype Client struct{ ... }\ntype Commit struct{ ... }\ntype PR struct{ ... }\ntype PRs []PR\ntype PullRequestResponse struct{ ... }\ntype Rendered struct{ ... }\ntype RenderedContent struct{ ... }\ntype Summary RenderedContent\ntype TargetBranch struct{ ... }" 7 | tags = ["bitbucket", "cli", "cmd", "golang", "terramate"] 8 | id = "a71a1a4f-bfff-4ffa-9bce-afa604969904" 9 | } 10 | -------------------------------------------------------------------------------- /cloud/integrations/github/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "github" { 4 | content = <<-EOT 5 | package github // import "github.com/terramate-io/terramate/cmd/terramate/cli/github" 6 | 7 | Package github implements a client SDK for the Github API. 8 | 9 | const ErrNotFound errors.Kind = "resource not found (HTTP Status: 404)" ... 10 | const Domain = "github.com" ... 11 | const ErrGithubEventPathEnvNotSet errors.Kind = `environment variable "GITHUB_EVENT_PATH" not set` ... 12 | func GetEventPR() (*github.PullRequest, error) 13 | func OIDCToken(ctx context.Context, cfg OIDCVars) (token string, err error) 14 | type OAuthDeviceFlowContext struct{ ... } 15 | func OAuthDeviceFlowAuthStart(clientID string) (oauthCtx OAuthDeviceFlowContext, err error) 16 | type OIDCVars struct{ ... } 17 | EOT 18 | 19 | filename = "${path.module}/mock-github.ignore" 20 | } 21 | -------------------------------------------------------------------------------- /cloud/integrations/gitlab/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "gitlab" { 4 | content = <<-EOT 5 | package gitlab // import "github.com/terramate-io/terramate/cmd/terramate/cli/gitlab" 6 | 7 | Package gitlab provides a SDK and helpers for the gitlab provider. 8 | 9 | const ErrNotFound errors.Kind = "resource not found (HTTP Status: 404)" 10 | type Client struct{ ... } 11 | type MR struct{ ... } 12 | type MRs []MR 13 | type User struct{ ... } 14 | EOT 15 | 16 | filename = "${path.module}/mock-gitlab.ignore" 17 | } 18 | -------------------------------------------------------------------------------- /cloud/integrations/gitlab/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package gitlab provides a SDK and helpers for the gitlab provider. 5 | package gitlab 6 | -------------------------------------------------------------------------------- /cloud/integrations/gitlab/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package gitlab // import \"github.com/terramate-io/terramate/cmd/terramate/cli/gitlab\"" 6 | description = "package gitlab // import \"github.com/terramate-io/terramate/cmd/terramate/cli/gitlab\"\n\nPackage gitlab provides a SDK and helpers for the gitlab provider.\n\nconst ErrNotFound errors.Kind = \"resource not found (HTTP Status: 404)\"\ntype Client struct{ ... }\ntype MR struct{ ... }\ntype MRs []MR\ntype User struct{ ... }" 7 | tags = ["cli", "cmd", "gitlab", "golang", "terramate"] 8 | id = "7d36b8af-2c53-4945-93cc-94511e0aefb5" 9 | } 10 | -------------------------------------------------------------------------------- /cloud/testserver/apikey.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package testserver 5 | 6 | import ( 7 | "net/http" 8 | "strings" 9 | 10 | "github.com/terramate-io/terramate/errors" 11 | ) 12 | 13 | func apikeyFromRequest(r *http.Request) (key string, found bool, err error) { 14 | authorization := r.Header.Get("Authorization") 15 | if authorization == "" { 16 | return "", false, nil 17 | } 18 | 19 | if !strings.HasPrefix(authorization, "Basic ") { 20 | return "", false, nil 21 | } 22 | 23 | key, notExpectedPass, ok := r.BasicAuth() 24 | if !ok { 25 | return "", true, errors.E("invalid basic auth") 26 | } 27 | if notExpectedPass != "" { 28 | return "", true, errors.E("API key must not have a password set") 29 | } 30 | return key, true, nil 31 | } 32 | -------------------------------------------------------------------------------- /cloud/testserver/cloudstore/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "cloudstore" { 4 | content = <<-EOT 5 | package cloudstore // import "github.com/terramate-io/terramate/cloud/testserver/cloudstore" 6 | 7 | Package cloudstore provides the in-memory store used by the fake Terramate Cloud 8 | server. 9 | 10 | const ErrAlreadyExists errors.Kind = "record already exists" ... 11 | type Data struct{ ... } 12 | func LoadDatastore(fpath string) (*Data, error) 13 | type Deployment struct{ ... } 14 | type DeploymentState struct{ ... } 15 | type Drift struct{ ... } 16 | type Member struct{ ... } 17 | type Org struct{ ... } 18 | type Preview struct{ ... } 19 | type Stack struct{ ... } 20 | type StackPreview struct{ ... } 21 | type StackState struct{ ... } 22 | func NewState() StackState 23 | EOT 24 | 25 | filename = "${path.module}/mock-cloudstore.ignore" 26 | } 27 | -------------------------------------------------------------------------------- /cloud/testserver/cloudstore/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package cloudstore provides the in-memory store used by the fake 5 | // Terramate Cloud server. 6 | package cloudstore 7 | -------------------------------------------------------------------------------- /cloud/testserver/cloudstore/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package cloudstore // import \"github.com/terramate-io/terramate/cloud/testserver/cloudstore\"" 6 | description = "package cloudstore // import \"github.com/terramate-io/terramate/cloud/testserver/cloudstore\"\n\nPackage cloudstore provides the in-memory store used by the fake Terramate Cloud\nserver.\n\nconst ErrAlreadyExists errors.Kind = \"record already exists\" ...\ntype Data struct{ ... }\n func LoadDatastore(fpath string) (*Data, error)\ntype Deployment struct{ ... }\ntype DeploymentState struct{ ... }\ntype Drift struct{ ... }\ntype Member struct{ ... }\ntype Org struct{ ... }\ntype Preview struct{ ... }\ntype Stack struct{ ... }\ntype StackPreview struct{ ... }\ntype StackState struct{ ... }\n func NewState() StackState" 7 | tags = ["cloud", "cloudstore", "golang", "testserver"] 8 | id = "87319590-2a04-4eea-a900-23edab55f7a9" 9 | } 10 | -------------------------------------------------------------------------------- /cloud/testserver/cmd/testserver/README.md: -------------------------------------------------------------------------------- 1 | # fakecloud 2 | 3 | A simple fake for the Terramate Cloud. 4 | 5 | ## Build 6 | 7 | ```sh 8 | $ make test/build 9 | ``` 10 | 11 | ## Run 12 | 13 | ```sh 14 | $ ./bin/fakecloud 15 | ``` 16 | -------------------------------------------------------------------------------- /cloud/testserver/cmd/testserver/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "testserver" { 4 | content = <<-EOT 5 | Package main implements the cloudmock service. 6 | EOT 7 | 8 | filename = "${path.module}/mock-testserver.ignore" 9 | } 10 | -------------------------------------------------------------------------------- /cloud/testserver/cmd/testserver/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package main implements the cloudmock service. 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "net/http" 10 | "os" 11 | 12 | "github.com/terramate-io/terramate/cloud/testserver" 13 | "github.com/terramate-io/terramate/cloud/testserver/cloudstore" 14 | ) 15 | 16 | func main() { 17 | datafile := "testdata/testserver/cloud.data.json" 18 | if len(os.Args) == 2 { 19 | datafile = os.Args[1] 20 | } 21 | store, _, err := cloudstore.LoadDatastore(datafile) 22 | if err != nil { 23 | panic(err) 24 | } 25 | s := &http.Server{ 26 | Addr: "0.0.0.0:3001", 27 | Handler: testserver.Router(store), 28 | } 29 | 30 | fmt.Printf("listening at %s\n", s.Addr) 31 | err = s.ListenAndServe() 32 | if err != nil { 33 | panic(err) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /cloud/testserver/cmd/testserver/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "Package main implements the cloudmock service." 6 | description = "Package main implements the cloudmock service." 7 | tags = ["cloud", "cmd", "golang", "testserver"] 8 | id = "69b6f99c-a383-4b62-abf9-463a4feee711" 9 | } 10 | -------------------------------------------------------------------------------- /cloud/testserver/helpers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package testserver 5 | 6 | import ( 7 | "encoding/json" 8 | "io" 9 | "log" 10 | ) 11 | 12 | func write(w io.Writer, data []byte) { 13 | _, err := w.Write(data) 14 | if err != nil { 15 | panic(err) 16 | } 17 | } 18 | 19 | func writeErr(w io.Writer, err error) { 20 | write(w, []byte(err.Error())) 21 | } 22 | 23 | func writeString(w io.Writer, str string) { 24 | write(w, []byte(str)) 25 | } 26 | 27 | func justClose(c io.Closer) { 28 | if err := c.Close(); err != nil { 29 | log.Printf("error: %v", err) 30 | } 31 | } 32 | 33 | func marshalWrite(w io.Writer, obj interface{}) { 34 | data, err := json.Marshal(obj) 35 | if err != nil { 36 | panic(err) 37 | } 38 | write(w, data) 39 | } 40 | -------------------------------------------------------------------------------- /cloud/testserver/well-known.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package testserver 5 | 6 | import ( 7 | "net/http" 8 | 9 | "github.com/julienschmidt/httprouter" 10 | "github.com/terramate-io/terramate/cloud/testserver/cloudstore" 11 | ) 12 | 13 | // GetWellKnown implements the /.well-known/cli.json endpoint. 14 | func GetWellKnown(store *cloudstore.Data, w http.ResponseWriter, _ *http.Request, _ httprouter.Params) { 15 | wk := store.GetWellKnown() 16 | if wk == nil { 17 | w.WriteHeader(http.StatusNotFound) 18 | return 19 | } 20 | w.Header().Set("Content-Type", "application/json") 21 | marshalWrite(w, wk) 22 | } 23 | -------------------------------------------------------------------------------- /cloudsync/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package cloudsync provides helper functions for cloud sync operations. 5 | package cloudsync 6 | -------------------------------------------------------------------------------- /cmd/terramate-ls/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "terramate-ls" { 4 | content = <<-EOT 5 | Terramate-ls is a language server. For details on how to use it just run: 6 | 7 | terramate-ls --help 8 | EOT 9 | 10 | filename = "${path.module}/mock-terramate-ls.ignore" 11 | } 12 | -------------------------------------------------------------------------------- /cmd/terramate-ls/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "Terramate-ls is a language server. For details on how to use it just run:" 6 | description = "Terramate-ls is a language server. For details on how to use it just run:\n\n terramate-ls --help" 7 | tags = ["cmd", "golang", "terramate-ls"] 8 | id = "5c7b673d-a46a-4bda-abf7-b56b7c43225d" 9 | } 10 | -------------------------------------------------------------------------------- /cmd/terramate/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "terramate" { 4 | content = <<-EOT 5 | Terramate is a tool for managing multiple Terraform stacks. Providing stack 6 | execution orchestration and code generation as a way to share data across 7 | different stacks. For details on how to use it just run: 8 | 9 | terramate --help 10 | EOT 11 | 12 | filename = "${path.module}/mock-terramate.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /cmd/terramate/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Terramate is a tool for managing multiple Terraform stacks. Providing stack 5 | // execution orchestration and code generation as a way to share data across 6 | // different stacks. 7 | // For details on how to use it just run: 8 | // 9 | // terramate --help 10 | package main 11 | 12 | import ( 13 | "os" 14 | 15 | "github.com/terramate-io/terramate/errors" 16 | "github.com/terramate-io/terramate/ui/tui" 17 | ) 18 | 19 | func main() { 20 | cli, err := tui.NewCLI() 21 | if err != nil { 22 | panic(errors.E(errors.ErrInternal, "unexpected error")) 23 | } 24 | 25 | cli.Exec(os.Args[1:]) 26 | } 27 | -------------------------------------------------------------------------------- /cmd/terramate/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "Terramate is a tool for managing multiple Terraform stacks. Providing stack" 6 | description = "Terramate is a tool for managing multiple Terraform stacks. Providing stack\nexecution orchestration and code generation as a way to share data across\ndifferent stacks. For details on how to use it just run:\n\n terramate --help" 7 | tags = ["cmd", "golang", "terramate"] 8 | id = "19baeccd-97fd-4f79-8e11-755ecb0d865e" 9 | } 10 | -------------------------------------------------------------------------------- /cmd/tgdeps/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "tgdeps" { 4 | content = <<-EOT 5 | Package main implements tgdeps. 6 | EOT 7 | 8 | filename = "${path.module}/mock-tgdeps.ignore" 9 | } 10 | -------------------------------------------------------------------------------- /cmd/tgdeps/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "Package main implements tgdeps." 6 | description = "Package main implements tgdeps." 7 | tags = ["cmd", "golang", "tgdeps"] 8 | id = "15091224-c282-43d9-bbd1-10a90c0957d5" 9 | } 10 | -------------------------------------------------------------------------------- /commands/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "commands" { 4 | content = <<-EOT 5 | package commands // import "github.com/terramate-io/terramate/commands" 6 | 7 | Package commands define all Terramate commands. All commands must: - Be defined 8 | in its own package (eg.: ./commands/generate) - Define a `.Spec` type 9 | declaring all variables that control the command behavior. - Implement the 10 | commands.Executor interface. - Never abort, panic or exit the process. 11 | 12 | type Executor interface{ ... } 13 | EOT 14 | 15 | filename = "${path.module}/mock-commands.ignore" 16 | } 17 | -------------------------------------------------------------------------------- /commands/clone/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "clone" { 4 | content = <<-EOT 5 | package clone // import "github.com/terramate-io/terramate/commands/clone" 6 | 7 | Package clone provides the clone command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-clone.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/clone/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package clone // import \"github.com/terramate-io/terramate/commands/clone\"" 6 | description = "package clone // import \"github.com/terramate-io/terramate/commands/clone\"\n\nPackage clone provides the clone command.\n\ntype Spec struct{ ... }" 7 | tags = ["clone", "commands", "golang"] 8 | id = "ad05c19d-65d6-48a7-8377-e531195ddd9a" 9 | } 10 | -------------------------------------------------------------------------------- /commands/cloud/drift/show/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "show" { 4 | content = <<-EOT 5 | package show // import "github.com/terramate-io/terramate/commands/cloud/drift/show" 6 | 7 | Package show provides the cloud drift show command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-show.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/cloud/drift/show/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package show // import \"github.com/terramate-io/terramate/commands/cloud/drift/show\"" 6 | description = "package show // import \"github.com/terramate-io/terramate/commands/cloud/drift/show\"\n\nPackage show provides the cloud drift show command.\n\ntype Spec struct{ ... }" 7 | tags = ["cloud", "commands", "drift", "golang", "show"] 8 | id = "f06c15f1-9a5e-4ec7-b884-e34e406cd47a" 9 | } 10 | -------------------------------------------------------------------------------- /commands/cloud/info/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "info" { 4 | content = <<-EOT 5 | package info // import "github.com/terramate-io/terramate/commands/cloud/info" 6 | 7 | Package info provides the cloud info command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-info.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/cloud/info/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package info // import \"github.com/terramate-io/terramate/commands/cloud/info\"" 6 | description = "package info // import \"github.com/terramate-io/terramate/commands/cloud/info\"\n\nPackage info provides the cloud info command.\n\ntype Spec struct{ ... }" 7 | tags = ["cloud", "commands", "golang", "info"] 8 | id = "a91233bd-01a7-47ee-86ce-66223ea4830f" 9 | } 10 | -------------------------------------------------------------------------------- /commands/cloud/login/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "login" { 4 | content = <<-EOT 5 | package login // import "github.com/terramate-io/terramate/commands/cloud/login" 6 | 7 | Package login provides login commands. 8 | 9 | type GithubSpec struct{ ... } 10 | type GoogleSpec struct{ ... } 11 | type SSOSpec struct{ ... } 12 | EOT 13 | 14 | filename = "${path.module}/mock-login.ignore" 15 | } 16 | -------------------------------------------------------------------------------- /commands/cloud/login/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package login provides login commands. 5 | package login 6 | -------------------------------------------------------------------------------- /commands/cloud/login/google.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package login 5 | 6 | import ( 7 | "context" 8 | 9 | "github.com/terramate-io/terramate/printer" 10 | "github.com/terramate-io/terramate/ui/tui/cliauth" 11 | "github.com/terramate-io/terramate/ui/tui/cliconfig" 12 | ) 13 | 14 | // GoogleSpec is the command specification for the google login command. 15 | type GoogleSpec struct { 16 | Printers printer.Printers 17 | CliCfg cliconfig.Config 18 | Verbosity int 19 | } 20 | 21 | // Name returns the name of the command. 22 | func (s *GoogleSpec) Name() string { return "google login" } 23 | 24 | // Exec executes the google login command. 25 | func (s *GoogleSpec) Exec(_ context.Context) error { 26 | err := cliauth.GoogleLogin(s.Printers, s.Verbosity, s.CliCfg) 27 | if err == nil { 28 | s.Printers.Stdout.Println("authenticated successfully") 29 | } 30 | return err 31 | } 32 | -------------------------------------------------------------------------------- /commands/cloud/login/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package login // import \"github.com/terramate-io/terramate/commands/cloud/login\"" 6 | description = "package login // import \"github.com/terramate-io/terramate/commands/cloud/login\"\n\nPackage login provides login commands.\n\ntype GithubSpec struct{ ... }\ntype GoogleSpec struct{ ... }\ntype SSOSpec struct{ ... }" 7 | tags = ["cloud", "commands", "golang", "login"] 8 | id = "c29cc1c0-87ca-4b97-b5bb-bc3d764a21cd" 9 | } 10 | -------------------------------------------------------------------------------- /commands/commands.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package commands 5 | 6 | import "context" 7 | 8 | // Executor is an interface for commands. 9 | type Executor interface { 10 | // Name of the comamnd. 11 | Name() string 12 | // Exec executes the command. 13 | Exec(ctx context.Context) error 14 | } 15 | -------------------------------------------------------------------------------- /commands/completions/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "completions" { 4 | content = <<-EOT 5 | package completions // import "github.com/terramate-io/terramate/commands/completions" 6 | 7 | Package completions provides the install-completions command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-completions.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/completions/completions.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package completions provides the install-completions command. 5 | package completions 6 | 7 | import ( 8 | "context" 9 | 10 | "github.com/alecthomas/kong" 11 | "github.com/terramate-io/terramate/errors" 12 | "github.com/willabides/kongplete" 13 | ) 14 | 15 | // Spec is the command specification for the install-completions command. 16 | type Spec struct { 17 | Installer kongplete.InstallCompletions 18 | KongCtx *kong.Context 19 | } 20 | 21 | // Name returns the name of the command. 22 | func (s *Spec) Name() string { return "install-completions" } 23 | 24 | // Exec executes the install-completions command. 25 | func (s *Spec) Exec(_ context.Context) error { 26 | err := s.Installer.Run(s.KongCtx) 27 | if err != nil { 28 | return errors.E(err, "installing shell completions") 29 | } 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /commands/completions/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package completions // import \"github.com/terramate-io/terramate/commands/completions\"" 6 | description = "package completions // import \"github.com/terramate-io/terramate/commands/completions\"\n\nPackage completions provides the install-completions command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "completions", "golang"] 8 | id = "8c04c6e3-0f03-4385-86bf-030f219f4d1c" 9 | } 10 | -------------------------------------------------------------------------------- /commands/debug/show/generate_origins/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "generate_origins" { 4 | content = <<-EOT 5 | package generateorigins // import "github.com/terramate-io/terramate/commands/debug/show/generate_origins" 6 | 7 | Package generateorigins provides the generate-origins command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-generate_origins.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/debug/show/generate_origins/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package generateorigins // import \"github.com/terramate-io/terramate/commands/debug/show/generate_origins\"" 6 | description = "package generateorigins // import \"github.com/terramate-io/terramate/commands/debug/show/generate_origins\"\n\nPackage generateorigins provides the generate-origins command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "debug", "generate_origins", "golang", "show"] 8 | id = "0a3dda80-bb24-4a12-b27d-32fc32c90611" 9 | } 10 | -------------------------------------------------------------------------------- /commands/debug/show/globals/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "globals" { 4 | content = <<-EOT 5 | package globals // import "github.com/terramate-io/terramate/commands/debug/show/globals" 6 | 7 | Package globals provides the debug globals command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-globals.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/debug/show/globals/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package globals // import \"github.com/terramate-io/terramate/commands/debug/show/globals\"" 6 | description = "package globals // import \"github.com/terramate-io/terramate/commands/debug/show/globals\"\n\nPackage globals provides the debug globals command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "debug", "globals", "golang", "show"] 8 | id = "17c40830-6d4d-482f-87e3-7905b1da1a89" 9 | } 10 | -------------------------------------------------------------------------------- /commands/debug/show/metadata/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "metadata" { 4 | content = <<-EOT 5 | package metadata // import "github.com/terramate-io/terramate/commands/debug/show/metadata" 6 | 7 | Package metadata provides the show-metadata command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-metadata.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/debug/show/metadata/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package metadata // import \"github.com/terramate-io/terramate/commands/debug/show/metadata\"" 6 | description = "package metadata // import \"github.com/terramate-io/terramate/commands/debug/show/metadata\"\n\nPackage metadata provides the show-metadata command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "debug", "golang", "metadata", "show"] 8 | id = "46cda58a-d00c-4810-9271-546e9e50ba25" 9 | } 10 | -------------------------------------------------------------------------------- /commands/debug/show/runtime_env/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "runtime_env" { 4 | content = <<-EOT 5 | package runtimeenv // import "github.com/terramate-io/terramate/commands/debug/show/runtime_env" 6 | 7 | Package runtimeenv provides the show-runtime-env command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-runtime_env.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/debug/show/runtime_env/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package runtimeenv // import \"github.com/terramate-io/terramate/commands/debug/show/runtime_env\"" 6 | description = "package runtimeenv // import \"github.com/terramate-io/terramate/commands/debug/show/runtime_env\"\n\nPackage runtimeenv provides the show-runtime-env command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "debug", "golang", "runtime_env", "show"] 8 | id = "b1974a92-fe89-4928-8ede-c14c24da3a2d" 9 | } 10 | -------------------------------------------------------------------------------- /commands/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package commands define all Terramate commands. 5 | // All commands must: 6 | // - Be defined in its own package (eg.: ./commands/generate) 7 | // - Define a `.Spec` type declaring all variables that control the command behavior. 8 | // - Implement the [commands.Executor] interface. 9 | // - Never abort, panic or exit the process. 10 | package commands 11 | -------------------------------------------------------------------------------- /commands/experimental/eval/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "eval" { 4 | content = <<-EOT 5 | package eval // import "github.com/terramate-io/terramate/commands/experimental/eval" 6 | 7 | Package eval provides the "experimental eval" and "experimental partial-eval" 8 | commands. 9 | 10 | type GetConfigValueSpec struct{ ... } 11 | type PartialSpec struct{ ... } 12 | type Spec struct{ ... } 13 | EOT 14 | 15 | filename = "${path.module}/mock-eval.ignore" 16 | } 17 | -------------------------------------------------------------------------------- /commands/experimental/eval/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package eval // import \"github.com/terramate-io/terramate/commands/experimental/eval\"" 6 | description = "package eval // import \"github.com/terramate-io/terramate/commands/experimental/eval\"\n\nPackage eval provides the \"experimental eval\" and \"experimental partial-eval\"\ncommands.\n\ntype GetConfigValueSpec struct{ ... }\ntype PartialSpec struct{ ... }\ntype Spec struct{ ... }" 7 | tags = ["commands", "eval", "experimental", "golang"] 8 | id = "fd4f6180-578d-4124-8f6f-019e800c597f" 9 | } 10 | -------------------------------------------------------------------------------- /commands/experimental/rungraph/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "rungraph" { 4 | content = <<-EOT 5 | package rungraph // import "github.com/terramate-io/terramate/commands/experimental/rungraph" 6 | 7 | Package rungraph provides the run-graph command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-rungraph.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/experimental/rungraph/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package rungraph // import \"github.com/terramate-io/terramate/commands/experimental/rungraph\"" 6 | description = "package rungraph // import \"github.com/terramate-io/terramate/commands/experimental/rungraph\"\n\nPackage rungraph provides the run-graph command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "experimental", "golang", "rungraph"] 8 | id = "dd09e3b5-c9ff-4b51-8b88-5fe217ddd786" 9 | } 10 | -------------------------------------------------------------------------------- /commands/experimental/vendordownload/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "vendordownload" { 4 | content = <<-EOT 5 | package vendordownload // import "github.com/terramate-io/terramate/commands/experimental/vendordownload" 6 | 7 | Package vendordownload provides the vendor download command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-vendordownload.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/experimental/vendordownload/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package vendordownload // import \"github.com/terramate-io/terramate/commands/experimental/vendordownload\"" 6 | description = "package vendordownload // import \"github.com/terramate-io/terramate/commands/experimental/vendordownload\"\n\nPackage vendordownload provides the vendor download command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "experimental", "golang", "vendordownload"] 8 | id = "909f50ee-528b-4da1-a16a-d0e585dace8f" 9 | } 10 | -------------------------------------------------------------------------------- /commands/fmt/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "fmt" { 4 | content = <<-EOT 5 | package fmt // import "github.com/terramate-io/terramate/commands/fmt" 6 | 7 | Package fmt provides the fmt command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-fmt.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/fmt/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package fmt // import \"github.com/terramate-io/terramate/commands/fmt\"" 6 | description = "package fmt // import \"github.com/terramate-io/terramate/commands/fmt\"\n\nPackage fmt provides the fmt command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "fmt", "golang"] 8 | id = "31858e29-a904-47df-9942-dac85d1016e8" 9 | } 10 | -------------------------------------------------------------------------------- /commands/generate/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "generate" { 4 | content = <<-EOT 5 | package generate // import "github.com/terramate-io/terramate/commands/generate" 6 | 7 | Package generate provides the generate command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-generate.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/generate/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package generate // import \"github.com/terramate-io/terramate/commands/generate\"" 6 | description = "package generate // import \"github.com/terramate-io/terramate/commands/generate\"\n\nPackage generate provides the generate command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "generate", "golang"] 8 | id = "21b69f74-3c73-4b94-bbd2-f9113cb8bc65" 9 | } 10 | -------------------------------------------------------------------------------- /commands/requiredversion/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "requiredversion" { 4 | content = <<-EOT 5 | package requiredversion // import "github.com/terramate-io/terramate/commands/requiredversion" 6 | 7 | Package requiredversion provides the required-version command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-requiredversion.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/requiredversion/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package requiredversion // import \"github.com/terramate-io/terramate/commands/requiredversion\"" 6 | description = "package requiredversion // import \"github.com/terramate-io/terramate/commands/requiredversion\"\n\nPackage requiredversion provides the required-version command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "golang", "requiredversion"] 8 | id = "b4d21d9d-b63e-431a-ac23-51a50e073216" 9 | } 10 | -------------------------------------------------------------------------------- /commands/script/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "script" { 4 | content = <<-EOT 5 | package script // import "github.com/terramate-io/terramate/commands/script" 6 | 7 | Package script provides the script command. 8 | 9 | type InfoEntry struct{ ... } 10 | type Matcher struct{ ... } 11 | func NewMatcher(labels []string) *Matcher 12 | EOT 13 | 14 | filename = "${path.module}/mock-script.ignore" 15 | } 16 | -------------------------------------------------------------------------------- /commands/script/info/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "info" { 4 | content = <<-EOT 5 | package info // import "github.com/terramate-io/terramate/commands/script/info" 6 | 7 | Package info provides the "script info" command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-info.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/script/info/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package info // import \"github.com/terramate-io/terramate/commands/script/info\"" 6 | description = "package info // import \"github.com/terramate-io/terramate/commands/script/info\"\n\nPackage info provides the \"script info\" command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "golang", "info", "script"] 8 | id = "0cc77f17-af45-42cc-b7da-fc6c1673413f" 9 | } 10 | -------------------------------------------------------------------------------- /commands/script/list/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "list" { 4 | content = <<-EOT 5 | package list // import "github.com/terramate-io/terramate/commands/script/list" 6 | 7 | Package list provides the script list command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-list.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/script/list/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package list // import \"github.com/terramate-io/terramate/commands/script/list\"" 6 | description = "package list // import \"github.com/terramate-io/terramate/commands/script/list\"\n\nPackage list provides the script list command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "golang", "list", "script"] 8 | id = "d05490a8-06db-466d-869c-ab01ed92aa5a" 9 | } 10 | -------------------------------------------------------------------------------- /commands/script/run/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "run" { 4 | content = <<-EOT 5 | package run // import "github.com/terramate-io/terramate/commands/script/run" 6 | 7 | Package run provides the script run command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-run.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/script/run/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package run // import \"github.com/terramate-io/terramate/commands/script/run\"" 6 | description = "package run // import \"github.com/terramate-io/terramate/commands/script/run\"\n\nPackage run provides the script run command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "golang", "run", "script"] 8 | id = "9ffa624d-0edb-4631-814f-77ee3712c33f" 9 | } 10 | -------------------------------------------------------------------------------- /commands/script/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package script // import \"github.com/terramate-io/terramate/commands/script\"" 6 | description = "package script // import \"github.com/terramate-io/terramate/commands/script\"\n\nPackage script provides the script command.\n\ntype InfoEntry struct{ ... }\ntype Matcher struct{ ... }\n func NewMatcher(labels []string) *Matcher" 7 | tags = ["commands", "golang", "script"] 8 | id = "2ab2c3fa-35e3-4be6-a487-11fc032a67fa" 9 | } 10 | -------------------------------------------------------------------------------- /commands/script/tree/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "tree" { 4 | content = <<-EOT 5 | package tree // import "github.com/terramate-io/terramate/commands/script/tree" 6 | 7 | Package tree provides the script tree command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-tree.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/script/tree/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package tree // import \"github.com/terramate-io/terramate/commands/script/tree\"" 6 | description = "package tree // import \"github.com/terramate-io/terramate/commands/script/tree\"\n\nPackage tree provides the script tree command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "golang", "script", "tree"] 8 | id = "0dd14379-6567-48de-b57e-aa8742fe7389" 9 | } 10 | -------------------------------------------------------------------------------- /commands/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package commands // import \"github.com/terramate-io/terramate/commands\"" 6 | description = "package commands // import \"github.com/terramate-io/terramate/commands\"\n\nPackage commands define all Terramate commands. All commands must: - Be defined\nin its own package (eg.: ./commands/generate) - Define a `.Spec` type\ndeclaring all variables that control the command behavior. - Implement the\ncommands.Executor interface. - Never abort, panic or exit the process.\n\ntype Executor interface{ ... }" 7 | tags = ["commands", "golang"] 8 | id = "cefaf477-a56f-40f8-b708-975b0b3a3fcf" 9 | } 10 | -------------------------------------------------------------------------------- /commands/stack/create/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "create" { 4 | content = <<-EOT 5 | package create // import "github.com/terramate-io/terramate/commands/stack/create" 6 | 7 | Package create provides the create stack command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-create.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/stack/create/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package create // import \"github.com/terramate-io/terramate/commands/stack/create\"" 6 | description = "package create // import \"github.com/terramate-io/terramate/commands/stack/create\"\n\nPackage create provides the create stack command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "create", "golang", "stack"] 8 | id = "91e493c2-2989-4608-a451-4e339dd444dc" 9 | } 10 | -------------------------------------------------------------------------------- /commands/stack/list/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "list" { 4 | content = <<-EOT 5 | package list // import "github.com/terramate-io/terramate/commands/stack/list" 6 | 7 | Package list provides the list command. 8 | 9 | type Spec struct{ ... } 10 | type StatusFilters struct{ ... } 11 | EOT 12 | 13 | filename = "${path.module}/mock-list.ignore" 14 | } 15 | -------------------------------------------------------------------------------- /commands/stack/list/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package list // import \"github.com/terramate-io/terramate/commands/stack/list\"" 6 | description = "package list // import \"github.com/terramate-io/terramate/commands/stack/list\"\n\nPackage list provides the list command.\n\ntype Spec struct{ ... }\ntype StatusFilters struct{ ... }" 7 | tags = ["commands", "golang", "list", "stack"] 8 | id = "1fe9000d-f4ce-4aa3-ad10-81ee5268efbb" 9 | } 10 | -------------------------------------------------------------------------------- /commands/trigger/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "trigger" { 4 | content = <<-EOT 5 | package trigger // import "github.com/terramate-io/terramate/commands/trigger" 6 | 7 | Package trigger provides the trigger command. 8 | 9 | type FilterSpec struct{ ... } 10 | type PathSpec struct{ ... } 11 | type StatusFilters struct{ ... } 12 | EOT 13 | 14 | filename = "${path.module}/mock-trigger.ignore" 15 | } 16 | -------------------------------------------------------------------------------- /commands/trigger/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package trigger // import \"github.com/terramate-io/terramate/commands/trigger\"" 6 | description = "package trigger // import \"github.com/terramate-io/terramate/commands/trigger\"\n\nPackage trigger provides the trigger command.\n\ntype FilterSpec struct{ ... }\ntype PathSpec struct{ ... }\ntype StatusFilters struct{ ... }" 7 | tags = ["commands", "golang", "trigger"] 8 | id = "281620fc-5b9e-449c-a65d-c3de4117a618" 9 | } 10 | -------------------------------------------------------------------------------- /commands/version/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "version" { 4 | content = <<-EOT 5 | package version // import "github.com/terramate-io/terramate/commands/version" 6 | 7 | Package version provides the version command. 8 | 9 | type Spec struct{ ... } 10 | EOT 11 | 12 | filename = "${path.module}/mock-version.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /commands/version/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package version // import \"github.com/terramate-io/terramate/commands/version\"" 6 | description = "package version // import \"github.com/terramate-io/terramate/commands/version\"\n\nPackage version provides the version command.\n\ntype Spec struct{ ... }" 7 | tags = ["commands", "golang", "version"] 8 | id = "800d482b-1260-4419-93f3-52bdbe06372a" 9 | } 10 | -------------------------------------------------------------------------------- /config/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package config provides high level Terramate configuration facilities. 5 | package config 6 | -------------------------------------------------------------------------------- /config/filter/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "filter" { 4 | content = <<-EOT 5 | package filter // import "github.com/terramate-io/terramate/config/filter" 6 | 7 | Package filter provides helpers for filtering objects. 8 | 9 | func MatchTags(filter TagClause, tags []string) bool 10 | func MatchTagsFrom(filters []string, tags []string) (bool, error) 11 | type Operation int 12 | const EQ Operation = iota + 1 ... 13 | type TagClause struct{ ... } 14 | func ParseTagClauses(filters ...string) (TagClause, bool, error) 15 | EOT 16 | 17 | filename = "${path.module}/mock-filter.ignore" 18 | } 19 | -------------------------------------------------------------------------------- /config/filter/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package filter // import \"github.com/terramate-io/terramate/config/filter\"" 6 | description = "package filter // import \"github.com/terramate-io/terramate/config/filter\"\n\nPackage filter provides helpers for filtering objects.\n\nfunc MatchTags(filter TagClause, tags []string) bool\nfunc MatchTagsFrom(filters []string, tags []string) (bool, error)\ntype Operation int\n const EQ Operation = iota + 1 ...\ntype TagClause struct{ ... }\n func ParseTagClauses(filters ...string) (TagClause, bool, error)" 7 | tags = ["config", "filter", "golang"] 8 | id = "a240182f-0b50-4afe-85c7-56e7e288c91c" 9 | } 10 | -------------------------------------------------------------------------------- /config/tag/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "tag" { 4 | content = <<-EOT 5 | package tag // import "github.com/terramate-io/terramate/config/tag" 6 | 7 | Package tag provides helpers for dealing with Terramate tags. 8 | 9 | const ErrInvalidTag errors.Kind = "invalid tag" 10 | func Validate(tag string) error 11 | EOT 12 | 13 | filename = "${path.module}/mock-tag.ignore" 14 | } 15 | -------------------------------------------------------------------------------- /config/tag/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package tag // import \"github.com/terramate-io/terramate/config/tag\"" 6 | description = "package tag // import \"github.com/terramate-io/terramate/config/tag\"\n\nPackage tag provides helpers for dealing with Terramate tags.\n\nconst ErrInvalidTag errors.Kind = \"invalid tag\"\nfunc Validate(tag string) error" 7 | tags = ["config", "golang", "tag"] 8 | id = "45241b3c-29b9-4f8a-92ed-84bd479dfae5" 9 | } 10 | -------------------------------------------------------------------------------- /constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package terramate 5 | 6 | const ( 7 | // DefaultFilename is the name of the default Terramate configuration file. 8 | DefaultFilename = "terramate.tm.hcl" 9 | 10 | // SkipFilename is the name of Terramate skip file. 11 | SkipFilename = ".tmskip" 12 | ) 13 | -------------------------------------------------------------------------------- /containers/test/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2023 Terramate GmbH 2 | # SPDX-License-Identifier: MPL-2.0 3 | 4 | FROM golang:1.20-alpine3.16 AS base 5 | # Needed for go test -race 6 | RUN apk add --no-cache git gcc g++ make bash 7 | WORKDIR /build 8 | RUN adduser -S tmuser 9 | # Change to non-root user for testing permissions properly 10 | USER tmuser 11 | 12 | COPY go.mod . 13 | COPY go.sum . 14 | RUN go mod download 15 | 16 | FROM base AS test 17 | 18 | ENV CGO_ENABLED=1 19 | 20 | RUN --mount=target=. \ 21 | --mount=type=cache,target=/root/.cache/go-build \ 22 | make test 23 | -------------------------------------------------------------------------------- /doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package terramate provides functions for managing terraform stacks. 5 | // A stack is a unit of independent runnable terraform modules. 6 | package terramate 7 | -------------------------------------------------------------------------------- /e2etests/cloud/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "cloud" { 4 | content = <<-EOT 5 | cloud 6 | EOT 7 | 8 | filename = "${path.module}/mock-cloud.ignore" 9 | } 10 | -------------------------------------------------------------------------------- /e2etests/cloud/interop/testdata/interop-stacks/basic-drift-uppercase-id/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Terramate GmbH 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | resource "local_file" "foo" { 7 | content = "hello world" 8 | filename = "${path.module}/foo.bar" 9 | } 10 | -------------------------------------------------------------------------------- /e2etests/cloud/interop/testdata/interop-stacks/basic-drift-uppercase-id/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "basic-drift" 6 | description = "basic-drift" 7 | id = "BASIC-DRIFT" 8 | after = ["../empty"] # only used for visualizing the graph. 9 | } 10 | -------------------------------------------------------------------------------- /e2etests/cloud/interop/testdata/interop-stacks/basic-drift/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Terramate GmbH 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | resource "local_file" "foo" { 7 | content = "hello world" 8 | filename = "${path.module}/foo.bar" 9 | } 10 | -------------------------------------------------------------------------------- /e2etests/cloud/interop/testdata/interop-stacks/basic-drift/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "basic-drift" 6 | description = "basic-drift" 7 | id = "2530f1b3-2691-48dc-b418-e966f7e1441c" 8 | after = ["../empty"] # only used for visualizing the graph. 9 | tags = ["interop", "tag.with.dots-and-dash_and_underscore"] 10 | } 11 | -------------------------------------------------------------------------------- /e2etests/cloud/interop/testdata/interop-stacks/empty-uppercase-id/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "empty" 6 | description = "empty" 7 | id = "EMPTY" 8 | before = ["/testdata/example-stack", "/testdata/testserver"] 9 | } 10 | -------------------------------------------------------------------------------- /e2etests/cloud/interop/testdata/interop-stacks/empty/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "empty" 6 | description = "empty" 7 | id = "04437b1f-27a9-4eab-8e63-1df968b76f6b" 8 | before = ["/testdata/example-stack", "/testdata/testserver"] 9 | tags = ["interop", "tag.with.dots-and-dash_and_underscore"] 10 | } 11 | -------------------------------------------------------------------------------- /e2etests/cloud/loglevel_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package cloud_test 5 | 6 | import "github.com/rs/zerolog" 7 | 8 | func init() { 9 | zerolog.SetGlobalLevel(zerolog.Disabled) 10 | } 11 | -------------------------------------------------------------------------------- /e2etests/cloud/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "cloud" 6 | description = "cloud" 7 | tags = ["cloud", "e2etests"] 8 | id = "88f4382b-a453-4228-bf80-788306af8c47" 9 | } 10 | -------------------------------------------------------------------------------- /e2etests/cloud/testdata/cloud-sync-drift-plan-file/main.tf: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2023 Terramate GmbH 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | resource "local_file" "foo" { 7 | content = var.content 8 | filename = "${path.module}/foo.bar" 9 | } 10 | 11 | variable "content" { 12 | sensitive = true 13 | } 14 | -------------------------------------------------------------------------------- /e2etests/cmd/helper/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "helper" { 4 | content = <<-EOT 5 | helper is a utility command that implements behaviors that are useful when 6 | testing terramate run features in a way that reduces dependencies on the 7 | environment to run the tests. 8 | EOT 9 | 10 | filename = "${path.module}/mock-helper.ignore" 11 | } 12 | -------------------------------------------------------------------------------- /e2etests/cmd/helper/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "helper is a utility command that implements behaviors that are useful when" 6 | description = "helper is a utility command that implements behaviors that are useful when\ntesting terramate run features in a way that reduces dependencies on the\nenvironment to run the tests." 7 | tags = ["cmd", "golang", "helper"] 8 | id = "b2c8a842-b230-4afd-9d99-47b72d423d54" 9 | } 10 | -------------------------------------------------------------------------------- /e2etests/cmd/helper/terragrunt.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package main 5 | 6 | import ( 7 | "fmt" 8 | "log" 9 | "os" 10 | ) 11 | 12 | func terragrunt(args ...string) { 13 | switch args[0] { 14 | case "show": 15 | forwardTfStdout := os.Getenv("TERRAGRUNT_FORWARD_TF_STDOUT") 16 | if forwardTfStdout == "" { 17 | log.Printf("error: TERRAGRUNT_FORWARD_TF_STDOUT is not set") 18 | os.Exit(1) 19 | } 20 | if forwardTfStdout != "true" { 21 | log.Printf("error: TERRAGRUNT_FORWARD_TF_STDOUT is not true; got %q", forwardTfStdout) 22 | os.Exit(1) 23 | } 24 | 25 | logFormat := os.Getenv("TERRAGRUNT_LOG_FORMAT") 26 | if logFormat == "" { 27 | log.Printf("error: TERRAGRUNT_LOG_FORMAT is not set") 28 | os.Exit(1) 29 | } 30 | if logFormat != "bare" { 31 | log.Printf("error: TERRAGRUNT_LOG_FORMAT is not bare; got %q", logFormat) 32 | os.Exit(1) 33 | } 34 | 35 | fmt.Println(`TERRAGRUNT SHOW TEST OUTPUT`) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /e2etests/core/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "core" { 4 | content = <<-EOT 5 | core 6 | EOT 7 | 8 | filename = "${path.module}/mock-core.ignore" 9 | } 10 | -------------------------------------------------------------------------------- /e2etests/core/disable_loglevel_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package core_test 5 | 6 | import "github.com/rs/zerolog" 7 | 8 | func init() { 9 | zerolog.SetGlobalLevel(zerolog.Disabled) 10 | } 11 | -------------------------------------------------------------------------------- /e2etests/core/list_nongit_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package core_test 5 | 6 | import ( 7 | "testing" 8 | 9 | . "github.com/terramate-io/terramate/e2etests/internal/runner" 10 | "github.com/terramate-io/terramate/test/sandbox" 11 | ) 12 | 13 | func TestE2EListNonGit(t *testing.T) { 14 | t.Parallel() 15 | for _, tcase := range listTestcases() { 16 | tc := tcase 17 | t.Run(tc.name, func(t *testing.T) { 18 | t.Parallel() 19 | 20 | s := sandbox.NoGit(t, true) 21 | s.BuildTree(tc.layout) 22 | 23 | cli := NewCLI(t, s.RootDir()) 24 | var args []string 25 | for _, filter := range tc.filterTags { 26 | args = append(args, "--tags", filter) 27 | } 28 | for _, filter := range tc.filterNoTags { 29 | args = append(args, "--no-tags", filter) 30 | } 31 | AssertRunResult(t, cli.ListStacks(args...), tc.want) 32 | }) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /e2etests/core/logging_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package core_test 5 | 6 | import ( 7 | "testing" 8 | 9 | . "github.com/terramate-io/terramate/e2etests/internal/runner" 10 | "github.com/terramate-io/terramate/test/sandbox" 11 | ) 12 | 13 | func TestLoggingChangeChannel(t *testing.T) { 14 | t.Parallel() 15 | s := sandbox.NoGit(t, true) 16 | cli := NewCLI(t, s.RootDir()) 17 | cli.LogLevel = "trace" 18 | 19 | AssertRunResult(t, cli.ListStacks(), RunExpected{ 20 | StderrRegex: "DBG", 21 | }) 22 | AssertRunResult(t, cli.ListStacks("--log-destination", "stderr"), RunExpected{ 23 | StderrRegex: "DBG", 24 | }) 25 | AssertRunResult(t, cli.ListStacks("--log-destination", "stdout"), RunExpected{ 26 | StdoutRegex: "DBG", 27 | }) 28 | } 29 | -------------------------------------------------------------------------------- /e2etests/core/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package core_test 5 | 6 | import ( 7 | "log" 8 | "os" 9 | "path/filepath" 10 | "testing" 11 | 12 | . "github.com/terramate-io/terramate/e2etests/internal/runner" 13 | ) 14 | 15 | func TestMain(m *testing.M) { 16 | packageDir, err := os.Getwd() 17 | if err != nil { 18 | log.Printf("failed to get test working directory: %v", err) 19 | os.Exit(1) 20 | } 21 | // this file is inside e2etests/core 22 | // change code below if it's not the case anymore. 23 | projectRoot := filepath.Join(packageDir, "../..") 24 | err = Setup(projectRoot) 25 | if err != nil { 26 | log.Printf("failed to setup e2e tests: %v", err) 27 | Teardown() 28 | os.Exit(1) 29 | } 30 | code := m.Run() 31 | Teardown() 32 | os.Exit(code) 33 | } 34 | -------------------------------------------------------------------------------- /e2etests/core/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "core" 6 | description = "core" 7 | tags = ["core", "e2etests"] 8 | id = "b36bb769-6f65-467a-9195-f043cd495e16" 9 | } 10 | -------------------------------------------------------------------------------- /e2etests/internal/runner/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package runner provides helpers for compiling and running the Terramate 5 | // binary with the intent of doing e2e tests. Additionally, it also 6 | // provides functions for building and installing dependency binaries. 7 | package runner 8 | -------------------------------------------------------------------------------- /errors/errlog/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "errlog" { 4 | content = <<-EOT 5 | package errlog // import "github.com/terramate-io/terramate/errors/errlog" 6 | 7 | Package errlog provides functions to log Terramate errors nicely and in a 8 | consistent manner. 9 | 10 | func Warn(logger zerolog.Logger, err error, args ...any) 11 | EOT 12 | 13 | filename = "${path.module}/mock-errlog.ignore" 14 | } 15 | -------------------------------------------------------------------------------- /errors/errlog/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package errlog // import \"github.com/terramate-io/terramate/errors/errlog\"" 6 | description = "package errlog // import \"github.com/terramate-io/terramate/errors/errlog\"\n\nPackage errlog provides functions to log Terramate errors nicely and in a\nconsistent manner.\n\nfunc Warn(logger zerolog.Logger, err error, args ...any)" 7 | tags = ["errlog", "errors", "golang"] 8 | id = "3d33d880-eef2-4aaa-9a85-f7bdab8d0be8" 9 | } 10 | -------------------------------------------------------------------------------- /errors/verbosity/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "verbosity" { 4 | content = <<-EOT 5 | package verbosity // import "github.com/terramate-io/terramate/errors/verbosity" 6 | 7 | Package verbosity defines the common Terramate error verbosity levels. 8 | 9 | const V0 int = iota ... 10 | EOT 11 | 12 | filename = "${path.module}/mock-verbosity.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /errors/verbosity/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package verbosity // import \"github.com/terramate-io/terramate/errors/verbosity\"" 6 | description = "package verbosity // import \"github.com/terramate-io/terramate/errors/verbosity\"\n\nPackage verbosity defines the common Terramate error verbosity levels.\n\nconst V0 int = iota ..." 7 | tags = ["errors", "golang", "verbosity"] 8 | id = "74ec6e10-bea7-426f-bd3d-aa5cce0f7b5a" 9 | } 10 | -------------------------------------------------------------------------------- /errors/verbosity/verbosity.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package verbosity defines the common Terramate error verbosity levels. 5 | package verbosity 6 | 7 | const ( 8 | // V0 is no verbosity. 9 | V0 int = iota 10 | // V1 is default verbosity level. 11 | V1 12 | // V2 is high verbosity level. 13 | V2 14 | ) 15 | -------------------------------------------------------------------------------- /event/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "event" { 4 | content = <<-EOT 5 | package event // import "github.com/terramate-io/terramate/event" 6 | 7 | Package event implements a simple event stream and defines all events generated 8 | by different parts of Terramate. 9 | 10 | type Stream[T any] chan T 11 | func NewStream[T any](buffsize int) Stream[T] 12 | type VendorProgress struct{ ... } 13 | type VendorRequest struct{ ... } 14 | EOT 15 | 16 | filename = "${path.module}/mock-event.ignore" 17 | } 18 | -------------------------------------------------------------------------------- /event/event_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package event_test 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/madlambda/spells/assert" 10 | "github.com/terramate-io/terramate/event" 11 | ) 12 | 13 | func TestEventStream(t *testing.T) { 14 | t.Parallel() 15 | stream := event.NewStream[int](3) 16 | 17 | assert.IsTrue(t, stream.Send(1)) 18 | assert.IsTrue(t, stream.Send(2)) 19 | assert.IsTrue(t, stream.Send(3)) 20 | assert.IsTrue(t, !stream.Send(4)) 21 | 22 | close(stream) 23 | 24 | want := 1 25 | for event := range stream { 26 | assert.EqualInts(t, event, want) 27 | want++ 28 | } 29 | } 30 | 31 | func TestEventStreamZeroValueWontBlock(t *testing.T) { 32 | t.Parallel() 33 | var stream event.Stream[string] 34 | 35 | assert.IsTrue(t, !stream.Send("ok")) 36 | assert.IsTrue(t, !stream.Send("ok2")) 37 | } 38 | -------------------------------------------------------------------------------- /event/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package event // import \"github.com/terramate-io/terramate/event\"" 6 | description = "package event // import \"github.com/terramate-io/terramate/event\"\n\nPackage event implements a simple event stream and defines all events generated\nby different parts of Terramate.\n\ntype Stream[T any] chan T\n func NewStream[T any](buffsize int) Stream[T]\ntype VendorProgress struct{ ... }\ntype VendorRequest struct{ ... }" 7 | tags = ["event", "golang"] 8 | id = "3bef7cce-e755-49c2-ac71-39f7a0e9144f" 9 | } 10 | -------------------------------------------------------------------------------- /exit/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "exit" { 4 | content = <<-EOT 5 | package exit // import "github.com/terramate-io/terramate/exit" 6 | 7 | Package exit provides standard exit codes for Terramate. 8 | 9 | type Status int 10 | const OK Status = iota ... 11 | EOT 12 | 13 | filename = "${path.module}/mock-exit.ignore" 14 | } 15 | -------------------------------------------------------------------------------- /exit/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package exit // import \"github.com/terramate-io/terramate/exit\"" 6 | description = "package exit // import \"github.com/terramate-io/terramate/exit\"\n\nPackage exit provides standard exit codes for Terramate.\n\ntype Status int\n const OK Status = iota ..." 7 | tags = ["exit", "golang"] 8 | id = "6f1acfec-42ba-4f5c-9425-7f89f2159097" 9 | } 10 | -------------------------------------------------------------------------------- /exit/status.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package exit provides standard exit codes for Terramate. 5 | package exit 6 | 7 | // Status represents the exit status of a command. 8 | type Status int 9 | 10 | // Standard exit codes of Terramate 11 | const ( 12 | OK Status = iota 13 | Failed 14 | Changed 15 | 16 | // this can be extended by external commands. 17 | ) 18 | -------------------------------------------------------------------------------- /fs/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "fs" { 4 | content = <<-EOT 5 | package fs // import "github.com/terramate-io/terramate/fs" 6 | 7 | Package fs provides filesystem related functionality. 8 | 9 | func CopyAll(dstdir, srcdir string) error 10 | func CopyDir(destdir, srcdir string, filter CopyFilterFunc) error 11 | func ListTerramateDirs(dir string) ([]string, error) 12 | func ListTerramateFiles(dir string) (filenames []string, err error) 13 | type CopyFilterFunc func(path string, entry os.DirEntry) bool 14 | EOT 15 | 16 | filename = "${path.module}/mock-fs.ignore" 17 | } 18 | -------------------------------------------------------------------------------- /fs/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package fs provides filesystem related functionality. 5 | package fs 6 | -------------------------------------------------------------------------------- /fs/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package fs // import \"github.com/terramate-io/terramate/fs\"" 6 | description = "package fs // import \"github.com/terramate-io/terramate/fs\"\n\nPackage fs provides filesystem related functionality.\n\nfunc CopyAll(dstdir, srcdir string) error\nfunc CopyDir(destdir, srcdir string, filter CopyFilterFunc) error\nfunc ListTerramateDirs(dir string) ([]string, error)\nfunc ListTerramateFiles(dir string) (filenames []string, err error)\ntype CopyFilterFunc func(path string, entry os.DirEntry) bool" 7 | tags = ["fs", "golang"] 8 | id = "68556dbf-d1d3-47de-a840-f9792dd06fa0" 9 | } 10 | -------------------------------------------------------------------------------- /generate/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package generate implements code generation. It includes all available 5 | // code generation strategies on Terramate and it also handles outdated code 6 | // detection and deletion. 7 | package generate 8 | -------------------------------------------------------------------------------- /generate/genfile/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "genfile" { 4 | content = <<-EOT 5 | package genfile // import "github.com/terramate-io/terramate/generate/genfile" 6 | 7 | Package genfile implements generate_file code generation. 8 | 9 | const ErrInvalidContentType errors.Kind = "invalid content type" ... 10 | const StackContext = "stack" ... 11 | type File struct{ ... } 12 | func Eval(block hcl.GenFileBlock, cfg *config.Tree, evalctx *eval.Context) (file File, skip bool, err error) 13 | func Load(root *config.Root, st *config.Stack, parentctx *eval.Context, ...) ([]File, error) 14 | EOT 15 | 16 | filename = "${path.module}/mock-genfile.ignore" 17 | } 18 | -------------------------------------------------------------------------------- /generate/genfile/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package genfile // import \"github.com/terramate-io/terramate/generate/genfile\"" 6 | description = "package genfile // import \"github.com/terramate-io/terramate/generate/genfile\"\n\nPackage genfile implements generate_file code generation.\n\nconst ErrInvalidContentType errors.Kind = \"invalid content type\" ...\nconst StackContext = \"stack\" ...\ntype File struct{ ... }\n func Eval(block hcl.GenFileBlock, cfg *config.Tree, evalctx *eval.Context) (file File, skip bool, err error)\n func Load(root *config.Root, st *config.Stack, parentctx *eval.Context, ...) ([]File, error)" 7 | tags = ["generate", "genfile", "golang"] 8 | id = "f9ecbd56-b4b3-4410-806f-bc412c5e3c36" 9 | } 10 | -------------------------------------------------------------------------------- /generate/genhcl/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "genhcl" { 4 | content = <<-EOT 5 | package genhcl // import "github.com/terramate-io/terramate/generate/genhcl" 6 | 7 | Package genhcl implements generate_hcl code generation. 8 | 9 | const HeaderMagic = "TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT" ... 10 | const ErrParsing errors.Kind = "parsing generate_hcl block" ... 11 | func DefaultHeader() string 12 | func Header(comment CommentStyle) string 13 | type CommentStyle int 14 | const SlashComment CommentStyle = iota ... 15 | func CommentStyleFromConfig(tree *config.Tree) CommentStyle 16 | type HCL struct{ ... } 17 | func Load(root *config.Root, st *config.Stack, evalctx *eval.Context, ...) ([]HCL, error) 18 | EOT 19 | 20 | filename = "${path.module}/mock-genhcl.ignore" 21 | } 22 | -------------------------------------------------------------------------------- /generate/genhcl/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package genhcl // import \"github.com/terramate-io/terramate/generate/genhcl\"" 6 | description = "package genhcl // import \"github.com/terramate-io/terramate/generate/genhcl\"\n\nPackage genhcl implements generate_hcl code generation.\n\nconst HeaderMagic = \"TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT\" ...\nconst ErrParsing errors.Kind = \"parsing generate_hcl block\" ...\nfunc DefaultHeader() string\nfunc Header(comment CommentStyle) string\ntype CommentStyle int\n const SlashComment CommentStyle = iota ...\n func CommentStyleFromConfig(tree *config.Tree) CommentStyle\ntype HCL struct{ ... }\n func Load(root *config.Root, st *config.Stack, evalctx *eval.Context, ...) ([]HCL, error)" 7 | tags = ["generate", "genhcl", "golang"] 8 | id = "140a4bdc-6dc0-4d89-9c0b-9c54256345db" 9 | } 10 | -------------------------------------------------------------------------------- /generate/report/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "report" { 4 | content = <<-EOT 5 | package report // import "github.com/terramate-io/terramate/generate/report" 6 | 7 | Package report provides a report of the code generation process. 8 | 9 | type Dir struct{ ... } 10 | type FailureResult struct{ ... } 11 | type Report struct{ ... } 12 | func Merge(reportChan chan *Report) *Report 13 | type Result struct{ ... } 14 | EOT 15 | 16 | filename = "${path.module}/mock-report.ignore" 17 | } 18 | -------------------------------------------------------------------------------- /generate/report/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package report // import \"github.com/terramate-io/terramate/generate/report\"" 6 | description = "package report // import \"github.com/terramate-io/terramate/generate/report\"\n\nPackage report provides a report of the code generation process.\n\ntype Dir struct{ ... }\ntype FailureResult struct{ ... }\ntype Report struct{ ... }\n func Merge(reportChan chan *Report) *Report\ntype Result struct{ ... }" 7 | tags = ["generate", "golang", "report"] 8 | id = "c9ba6552-72b6-46ad-8ef1-828183f72d59" 9 | } 10 | -------------------------------------------------------------------------------- /generate/sharing/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "sharing" { 4 | content = <<-EOT 5 | package sharing // import "github.com/terramate-io/terramate/generate/sharing" 6 | 7 | Package sharing implements the loading of sharing related blocks. 8 | 9 | type File struct{ ... } 10 | func PrepareFile(root *config.Root, filename string, inputs config.Inputs, ...) (File, error) 11 | EOT 12 | 13 | filename = "${path.module}/mock-sharing.ignore" 14 | } 15 | -------------------------------------------------------------------------------- /generate/sharing/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package sharing // import \"github.com/terramate-io/terramate/generate/sharing\"" 6 | description = "package sharing // import \"github.com/terramate-io/terramate/generate/sharing\"\n\nPackage sharing implements the loading of sharing related blocks.\n\ntype File struct{ ... }\n func PrepareFile(root *config.Root, filename string, inputs config.Inputs, ...) (File, error)" 7 | tags = ["generate", "golang", "sharing"] 8 | id = "3c45e985-14d7-4dcf-8054-c07f74210783" 9 | } 10 | -------------------------------------------------------------------------------- /generate_mkconfig.tm: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | generate_file "makefiles/_mkconfig.mk" { 5 | inherit = false 6 | 7 | content = <0}") 3 | -------------------------------------------------------------------------------- /hcl/eval/testdata/fuzz/FuzzPartialEval/adfadc9a0835ffb53cc906ea281dd91486510688b43dd47713057ad7bde208cb: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("A(!\n0)") 3 | -------------------------------------------------------------------------------- /hcl/eval/testdata/fuzz/FuzzPartialEval/af0977e984bd55c8e48f13af6ecf722b73b8eec6259e44dfd1d85d46fde46526: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("(!\n!0)") 3 | -------------------------------------------------------------------------------- /hcl/eval/testdata/fuzz/FuzzPartialEval/b116e89887aa9e3f5b846b8e943d40fb59bce0415d4277639e307b3c4d680c4b: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("(0\n.0\n.0)") 3 | -------------------------------------------------------------------------------- /hcl/eval/testdata/fuzz/FuzzPartialEval/b8e7b37e86a6bc6d692ad2fd6cd0b3ebb1a94305dfe7ce5b0488de4a27caa6de: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("(0\n.0)") 3 | -------------------------------------------------------------------------------- /hcl/eval/testdata/fuzz/FuzzPartialEval/ba6edc08e0d40d285f5a74474f6fb94563365b4d88dbf1be18d54cdc40545d69: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("global.*") 3 | -------------------------------------------------------------------------------- /hcl/eval/testdata/fuzz/FuzzPartialEval/c832672669ea3aa88a312b9521927abb062921923c382b96072120ece09bfd88: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("A00.0[0][0]") 3 | -------------------------------------------------------------------------------- /hcl/eval/testdata/fuzz/FuzzPartialEval/cb0065cb8b038e7901d0a48e766c28156c2665f67023ac2e7d72ad7adb35b417: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("\"${\n0}\"") 3 | -------------------------------------------------------------------------------- /hcl/eval/testdata/fuzz/FuzzPartialEval/cb70dbc367f763f274137ac8f7577b67ebbee60d63476d4926fa141a24d79eb9: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[!\n0]") 3 | -------------------------------------------------------------------------------- /hcl/eval/testdata/fuzz/FuzzPartialEval/cbe8142af83846f8115da94dad768d5b1b7a0693de7a9171a6983afd6c1ea289: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("\"$0\"") 3 | -------------------------------------------------------------------------------- /hcl/eval/testdata/fuzz/FuzzPartialEval/d2eeeb93a3870300e91cb65a28c2bb11fd8411a7229d877ae95cf31eff9302e9: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("<0}") 3 | -------------------------------------------------------------------------------- /hcl/eval/testdata/fuzz/FuzzPartialEval/f27fa2cd3f65cea1caf13686a7d913e56e6fab9c6deba33b9d8696c35d540718: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("{\n}") 3 | -------------------------------------------------------------------------------- /hcl/fmt/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "fmt" { 4 | content = <<-EOT 5 | package fmt // import "github.com/terramate-io/terramate/hcl/fmt" 6 | 7 | Package fmt contains functions for formatting hcl config. 8 | 9 | const ErrHCLSyntax errors.Kind = "HCL syntax error" 10 | const ErrReadFile errors.Kind = "failed to read file" 11 | func Format(src, filename string) (string, error) 12 | func FormatAttributes(attrs map[string]cty.Value) string 13 | func FormatMultiline(src, filename string) (string, error) 14 | type FormatResult struct{ ... } 15 | func FormatFiles(basedir string, files []string) ([]FormatResult, error) 16 | func FormatTree(dir string) ([]FormatResult, error) 17 | EOT 18 | 19 | filename = "${path.module}/mock-fmt.ignore" 20 | } 21 | -------------------------------------------------------------------------------- /hcl/fmt/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package fmt // import \"github.com/terramate-io/terramate/hcl/fmt\"" 6 | description = "package fmt // import \"github.com/terramate-io/terramate/hcl/fmt\"\n\nPackage fmt contains functions for formatting hcl config.\n\nconst ErrHCLSyntax errors.Kind = \"HCL syntax error\"\nconst ErrReadFile errors.Kind = \"failed to read file\"\nfunc Format(src, filename string) (string, error)\nfunc FormatAttributes(attrs map[string]cty.Value) string\nfunc FormatMultiline(src, filename string) (string, error)\ntype FormatResult struct{ ... }\n func FormatFiles(basedir string, files []string) ([]FormatResult, error)\n func FormatTree(dir string) ([]FormatResult, error)" 7 | tags = ["fmt", "golang", "hcl"] 8 | id = "4c9c3934-72bb-4520-90c9-89de1dff254b" 9 | } 10 | -------------------------------------------------------------------------------- /hcl/info/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "info" { 4 | content = <<-EOT 5 | package info // import "github.com/terramate-io/terramate/hcl/info" 6 | 7 | Package info provides informational types related to hcl. 8 | 9 | type Pos struct{ ... } 10 | func NewPos(p hcl.Pos) Pos 11 | type Range struct{ ... } 12 | func NewRange(rootdir string, r hcl.Range) Range 13 | type Ranges []Range 14 | EOT 15 | 16 | filename = "${path.module}/mock-info.ignore" 17 | } 18 | -------------------------------------------------------------------------------- /hcl/info/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package info provides informational types related to hcl. 5 | package info 6 | -------------------------------------------------------------------------------- /hcl/info/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package info // import \"github.com/terramate-io/terramate/hcl/info\"" 6 | description = "package info // import \"github.com/terramate-io/terramate/hcl/info\"\n\nPackage info provides informational types related to hcl.\n\ntype Pos struct{ ... }\n func NewPos(p hcl.Pos) Pos\ntype Range struct{ ... }\n func NewRange(rootdir string, r hcl.Range) Range\ntype Ranges []Range" 7 | tags = ["golang", "hcl", "info"] 8 | id = "ed8a764a-e3bb-4811-8677-ce125db06359" 9 | } 10 | -------------------------------------------------------------------------------- /hcl/sharing_backend.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package hcl 5 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/03e108ccb2adca4afc9d6ccafc885ff00e2b281215f1ad995b0dfb4ba6dabf77: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[[[]#\n[*]]]") 3 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/1968484d4c23b26974561db7524f1d8562293b53ca9d767ce179e627c041b777: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[0\n[[]]]") 3 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/3012dfcb01972a1f3a5101be3df9ba9e54ff7c58493aaa5b14546068511c63ae: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[[0#00000\n[ []]]]") 3 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/57786df2fa66eddc5a9f77c1d3ec3d08194d2780a9b01894738f611abe939a36: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[[]%\n[]]") 3 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/6c08602dd987861b76591e0c5181b101ea1a76ed55ac573f885973722758a505: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[[]#0\n\n]") 3 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/76d21ab7a1739feca98d5cf0a43090286669c47538bbe2379b1467fd44993190: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[[0]%[0]]") 3 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/7f89f2cf1a2eb758cba76dca15e2265a507383e9ad270371ffa66582ffee4407: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[0.*[0]]") 3 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/87c917a6fb6807a9ae20fea1da8b2a88c71f78353ed57d5d365cc10b096d76a1: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[[#\n]]") 3 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/8a3f7a02b84109cee96011556e5185d2ae11c627066e8f719e69d6bfd23b576a: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[] [0]") 3 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/94d618c9ccb5beac5954f686324b7f23e05fd8122baa8d78245e487d0fbbaa78: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[[]#\n\n[[]]]") 3 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/9e8326443fdb02f7b334e7af4811c7a57b5cba251f5b017808bc2ed97e8ecc33: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[{}%0]") 3 | -------------------------------------------------------------------------------- /hcl/testdata/fuzz/FuzzFormatMultiline/b2ccdcc012eec170761e719bb8b221f1582ac39c3bc85a95a1ec08d6aab7543d: -------------------------------------------------------------------------------- 1 | go test fuzz v1 2 | string("[< ancestors relationship is 10 | kept. 11 | 12 | const ErrDuplicateNode errors.Kind = "duplicate node" ... 13 | type DAG[V any] struct{ ... } 14 | func New[V any]() *DAG[V] 15 | func Transform[D, S any](from *DAG[S], f func(id ID, v S) (D, error)) (*DAG[D], error) 16 | type ID string 17 | type Visited map[ID]struct{} 18 | EOT 19 | 20 | filename = "${path.module}/mock-dag.ignore" 21 | } 22 | -------------------------------------------------------------------------------- /run/dag/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package dag // import \"github.com/terramate-io/terramate/run/dag\"" 6 | description = "package dag // import \"github.com/terramate-io/terramate/run/dag\"\n\nPackage dag provides the Directed-Acyclic-Graph (DAG) primitives required\nby Terramate. The nodes can be added by providing both the descendants and\nancestors of each node but only the descendant -> ancestors relationship is\nkept.\n\nconst ErrDuplicateNode errors.Kind = \"duplicate node\" ...\ntype DAG[V any] struct{ ... }\n func New[V any]() *DAG[V]\n func Transform[D, S any](from *DAG[S], f func(id ID, v S) (D, error)) (*DAG[D], error)\ntype ID string\ntype Visited map[ID]struct{}" 7 | tags = ["dag", "golang", "run"] 8 | id = "4afcc942-9533-4d27-86d5-fa24d0b099be" 9 | } 10 | -------------------------------------------------------------------------------- /run/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package run provides facilities to run commands inside Terramate 5 | // context and ordering. 6 | package run 7 | -------------------------------------------------------------------------------- /safeguard/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "safeguard" { 4 | content = <<-EOT 5 | package safeguard // import "github.com/terramate-io/terramate/safeguard" 6 | 7 | Package safeguard provides types and methods for dealing with safeguards 8 | keywords. 9 | 10 | type Keyword string 11 | const All Keyword = "all" ... 12 | type Keywords []Keyword 13 | func FromStrings(strs []string) (Keywords, error) 14 | EOT 15 | 16 | filename = "${path.module}/mock-safeguard.ignore" 17 | } 18 | -------------------------------------------------------------------------------- /safeguard/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package safeguard provides types and methods for dealing with 5 | // safeguards keywords. 6 | package safeguard 7 | -------------------------------------------------------------------------------- /safeguard/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package safeguard // import \"github.com/terramate-io/terramate/safeguard\"" 6 | description = "package safeguard // import \"github.com/terramate-io/terramate/safeguard\"\n\nPackage safeguard provides types and methods for dealing with safeguards\nkeywords.\n\ntype Keyword string\n const All Keyword = \"all\" ...\ntype Keywords []Keyword\n func FromStrings(strs []string) (Keywords, error)" 7 | tags = ["golang", "safeguard"] 8 | id = "5b526d39-4c1a-4d18-9f61-5302e8d88fdc" 9 | } 10 | -------------------------------------------------------------------------------- /scheduler/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "scheduler" { 4 | content = <<-EOT 5 | package scheduler // import "github.com/terramate-io/terramate/scheduler" 6 | 7 | Package scheduler defines schedulers to execute functions on DAGs based on a 8 | specific scheduling strategy. 9 | 10 | type Func[V any] func(V) error 11 | type Parallel[V any] struct{ ... } 12 | func NewParallel[V any](d *dag.DAG[V], reverse bool) *Parallel[V] 13 | type S[V any] interface{ ... } 14 | type Sequential[V any] struct{ ... } 15 | func NewSequential[V any](d *dag.DAG[V], reverse bool) *Sequential[V] 16 | EOT 17 | 18 | filename = "${path.module}/mock-scheduler.ignore" 19 | } 20 | -------------------------------------------------------------------------------- /scheduler/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package scheduler defines schedulers to execute functions on DAGs based on a 5 | // specific scheduling strategy. 6 | package scheduler 7 | -------------------------------------------------------------------------------- /scheduler/resource/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "resource" { 4 | content = <<-EOT 5 | package resource // import "github.com/terramate-io/terramate/scheduler/resource" 6 | 7 | Package resource defines different concurrent access strategies for resources. 8 | 9 | type Bounded struct{ ... } 10 | func NewBounded(n int) *Bounded 11 | type R interface{ ... } 12 | type Throttled struct{ ... } 13 | func NewThrottled(requestsPerSecond int64) *Throttled 14 | EOT 15 | 16 | filename = "${path.module}/mock-resource.ignore" 17 | } 18 | -------------------------------------------------------------------------------- /scheduler/resource/bounded.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package resource 5 | 6 | import ( 7 | "context" 8 | 9 | "golang.org/x/sync/semaphore" 10 | ) 11 | 12 | // Bounded is a bounded resource. 13 | type Bounded struct { 14 | sem *semaphore.Weighted 15 | } 16 | 17 | // NewBounded creates a new bounded resource that can be acquired n times concurrently. 18 | func NewBounded(n int) *Bounded { 19 | return &Bounded{ 20 | sem: semaphore.NewWeighted(int64(n)), 21 | } 22 | } 23 | 24 | // Acquire acquires the resource. If the resource is already acquired n times, 25 | // wait until another one is released. 26 | func (r *Bounded) Acquire(ctx context.Context) bool { 27 | err := r.sem.Acquire(ctx, 1) 28 | return err == nil 29 | } 30 | 31 | // Release a previously acquired resource. 32 | func (r *Bounded) Release() { 33 | r.sem.Release(1) 34 | } 35 | -------------------------------------------------------------------------------- /scheduler/resource/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package resource defines different concurrent access strategies for resources. 5 | package resource 6 | -------------------------------------------------------------------------------- /scheduler/resource/resource.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package resource 5 | 6 | import "context" 7 | 8 | // R is the resource interface. 9 | type R interface { 10 | Acquire(ctx context.Context) bool 11 | Release() 12 | } 13 | -------------------------------------------------------------------------------- /scheduler/resource/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package resource // import \"github.com/terramate-io/terramate/scheduler/resource\"" 6 | description = "package resource // import \"github.com/terramate-io/terramate/scheduler/resource\"\n\nPackage resource defines different concurrent access strategies for resources.\n\ntype Bounded struct{ ... }\n func NewBounded(n int) *Bounded\ntype R interface{ ... }\ntype Throttled struct{ ... }\n func NewThrottled(requestsPerSecond int64) *Throttled" 7 | tags = ["golang", "resource", "scheduler"] 8 | id = "580bae4e-4ca4-422d-8529-4b06849ce989" 9 | } 10 | -------------------------------------------------------------------------------- /scheduler/resource/throttled.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package resource 5 | 6 | import ( 7 | "context" 8 | "time" 9 | ) 10 | 11 | // Throttled in a rate-limited resource. 12 | type Throttled struct { 13 | ticker *time.Ticker 14 | } 15 | 16 | // NewThrottled creates a resource with the given rate limit. 17 | func NewThrottled(requestsPerSecond int64) *Throttled { 18 | interval := time.Duration(1.0/float64(requestsPerSecond)*1000.0) * time.Millisecond 19 | return &Throttled{ 20 | ticker: time.NewTicker(interval), 21 | } 22 | } 23 | 24 | // Acquire can be called concurrently, and blocks callers so that are let through as 25 | // the rate limit requires. 26 | func (r *Throttled) Acquire(ctx context.Context) bool { 27 | select { 28 | case <-ctx.Done(): 29 | return false 30 | case <-r.ticker.C: 31 | return true 32 | } 33 | } 34 | 35 | // Release for this resource type is no-op. 36 | func (*Throttled) Release() { 37 | } 38 | -------------------------------------------------------------------------------- /scheduler/scheduler.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package scheduler 5 | 6 | // Func is the function type called when visiting nodes of the DAG. 7 | type Func[V any] func(V) error 8 | 9 | // S is the scheduler interface. 10 | type S[V any] interface { 11 | // Run executes a given function by a specific scheduling strategy. 12 | Run(Func[V]) error 13 | } 14 | -------------------------------------------------------------------------------- /scheduler/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package scheduler // import \"github.com/terramate-io/terramate/scheduler\"" 6 | description = "package scheduler // import \"github.com/terramate-io/terramate/scheduler\"\n\nPackage scheduler defines schedulers to execute functions on DAGs based on a\nspecific scheduling strategy.\n\ntype Func[V any] func(V) error\ntype Parallel[V any] struct{ ... }\n func NewParallel[V any](d *dag.DAG[V], reverse bool) *Parallel[V]\ntype S[V any] interface{ ... }\ntype Sequential[V any] struct{ ... }\n func NewSequential[V any](d *dag.DAG[V], reverse bool) *Sequential[V]" 7 | tags = ["golang", "scheduler"] 8 | id = "5215a993-ae93-4799-a113-1adb9fdbc69e" 9 | } 10 | -------------------------------------------------------------------------------- /stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package terramate // import \"github.com/terramate-io/terramate\"" 6 | description = "package terramate // import \"github.com/terramate-io/terramate\"\n\nPackage terramate provides functions for managing terraform stacks. A stack is a\nunit of independent runnable terraform modules.\n\nfunc Version() string" 7 | tags = ["golang", "tag.with.dots"] 8 | id = "ff77cc8c-87da-4411-bdbe-ad2feec7ba23" 9 | } 10 | -------------------------------------------------------------------------------- /stack/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package stack defines all functionality around stacks, like 5 | // loading, listing all stacks, etc. 6 | package stack 7 | -------------------------------------------------------------------------------- /stack/loglevel_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package stack_test 5 | 6 | import "github.com/rs/zerolog" 7 | 8 | func init() { 9 | zerolog.SetGlobalLevel(zerolog.Disabled) 10 | } 11 | -------------------------------------------------------------------------------- /stack/stack.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package stack 5 | 6 | import "github.com/terramate-io/terramate/config" 7 | 8 | // List loads from the config all terramate stacks. 9 | // It returns a lexicographic sorted list of stack directories. 10 | func List(root *config.Root, cfg *config.Tree) ([]Entry, error) { 11 | stacks, err := config.LoadAllStacks(root, cfg) 12 | if err != nil { 13 | return nil, err 14 | } 15 | 16 | entries := make([]Entry, len(stacks)) 17 | for i, elem := range stacks { 18 | entries[i] = Entry{Stack: elem.Stack} 19 | } 20 | return entries, nil 21 | } 22 | -------------------------------------------------------------------------------- /stack/stack_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package stack_test 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/madlambda/spells/assert" 10 | "github.com/rs/zerolog" 11 | "github.com/terramate-io/terramate/config" 12 | "github.com/terramate-io/terramate/errors" 13 | "github.com/terramate-io/terramate/test/sandbox" 14 | ) 15 | 16 | func TestLoadAllFailsIfStacksIDIsNotUnique(t *testing.T) { 17 | t.Parallel() 18 | s := sandbox.NoGit(t, true) 19 | s.BuildTree([]string{ 20 | "s:stacks/stack-1:id=terramate", 21 | "s:stacks/stack-2:id=TerraMate", 22 | }) 23 | root, err := config.LoadRoot(s.RootDir(), false) 24 | assert.NoError(t, err) 25 | _, err = config.LoadAllStacks(root, root.Tree()) 26 | assert.IsError(t, err, errors.E(config.ErrStackDuplicatedID)) 27 | } 28 | 29 | func init() { 30 | zerolog.SetGlobalLevel(zerolog.Disabled) 31 | } 32 | -------------------------------------------------------------------------------- /stack/trigger/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "trigger" { 4 | content = <<-EOT 5 | package trigger // import "github.com/terramate-io/terramate/stack/trigger" 6 | 7 | Package trigger provides functionality that help manipulate stacks triggers. 8 | 9 | const ErrTrigger errors.Kind = "trigger failed" ... 10 | const DefaultContext = "stack" 11 | func Create(root *config.Root, path project.Path, kind Kind, reason string) error 12 | func Dir(rootdir string) string 13 | func StackPath(triggerFile project.Path) (project.Path, bool) 14 | type Info struct{ ... } 15 | func Is(root *config.Root, filename project.Path) (info Info, stack project.Path, exists bool, err error) 16 | func ParseFile(path string) (Info, error) 17 | type Kind string 18 | const Changed Kind = "changed" ... 19 | EOT 20 | 21 | filename = "${path.module}/mock-trigger.ignore" 22 | } 23 | -------------------------------------------------------------------------------- /stack/trigger/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package trigger // import \"github.com/terramate-io/terramate/stack/trigger\"" 6 | description = "package trigger // import \"github.com/terramate-io/terramate/stack/trigger\"\n\nPackage trigger provides functionality that help manipulate stacks triggers.\n\nconst ErrTrigger errors.Kind = \"trigger failed\" ...\nconst DefaultContext = \"stack\"\nfunc Create(root *config.Root, path project.Path, kind Kind, reason string) error\nfunc Dir(rootdir string) string\nfunc StackPath(triggerFile project.Path) (project.Path, bool)\ntype Info struct{ ... }\n func Is(root *config.Root, filename project.Path) (info Info, stack project.Path, exists bool, err error)\n func ParseFile(path string) (Info, error)\ntype Kind string\n const Changed Kind = \"changed\" ..." 7 | tags = ["golang", "stack", "trigger"] 8 | id = "c0f5d20b-0765-4c23-9c52-2905a1621caa" 9 | } 10 | -------------------------------------------------------------------------------- /stdlib/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package stdlib implements the Terramate language functions. 5 | package stdlib 6 | -------------------------------------------------------------------------------- /strconv/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "strconv" { 4 | content = <<-EOT 5 | package strconv // import "github.com/terramate-io/terramate/strconv" 6 | 7 | Package strconv provides helper functions for the Go standard strconv package. 8 | 9 | func Atoi64(a string) (int64, error) 10 | func Itoa64(i int64) string 11 | EOT 12 | 13 | filename = "${path.module}/mock-strconv.ignore" 14 | } 15 | -------------------------------------------------------------------------------- /strconv/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package strconv provides helper functions for the Go standard 5 | // strconv package. 6 | package strconv 7 | -------------------------------------------------------------------------------- /strconv/format.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package strconv 5 | 6 | import "strconv" 7 | 8 | // Itoa64 returns the string representation of the provided int64 using base 10. 9 | func Itoa64(i int64) string { return strconv.FormatInt(i, 10) } 10 | 11 | // Atoi64 returns the int64 represented in the given string. 12 | func Atoi64(a string) (int64, error) { 13 | return strconv.ParseInt(a, 10, 64) 14 | } 15 | -------------------------------------------------------------------------------- /strconv/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package strconv // import \"github.com/terramate-io/terramate/strconv\"" 6 | description = "package strconv // import \"github.com/terramate-io/terramate/strconv\"\n\nPackage strconv provides helper functions for the Go standard strconv package.\n\nfunc Atoi64(a string) (int64, error)\nfunc Itoa64(i int64) string" 7 | tags = ["golang", "strconv"] 8 | id = "1497d99c-2088-4ca4-87e1-4c1a182b78ec" 9 | } 10 | -------------------------------------------------------------------------------- /terramate.tm: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | terramate { 5 | config { 6 | experiments = ["toml-functions", "scripts", "targets"] 7 | run { 8 | env { 9 | PATH = "${terramate.root.path.fs.absolute}/bin${global.PS}${env.PATH}" 10 | NO_COLOR = "1" # needed for our printer tests 11 | } 12 | } 13 | 14 | git { 15 | check_untracked = false 16 | check_uncommitted = false 17 | check_remote = false 18 | } 19 | 20 | cloud { 21 | location = "eu" 22 | organization = "terramate-tests" 23 | 24 | targets { 25 | enabled = true 26 | } 27 | } 28 | } 29 | } 30 | 31 | globals { 32 | # TODO(i4k): very brittle but works for now. 33 | PS = tm_fileexists("/etc/hosts") ? ":" : ";" 34 | } 35 | 36 | -------------------------------------------------------------------------------- /terramate_platform_overview_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/terramate-io/terramate/e89f1f44d6637ff39c04ab9c199e8a2919dc933c/terramate_platform_overview_dark.png -------------------------------------------------------------------------------- /terramate_platform_overview_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/terramate-io/terramate/e89f1f44d6637ff39c04ab9c199e8a2919dc933c/terramate_platform_overview_light.png -------------------------------------------------------------------------------- /test/assert.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package test 5 | 6 | import "testing" 7 | 8 | // AssertEqualSets checks if two sets contains the same elements 9 | // independent of order (handles slices as sets). 10 | func AssertEqualSets[T comparable](t *testing.T, got, want []T) { 11 | if len(got) != len(want) { 12 | t.Fatalf("got: %+v; want: %+v", got, want) 13 | } 14 | 15 | for _, w := range want { 16 | for i, g := range got { 17 | if g == w { 18 | got = append(got[:i], got[i+1:]...) 19 | break 20 | } 21 | } 22 | } 23 | 24 | if len(got) > 0 { 25 | t.Fatalf("unable to find %v from got inside wanted set %v", got, want) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /test/cloud/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "cloud" { 4 | content = <<-EOT 5 | package cloud // import "github.com/terramate-io/terramate/test/cloud" 6 | 7 | Package cloud provides testing helpers for the TMC cloud. 8 | 9 | func PutStack(t *testing.T, addr string, orgUUID cloud.UUID, st cloud.StackObject) 10 | EOT 11 | 12 | filename = "${path.module}/mock-cloud.ignore" 13 | } 14 | -------------------------------------------------------------------------------- /test/cloud/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package cloud provides testing helpers for the TMC cloud. 5 | package cloud 6 | -------------------------------------------------------------------------------- /test/cloud/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package cloud // import \"github.com/terramate-io/terramate/test/cloud\"" 6 | description = "package cloud // import \"github.com/terramate-io/terramate/test/cloud\"\n\nPackage cloud provides testing helpers for the TMC cloud.\n\nfunc PutStack(t *testing.T, addr string, orgUUID cloud.UUID, st cloud.StackObject)" 7 | tags = ["cloud", "golang", "test"] 8 | id = "7ea9aa1d-86ce-4209-85a5-cec41f413a39" 9 | } 10 | -------------------------------------------------------------------------------- /test/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package test 5 | 6 | import ( 7 | "path/filepath" 8 | 9 | "github.com/terramate-io/terramate/config" 10 | ) 11 | 12 | // FixupRangeOnAsserts fixes the range on all the given asserts. 13 | // It assumes the asserts where created with relative paths and will 14 | // join the relative path with the given dir to provide a final absolute path. 15 | func FixupRangeOnAsserts(dir string, asserts []config.Assert) { 16 | for i := range asserts { 17 | asserts[i].Range.Filename = filepath.Join(dir, asserts[i].Range.Filename) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /test/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package test provides testing routines reused throughout terramate code 5 | // base. 6 | package test 7 | -------------------------------------------------------------------------------- /test/errors/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "errors" { 4 | content = <<-EOT 5 | package errors // import "github.com/terramate-io/terramate/test/errors" 6 | 7 | Package errors provides useful assert functions for handling errors on tests 8 | 9 | func Assert(t *testing.T, err, target error, args ...interface{}) 10 | func AssertAsErrorsList(t *testing.T, err error) 11 | func AssertErrorList(t *testing.T, err error, targets []error) 12 | func AssertIsErrors(t *testing.T, err error, targets []error) 13 | func AssertIsKind(t *testing.T, err error, k errors.Kind) 14 | func AssertKind(t *testing.T, got, want error) 15 | EOT 16 | 17 | filename = "${path.module}/mock-errors.ignore" 18 | } 19 | -------------------------------------------------------------------------------- /test/errors/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package errors // import \"github.com/terramate-io/terramate/test/errors\"" 6 | description = "package errors // import \"github.com/terramate-io/terramate/test/errors\"\n\nPackage errors provides useful assert functions for handling errors on tests\n\nfunc Assert(t *testing.T, err, target error, args ...interface{})\nfunc AssertAsErrorsList(t *testing.T, err error)\nfunc AssertErrorList(t *testing.T, err error, targets []error)\nfunc AssertIsErrors(t *testing.T, err error, targets []error)\nfunc AssertIsKind(t *testing.T, err error, k errors.Kind)\nfunc AssertKind(t *testing.T, got, want error)" 7 | tags = ["errors", "golang", "test"] 8 | id = "1799cd5a-2c75-4fea-a381-18f31a7b0375" 9 | } 10 | -------------------------------------------------------------------------------- /test/exec.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package test 5 | 6 | import ( 7 | "os/exec" 8 | "testing" 9 | ) 10 | 11 | // LookPath is identical to exec.LookPath except it will 12 | // fail the test if the lookup fails 13 | func LookPath(t *testing.T, file string) string { 14 | t.Helper() 15 | 16 | path, err := exec.LookPath(file) 17 | if err != nil { 18 | t.Fatalf("exec.LookPath(%q) = %v", file, err) 19 | } 20 | return path 21 | } 22 | -------------------------------------------------------------------------------- /test/fs_js.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build js 5 | 6 | package test 7 | 8 | import ( 9 | "io/fs" 10 | ) 11 | 12 | func chmod(fname string, mode fs.FileMode) error { 13 | panic("`chmod` is not implemented for wasm") 14 | } 15 | -------------------------------------------------------------------------------- /test/fs_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build aix || android || darwin || dragonfly || freebsd || hurd || illumos || ios || linux || netbsd || openbsd || solaris 5 | 6 | package test 7 | 8 | import ( 9 | "io/fs" 10 | "os" 11 | ) 12 | 13 | // Chmod changes file permissions. 14 | func Chmod(fname string, mode fs.FileMode) error { 15 | return os.Chmod(fname, mode) 16 | } 17 | -------------------------------------------------------------------------------- /test/fs_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build windows 5 | 6 | package test 7 | 8 | import ( 9 | "io/fs" 10 | 11 | "github.com/hectane/go-acl" 12 | ) 13 | 14 | // Chmod changes file permissions. 15 | func Chmod(fname string, mode fs.FileMode) error { 16 | return acl.Chmod(fname, mode) 17 | } 18 | -------------------------------------------------------------------------------- /test/hclutils/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "hclutils" { 4 | content = <<-EOT 5 | package hclutils // import "github.com/terramate-io/terramate/test/hclutils" 6 | 7 | Package hclutils provides test utils related to hcl. 8 | 9 | func End(line, column, char int) hhcl.Pos 10 | func FixupFiledirOnErrorsFileRanges(dir string, errs []error) 11 | func Mkrange(fname string, start, end hhcl.Pos) hhcl.Range 12 | func Start(line, column, char int) hhcl.Pos 13 | EOT 14 | 15 | filename = "${path.module}/mock-hclutils.ignore" 16 | } 17 | -------------------------------------------------------------------------------- /test/hclutils/info/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "info" { 4 | content = <<-EOT 5 | package info // import "github.com/terramate-io/terramate/test/hclutils/info" 6 | 7 | Package info provides functions useful to create types like info.Range 8 | 9 | func FixRange(rootdir string, old info.Range) info.Range 10 | func FixRangesOnConfig(dir string, cfg hcl.Config) 11 | func Range(fname string, start, end hhcl.Pos) info.Range 12 | EOT 13 | 14 | filename = "${path.module}/mock-info.ignore" 15 | } 16 | -------------------------------------------------------------------------------- /test/hclutils/info/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package info // import \"github.com/terramate-io/terramate/test/hclutils/info\"" 6 | description = "package info // import \"github.com/terramate-io/terramate/test/hclutils/info\"\n\nPackage info provides functions useful to create types like info.Range\n\nfunc FixRange(rootdir string, old info.Range) info.Range\nfunc FixRangesOnConfig(dir string, cfg hcl.Config)\nfunc Range(fname string, start, end hhcl.Pos) info.Range" 7 | tags = ["golang", "hclutils", "info", "test"] 8 | id = "d997cacf-1b94-4315-a860-2ad654150d04" 9 | } 10 | -------------------------------------------------------------------------------- /test/hclutils/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package hclutils // import \"github.com/terramate-io/terramate/test/hclutils\"" 6 | description = "package hclutils // import \"github.com/terramate-io/terramate/test/hclutils\"\n\nPackage hclutils provides test utils related to hcl.\n\nfunc End(line, column, char int) hhcl.Pos\nfunc FixupFiledirOnErrorsFileRanges(dir string, errs []error)\nfunc Mkrange(fname string, start, end hhcl.Pos) hhcl.Range\nfunc Start(line, column, char int) hhcl.Pos" 7 | tags = ["golang", "hclutils", "test"] 8 | id = "a1229483-5d7c-4745-bfe9-55b2b0825852" 9 | } 10 | -------------------------------------------------------------------------------- /test/hclwrite/hclutils/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package hclutils provides useful functions to build HCL documents. 5 | // It is usually imported with . so building HCL documents can be done 6 | // very fluently and yet in a type safe manner. 7 | package hclutils 8 | -------------------------------------------------------------------------------- /test/ls/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "ls" { 4 | content = <<-EOT 5 | package ls // import "github.com/terramate-io/terramate/test/ls" 6 | 7 | Package ls provides test utilities used when testing the Terramate Language 8 | Server. 9 | 10 | func DefaultInitializeResult() lsp.InitializeResult 11 | type Editor struct{ ... } 12 | func NewEditor(t *testing.T, s sandbox.S, conn jsonrpc2.Conn) *Editor 13 | type Fixture struct{ ... } 14 | func Setup(t *testing.T, layout ...string) Fixture 15 | func SetupNoRootConfig(t *testing.T, layout ...string) Fixture 16 | EOT 17 | 18 | filename = "${path.module}/mock-ls.ignore" 19 | } 20 | -------------------------------------------------------------------------------- /test/ls/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package ls provides test utilities used when testing the Terramate Language Server. 5 | package ls 6 | -------------------------------------------------------------------------------- /test/ls/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package ls // import \"github.com/terramate-io/terramate/test/ls\"" 6 | description = "package ls // import \"github.com/terramate-io/terramate/test/ls\"\n\nPackage ls provides test utilities used when testing the Terramate Language\nServer.\n\nfunc DefaultInitializeResult() lsp.InitializeResult\ntype Editor struct{ ... }\n func NewEditor(t *testing.T, s sandbox.S, conn jsonrpc2.Conn) *Editor\ntype Fixture struct{ ... }\n func Setup(t *testing.T, layout ...string) Fixture\n func SetupNoRootConfig(t *testing.T, layout ...string) Fixture" 7 | tags = ["golang", "ls", "test"] 8 | id = "288082d0-0e81-4e03-9792-cfaa2055cef6" 9 | } 10 | -------------------------------------------------------------------------------- /test/sandbox/sandbox_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package sandbox_test 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/terramate-io/terramate/test/sandbox" 10 | ) 11 | 12 | func TestSandboxWithArbitraryRepoConfig(t *testing.T) { 13 | t.Parallel() 14 | const remote = "mineiros" 15 | const remoteBranch = "default" 16 | const localBranch = "trunk" 17 | 18 | s := sandbox.NewWithGitConfig(t, sandbox.GitConfig{ 19 | LocalBranchName: localBranch, 20 | DefaultRemoteName: remote, 21 | DefaultRemoteBranchName: remoteBranch, 22 | }) 23 | 24 | git := s.Git() 25 | git.RevParse(localBranch) 26 | git.RevParse(remote + "/" + remoteBranch) 27 | } 28 | -------------------------------------------------------------------------------- /test/tf.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package test 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/madlambda/spells/assert" 10 | "github.com/terramate-io/terramate/tf" 11 | ) 12 | 13 | // ParseSource calls [tf.ParseSource] failing the test if it fails. 14 | func ParseSource(t *testing.T, source string) tf.Source { 15 | t.Helper() 16 | 17 | modsrc, err := tf.ParseSource(source) 18 | assert.NoError(t, err) 19 | return modsrc 20 | } 21 | -------------------------------------------------------------------------------- /testdata/example-stack/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | id = "terramate-example-stack" 6 | name = "test-stacks" 7 | description = "Used in terramate tests" 8 | tags = [ 9 | "test", 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /testdata/testserver/generate-testserver-data.tm: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | generate_file "cloud.data.json" { 5 | lets { 6 | well_known = { 7 | required_version = "> 0.4.3" 8 | } 9 | } 10 | content = tm_jsonencode({ 11 | default_test_org = global.testserver.default_test_org 12 | orgs = global.testserver.orgs, 13 | users = global.testserver.users, 14 | well_known = let.well_known, 15 | apikeys = global.testserver.apikeys, 16 | }) 17 | } 18 | -------------------------------------------------------------------------------- /testdata/testserver/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "testserver" 6 | description = "testserver" 7 | id = "156eb962-5f1c-470b-862b-0845a82dba23" 8 | } 9 | -------------------------------------------------------------------------------- /testdata/testserver/test-cloud-apikeys.tm: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | # Define the apikeys of the testserver. 5 | 6 | globals "testserver" "apikeys" "some_key" { 7 | value = "tmco_mykey_checksum" 8 | } 9 | 10 | globals "testserver" "memberships" "terramate" { 11 | some_key = { 12 | role = "member" 13 | status = "active" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /testdata/testserver/test-cloud-users.tm: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | # Define the users and the organizations memberships in this file. 5 | 6 | # Users definition: 7 | # Each user MUST have an unique `user_uuid`. 8 | # Required fields: 9 | # - email 10 | # - user_uuid 11 | 12 | globals "testserver" "users" "batman" { 13 | display_name = "Batman" 14 | email = "batman@terramate.io" 15 | job_title = "Entrepreneur" 16 | user_uuid = "deadbeef-dead-dead-dead-deaddeadbeef" 17 | } 18 | 19 | # Membership definition: 20 | # Each attribute name MUST match the `testserver.users.`. 21 | # The membership fields `role` and `status` are required. 22 | 23 | globals "testserver" "memberships" "terramate" { 24 | batman = { 25 | role = "member" 26 | status = "active" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tf/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "tf" { 4 | content = <<-EOT 5 | package tf // import "github.com/terramate-io/terramate/tf" 6 | 7 | Package tf provides parsing and abstractions specific to Terraform. 8 | 9 | const ErrUnsupportedModSrc errors.Kind = "unsupported module source" ... 10 | const ErrHCLSyntax errors.Kind = "HCL syntax error" 11 | func IsStack(path string) (bool, error) 12 | type Module struct{ ... } 13 | func ParseModules(path string) ([]Module, error) 14 | type Source struct{ ... } 15 | func ParseSource(modsource string) (Source, error) 16 | EOT 17 | 18 | filename = "${path.module}/mock-tf.ignore" 19 | } 20 | -------------------------------------------------------------------------------- /tf/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package tf provides parsing and abstractions specific to Terraform. 5 | package tf 6 | -------------------------------------------------------------------------------- /tf/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package tf // import \"github.com/terramate-io/terramate/tf\"" 6 | description = "package tf // import \"github.com/terramate-io/terramate/tf\"\n\nPackage tf provides parsing and abstractions specific to Terraform.\n\nconst ErrUnsupportedModSrc errors.Kind = \"unsupported module source\" ...\nconst ErrHCLSyntax errors.Kind = \"HCL syntax error\"\nfunc IsStack(path string) (bool, error)\ntype Module struct{ ... }\n func ParseModules(path string) ([]Module, error)\ntype Source struct{ ... }\n func ParseSource(modsource string) (Source, error)" 7 | tags = ["golang", "tf"] 8 | id = "c5a8d204-0193-4beb-a0e5-28a0fbe798e3" 9 | } 10 | -------------------------------------------------------------------------------- /tg/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "tg" { 4 | content = <<-EOT 5 | package tg // import "github.com/terramate-io/terramate/tg" 6 | 7 | Package tg implements functions to deal with Terragrunt files. 8 | 9 | const ErrParsing errors.Kind = "parsing Terragrunt file" 10 | type Module struct{ ... } 11 | type Modules []*Module 12 | func ScanModules(rootdir string, dir project.Path, trackDependencies bool) (Modules, error) 13 | EOT 14 | 15 | filename = "${path.module}/mock-tg.ignore" 16 | } 17 | -------------------------------------------------------------------------------- /tg/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package tg implements functions to deal with Terragrunt files. 5 | package tg 6 | -------------------------------------------------------------------------------- /tg/logging_level_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package tg_test 5 | 6 | import "github.com/rs/zerolog" 7 | 8 | func init() { 9 | zerolog.SetGlobalLevel(zerolog.Disabled) 10 | } 11 | -------------------------------------------------------------------------------- /tg/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package tg // import \"github.com/terramate-io/terramate/tg\"" 6 | description = "package tg // import \"github.com/terramate-io/terramate/tg\"\n\nPackage tg implements functions to deal with Terragrunt files.\n\nconst ErrParsing errors.Kind = \"parsing Terragrunt file\"\ntype Module struct{ ... }\ntype Modules []*Module\n func ScanModules(rootdir string, dir project.Path, trackDependencies bool) (Modules, error)" 7 | tags = ["golang", "tg"] 8 | id = "84d2ad63-38a0-408f-9d11-3b95168d9484" 9 | } 10 | -------------------------------------------------------------------------------- /tg/tg_module_bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package tg_test 5 | 6 | import ( 7 | "testing" 8 | 9 | "github.com/terramate-io/terramate/project" 10 | 11 | "github.com/terramate-io/terramate/test/sandbox" 12 | "github.com/terramate-io/terramate/tg" 13 | ) 14 | 15 | func BenchmarkModuleDiscovery(b *testing.B) { 16 | // mimics the repository below for a real world scenario 17 | // https://github.com/terramate-io/terramate-terragrunt-infrastructure-live-example/ 18 | 19 | b.StopTimer() 20 | 21 | s := sandbox.NoGit(b, false) 22 | s.BuildTree(testInfraLayout()) 23 | 24 | b.StartTimer() 25 | for i := 0; i < b.N; i++ { 26 | _, err := tg.ScanModules(s.RootDir(), project.NewPath("/"), true) 27 | if err != nil { 28 | b.Fatal(err) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ui/tui/checkpoint_localhost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build localhostEndpoints 5 | 6 | package tui 7 | 8 | import "net/url" 9 | 10 | func defaultTelemetryEndpoint() url.URL { 11 | var u url.URL 12 | u.Scheme = "http" 13 | u.Host = "localhost:3000" 14 | u.Path = "/" 15 | return u 16 | } 17 | -------------------------------------------------------------------------------- /ui/tui/checkpoint_mineiros.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build !localhostEndpoints 5 | 6 | package tui 7 | 8 | import "net/url" 9 | 10 | func defaultTelemetryEndpoint() url.URL { 11 | var u url.URL 12 | u.Scheme = "https" 13 | u.Host = "checkpoint-api.mineiros.io" 14 | u.Path = "/" 15 | return u 16 | } 17 | -------------------------------------------------------------------------------- /ui/tui/cli_guesswidth.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build !unix 5 | 6 | package tui 7 | 8 | import "io" 9 | 10 | func guessWidth(_ io.Writer) int { 11 | return 80 12 | } 13 | -------------------------------------------------------------------------------- /ui/tui/cli_noprofiling.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build !profiler 5 | 6 | package tui 7 | 8 | func startProfiler(_ bool) {} 9 | func stopProfiler(_ bool) {} 10 | -------------------------------------------------------------------------------- /ui/tui/cli_profiling.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build profiler 5 | 6 | package tui 7 | 8 | import ( 9 | stdfmt "fmt" 10 | "os" 11 | "runtime/pprof" 12 | 13 | "github.com/terramate-io/terramate/printer" 14 | ) 15 | 16 | func startProfiler(enable bool) { 17 | if !enable { 18 | return 19 | } 20 | const defaultProfilerName = "terramate.prof" 21 | 22 | fname := os.Getenv("TM_TEST_PROFILING_PATH") 23 | if fname == "" { 24 | fname = defaultProfilerName 25 | } 26 | 27 | stdfmt.Printf("Creating CPU profile (%s)...\n", fname) 28 | 29 | f, err := os.Create(fname) 30 | if err != nil { 31 | printer.Stderr.Fatal(err) 32 | } 33 | err = pprof.StartCPUProfile(f) 34 | if err != nil { 35 | printer.Stderr.Fatal(err) 36 | } 37 | } 38 | 39 | func stopProfiler(enable bool) { 40 | if !enable { 41 | return 42 | } 43 | pprof.StopCPUProfile() 44 | } 45 | -------------------------------------------------------------------------------- /ui/tui/cli_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build aix || android || darwin || dragonfly || freebsd || hurd || illumos || ios || linux || netbsd || openbsd || solaris 5 | 6 | package tui 7 | 8 | import ( 9 | "os" 10 | "path/filepath" 11 | 12 | "github.com/terramate-io/terramate/errors" 13 | ) 14 | 15 | func userTerramateDir() (string, error) { 16 | homeDir, err := userHomeDir() 17 | if err != nil { 18 | return "", errors.E(err, "failed to discover the location of the local %s directory", terramateUserConfigDir) 19 | } 20 | return filepath.Join(homeDir, terramateUserConfigDir), nil 21 | } 22 | 23 | func userHomeDir() (string, error) { 24 | homeDir, err := os.UserHomeDir() 25 | if err != nil { 26 | return "", errors.E(err, "failed to retrieve the user's home directory") 27 | } 28 | return homeDir, nil 29 | } 30 | -------------------------------------------------------------------------------- /ui/tui/cli_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build windows 5 | 6 | package tui 7 | 8 | import ( 9 | "os" 10 | "path/filepath" 11 | 12 | "github.com/terramate-io/terramate/errors" 13 | "github.com/terramate-io/terramate/ui/tui/cliconfig" 14 | ) 15 | 16 | func userTerramateDir() (string, error) { 17 | appdata := os.Getenv(cliconfig.DirEnv) 18 | if appdata == "" { 19 | return "", errors.E("APPDATA not set") 20 | } 21 | return filepath.Join(appdata, terramateUserConfigDir), nil 22 | } 23 | -------------------------------------------------------------------------------- /ui/tui/cliauth/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "cliauth" { 4 | content = <<-EOT 5 | package auth // import "github.com/terramate-io/terramate/cmd/terramate/cli/tmcloud/auth" 6 | 7 | Package auth provides the helper functions for loading the Terramate Cloud 8 | credentials. 9 | 10 | const ErrIDPNeedConfirmation errors.Kind ... 11 | func CredentialFile(clicfg cliconfig.Config) string 12 | func GithubLogin(output out.O, tmcBaseURL string, clicfg cliconfig.Config) error 13 | func GoogleLogin(output out.O, clicfg cliconfig.Config) error 14 | type APIKey struct{ ... } 15 | type Credencial interface{ ... } 16 | func ProbingPrecedence(output out.O, client *cloud.Client, clicfg cliconfig.Config) []Credencial 17 | EOT 18 | 19 | filename = "${path.module}/mock-cliauth.ignore" 20 | } 21 | -------------------------------------------------------------------------------- /ui/tui/cliauth/cli_cloud.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package cliauth 5 | 6 | import "os" 7 | 8 | // EnvBaseURL returns the base URL for the TMC API. 9 | func EnvBaseURL() (string, bool) { 10 | if cloudHost := os.Getenv("TMC_API_HOST"); cloudHost != "" { 11 | return "https://" + cloudHost, true 12 | } 13 | if cloudURL := os.Getenv("TMC_API_URL"); cloudURL != "" { 14 | return cloudURL, true 15 | } 16 | return "", false 17 | } 18 | -------------------------------------------------------------------------------- /ui/tui/cliauth/cloud_credential.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package cliauth 5 | 6 | import "net/http" 7 | 8 | type providerID string 9 | 10 | func (p providerID) String() string { 11 | switch p { 12 | case "google.com": 13 | return "Google" 14 | case "github.com": 15 | return "GitHub" 16 | default: 17 | return string(p) 18 | } 19 | } 20 | 21 | func applyJWTBasedCredentials(req *http.Request, cred Credential) error { 22 | token, err := cred.Token() 23 | if err != nil { 24 | return err 25 | } 26 | req.Header.Set("Authorization", "Bearer "+token) 27 | return nil 28 | } 29 | 30 | func redactJWTBasedCredentials(req *http.Request) { 31 | req.Header.Set("Authorization", "Bearer REDACTED") 32 | } 33 | -------------------------------------------------------------------------------- /ui/tui/cliauth/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package cliauth provides the helper functions for loading the Terramate Cloud credentials. 5 | package cliauth 6 | -------------------------------------------------------------------------------- /ui/tui/cliauth/oidc_audience_default.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build defaultAudience 5 | 6 | package auth 7 | 8 | import "github.com/terramate-io/terramate/cloud" 9 | 10 | func oidcAudience(_ cloud.Region) string { 11 | return "" 12 | } 13 | -------------------------------------------------------------------------------- /ui/tui/cliauth/oidc_audience_terramate.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build !defaultAudience 5 | 6 | package cliauth 7 | 8 | import "github.com/terramate-io/terramate/cloud" 9 | 10 | func oidcAudience(region cloud.Region) string { 11 | return cloud.BaseDomain(region) 12 | } 13 | -------------------------------------------------------------------------------- /ui/tui/cliauth/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package auth // import \"github.com/terramate-io/terramate/cmd/terramate/cli/tmcloud/auth\"" 6 | description = "package auth // import \"github.com/terramate-io/terramate/cmd/terramate/cli/tmcloud/auth\"\n\nPackage auth provides the helper functions for loading the Terramate Cloud\ncredentials.\n\nconst ErrIDPNeedConfirmation errors.Kind ...\nfunc CredentialFile(clicfg cliconfig.Config) string\nfunc GithubLogin(output out.O, tmcBaseURL string, clicfg cliconfig.Config) error\nfunc GoogleLogin(output out.O, clicfg cliconfig.Config) error\ntype APIKey struct{ ... }\ntype Credencial interface{ ... }\n func ProbingPrecedence(output out.O, client *cloud.Client, clicfg cliconfig.Config) []Credencial" 7 | tags = ["auth", "cli", "cmd", "golang", "terramate", "tmcloud"] 8 | id = "a4b7b6ac-a1f3-4153-8a40-9a58b61a3741" 9 | } 10 | -------------------------------------------------------------------------------- /ui/tui/cliconfig/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "cliconfig" { 4 | content = <<-EOT 5 | package cliconfig // import "github.com/terramate-io/terramate/cmd/terramate/cli/cliconfig" 6 | 7 | Package cliconfig implements the parser and load of Terramate CLI Configuration 8 | files (.terramaterc and terramate.rc). 9 | 10 | const ErrInvalidAttributeType errors.Kind = "attribute with invalid type" ... 11 | const DirEnv = "HOME" 12 | const Filename = ".terramaterc" 13 | type Config struct{ ... } 14 | func Load() (cfg Config, err error) 15 | func LoadFrom(fname string) (Config, error) 16 | EOT 17 | 18 | filename = "${path.module}/mock-cliconfig.ignore" 19 | } 20 | -------------------------------------------------------------------------------- /ui/tui/cliconfig/cliconfig_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build aix || android || darwin || dragonfly || freebsd || hurd || illumos || ios || linux || netbsd || openbsd || solaris 5 | 6 | package cliconfig 7 | 8 | import ( 9 | "os/user" 10 | "path/filepath" 11 | ) 12 | 13 | // Filename is the name of the CLI configuration file. 14 | const Filename = ".terramaterc" 15 | 16 | // DirEnv is the environment variable used to define the config location. 17 | const DirEnv = "HOME" 18 | 19 | func configAbsPath() (string, bool) { 20 | usr, err := user.Current() 21 | if err != nil { 22 | return "", false 23 | } 24 | return filepath.Join(usr.HomeDir, Filename), true 25 | } 26 | -------------------------------------------------------------------------------- /ui/tui/cliconfig/cliconfig_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build windows 5 | 6 | package cliconfig 7 | 8 | import ( 9 | "os" 10 | "path/filepath" 11 | ) 12 | 13 | // Filename is the name of the CLI configuration file. 14 | const Filename = "terramate.rc" 15 | 16 | // DirEnv is the environment variable used to define the config location. 17 | const DirEnv = "APPDATA" 18 | 19 | func configAbsPath() (string, bool) { 20 | appdata := os.Getenv(DirEnv) 21 | if appdata == "" { 22 | return "", false 23 | } 24 | return filepath.Join(appdata, Filename), true 25 | } 26 | -------------------------------------------------------------------------------- /ui/tui/cliconfig/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package cliconfig implements the parser and load of Terramate CLI 5 | // Configuration files (.terramaterc and terramate.rc). 6 | package cliconfig 7 | -------------------------------------------------------------------------------- /ui/tui/cliconfig/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package cliconfig // import \"github.com/terramate-io/terramate/cmd/terramate/cli/cliconfig\"" 6 | description = "package cliconfig // import \"github.com/terramate-io/terramate/cmd/terramate/cli/cliconfig\"\n\nPackage cliconfig implements the parser and load of Terramate CLI Configuration\nfiles (.terramaterc and terramate.rc).\n\nconst ErrInvalidAttributeType errors.Kind = \"attribute with invalid type\" ...\nconst DirEnv = \"HOME\"\nconst Filename = \".terramaterc\"\ntype Config struct{ ... }\n func Load() (cfg Config, err error)\n func LoadFrom(fname string) (Config, error)" 7 | tags = ["cli", "cliconfig", "cmd", "golang", "terramate"] 8 | id = "ffda9adf-be7b-47fd-9558-a311bfb8c44c" 9 | } 10 | -------------------------------------------------------------------------------- /ui/tui/clitest/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "clitest" { 4 | content = <<-EOT 5 | package clitest // import "github.com/terramate-io/terramate/cmd/terramate/cli/clitest" 6 | 7 | Package clitest provides constants and errors kind reused by the cli 8 | implementation and the e2e test infrastructure. 9 | 10 | const CloudDisablingMessage = "disabling the cloud features" ... 11 | const ErrCloud errors.Kind = "unprocessable cloud feature" ... 12 | EOT 13 | 14 | filename = "${path.module}/mock-clitest.ignore" 15 | } 16 | -------------------------------------------------------------------------------- /ui/tui/clitest/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package clitest provides constants and errors kind reused by the cli implementation 5 | // and the e2e test infrastructure. 6 | package clitest 7 | -------------------------------------------------------------------------------- /ui/tui/clitest/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package clitest // import \"github.com/terramate-io/terramate/cmd/terramate/cli/clitest\"" 6 | description = "package clitest // import \"github.com/terramate-io/terramate/cmd/terramate/cli/clitest\"\n\nPackage clitest provides constants and errors kind reused by the cli\nimplementation and the e2e test infrastructure.\n\nconst CloudDisablingMessage = \"disabling the cloud features\" ...\nconst ErrCloud errors.Kind = \"unprocessable cloud feature\" ..." 7 | tags = ["cli", "clitest", "cmd", "golang", "terramate"] 8 | id = "5b536408-2561-4011-93e9-da47aa9656cf" 9 | } 10 | -------------------------------------------------------------------------------- /ui/tui/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2025 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package tui provides the Terminal User Interface (TUI) of the CLI. 5 | package tui 6 | -------------------------------------------------------------------------------- /ui/tui/out/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "out" { 4 | content = <<-EOT 5 | package out // import "github.com/terramate-io/terramate/cmd/terramate/cli/out" 6 | 7 | Package out provides output functionality, including verboseness level and 8 | normal/error messages support. 9 | 10 | type O struct{ ... } 11 | func New(verboseness int, stdout, stderr io.Writer) O 12 | EOT 13 | 14 | filename = "${path.module}/mock-out.ignore" 15 | } 16 | -------------------------------------------------------------------------------- /ui/tui/out/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package out // import \"github.com/terramate-io/terramate/cmd/terramate/cli/out\"" 6 | description = "package out // import \"github.com/terramate-io/terramate/cmd/terramate/cli/out\"\n\nPackage out provides output functionality, including verboseness level and\nnormal/error messages support.\n\ntype O struct{ ... }\n func New(verboseness int, stdout, stderr io.Writer) O" 7 | tags = ["cli", "cmd", "golang", "out", "terramate"] 8 | id = "1a00f5ed-e82f-4282-848e-ea9019bdc9e9" 9 | } 10 | -------------------------------------------------------------------------------- /ui/tui/telemetry/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package telemetry provides types and helpers for CLI telemetry. 5 | package telemetry 6 | -------------------------------------------------------------------------------- /ui/tui/telemetry/endpoint.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build !localhostEndpoints 5 | 6 | package telemetry 7 | 8 | import ( 9 | "net/url" 10 | ) 11 | 12 | // Endpoint returns the real telemetry endpoint. 13 | func Endpoint() url.URL { 14 | var u url.URL 15 | u.Scheme = "https" 16 | u.Host = "analytics.terramate.io" 17 | u.Path = "/" 18 | return u 19 | } 20 | -------------------------------------------------------------------------------- /ui/tui/telemetry/endpoint_localhost.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | //go:build localhostEndpoints 5 | 6 | package telemetry 7 | 8 | import ( 9 | "net/url" 10 | ) 11 | 12 | func Endpoint() url.URL { 13 | var u url.URL 14 | u.Scheme = "http" 15 | u.Host = "localhost:3000" 16 | u.Path = "/" 17 | return u 18 | } 19 | -------------------------------------------------------------------------------- /version.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | package terramate 5 | 6 | import ( 7 | _ "embed" 8 | "strings" 9 | ) 10 | 11 | //go:embed VERSION 12 | var version string 13 | 14 | // ErrVersion indicates failure when checking Terramate version. 15 | 16 | // Version of terramate. 17 | func Version() string { 18 | return strings.TrimSpace(version) 19 | } 20 | -------------------------------------------------------------------------------- /versions/_test_mock.tf: -------------------------------------------------------------------------------- 1 | // TERRAMATE: GENERATED AUTOMATICALLY DO NOT EDIT 2 | 3 | resource "local_file" "versions" { 4 | content = <<-EOT 5 | package versions // import "github.com/terramate-io/terramate/versions" 6 | 7 | Package versions provide helper functions for version constraint matching. 8 | 9 | const ErrCheck errors.Kind = "version check error" 10 | func Check(version string, constraint string, allowPrereleases bool) error 11 | func Match(version, constraint string, allowPrereleases bool) (bool, error) 12 | EOT 13 | 14 | filename = "${path.module}/mock-versions.ignore" 15 | } 16 | -------------------------------------------------------------------------------- /versions/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | // Package versions provide helper functions for version constraint matching. 5 | package versions 6 | -------------------------------------------------------------------------------- /versions/stack.tm.hcl: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Terramate GmbH 2 | // SPDX-License-Identifier: MPL-2.0 3 | 4 | stack { 5 | name = "package versions // import \"github.com/terramate-io/terramate/versions\"" 6 | description = "package versions // import \"github.com/terramate-io/terramate/versions\"\n\nPackage versions provide helper functions for version constraint matching.\n\nconst ErrCheck errors.Kind = \"version check error\"\nfunc Check(version string, constraint string, allowPrereleases bool) error\nfunc Match(version, constraint string, allowPrereleases bool) (bool, error)" 7 | tags = ["golang", "versions"] 8 | id = "a885a9ed-eb00-4f79-b342-c7239ebfb5bd" 9 | } 10 | --------------------------------------------------------------------------------