-
Notifications
You must be signed in to change notification settings - Fork 2
Multi go module setup #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
26b2aa1
Add initial directory structure
rytswd b381bc9
Add separate modules for each handler domain
rytswd b228514
Add go.work to gitignore
rytswd 3c24a99
Update document to match new module structure
rytswd 60e4f3c
Update responsibility wording
rytswd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,6 @@ result-* | |
|
|
||
| # generic | ||
| dist/ | ||
|
|
||
| # Go | ||
| go.work | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,13 +5,13 @@ | |
| ## Development Environment | ||
|
|
||
| ### Language Configuration | ||
| - **Language**: Go 1.24+ | ||
| - **Build System**: Make for task orchestration, Go modules for dependencies | ||
| - **Project Structure**: Standard Kubebuilder layout - `api/`, `cmd/`, `internal/`, `config/` | ||
| - **Language**: Go 1.25+ | ||
| - **Build System**: Make for task orchestration, Go workspaces for multi-module management | ||
| - **Project Structure**: Multi-module workspace - `go.work`, `pkg/{module}/`, `cmd/`, `config/` | ||
| - **Linting**: golangci-lint (configured in `.golangci.yml`) | ||
|
|
||
| ### Required Tools | ||
| - **go**: 1.24 or higher | ||
| - **go**: 1.25 or higher (workspace support required) | ||
| - **kubectl**: Kubernetes CLI for cluster interaction | ||
| - **kind**: Local Kubernetes cluster for testing (or other local cluster) | ||
| - **kubebuilder**: Optional - for regenerating CRDs and scaffolding | ||
|
|
@@ -22,10 +22,14 @@ | |
| - **kustomize**: Included with kubectl 1.14+, used for manifest management | ||
|
|
||
| ### Dependency Management | ||
| - **Go Modules**: `go.mod` and `go.sum` for dependency tracking | ||
| - **Version Pinning**: Pin controller-runtime and client-go to compatible versions | ||
| - **Vendor Directory**: Not used - rely on module cache | ||
| - **Updating Dependencies**: Use `go get -u` carefully, test thoroughly after updates | ||
| - **Per-Module Dependencies**: Each module (`cluster-handler`, `data-handler`, `resource-handler`) has its own `go.mod` and `go.sum` | ||
| - **Version Pinning**: Pin controller-runtime and client-go to compatible versions in each module | ||
| - **Go Workspaces (Local Only)**: | ||
| - Create `go.work` locally for easier multi-module development: `go work init ./pkg/cluster-handler ./pkg/data-handler ./pkg/resource-handler` | ||
| - `go.work` is in `.gitignore` | ||
| - **IMPORTANT**: `go.work` MUST NOT be committed - committing it would break the build and cause artifacts to ignore pinned versions | ||
| - Workspaces simplify local development by allowing cross-module references without publishing | ||
| - **Updating Dependencies**: Update in each module separately with `go get -u`, test thoroughly after updates | ||
|
|
||
| ## Coding Standards | ||
|
|
||
|
|
@@ -64,15 +68,17 @@ Common markers: | |
|
|
||
| ### Testing Strategy | ||
|
|
||
| **Unit Tests** (internal/resources, internal/webhook): | ||
| **Unit Tests** (per module): | ||
| - Test pure resource builder functions with table-driven tests | ||
| - Mock nothing - builders are pure functions | ||
| - Focus on correct Kubernetes manifest generation | ||
| - Run tests in each module: `cd pkg/resource-handler && go test ./...` | ||
|
|
||
| **Integration Tests** (internal/controller): | ||
| **Integration Tests** (per module): | ||
| - Use `envtest` - provides real Kubernetes API without full cluster | ||
| - Test reconciliation loops end-to-end | ||
| - Verify resource creation, updates, and status updates | ||
| - Each module has its own integration tests scoped to its controllers | ||
|
|
||
| **Test Commands**: | ||
| ```bash | ||
|
|
@@ -145,12 +151,13 @@ make manifests | |
| make install | ||
| ``` | ||
|
|
||
| **Controller Changes** (`internal/controller/`): | ||
| - Run `make test` frequently during development | ||
| **Controller Changes** (`pkg/{module}/controller/`): | ||
| - Run tests in the specific module: `cd pkg/resource-handler && go test ./...` | ||
| - Integration tests catch reconciliation bugs early | ||
| - Use `make run` for quick iteration (no docker build needed) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realise that this line is unchanged - just pointing out that we should remember to create a Makefile with a |
||
| - Changes in one module don't require rebuilding others during local development | ||
|
|
||
| **Resource Builder Changes** (`internal/resources/`): | ||
| - Write/update table-driven tests first | ||
| - Run `make test` - very fast feedback loop | ||
| - Integration tests verify end-to-end behavior | ||
| **Module-Specific Development**: | ||
| - **Resource Handler** (`pkg/resource-handler`): Component reconcilers and resource builders | ||
| - **Cluster Handler** (`pkg/cluster-handler`): MultigresCluster orchestration logic | ||
| - **Data Handler** (`pkg/data-handler`): Cell management and data plane configuration | ||
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package multigrescluster | ||
|
|
||
| func Dummy() string { | ||
| return "dummy string from cluster-handler's multigrescluster controller" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module github.com/numtide/multigres-operator/pkg/cluster-handler | ||
|
|
||
| go 1.25.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package cell | ||
|
|
||
| func Dummy() string { | ||
| return "dummy string from data-handler's cell controller" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module github.com/numtide/multigres-operator/pkg/data-handler | ||
|
|
||
| go 1.25.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package multigateway | ||
|
|
||
| func Dummy() string { | ||
| return "dummy string from resource-handler's multigateway controller" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module github.com/numtide/multigres-operator/pkg/resource-handler | ||
|
|
||
| go 1.25.0 |
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.