New 🌊 wave for @helm

Commit afbf2c64

afbf2c64f688Merged

Sviatoslav Dumchenko <[email protected]> · 2 years ago · 4 files · +1 added · ~3 modified

Description

chore: refactor context funcs into separate package

Details

Commit
afbf2c64f688
Parent
0758de9e6a81

pkg/action/interface.gomodifiedView file

@@ -3,7 +3,7 @@
33 import (
44 "context"
55
6- log "github.com/sirupsen/logrus"
6+ "github.com/helmwave/helmwave/pkg/clictx"
77 "github.com/urfave/cli/v2"
88 )
99
@@ -17,21 +17,8 @@
1717 // toCtx is a wrapper for urfave v2.
1818 func toCtx(a func(context.Context) error) func(c *cli.Context) error {
1919 return func(c *cli.Context) error {
20- ctx := getContextWithFlags(c)
20+ ctx := clictx.CLIContextToContext(c)
2121
2222 return a(ctx)
2323 }
24-}
25-
26-func getContextWithFlags(c *cli.Context) context.Context {
27- ctx := c.Context
28- for _, flagName := range c.FlagNames() {
29- g := c.Value(flagName)
30- log.WithField("name", flagName).WithField("value", g).Trace("adding flag to action context.Context")
31- ctx = context.WithValue(ctx, flagName, g) //nolint:staticcheck // weird issue, we won't have any collisions with strings
32- }
33-
34- ctx = context.WithValue(ctx, "cli", c) //nolint:staticcheck // same
35-
36- return ctx
3724 }