k0sproject / k0s

k0s - The Zero Friction Kubernetes
https://docs.k0sproject.io
Other
3.47k stars 354 forks source link

Context in structs #3518

Open jnummelin opened 11 months ago

jnummelin commented 11 months ago

Prompted by discussion in https://github.com/k0sproject/k0s/pull/3406#pullrequestreview-1617279953

We have few structs which uses Context in structs which is bit of a bad pattern.

Essentially we have the root signal aware context which is the root context for everything which we need to convey to all the components. We need to figure out a way to do that without storing the context in structs.

kke commented 11 months ago
github-actions[bot] commented 10 months ago

The issue is marked as stale since no activity has been recorded in 30 days

github-actions[bot] commented 9 months ago

The issue is marked as stale since no activity has been recorded in 30 days

github-actions[bot] commented 8 months ago

The issue is marked as stale since no activity has been recorded in 30 days

github-actions[bot] commented 7 months ago

The issue is marked as stale since no activity has been recorded in 30 days

github-actions[bot] commented 6 months ago

The issue is marked as stale since no activity has been recorded in 30 days

github-actions[bot] commented 5 months ago

The issue is marked as stale since no activity has been recorded in 30 days

github-actions[bot] commented 4 months ago

The issue is marked as stale since no activity has been recorded in 30 days

github-actions[bot] commented 3 months ago

The issue is marked as stale since no activity has been recorded in 30 days

github-actions[bot] commented 2 months ago

The issue is marked as stale since no activity has been recorded in 30 days

twz123 commented 2 months ago

There's also a linter for that:

diff --git a/.golangci.yml b/.golangci.yml
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -10,11 +10,12 @@ run:

 linters:
   enable:
-    - depguard  # Checks if package imports are in a list of acceptable packages
-    - errorlint # Find code that will cause problems with Go's error wrapping scheme
-    - gofmt     # Checks whether code was gofmt-ed
-    - goheader  # Checks is file headers matche a given pattern
-    - revive    # Stricter drop-in replacement for golint
+    - containedctx # Detects structs containing context.Context fields
+    - depguard     # Checks if package imports are in a list of acceptable packages
+    - errorlint    # Find code that will cause problems with Go's error wrapping scheme
+    - gofmt        # Checks whether code was gofmt-ed
+    - goheader     # Checks is file headers matche a given pattern
+    - revive       # Stricter drop-in replacement for golint

 linters-settings:
   depguard:
twz123 commented 2 months ago

The contexts in the autopilot structs may be harder to kill, as they are using this external cron library, which has some interfaces to be satisfied that can't be modified with an additional context parameter.

github-actions[bot] commented 1 month ago

The issue is marked as stale since no activity has been recorded in 30 days