- Trigger: When modifying Kubernetes API definitions, struct fields, or deepcopy logic.
- Action:
- Run
make generateto updateDeepCopymethods. - Run
make manifeststo update CustomResourceDefinitions (CRDs).
- Run
- Scope: Interfaces defined within
github.com/AliyunContainerService/terway. - Tool: Use
mockeryto generate mock implementations.
- Scope: Hard-to-mock system interactions such as
oscalls,netlink,grpc, or file system operations. - Tool: Use
gomonkeyto patch functions or methods inline.
- Primary Framework: Use
sigs.k8s.io/controller-runtime/pkg/envtestto spin up a real API server environment.- Why: To ensure accurate behavior validation that
client/fakecannot provide.
- Why: To ensure accurate behavior validation that
- Discouraged: Avoid
sigs.k8s.io/controller-runtime/pkg/client/fakeunless the logic is trivial and stateless. - Constraints (Crucial):
- Do NOT manually set server-managed fields:
UID,ResourceVersion, orDeletionTimestamp. - To set
DeletionTimestamp, you must perform a clientDeleteoperation on the object.
- Do NOT manually set server-managed fields:
- Linting:
- Strict adherence to
.golangci.yml. Runmake lint-fixfor auto-fixes. - Run
make vetto verify build tags.
- Strict adherence to
- Test Execution:
- Run
make test-quickfor the standard suite (outputs test report and coverage tocoverage.txt).
- Run
- Trigger: When adding/removing imports.
- Action: Run
go mod tidy && go mod vendor. CI requires vendor files to be in sync.
- Naming:
[terway] <Title>or[component] <Title>. - Checklist: Format (
make fmt) -> Lint (make lint) -> Test (make quick-test).