Makes /cmd/cainjector/main more DRY
reuses util.ContextWithStopCh to create a context with cancel func Signed-off-by: irbekrm <irbekrm@gmail.com>
This commit is contained in:
parent
1abc7107ca
commit
34fd9e9fef
@ -10,6 +10,7 @@ go_library(
|
||||
deps = [
|
||||
"//cmd/cainjector/app:go_default_library",
|
||||
"//pkg/logs:go_default_library",
|
||||
"//pkg/util:go_default_library",
|
||||
"//pkg/util/cmd:go_default_library",
|
||||
"@io_k8s_sigs_controller_runtime//:go_default_library",
|
||||
],
|
||||
|
||||
@ -26,6 +26,7 @@ import (
|
||||
|
||||
"github.com/jetstack/cert-manager/cmd/cainjector/app"
|
||||
logf "github.com/jetstack/cert-manager/pkg/logs"
|
||||
"github.com/jetstack/cert-manager/pkg/util"
|
||||
utilcmd "github.com/jetstack/cert-manager/pkg/util/cmd"
|
||||
)
|
||||
|
||||
@ -37,12 +38,7 @@ func main() {
|
||||
// Set up signal handlers and a cancellable context which gets cancelled on
|
||||
// when either SIGINT or SIGTERM are received.
|
||||
stopCh := utilcmd.SetupSignalHandler()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
go func() {
|
||||
<-stopCh
|
||||
cancel()
|
||||
}()
|
||||
ctx := util.ContextWithStopCh(context.Background(), stopCh)
|
||||
|
||||
cmd := app.NewCommandStartInjectorController(ctx, os.Stdout, os.Stderr)
|
||||
cmd.Flags().AddGoFlagSet(flag.CommandLine)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user