Skip to content

Commit 597278e

Browse files
committed
Merge branch 'release-2.7.3+k8s-1.31' into k0s-1-29
2 parents cb9a1fb + d0a2224 commit 597278e

File tree

206 files changed

+17614
-3384
lines changed

Some content is hidden

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

206 files changed

+17614
-3384
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
description:
3+
globs: "*.go,web/*.tsx,web/*.ts,web/*.js,web/*.jsx"
4+
alwaysApply: false
5+
---
6+
# Code Quality Checks
7+
8+
Essential code quality checks that must be run after making changes to ensure code standards.
9+
10+
## Quality Assurance Commands
11+
12+
### Web Changes
13+
When making changes to files in the `/web` directory:
14+
15+
```bash
16+
# Navigate to web directory
17+
cd web
18+
19+
# Run linting to check code quality
20+
npm run lint
21+
22+
# Run unit tests to ensure functionality
23+
npm run test:unit
24+
```
25+
26+
### Go Changes
27+
When making changes to Go files:
28+
29+
```bash
30+
# Format Go code to ensure consistent style
31+
go fmt ./...
32+
33+
# Run Go vet to check for common issues
34+
make vet
35+
36+
# Run unit tests
37+
make unit-tests
38+
39+
# Run integration tests
40+
make test-integration
41+
```
42+
43+
## Pre-commit Checklist
44+
45+
Before committing changes, ensure you have:
46+
47+
### For Web Changes
48+
- [ ] Ran `npm run lint` with no errors
49+
- [ ] Ran `npm run test:unit` with all tests passing
50+
- [ ] Verified TypeScript compilation with no errors
51+
- [ ] Checked for proper data-testid attributes in new components
52+
53+
### For Go Changes
54+
- [ ] Ran `go fmt ./...` to ensure consistent formatting
55+
- [ ] Ran `make vet` with no issues
56+
- [ ] Ran `make unit-tests` with all tests passing
57+
- [ ] Verified proper error handling and context wrapping
58+
- [ ] Ensured interfaces are used for external dependencies
59+
60+
## Continuous Integration
61+
62+
These checks are also run in CI/CD pipelines, but running them locally first:
63+
- Saves time by catching issues early
64+
- Provides faster feedback during development
65+
- Ensures consistent code quality across the team
66+
67+
## Error Resolution
68+
69+
If quality checks fail:
70+
- **Linting errors**: Fix the specific style/format issues indicated
71+
- **Test failures**: Debug and fix the failing tests
72+
- **Type errors**: Resolve TypeScript compilation issues
73+
- **Vet issues**: Address Go code quality problems
74+
75+
## Integration with Development Workflow
76+
77+
Make these checks part of your standard development workflow:
78+
1. Make code changes
79+
2. Run appropriate quality checks
80+
3. Fix any issues found
81+
82+
This ensures high code quality and reduces the likelihood of CI/CD pipeline failures.

.cursor/rules/go-best-practices.mdc

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,73 @@ Use the functional options pattern for component initialization. This is the sta
134134

135135
- **Error Logging**: Always log errors at the outermost caller (bottom of the stack). All the context from the trace should be included in the message wrapping.
136136
- **Discard Logger**: Use `logger.NewDiscardLogger()` for tests
137+
138+
## Function Organization and Ordering
139+
140+
### Function Ordering Principles
141+
142+
Organize functions within a file to maximize readability and maintainability:
143+
144+
- **Public Functions First**: Place exported (public) functions at the top of the file, as they are the primary interface for the package
145+
- **Similar Functions Together**: Group related functions together (e.g., all CRUD operations, all validation functions, all utility functions)
146+
- **Private Functions Last**: Place unexported (private) functions at the bottom of the file
147+
- **Constructor Functions**: Place constructor functions (e.g., `New*`) near the top, after any constants or type definitions
148+
149+
### Recommended Order
150+
151+
1. **Package declaration and imports**
152+
2. **Constants and type definitions**
153+
3. **Constructor functions** (`New*`)
154+
4. **Public interface methods** (if implementing an interface)
155+
5. **Public utility functions**
156+
6. **Public business logic functions**
157+
7. **Private helper functions**
158+
8. **Private utility functions**
159+
160+
### Example Structure
161+
162+
```go
163+
package example
164+
165+
import (
166+
// imports...
167+
)
168+
169+
const (
170+
// constants...
171+
)
172+
173+
type MyStruct struct {
174+
// fields...
175+
}
176+
177+
// Constructor
178+
func NewMyStruct() *MyStruct {
179+
// implementation...
180+
}
181+
182+
// Public interface methods
183+
func (m *MyStruct) PublicMethod() error {
184+
// implementation...
185+
}
186+
187+
// Public utility functions
188+
func ValidateInput(input string) error {
189+
// implementation...
190+
}
191+
192+
// Public business logic
193+
func (m *MyStruct) ProcessData() error {
194+
// implementation...
195+
}
196+
197+
// Private helper functions
198+
func (m *MyStruct) validateInternal() error {
199+
// implementation...
200+
}
201+
202+
// Private utility functions
203+
func helperFunction() {
204+
// implementation...
205+
}
206+
```

