Commit bd90f477
bd90f477e7b8Merged
Sviatoslav Dumchenko <[email protected]> · 2 years ago · 4 files · +1 added · ~3 modified
Description
Merge pull request #877 from helmwave/clictx
chore: refactor context funcs into separate package
Details
- Commit
- bd90f477e7b8
- Parent
- 9a50134f3775
- Merge parent
- afbf2c64f688
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.Context28-
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 strings32-
}33-
34-
ctx = context.WithValue(ctx, "cli", c) //nolint:staticcheck // same35-
36-
return ctx3724
}pkg/action/up.gomodifiedView file
Loading diff…
pkg/clictx/clictx.goaddedView file
Loading diff…
pkg/plan/up.gomodifiedView file
Loading diff…