diff --git a/README.md b/README.md index bc7faa9..f68d655 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,8 @@ EOF helm install external-dns-ionos bitnami/external-dns -f external-dns-ionos-values.yaml ``` +See [here](./cmd/webhook/init/configuration/configuration.go) for all available configuration options of webhook sidecar. + ## Verify the image resource integrity All official webhooks provided by IONOS are signed using [Cosign](https://docs.sigstore.dev/cosign/overview/). diff --git a/cmd/webhook/init/configuration/configuration.go b/cmd/webhook/init/configuration/configuration.go index 2768736..03f1cc1 100644 --- a/cmd/webhook/init/configuration/configuration.go +++ b/cmd/webhook/init/configuration/configuration.go @@ -1,19 +1,22 @@ package configuration import ( + "time" + "github.com/caarlos0/env/v8" log "github.com/sirupsen/logrus" ) // Config struct for configuration environmental variables type Config struct { - ServerHost string `env:"SERVER_HOST" envDefault:"localhost"` - ServerPort int `env:"SERVER_PORT" envDefault:"8888"` - - DomainFilter []string `env:"DOMAIN_FILTER" envDefault:""` - ExcludeDomains []string `env:"EXCLUDE_DOMAIN_FILTER" envDefault:""` - RegexDomainFilter string `env:"REGEXP_DOMAIN_FILTER" envDefault:""` - RegexDomainExclusion string `env:"REGEXP_DOMAIN_FILTER_EXCLUSION" envDefault:""` + ServerHost string `env:"SERVER_HOST" envDefault:"localhost"` + ServerPort int `env:"SERVER_PORT" envDefault:"8888"` + ServerReadTimeout time.Duration `env:"SERVER_READ_TIMEOUT"` + ServerWriteTimeout time.Duration `env:"SERVER_WRITE_TIMEOUT"` + DomainFilter []string `env:"DOMAIN_FILTER" envDefault:""` + ExcludeDomains []string `env:"EXCLUDE_DOMAIN_FILTER" envDefault:""` + RegexDomainFilter string `env:"REGEXP_DOMAIN_FILTER" envDefault:""` + RegexDomainExclusion string `env:"REGEXP_DOMAIN_FILTER_EXCLUSION" envDefault:""` } // Init sets up configuration by reading set environmental variables diff --git a/cmd/webhook/init/server/server.go b/cmd/webhook/init/server/server.go index b39094c..b4c157f 100644 --- a/cmd/webhook/init/server/server.go +++ b/cmd/webhook/init/server/server.go @@ -33,7 +33,7 @@ func Init(config configuration.Config, p *webhook.Webhook) *http.Server { r.Post("/records", p.ApplyChanges) r.Post("/adjustendpoints", p.AdjustEndpoints) - srv := createHTTPServer(fmt.Sprintf("%s:%d", config.ServerHost, config.ServerPort), r) + srv := createHTTPServer(fmt.Sprintf("%s:%d", config.ServerHost, config.ServerPort), r, config.ServerReadTimeout, config.ServerWriteTimeout) go func() { log.Infof("starting server on addr: '%s' ", srv.Addr) if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { @@ -43,14 +43,12 @@ func Init(config configuration.Config, p *webhook.Webhook) *http.Server { return srv } -func createHTTPServer(addr string, hand http.Handler) *http.Server { +func createHTTPServer(addr string, hand http.Handler, readTimeout, writeTimeout time.Duration) *http.Server { return &http.Server{ - ReadTimeout: 5 * time.Second, - WriteTimeout: 10 * time.Second, - IdleTimeout: 120 * time.Second, - ReadHeaderTimeout: 5 * time.Second, - Addr: addr, - Handler: hand, + ReadTimeout: readTimeout, + WriteTimeout: writeTimeout, + Addr: addr, + Handler: hand, } }