.cursor/rules/project-overview.mdc

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
---
2+
description:
3+
globs: "*.go,web/*.tsx,web/*.ts,web/*.js,web/*.jsx,*.md,*.yaml,*.yml"
4+
alwaysApply: true
5+
---
6+
# Embedded Cluster Project Overview
7+
8+
## Project Description
9+
10+
Embedded Cluster is a platform by Replicated that allows you to distribute a Kubernetes cluster and your application together as a single appliance. It simplifies enterprise software deployment by consolidating all components into a single binary that handles streamlined cluster installation without external dependencies.
11+
12+
The project bundles k0s (open source Kubernetes distribution) with applications, providing a complete Kubernetes distribution that can be installed and managed as a single unit.
13+
14+
## Technology Stack
15+
16+
### Core Technologies
17+
- **Go** - Primary language for backend, CLI, and operators
18+
- **TypeScript/React** - Frontend web UI with Vite build system
19+
- **Kubernetes (k0s)** - Foundation Kubernetes distribution
20+
- **Docker** - Container runtime and development environment
21+
22+
### Key Dependencies
23+
- **KOTS** - Application lifecycle management
24+
- **Velero** - Backup and disaster recovery
25+
- **OpenEBS** - Storage provisioner
26+
- **SeaweedFS** - Distributed object storage for HA air gap mode
27+
- **Helm** - Package management for Kubernetes applications
28+
29+
## Essential Build Commands
30+
31+
```bash
32+
# Create initial installation release
33+
make initial-release
34+
35+
# Create upgrade release
36+
make upgrade-release
37+
38+
# Set up development node
39+
make create-node0
40+
41+
# Build with TTL.sh integration
42+
make build-ttl.sh
43+
44+
# Run unit tests
45+
make unit-tests
46+
47+
# Run integration tests
48+
make test-integration
49+
50+
# Run end-to-end tests
51+
make e2e-tests
52+
53+
# Code linting
54+
make lint
55+
56+
# Go code quality checks
57+
make vet
58+
```
59+
60+
## Architecture Overview
61+
62+
### Core Design Patterns
63+
- **Functional Options Pattern** - Standard for component initialization
64+
- **Interface-Driven Design** - Behavior through interfaces for mocking/testing
65+
- **Dependency Injection** - Decoupled components with clean interfaces
66+
- **State Machine** - Enforces valid state transitions for installation workflows
67+
68+
### Key Components
69+
- **Single Binary Distribution** - All components consolidated for easy deployment
70+
- **Controller-Manager Pattern** - Controllers handle workflows, managers handle subdomains
71+
- **Air Gap Support** - Complete offline installation capability
72+
- **Custom Resource Definitions** - Installation, Config, KubernetesInstallation types
73+
74+
## Code Organization
75+
76+
### Primary Directories
77+
- **`/cmd/installer/`** - Main CLI application with installation, join, reset, and management commands
78+
- **`/cmd/local-artifact-mirror/`** - Local artifact mirror for air gap deployments
79+
- **`/cmd/buildtools/`** - Build utilities and tooling
80+
81+
### API & Backend
82+
- **`/api/`** - REST API server with controllers, handlers, and state management
83+
- Controllers for auth, console, kubernetes, and linux installation
84+
- Internal managers for domain-specific functionality
85+
- Swagger documentation generation
86+
87+
### Kubernetes Components
88+
- **`/operator/`** - Kubernetes operator for managing cluster lifecycle
89+
- **`/kinds/`** - Custom Resource Definitions (CRDs)
90+
- **`/pkg/`** - Shared libraries and utilities
91+
- Addons (admin console, operator, storage, registry, etc.)
92+
- Network utilities, configuration management
93+
- Helm client, Kubernetes utilities
94+
95+
### Frontend & Testing
96+
- **`/web/`** - React/TypeScript web UI with Tailwind CSS
97+
- **`/e2e/`** - End-to-end integration tests
98+
- **`/tests/`** - Unit and integration test suites
99+
- **`/dev/`** - Development environment setup and tooling
100+
101+
## Architecture Decisions
102+
103+
1. **Release Metadata Independence** - API doesn't depend on CLI embedded metadata
104+
2. **Kubernetes as Linux Subset** - Kubernetes installations are subset of Linux installations
105+
3. **Interface-Driven Design** - All components use interfaces for testability
106+
107+
## Key Custom Resources
108+
109+
The system uses several custom Kubernetes resources:
110+
- **Installation** - Tracks cluster and application upgrades
111+
- **Config** - Runtime configuration management
112+
- **ClusterConfig** - k0s configuration ingestion
113+
- **Plan** - Autopilot operator configuration for upgrades
114+
- **Chart** - Helm chart tracking and management
115+
116+
## Development Environment
117+
118+
### Requirements
119+
- macOS with Docker Desktop
120+
- Go 1.24.4+
121+
- Various CLI tools (helm, aws, kubectl, etc.)
122+
123+
### Development Flow
124+
1. Set environment variables for Replicated API access
125+
2. Create initial release with `make initial-release`
126+
3. Spin up development nodes with `make create-node0`
127+
4. Install using generated binary with license
128+
5. Access admin console at localhost:30000

0 commit comments

Comments
 (0)