From 064a37ee6325b77c1bda80936a718f2373ceabc5 Mon Sep 17 00:00:00 2001 From: Brian Downs Date: Fri, 28 Aug 2020 19:44:03 -0700 Subject: [PATCH] update cli context arg name Signed-off-by: Brian Downs --- pkg/cli/cmds/agent.go | 6 +++--- pkg/cli/cmds/root.go | 2 +- pkg/cli/cmds/server.go | 6 +++--- pkg/cli/defaults/defaults.go | 4 ++-- pkg/rke2/rke2.go | 28 ++++++++++++++-------------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/pkg/cli/cmds/agent.go b/pkg/cli/cmds/agent.go index 6f8789e5b1..ce3c2397b2 100644 --- a/pkg/cli/cmds/agent.go +++ b/pkg/cli/cmds/agent.go @@ -53,9 +53,9 @@ func NewAgentCommand() *cli.Command { return cmd } -func AgentRun(ctx *cli.Context) error { - if ctx.String("profile") == "" { +func AgentRun(clx *cli.Context) error { + if clx.String("profile") == "" { logrus.Warn("not running in CIS 1.5 mode") } - return rke2.Agent(ctx, config) + return rke2.Agent(clx, config) } diff --git a/pkg/cli/cmds/root.go b/pkg/cli/cmds/root.go index a87769df44..3b2aa4d3ee 100644 --- a/pkg/cli/cmds/root.go +++ b/pkg/cli/cmds/root.go @@ -141,7 +141,7 @@ func NewApp() *cli.App { }, } - app.Before = func(ctx *cli.Context) error { + app.Before = func(clx *cli.Context) error { if debug { logrus.SetLevel(logrus.DebugLevel) } diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index fb9090e5d7..fe1122e490 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -95,9 +95,9 @@ func NewServerCommand() *cli.Command { return cmd } -func ServerRun(ctx *cli.Context) error { - if ctx.String("profile") == "" { +func ServerRun(clx *cli.Context) error { + if clx.String("profile") == "" { logrus.Warn("not running in CIS 1.5 mode") } - return rke2.Server(ctx, config) + return rke2.Server(clx, config) } diff --git a/pkg/cli/defaults/defaults.go b/pkg/cli/defaults/defaults.go index d14f6933a9..9e3fa7f72a 100644 --- a/pkg/cli/defaults/defaults.go +++ b/pkg/cli/defaults/defaults.go @@ -12,7 +12,7 @@ import ( "google.golang.org/grpc/grpclog" ) -func Set(ctx *cli.Context, images images.Images, dataDir string) error { +func Set(clx *cli.Context, images images.Images, dataDir string) error { logsDir := filepath.Join(dataDir, "agent", "logs") if err := os.MkdirAll(logsDir, 0755); err != nil { return errors.Wrapf(err, "failed to create directory %s", logsDir) @@ -38,7 +38,7 @@ func Set(ctx *cli.Context, images images.Images, dataDir string) error { "alsologtostderr=false", "logtostderr=false", "log-file="+filepath.Join(logsDir, "kubelet.log")) - if ctx.String("profile") != "" { + if clx.String("profile") != "" { cmds.AgentConfig.ExtraKubeletArgs = append(cmds.AgentConfig.ExtraKubeletArgs, "protect-kernel-defaults=true") } diff --git a/pkg/rke2/rke2.go b/pkg/rke2/rke2.go index d83acc2a68..718d240715 100644 --- a/pkg/rke2/rke2.go +++ b/pkg/rke2/rke2.go @@ -26,35 +26,35 @@ type Config struct { CloudProviderConfig string } -func Server(ctx *cli.Context, cfg Config) error { - if err := setup(ctx, cfg); err != nil { +func Server(clx *cli.Context, cfg Config) error { + if err := setup(clx, cfg); err != nil { return err } - if err := ctx.Set("disable", cmds.DisableItems); err != nil { + if err := clx.Set("disable", cmds.DisableItems); err != nil { return err } - if err := ctx.Set("secrets-encryption", "true"); err != nil { + if err := clx.Set("secrets-encryption", "true"); err != nil { return err } cmds.ServerConfig.StartupHooks = append(cmds.ServerConfig.StartupHooks, - setPSPs(ctx), - setNetworkPolicies(ctx), + setPSPs(clx), + setNetworkPolicies(clx), ) - return server.Run(ctx) + return server.Run(clx) } -func Agent(ctx *cli.Context, cfg Config) error { - if err := setup(ctx, cfg); err != nil { +func Agent(clx *cli.Context, cfg Config) error { + if err := setup(clx, cfg); err != nil { return err } - return agent.Run(ctx) + return agent.Run(clx) } -func setup(ctx *cli.Context, cfg Config) error { +func setup(clx *cli.Context, cfg Config) error { var dataDir string - for _, f := range ctx.Command.Flags { + for _, f := range clx.Command.Flags { switch t := f.(type) { case *cli.StringFlag: if strings.Contains(t.Name, "data-dir") { @@ -64,7 +64,7 @@ func setup(ctx *cli.Context, cfg Config) error { } images := images.New(cfg.Repo) - if err := defaults.Set(ctx, images, dataDir); err != nil { + if err := defaults.Set(clx, images, dataDir); err != nil { return err } @@ -79,7 +79,7 @@ func setup(ctx *cli.Context, cfg Config) error { manifests := filepath.Join(dataDir, "agent", config.DefaultPodManifestPath) pullImages := filepath.Join(dataDir, "agent", "images") - cisMode := ctx.String("profile") != "" + cisMode := clx.String("profile") != "" managed.RegisterDriver(&etcd.ETCD{})