File tree Expand file tree Collapse file tree 5 files changed +62
-2
lines changed
cmd/registration-operator Expand file tree Collapse file tree 5 files changed +62
-2
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ func newNucleusCommand() *cobra.Command {
4848
4949 cmd .AddCommand (hub .NewHubOperatorCmd ())
5050 cmd .AddCommand (hub .NewHubManagerCmd ())
51+ cmd .AddCommand (hub .NewWebhookCmd ())
5152 cmd .AddCommand (spoke .NewKlusterletOperatorCmd ())
5253 cmd .AddCommand (spoke .NewKlusterletAgentCmd ())
5354
Original file line number Diff line number Diff line change 55
66 "github.com/spf13/cobra"
77 "k8s.io/utils/clock"
8+ ctrl "sigs.k8s.io/controller-runtime"
89
910 commonoptions "open-cluster-management.io/ocm/pkg/common/options"
1011 "open-cluster-management.io/ocm/pkg/operator/operators/clustermanager"
@@ -47,3 +48,24 @@ func NewHubManagerCmd() *cobra.Command {
4748 opts .AddFlags (flags )
4849 return cmd
4950}
51+
52+ func NewWebhookCmd () * cobra.Command {
53+ webhookOptions := commonoptions .NewWebhookOptions ()
54+ opts := hub .NewWebhookOptions ()
55+ cmd := & cobra.Command {
56+ Use : "webhook-server" ,
57+ Short : "Start the registration webhook server" ,
58+ RunE : func (c * cobra.Command , args []string ) error {
59+ if err := opts .SetupWebhookServer (webhookOptions ); err != nil {
60+ return err
61+ }
62+ return webhookOptions .RunWebhookServer (ctrl .SetupSignalHandler ())
63+ },
64+ }
65+
66+ flags := cmd .Flags ()
67+ opts .AddFlags (flags )
68+ webhookOptions .AddFlags (flags )
69+
70+ return cmd
71+ }
Original file line number Diff line number Diff line change 1+ package hub
2+
3+ import (
4+ "github.com/spf13/pflag"
5+
6+ commonoptions "open-cluster-management.io/ocm/pkg/common/options"
7+ registrationwebhook "open-cluster-management.io/ocm/pkg/registration/webhook"
8+ workwebhook "open-cluster-management.io/ocm/pkg/work/webhook"
9+ )
10+
11+ // Config contains the server (the webhook) cert and key.
12+ type WebhookOptions struct {
13+ workWebhookOptions * workwebhook.Options
14+ }
15+
16+ // NewWebhookOptions constructs a new set of default options for webhook.
17+ func NewWebhookOptions () * WebhookOptions {
18+ return & WebhookOptions {
19+ workWebhookOptions : workwebhook .NewOptions (),
20+ }
21+ }
22+
23+ func (c * WebhookOptions ) AddFlags (fs * pflag.FlagSet ) {
24+ c .workWebhookOptions .AddFlags (fs )
25+ }
26+
27+ func (c * WebhookOptions ) SetupWebhookServer (opts * commonoptions.WebhookOptions ) error {
28+ if err := registrationwebhook .SetupWebhookServer (opts ); err != nil {
29+ return err
30+ }
31+ if err := c .workWebhookOptions .SetupWebhookServer (opts ); err != nil {
32+ return err
33+ }
34+
35+ return nil
36+ }
Original file line number Diff line number Diff line change 11package webhook
22
3- import "github.com/spf13/pflag"
3+ import (
4+ "github.com/spf13/pflag"
5+ )
46
57// Config contains the server (the webhook) cert and key.
68type Options struct {
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package webhook
22
33import (
44 clientgoscheme "k8s.io/client-go/kubernetes/scheme"
5- _ "k8s.io/client-go/plugin/pkg/client/auth"
65
76 ocmfeature "open-cluster-management.io/api/feature"
87 workv1 "open-cluster-management.io/api/work/v1"
You can’t perform that action at this time.
0 commit comments