Expose the function to generate tls.Config

We're looking to reuse this in Cortex to client side encrypt our
connections and not having this exposed is making us copy this entire
function.

Signed-off-by: Goutham Veeramachaneni <gouthamve@gmail.com>
This commit is contained in:
Goutham Veeramachaneni 2020-04-16 08:58:51 +01:00 committed by Johannes 'fish' Ziemke
parent b14168cf6a
commit bd0918f29a
1 changed files with 3 additions and 2 deletions

View File

@ -45,10 +45,11 @@ func getTLSConfig(configPath string) (*tls.Config, error) {
if err != nil {
return nil, err
}
return configToTLSConfig(&c.TLSConfig)
return ConfigToTLSConfig(&c.TLSConfig)
}
func configToTLSConfig(c *TLSStruct) (*tls.Config, error) {
// ConfigToTLSConfig generates the golang tls.Config from the TLSStruct config.
func ConfigToTLSConfig(c *TLSStruct) (*tls.Config, error) {
cfg := &tls.Config{}
if len(c.TLSCertPath) == 0 {
return nil, errors.New("missing TLSCertPath")