fleet/server/archtest
Victor Lyuboslavsky c88cc953fb
Refactor endpoint_utils for modularization (#36484)
Resolves #37192

Separating generic endpoint_utils middleware logic from domain-specific
business logic. New bounded contexts would share the generic logic and
implement their own domain-specific logic. The two approaches used in
this PR are:
- Use common `platform` types
- Use interfaces

In the next PR we will move `endpointer_utils`, `authzcheck` and
`ratelimit` into `platform` directory.

# Checklist for submitter

- [x] Added changes file

## Testing

- [x] Added/updated tests
- [x] QA'd all new/changed functionality manually



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
* Restructured internal error handling and context management to support
bounded context architecture.
* Improved error context collection and telemetry observability through
a provider-based mechanism.
* Decoupled licensing and authentication concerns into interfaces for
better modularity.

* **Chores**
* Updated internal package dependencies to align with new architectural
boundaries.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-12-31 09:12:00 -06:00
..
test_files Updated archtest to be more ergonomic (#37433) 2025-12-18 09:28:41 -06:00
archtest.go Refactor endpoint_utils for modularization (#36484) 2025-12-31 09:12:00 -06:00
archtest_test.go Updated archtest to be more ergonomic (#37433) 2025-12-18 09:28:41 -06:00
README.md Updated archtest to be more ergonomic (#37433) 2025-12-18 09:28:41 -06:00

archtest

Architecture testing package for enforcing package dependency rules.

Usage

func TestMyPackageDependencies(t *testing.T) {
    archtest.NewPackageTest(t, "github.com/example/mypackage/...").
        OnlyInclude(regexp.MustCompile(`^github\.com/example/`)).
        WithTests().
        ShouldNotDependOn("github.com/example/forbidden/...").
        IgnoreDeps("github.com/example/infra/...").
        Check()
}

Methods

Method Description
OnlyInclude(regex) Filter to only check packages matching the regex (for performance)
ShouldNotDependOn(pkgs...) Specify forbidden dependencies
IgnoreRecursively(pkgs...) Skip packages entirely (including their transitive deps); try not to use
IgnoreDeps(pkgs...) Allow packages but still check their transitive deps
WithTests() Include test imports from root packages only
WithTestsRecursively() Include test imports from all packages
IgnoreXTests(pkgs...) Ignore external test packages (_test suffix)
Check() Run the dependency check