infra: #1007 pin covers every module file (Astra R3)
OpenTofu also loads .tofu, .tofu.json and override files, so the pin now counts every top-level file except README.md, refuses symlinks and any directory but tests/, and the mutation test adds those cases.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
internal/provision/remote_host_module_test.go+21 −4
Intent
<task-notification> <task-id>b689pond9</task-id> <tool-use-id>toolu_01TSwuLQbudTPiKxYTyZQhU1</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/533b74b1-f52c-4095-800a-7716df14b9ab/tasks/b689pond9.output</output-file> <status>completed</status> <summary>Background command "Wait for copy review result" completed (exit code 0)</summary> </task-notification>
What app do you recommend? I don’t mind.
<task-notification> <task-id>b9q8gkyvl</task-id> <tool-use-id>toolu_01PGBJhp3Yq4jkhfTpmghGZv</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/533b74b1-f52c-4095-800a-7716df14b9ab/tasks/b9q8gkyvl.output</output-file> <status>completed</status> <summary>Background command "Run Astra review round 3" completed (exit code 0)</summary> </task-notification>
diff --git a/internal/provision/remote_host_module_test.go b/internal/provision/remote_host_module_test.go| index c03f796f1..d7f89415e 100644 |
| --- a/internal/provision/remote_host_module_test.go |
| +++ b/internal/provision/remote_host_module_test.go |
| @@ -56,16 +56,30 @@ func TestRegionRemoteHostGrantsNoDeploymentBucket(t *testing.T) { |
| if err != nil { |
| t.Fatal(err) |
| } |
| + // Every top-level entry counts, whatever its extension: OpenTofu also |
| + // loads .tofu, .tofu.json and *_override files. Dot-files are skipped |
| + // because OpenTofu ignores them too. Only tests/ may be a directory, |
| + // and nothing may be a symlink. |
| files := map[string]string{} |
| for _, e := range entries { |
| - if e.IsDir() { |
| + name := e.Name() |
| + switch { |
| + case strings.HasPrefix(name, "."): |
| + continue |
| + case e.Type()&os.ModeSymlink != 0: |
| + t.Errorf("region-remote-host/%s is a symlink; the module must hold only regular files (#1007)", name) |
| + continue |
| + case e.IsDir(): |
| + if name != "tests" { |
| + t.Errorf("region-remote-host/%s is an unexpected directory; review it, then update this guard (#1007)", name) |
| + } |
| continue |
| } |
| - b, err := os.ReadFile(filepath.Join(dir, e.Name())) |
| + b, err := os.ReadFile(filepath.Join(dir, name)) |
| if err != nil { |
| t.Fatal(err) |
| } |
| - files[e.Name()] = string(b) |
| + files[name] = string(b) |
| } |
| for _, problem := range remoteHostModuleProblems(files) { |
| t.Error(problem) |
| @@ -130,6 +144,9 @@ func TestRegionRemoteHostGuardCatchesRegrants(t *testing.T) { |
| }}, |
| {"new tf file", "extra.tf", func(string) string { return "# nothing yet\n" }}, |
| {"tf.json file", "extra.tf.json", func(string) string { return "{}" }}, |
| + {"tofu file", "extra.tofu", func(string) string { return "# nothing yet\n" }}, |
| + {"tofu.json file", "extra.tofu.json", func(string) string { return "{}" }}, |
| + {"override file", "main_override.tofu", func(string) string { return "# nothing yet\n" }}, |
| {"resource in variables.tf", "variables.tf", func(s string) string { |
| return s + "\nresource \"aws_iam_user_policy_attachment\" \"s3\" {\n user = \"x\"\n}\n" |
| }}, |
| @@ -153,7 +170,7 @@ func remoteHostModuleProblems(files map[string]string) []string { |
| var problems []string |
| var names []string |
| for name := range files { |
| - if strings.HasSuffix(name, ".tf") || strings.HasSuffix(name, ".tf.json") { |
| + if name != "README.md" { |
| names = append(names, name) |
| } |
| } |