From a0a09665d8500516b6382e17ec767b358b5f9f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Samin?= Date: Fri, 19 Jun 2020 16:44:08 +0200 Subject: [PATCH] feat(api): config to set timeout and tls config (#5270) --- engine/api/api.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/engine/api/api.go b/engine/api/api.go index 94bb1a9dd4..7f03b08ca2 100644 --- a/engine/api/api.go +++ b/engine/api/api.go @@ -81,6 +81,10 @@ type Configuration struct { Directories struct { Download string `toml:"download" default:"/var/lib/cds-engine" json:"download"` } `toml:"directories" json:"directories"` + InternalServiceMesh struct { + RequestSecondsTimeout int `toml:"requestSecondsTimeout" json:"requestSecondsTimeout" default:"60"` + InsecureSkipVerifyTLS bool `toml:"insecureSkipVerifyTLS" json:"insecureSkipVerifyTLS" default:"false"` + } `toml:"internalServiceMesh" json:"internalServiceMesh"` Auth struct { DefaultGroup string `toml:"defaultGroup" default:"" comment:"The default group is the group in which every new user will be granted at signup" json:"defaultGroup"` RSAPrivateKey string `toml:"rsaPrivateKey" default:"" comment:"The RSA Private Key used to sign and verify the JWT Tokens issued by the API \nThis is mandatory." json:"-"` @@ -404,6 +408,15 @@ func (a *API) Serve(ctx context.Context) error { return sdk.WrapError(err, "unable to initialize the JWT Layer") } + // Intialize service mesh httpclient + if a.Config.InternalServiceMesh.RequestSecondsTimeout == 0 { + a.Config.InternalServiceMesh.RequestSecondsTimeout = 60 + } + services.HTTPClient = cdsclient.NewHTTPClient( + time.Duration(a.Config.InternalServiceMesh.RequestSecondsTimeout)*time.Second, + a.Config.InternalServiceMesh.InsecureSkipVerifyTLS, + ) + // Initialize mail package log.Info(ctx, "Initializing mail driver...") mail.Init(a.Config.SMTP.User,