charmkeeper-terraform
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePlan:
- Find the terraform modules in the repository.
- Ensure each terraform module is following the implementation standards.
- Run the tests to ensure the modules work as expected.
计划:
- 在代码仓库中找到Terraform模块。
- 确保每个Terraform模块都符合实施标准。
- 运行测试以确保模块按预期工作。
Implementation standards
实施标准
-
Expected versions:
- : ~> 1.12
terraform - : ~> 1.0
juju provider
-
The module should only have a "model_uuid" variable, no "model" variable.
-
Lint terraform modules withand
terraform fmt --recursive(fix the errors and the warnings).tflint --recursive
-
预期版本:
- : ~> 1.12
terraform - : ~> 1.0
juju provider
-
模块应仅包含"model_uuid"变量,不得有"model"变量。
-
使用和
terraform fmt --recursive对Terraform模块进行代码检查(修复所有错误和警告)。tflint --recursive
Testing
测试
Writing terraform tests
编写Terraform测试
-
Thefolder should look like: https://github.com/canonical/platform-engineering-charm-template/tree/main/terraform/tests
terraform/tests-
There is afolder to configure the model. Follow the example from https://raw.githubusercontent.com/canonical/platform-engineering-charm-template/refs/heads/main/terraform/tests/setup/main.tf
setup -
There isfile. Follow the example of https://raw.githubusercontent.com/canonical/platform-engineering-charm-template/refs/heads/main/terraform/tests/main.tftest.hcl
main.tftest.hcl- Ensure that there is a renovate directive above each "revision" line.
-
After adapting the tests. There should not be afile.
terraform/tests/main.tf
-
-
文件夹的结构应参考:https://github.com/canonical/platform-engineering-charm-template/tree/main/terraform/tests
terraform/tests-
包含文件,可参考示例:https://raw.githubusercontent.com/canonical/platform-engineering-charm-template/refs/heads/main/terraform/tests/main.tftest.hcl
main.tftest.hcl- 确保在每一行"revision"上方都有Renovate指令。
-
适配测试后,不应存在文件。
terraform/tests/main.tf
Local testing
本地测试
The terraform tests should be run in a virtual machine named "charmkeeper".
If the machine doesn't exist, create it with: .
scripts/create-charmkeeper-vm.shIf not already done, mount the working directory folder in the machine with
bash
multipass mount --type native $PWD charmkeeper:/workdirFor each TERRAFORM_MODULE
bash
multipass exec charmkeeper -d /workdir/$TERRAFORM_MODULE -- terraform init
multipass exec charmkeeper -d /workdir/$TERRAFORM_MODULE -- terraform testTerraform测试应在名为"charmkeeper"的虚拟机中运行。
如果该虚拟机不存在,可通过以下命令创建:。
scripts/create-charmkeeper-vm.sh如果尚未挂载工作目录,可通过以下命令将其挂载到虚拟机中:
bash
multipass mount --type native $PWD charmkeeper:/workdir对于每个TERRAFORM_MODULE:
bash
multipass exec charmkeeper -d /workdir/$TERRAFORM_MODULE -- terraform init
multipass exec charmkeeper -d /workdir/$TERRAFORM_MODULE -- terraform testCI testing
CI测试
This workflow is the reference to use to implement or update CI tests: https://raw.githubusercontent.com/canonical/platform-engineering-charm-template/refs/heads/main/.github/workflows/test_terraform_modules.yaml
- Adapt the k8s-controller and lxd-controller value depending on the charm type.
- Adapt the to reflect where the modules are in this charm.
terraform-directories
以下工作流可作为实现或更新CI测试的参考:https://raw.githubusercontent.com/canonical/platform-engineering-charm-template/refs/heads/main/.github/workflows/test_terraform_modules.yaml
- 根据Charm类型调整k8s-controller和lxd-controller的值。
- 调整以反映当前Charm中模块的位置。
terraform-directories
Maintain
维护
Configuring renovate
配置Renovate
Configure renovate like https://raw.githubusercontent.com/canonical/platform-engineering-charm-template/refs/heads/main/renovate.json to
- Add a charmhub datasource and use it.
- Add a regex custom manager for revisions.
- Set ignorePath to an empty array to not exclude the tests/ folders of terraform.
参考以下配置文件设置Renovate:https://raw.githubusercontent.com/canonical/platform-engineering-charm-template/refs/heads/main/renovate.json,以实现:
- 添加并使用charmhub数据源。
- 为版本号添加正则自定义管理器。
- 将ignorePath设置为空数组,不排除Terraform的tests/文件夹。