Skip to content

Commit c8458a2

Browse files
authored
Add two controller flags to enable and configure the webhook server (#25)
Part of aws-controllers-k8s/community#835 Introduces two new controller flags: - `--enable-webhook-server` a boolean flag instructing whether to spin a webhook server or not. Default is `false` - `--webhook-server-addr` a string flag used to configure the webhook serving address. Default is `0.0.0.0:443` This patch also run golint against `pkg/config/config.go` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent d48e9e0 commit c8458a2

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

pkg/config/config.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ const (
3434
flagLogLevel = "log-level"
3535
flagResourceTags = "resource-tags"
3636
flagWatchNamespace = "watch-namespace"
37+
flagEnableWebhookServer = "enable-webhook-server"
38+
flagWebhookServerAddr = "webhook-server-addr"
3739
)
3840

3941
// Config contains configuration otpions for ACK service controllers
@@ -48,6 +50,8 @@ type Config struct {
4850
LogLevel string
4951
ResourceTags []string
5052
WatchNamespace string
53+
EnableWebhookServer bool
54+
WebhookServerAddr string
5155
}
5256

5357
// BindFlags defines CLI/runtime configuration options
@@ -62,6 +66,16 @@ func (cfg *Config) BindFlags() {
6266
"0.0.0.0:8080",
6367
"The address the metric endpoint binds to.",
6468
)
69+
flag.BoolVar(
70+
&cfg.EnableWebhookServer, flagEnableWebhookServer,
71+
false,
72+
"Enable webhook server for controller manager. ",
73+
)
74+
flag.StringVar(
75+
&cfg.WebhookServerAddr, flagWebhookServerAddr,
76+
"0.0.0.0:443",
77+
"The address the webhook endpoint binds to.",
78+
)
6579
flag.BoolVar(
6680
&cfg.EnableLeaderElection, flagEnableLeaderElection,
6781
false,
@@ -87,8 +101,8 @@ func (cfg *Config) BindFlags() {
87101
flag.StringVar(
88102
&cfg.EndpointURL, flagAWSEndpointURL,
89103
"",
90-
"The AWS endpoint URL the service controller will use to create its resources. This is an optional" +
91-
" flag that can be used to override the default behaviour of aws-sdk-go that constructs endpoint URLs" +
104+
"The AWS endpoint URL the service controller will use to create its resources. This is an optional"+
105+
" flag that can be used to override the default behaviour of aws-sdk-go that constructs endpoint URLs"+
92106
" automatically based on service and region",
93107
)
94108
flag.StringVar(
@@ -102,9 +116,9 @@ func (cfg *Config) BindFlags() {
102116
"Configures the ACK service controller to always set key/value pairs tags on resources that it manages.",
103117
)
104118
flag.StringVar(
105-
&cfg.WatchNamespace , flagWatchNamespace,
119+
&cfg.WatchNamespace, flagWatchNamespace,
106120
"",
107-
"Specific namespace the service controller will watch for object creation from CRD. "+
121+
"Specific namespace the service controller will watch for object creation from CRD. "+
108122
" By default it will listen to all namespaces",
109123
)
110124
}
@@ -143,5 +157,9 @@ func (cfg *Config) Validate() error {
143157
"https://docs.aws.amazon.com/general/latest/gr/aws-service-information.html for more details")
144158
}
145159
}
160+
161+
if cfg.EnableWebhookServer && cfg.WebhookServerAddr == "" {
162+
return errors.New("empty webhook server address")
163+
}
146164
return nil
147165
}

0 commit comments

Comments
 (0)