Move disabled items to a const to keep more consistency

This also help when embedding k3s because we can programmitically know
all the components to disable.
pull/1693/head
Darren Shepherd 2020-04-27 09:45:51 -07:00
parent 0efe2af1a7
commit 8b8af94eb2
2 changed files with 8 additions and 2 deletions

View File

@ -6,6 +6,10 @@ import (
"github.com/urfave/cli"
)
const (
DisableItems = "coredns, servicelb, traefik, local-storage, metrics-server"
)
type Server struct {
ClusterCIDR string
AgentToken string
@ -194,7 +198,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
},
cli.StringSliceFlag{
Name: "disable",
Usage: "(components) Do not deploy packaged components and delete any deployed components (valid items: coredns, servicelb, traefik, local-storage, metrics-server)",
Usage: "(components) Do not deploy packaged components and delete any deployed components (valid items: " + DisableItems + ")",
},
cli.BoolFlag{
Name: "disable-scheduler",
@ -275,7 +279,7 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command {
FlannelFlag,
cli.StringSliceFlag{
Name: "no-deploy",
Usage: "(deprecated) Do not deploy packaged components (valid items: coredns, servicelb, traefik, local-storage, metrics-server)",
Usage: "(deprecated) Do not deploy packaged components (valid items: " + DisableItems + ")",
},
cli.StringFlag{
Name: "cluster-secret",

View File

@ -154,12 +154,14 @@ func run(app *cli.Context, cfg *cmds.Server) error {
serverConfig.ControlConfig.Skips = map[string]bool{}
for _, noDeploy := range app.StringSlice("no-deploy") {
for _, v := range strings.Split(noDeploy, ",") {
v = strings.TrimSpace(v)
serverConfig.ControlConfig.Skips[v] = true
}
}
serverConfig.ControlConfig.Disables = map[string]bool{}
for _, disable := range app.StringSlice("disable") {
for _, v := range strings.Split(disable, ",") {
v = strings.TrimSpace(v)
serverConfig.ControlConfig.Skips[v] = true
serverConfig.ControlConfig.Disables[v] = true
}