Skip to content

Commit f4cfdbb

Browse files
authored
Merge branch 'main' into osterman/atmos-gists
2 parents 8103b57 + 2d6917c commit f4cfdbb

File tree

137 files changed

+17125
-2441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+17125
-2441
lines changed

CLAUDE.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,18 @@ ALWAYS use `cmd.NewTestKit(t)` for cmd tests. Auto-cleans RootCmd state (flags,
207207
- No coverage theater
208208
- Remove always-skipped tests
209209
- Use `errors.Is()` for error checking
210+
- **For aliasing/isolation tests, verify BOTH directions:** after a merge, mutate the result and confirm the original inputs are unchanged (result→src isolation); also mutate a source map before the merge and confirm the result is unaffected (src→result isolation).
211+
- **For slice-result tests, assert element contents, not just length:** `require.Len` alone allows regressions that drop or corrupt contents. Assert at least the first and last element by value.
212+
- **Never use platform-specific binaries in tests** (e.g., `false`, `true`, `sh` on Unix): these don't exist on Windows. Use Go-native test helpers: subprocess via `os.Executable()` + `TestMain`, temp files with cross-platform scripts, or DI to inject a fake command runner.
213+
- **Safety guards must fail loudly:** any check that counts fixture files or validates test preconditions must use `require.Positive` (or equivalent) — never `if count > 0 { ... }` which silently disables the check when misconfigured.
214+
- **Use absolute paths for fixture counting:** any `filepath.WalkDir` or file-count assertion must use an already-resolved absolute path (not a relative one) to be CWD-independent.
215+
- **Add compile-time sentinels for schema field references in tests:** when a test uses a specific struct field (e.g., `schema.Provider{Kind: "azure"}`), add `var _ = schema.Provider{Kind: "azure"}` as a compile guard so a field rename immediately fails the build.
216+
- **Add prerequisite sub-tests for subprocess behavior:** when a test depends on implicit env propagation (e.g., `ComponentEnvList` reaching a subprocess), add an explicit sub-test that confirms the behavior before the main test runs.
217+
- **Contract vs. legacy behavior:** if a test says "matches mergo" (or any other library), add an opt-in cross-validation test behind a build tag (e.g., `//go:build compare_mergo`); otherwise state "defined contract" explicitly so it's clear the native implementation owns the behavior. Run cross-validation tests with: `go test -tags compare_mergo ./pkg/merge/... -run CompareMergo -v` (requires mergo v1.0.x installed).
218+
- **Include negative-path tests for recovery logic:** whenever a test verifies that a recovery/fallback triggers under condition X, add a corresponding test that verifies the recovery does NOT trigger when condition X is absent (e.g., mismatched workspace name).
219+
220+
### Follow-up Tracking (MANDATORY)
221+
When a PR defers work to a follow-up (e.g., migration, cleanup, refactor), **open a GitHub issue and link it by number** in the blog post, roadmap, and/or PR description before merging. Blog posts with "a follow-up issue will..." with no `#number` are incomplete — the work will never be tracked.
210222

211223
### Mock Generation (MANDATORY)
212224
Use `go.uber.org/mock/mockgen` with `//go:generate` directives. Never manual mocks.
@@ -362,6 +374,14 @@ Always ask first: "This will discard uncommitted changes. Proceed? [y/N]"
362374
### Test Coverage (MANDATORY)
363375
80% minimum (CodeCov enforced). All features need tests. `make testacc-coverage` for reports.
364376

377+
### Cyclomatic Complexity (MANDATORY)
378+
golangci-lint enforces `cyclop: max-complexity: 15` and `funlen: lines: 60, statements: 40`.
379+
When refactoring high-complexity functions:
380+
1. Extract blocks with clear single responsibilities into named helper functions.
381+
2. Use the pattern: `buildXSubcommandArgs`, `resolveX`, `checkX`, `assembleX`, `handleX`.
382+
3. Keep the orchestrator function as a flat linear pipeline of named steps (see `ExecuteTerraform`).
383+
4. Previously high-complexity functions: `ExecuteTerraform` (160→26, see `internal/exec/terraform.go`), `ExecuteDescribeStacks` (247→10), `processArgsAndFlags`.
384+
365385
### Environment Variables (MANDATORY)
366386
Use `viper.BindEnv("ATMOS_VAR", "ATMOS_VAR", "FALLBACK")` - ATMOS_ prefix required.
367387

@@ -383,6 +403,27 @@ Search `internal/exec/` and `pkg/` before implementing. Extend, don't duplicate.
383403
### Cross-Platform (MANDATORY)
384404
Linux/macOS/Windows compatible. Use SDKs over binaries. Use `filepath.Join()` instead of hardcoded path separators.
385405

406+
**Subprocess helpers in tests (cross-platform):**
407+
Instead of `exec.LookPath("false")` or other Unix-only binaries, use the test binary itself.
408+
**Important:** If your package already has a `TestMain`, add the env-gate check **inside the existing `TestMain`** — do not add a second `TestMain` function (Go does not allow two in the same package).
409+
410+
```go
411+
// In testmain_test.go — merge this check into the existing TestMain:
412+
func TestMain(m *testing.M) {
413+
// If _ATMOS_TEST_EXIT_ONE is set, exit immediately with code 1.
414+
// This lets tests use the test binary itself as a cross-platform "exit 1" command.
415+
if os.Getenv("_ATMOS_TEST_EXIT_ONE") == "1" { os.Exit(1) }
416+
os.Exit(m.Run())
417+
}
418+
// NOTE: If your package already defines TestMain, insert the _ATMOS_TEST_EXIT_ONE
419+
// check at the top of the existing function rather than copying the whole snippet.
420+
421+
// In the test itself:
422+
exePath, _ := os.Executable()
423+
info.Command = exePath
424+
info.ComponentEnvList = []string{"_ATMOS_TEST_EXIT_ONE=1"}
425+
```
426+
386427
**Path handling in tests:**
387428
- **NEVER use forward slash concatenation** like `tempDir + "/components/terraform/vpc"`
388429
- **ALWAYS use `filepath.Join()`** with separate arguments: `filepath.Join(tempDir, "components", "terraform", "vpc")`

NOTICE

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ APACHE 2.0 LICENSED DEPENDENCIES
145145
License: Apache-2.0
146146
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/ecr/v1.56.1/service/ecr/LICENSE.txt
147147

148+
- github.com/aws/aws-sdk-go-v2/service/eks
149+
License: Apache-2.0
150+
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/eks/v1.80.2/service/eks/LICENSE.txt
151+
148152
- github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding
149153
License: Apache-2.0
150154
URL: https://github.com/aws/aws-sdk-go-v2/blob/service/internal/accept-encoding/v1.13.7/service/internal/accept-encoding/LICENSE.txt
@@ -565,18 +569,42 @@ APACHE 2.0 LICENSED DEPENDENCIES
565569
License: Apache-2.0
566570
URL: https://github.com/go-yaml/yaml/blob/v2.4.0/LICENSE
567571

568-
- k8s.io/client-go/util/jsonpath
572+
- k8s.io/apimachinery/pkg
573+
License: Apache-2.0
574+
URL: https://github.com/kubernetes/apimachinery/blob/v0.35.2/LICENSE
575+
576+
- k8s.io/client-go
569577
License: Apache-2.0
570578
URL: https://github.com/kubernetes/client-go/blob/v0.35.2/LICENSE
571579

572-
- k8s.io/utils/strings/slices
580+
- k8s.io/klog/v2
581+
License: Apache-2.0
582+
URL: https://github.com/kubernetes/klog/blob/v2.130.1/LICENSE
583+
584+
- k8s.io/kube-openapi/pkg/util
585+
License: Apache-2.0
586+
URL: https://github.com/kubernetes/kube-openapi/blob/589584f1c912/LICENSE
587+
588+
- k8s.io/utils
573589
License: Apache-2.0
574590
URL: https://github.com/kubernetes/utils/blob/b8788abfbbc2/LICENSE
575591

576592
- oras.land/oras-go/v2
577593
License: Apache-2.0
578594
URL: https://github.com/oras-project/oras-go/blob/v2.6.0/LICENSE
579595

596+
- sigs.k8s.io/json
597+
License: Apache-2.0
598+
URL: https://github.com/kubernetes-sigs/json/blob/2d320260d730/LICENSE
599+
600+
- sigs.k8s.io/randfill
601+
License: Apache-2.0
602+
URL: https://github.com/kubernetes-sigs/randfill/blob/v1.0.0/LICENSE
603+
604+
- sigs.k8s.io/structured-merge-diff/v6/value
605+
License: Apache-2.0
606+
URL: https://github.com/kubernetes-sigs/structured-merge-diff/blob/v6.3.0/LICENSE
607+
580608
- sigs.k8s.io/yaml
581609
License: Apache-2.0
582610
URL: https://github.com/kubernetes-sigs/yaml/blob/v1.6.0/LICENSE
@@ -850,6 +878,10 @@ BSD LICENSED DEPENDENCIES
850878
License: BSD-3-Clause
851879
URL: https://github.com/protocolbuffers/protobuf-go/blob/v1.36.11/LICENSE
852880

881+
- gopkg.in/inf.v0
882+
License: BSD-3-Clause
883+
URL: https://github.com/go-inf/inf/blob/v0.9.1/LICENSE
884+
853885
- gopkg.in/op/go-logging.v1
854886
License: BSD-3-Clause
855887
URL: https://github.com/op/go-logging/blob/b2cb9fa56473/LICENSE
@@ -862,10 +894,18 @@ BSD LICENSED DEPENDENCIES
862894
License: BSD-3-Clause
863895
URL: Unknown
864896

897+
- k8s.io/apimachinery/third_party/forked/golang/reflect
898+
License: BSD-3-Clause
899+
URL: https://github.com/kubernetes/apimachinery/blob/v0.35.2/third_party/forked/golang/LICENSE
900+
865901
- k8s.io/client-go/third_party/forked/golang/template
866902
License: BSD-3-Clause
867903
URL: https://github.com/kubernetes/client-go/blob/v0.35.2/third_party/forked/golang/LICENSE
868904

905+
- k8s.io/utils/internal/third_party/forked/golang/net
906+
License: BSD-3-Clause
907+
URL: https://github.com/kubernetes/utils/blob/b8788abfbbc2/internal/third_party/forked/golang/LICENSE
908+
869909
- modernc.org/memory
870910
License: BSD-3-Clause
871911
URL: https://gitlab.com/cznic/memory/blob/v1.11.0/LICENSE-GO
@@ -1300,6 +1340,10 @@ MIT LICENSED DEPENDENCIES
13001340
License: MIT
13011341
URL: https://github.com/forPelevin/gomoji/blob/v1.4.1/LICENSE
13021342

1343+
- github.com/fxamacker/cbor/v2
1344+
License: MIT
1345+
URL: https://github.com/fxamacker/cbor/blob/v2.9.0/LICENSE
1346+
13031347
- github.com/gabriel-vasile/mimetype
13041348
License: MIT
13051349
URL: https://github.com/gabriel-vasile/mimetype/blob/v1.4.13/LICENSE
@@ -1696,6 +1740,10 @@ MIT LICENSED DEPENDENCIES
16961740
License: MIT
16971741
URL: https://github.com/wlynxg/chardet/blob/v1.0.4/LICENSE
16981742

1743+
- github.com/x448/float16
1744+
License: MIT
1745+
URL: https://github.com/x448/float16/blob/v0.8.4/LICENSE
1746+
16991747
- github.com/xo/terminfo
17001748
License: MIT
17011749
URL: https://github.com/xo/terminfo/blob/abceb7e1c41e/LICENSE

0 commit comments

Comments
 (0)