mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
add ctx to hook, handle hook errors
Signed-off-by: Brian Downs <brian.downs@gmail.com>
This commit is contained in:
parent
fa2c1422b3
commit
324bb55986
@ -1,6 +1,8 @@
|
||||
package cmds
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/k3s/pkg/daemons/config"
|
||||
"github.com/rancher/k3s/pkg/version"
|
||||
"github.com/rancher/spur/cli"
|
||||
@ -55,7 +57,7 @@ type Server struct {
|
||||
ClusterInit bool
|
||||
ClusterReset bool
|
||||
EncryptSecrets bool
|
||||
StartupHooks []func(config.Control) error
|
||||
StartupHooks []func(context.Context, config.Control) error
|
||||
}
|
||||
|
||||
var ServerConfig Server
|
||||
|
@ -61,7 +61,9 @@ func StartServer(ctx context.Context, config *Config) error {
|
||||
}
|
||||
|
||||
for _, hook := range config.StartupHooks {
|
||||
hook(config.ControlConfig)
|
||||
if err := hook(ctx, config.ControlConfig); err != nil {
|
||||
return errors.Wrap(err, "startup hook")
|
||||
}
|
||||
}
|
||||
|
||||
ip := net2.ParseIP(config.ControlConfig.BindAddress)
|
||||
|
@ -1,6 +1,8 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/rancher/k3s/pkg/daemons/config"
|
||||
)
|
||||
|
||||
@ -10,5 +12,5 @@ type Config struct {
|
||||
ControlConfig config.Control
|
||||
Rootless bool
|
||||
SupervisorPort int
|
||||
StartupHooks []func(config.Control) error
|
||||
StartupHooks []func(context.Context, config.Control) error
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user