You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: pass config values from memory store to kots cli (#2440)
* Add API endpoint to set config values
* f
* f
* pass config values from store to kots install
* address conflicts
* removing comments
* fix dependency injection order and config values file generation
* use same yaml library in tests
* cleanup
* update api docs and cursor rules
* refactor
* refactor
* use appconfig store from controller to update config values
* cleanup
* cleanup
* update cursor rules
* fix lint
* Update api/README.md
Co-authored-by: Salah Al Saleh <sg.alsaleh@gmail.com>
* pass config values to infra manager install function
* remove config values file from disk after installation
* f
* f
* cleanup
* address feedback
* Update api/controllers/linux/install/infra.go
Co-authored-by: Salah Al Saleh <sg.alsaleh@gmail.com>
---------
Co-authored-by: Salah Aldeen Al Saleh <sg.alsaleh@gmail.com>
Copy file name to clipboardExpand all lines: .cursor/rules/go-best-practices.mdc
+15-6Lines changed: 15 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -31,11 +31,20 @@ Use the functional options pattern for component initialization. This is the sta
31
31
32
32
### Error Wrapping and Context
33
33
34
-
- **Wrap Errors**: Always add context when propagating errors using `fmt.Errorf("operation failed: %w", err)`
34
+
- **Wrap Errors**: Always add context when propagating errors using `fmt.Errorf("operation context: %w", err)`
35
35
- **Use %w verb for error wrapping**: Use `%w` instead of `%v` when wrapping errors to maintain the error chain
36
+
- **Avoid verbose prefixes**: Don't use "failed to" or "unable to" prefixes as they create repetitive error chains
36
37
```go
37
-
return fmt.Errorf("processing config: %w", err) // Good - contextual, no prefix
38
-
return fmt.Errorf("reading config file: %w", err) // Good - specific context
38
+
return fmt.Errorf("processing config: %w", err) // Good - concise context
39
+
return fmt.Errorf("reading config file: %w", err) // Good - specific context
40
+
return fmt.Errorf("failed to process config: %w", err) // Bad - verbose prefix
41
+
return fmt.Errorf("unable to read config file: %w", err) // Bad - verbose prefix
42
+
```
43
+
- **Use gerunds or nouns for context**: Describe the operation being performed
44
+
```go
45
+
return fmt.Errorf("creating directory: %w", err) // Good - gerund
46
+
return fmt.Errorf("config validation: %w", err) // Good - noun
47
+
return fmt.Errorf("installing component: %w", err) // Good - gerund
39
48
```
40
49
- **Preserve Original**: Store the original error for unwrapping when using custom error types
41
50
- **Meaningful Messages**: Error messages should be actionable and include relevant context without redundant prefixes
@@ -109,9 +118,9 @@ Use the functional options pattern for component initialization. This is the sta
109
118
- Always use defer for unlocking: `defer mu.Unlock()`
110
119
111
120
### Context Usage
112
-
- Pass `context.Context` as the first parameter to functions that may block or need cancellation
113
-
- Use `ctx context.Context` as the parameter name
114
-
- Don't store contexts in structs; pass them through function calls
121
+
- **Context parameter placement**: When added, use `ctx context.Context` as the first parameter
122
+
- **Only add context when it's actually used**: Don't add `context.Context` parameters unless the function will actually use it for cancellation, deadlines, or passing values
123
+
- **Don't store contexts in structs**: Pass them through function calls
Copy file name to clipboardExpand all lines: api/README.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -10,13 +10,13 @@ The root directory contains the main API setup files and request handlers.
10
10
### Subpackages
11
11
12
12
#### `/controllers`
13
-
Contains the business logic for different API endpoints. Each controller package focuses on a specific domain of functionality or workflow (e.g., authentication, console, install, upgrade, join, etc.) and implements the core business logic for that domain or workflow. Controllers can utilize multiple managers with each manager handling a specific subdomain of functionality.
13
+
Contains the business logic for different API endpoints. Each controller package focuses on a specific domain of functionality or workflow (e.g., authentication, console, install, upgrade, join, etc.) and implements the core business logic for that domain or workflow. Controllers can utilize multiple managers with each manager handling a specific subdomain of functionality. Controllers act as orchestrators that read from one manager and pass data to another - never inject managers into other managers.
14
14
15
15
#### `/internal`
16
16
Contains shared utilities and helper packages that provide common functionality used across different parts of the API. This includes both general-purpose utilities and domain-specific helpers.
17
17
18
18
#### `/internal/managers`
19
-
Each manager is responsible for a specific subdomain of functionality and provides a clean interface for controllers to interact with. For example, the Preflight Manager manages system requirement checks and validation.
19
+
Each manager is responsible for a specific subdomain of functionality and provides a clean interface for controllers to interact with. For example, the Preflight Manager manages system requirement checks and validation. Managers must remain independent with no cross-manager dependencies - data flows between managers through the controller, not directly between managers.
20
20
21
21
#### `/internal/statemachine`
22
22
The statemachine is used by controllers to capture workflow state and enforce valid transitions.
0 commit comments