Skip to content

Commit

Permalink
update cli context arg name
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Downs <[email protected]>
  • Loading branch information
briandowns authored and Craig Jellick committed Aug 29, 2020
1 parent 8b46489 commit 064a37e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
6 changes: 3 additions & 3 deletions pkg/cli/cmds/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion pkg/cli/cmds/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cli/cmds/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions pkg/cli/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
}
Expand Down
28 changes: 14 additions & 14 deletions pkg/rke2/rke2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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
}

Expand All @@ -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{})

Expand Down

0 comments on commit 064a37e

Please sign in to comment.