-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
traefik_dynamic_tls.go
48 lines (43 loc) · 992 Bytes
/
traefik_dynamic_tls.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"fmt"
"gopkg.in/yaml.v3"
)
/*
Create dynamic traefik tls config
*/
func createTraefikTlsFile() []byte {
type CertsStruct struct {
CertFile string `yaml:"certFile,omitempty"`
KeyFile string `yaml:"KeyFile,omitempty"`
}
type DefaultCertificateStruct struct {
DefaultCertificate CertsStruct `yaml:"defaultCertificate,omitempty"`
}
type DefaultStruct struct {
Default DefaultCertificateStruct `yaml:"default,omitempty"`
}
type StoresStruct struct {
Stores DefaultStruct `yaml:"stores,omitempty"`
}
type TlsStruct struct {
Tls StoresStruct `yaml:"tls,omitempty"`
}
tlsConfig := TlsStruct{
Tls: StoresStruct{
Stores: DefaultStruct{
Default: DefaultCertificateStruct{
DefaultCertificate: CertsStruct{
CertFile: "/certs/local.crt",
KeyFile: "/certs/local.key",
},
},
},
},
}
yamlData, err := yaml.Marshal(&tlsConfig)
if err != nil {
fmt.Printf("Error while Marshaling. %v", err)
}
return yamlData
}