Skip to content

Commit 9f96d70

Browse files
update claude plans
Signed-off-by: ivan katliarchuk <[email protected]>
1 parent 4c15957 commit 9f96d70

File tree

5 files changed

+1079
-0
lines changed

5 files changed

+1079
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,4 @@ extras
189189
zsh/zshrc
190190
tools/claude/*
191191
!tools/claude/settings.json
192+
!tools/claude/plans/

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,12 @@ These scripts are meant to run only on OS X
9494

9595
- [Emoji: github](https://github.com/ikatyang/emoji-cheat-sheet)
9696

97+
### Commands
98+
99+
```sh
100+
git check-ignore -v tools/claude/plans/
101+
```
102+
97103
## #️⃣ TODO
98104

99105
- ✅ ZSH (zsh-config)
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Move createDomainFilter to Endpoint Package
2+
3+
## Overview
4+
Refactor `createDomainFilter` from `controller/execute.go` to the `endpoint` package, addressing the TODO comments in both the implementation and tests.
5+
6+
## Current State
7+
- **Function**: `controller/execute.go:466-475` with TODO: "move to endpoint package"
8+
- **Test**: `controller/execute_test.go:335-470` with TODO: "this test should live in endpoint package"
9+
- **Usage**: Single call site at `controller/execute.go:117`
10+
11+
## Implementation Strategy
12+
13+
### Architectural Constraint
14+
The `endpoint` package cannot import `externaldns.Config` due to dependency direction (`pkg/apis/externaldns``endpoint`). Solution: use individual parameters instead of config struct.
15+
16+
### New Function Design
17+
```go
18+
// In endpoint/domain_filter.go
19+
func NewDomainFilterFromConfig(
20+
domainFilter []string,
21+
excludeDomains []string,
22+
regexDomainFilter *regexp.Regexp,
23+
regexDomainExclusion *regexp.Regexp,
24+
) *DomainFilter
25+
```
26+
27+
This function will:
28+
- Be exported (public) - tests and providers can use it
29+
- Follow existing endpoint package patterns (simple parameters)
30+
- Preserve the logic: regex filters take precedence over plain filters
31+
- Match naming convention: similar to `NewDomainFilterWithExclusions`
32+
33+
## Implementation Steps
34+
35+
### 1. Add Factory Function to Endpoint Package
36+
**File**: `endpoint/domain_filter.go`
37+
**Location**: After line 96 (after `NewRegexDomainFilter`)
38+
39+
Add `NewDomainFilterFromConfig` with:
40+
- Full GoDoc explaining regex precedence behavior
41+
- Same logic as current `createDomainFilter`
42+
- ~15 lines of code
43+
44+
### 2. Migrate Tests to Endpoint Package
45+
**File**: `endpoint/domain_filter_test.go`
46+
**Location**: End of file (after line 1041)
47+
48+
Create `TestNewDomainFilterFromConfig` by:
49+
- Copying all 15 test cases from `controller/execute_test.go:335-470`
50+
- Adapting setup to use explicit parameters instead of `externaldns.Config`
51+
- Removing dependency on `externaldns` package
52+
- ~150 lines of test code
53+
54+
Example transformation:
55+
```go
56+
// Before (controller)
57+
cfg := &externaldns.Config{RegexDomainFilter: regexp.MustCompile(`example\.com`)}
58+
filter := createDomainFilter(cfg)
59+
60+
// After (endpoint)
61+
filter := NewDomainFilterFromConfig(nil, nil, regexp.MustCompile(`example\.com`), nil)
62+
```
63+
64+
### 3. Update Controller Call Site
65+
**File**: `controller/execute.go`
66+
67+
Replace line 117:
68+
```go
69+
domainFilter := endpoint.NewDomainFilterFromConfig(
70+
cfg.DomainFilter,
71+
cfg.ExcludeDomains,
72+
cfg.RegexDomainFilter,
73+
cfg.RegexDomainExclusion,
74+
)
75+
```
76+
77+
Delete lines 466-475 (old `createDomainFilter` function and TODOs)
78+
79+
### 4. Remove Old Test from Controller
80+
**File**: `controller/execute_test.go`
81+
82+
Delete lines 335-470 (`TestCreateDomainFilter` function)
83+
84+
### 5. Verify Implementation
85+
Run tests:
86+
```bash
87+
go test ./endpoint/... # New tests pass
88+
go test ./controller/... # Controller tests still pass
89+
go test ./... # Full suite passes
90+
```
91+
92+
## Files Modified
93+
1. ✏️ `endpoint/domain_filter.go` - Add new factory function
94+
2. ✏️ `endpoint/domain_filter_test.go` - Add 15 test cases
95+
3. ✏️ `controller/execute.go` - Update call site, remove old function
96+
4. ✏️ `controller/execute_test.go` - Remove old tests
97+
98+
## Success Criteria
99+
- [ ] All 15 test cases pass in new location
100+
- [ ] No circular import dependencies
101+
- [ ] Controller tests pass
102+
- [ ] No references to `createDomainFilter` remain
103+
- [ ] Domain filtering behavior unchanged

0 commit comments

Comments
 (0)