Unverified Commit 64017c52 authored by Chris Kim's avatar Chris Kim Committed by GitHub

Define a Controllers and LeaderControllers on the server config (#3052)

Signed-off-by: 's avatarChris Kim <oats87g@gmail.com>
parent f6217608
......@@ -41,10 +41,17 @@ func Run(app *cli.Context) error {
if err := cmds.InitLogging(); err != nil {
return err
}
return run(app, &cmds.ServerConfig)
return run(app, &cmds.ServerConfig, server.CustomControllers{}, server.CustomControllers{})
}
func run(app *cli.Context, cfg *cmds.Server) error {
func RunWithControllers(app *cli.Context, leaderControllers server.CustomControllers, controllers server.CustomControllers) error {
if err := cmds.InitLogging(); err != nil {
return err
}
return run(app, &cmds.ServerConfig, leaderControllers, controllers)
}
func run(app *cli.Context, cfg *cmds.Server, leaderControllers server.CustomControllers, controllers server.CustomControllers) error {
var (
err error
)
......@@ -226,6 +233,9 @@ func run(app *cli.Context, cfg *cmds.Server) error {
serverConfig.StartupHooks = append(serverConfig.StartupHooks, cfg.StartupHooks...)
serverConfig.LeaderControllers = append(serverConfig.LeaderControllers, leaderControllers...)
serverConfig.Controllers = append(serverConfig.Controllers, controllers...)
// TLS config based on mozilla ssl-config generator
// https://ssl-config.mozilla.org/#server=golang&version=1.13.6&config=intermediate&guideline=5.4
// Need to disable the TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 Cipher for TLS1.2
......
......@@ -138,6 +138,12 @@ func runControllers(ctx context.Context, config *Config) error {
}
}
for _, controller := range config.Controllers {
if err := controller(ctx, sc); err != nil {
return errors.Wrap(err, "controller")
}
}
if err := sc.Start(ctx); err != nil {
return err
}
......@@ -146,6 +152,11 @@ func runControllers(ctx context.Context, config *Config) error {
if err := masterControllers(ctx, sc, config); err != nil {
panic(err)
}
for _, controller := range config.LeaderControllers {
if err := controller(ctx, sc); err != nil {
panic(errors.Wrap(err, "leader controller"))
}
}
if err := sc.Start(ctx); err != nil {
panic(err)
}
......
......@@ -7,10 +7,14 @@ import (
)
type Config struct {
DisableAgent bool
DisableServiceLB bool
ControlConfig config.Control
Rootless bool
SupervisorPort int
StartupHooks []func(context.Context, <-chan struct{}, string) error
DisableAgent bool
DisableServiceLB bool
ControlConfig config.Control
Rootless bool
SupervisorPort int
StartupHooks []func(context.Context, <-chan struct{}, string) error
LeaderControllers CustomControllers
Controllers CustomControllers
}
type CustomControllers []func(ctx context.Context, sc *Context) error
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment