This repository was archived by the owner on Oct 7, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ type Config struct {
1919 User string
2020 Pwd string
2121 IgnoreCertificate bool
22+ Scheme string
2223 Index string
2324 IndexColumn string
2425 DocIDColumn string
@@ -59,11 +60,20 @@ func NewConfig() Config {
5960 ignoreCert = res
6061 }
6162 }
63+
64+ scheme := "http"
65+ if c := os .Getenv ("ELASTICSEARCH_SCHEME" ); c != "" {
66+ switch c {
67+ case "https" :
68+ scheme = c
69+ }
70+ }
6271 return Config {
6372 Host : os .Getenv ("ELASTICSEARCH_HOST" ),
6473 User : os .Getenv ("ELASTICSEARCH_USER" ),
6574 Pwd : os .Getenv ("ELASTICSEARCH_PASSWORD" ),
6675 IgnoreCertificate : ignoreCert ,
76+ Scheme : scheme ,
6777 Index : os .Getenv ("ES_INDEX" ),
6878 IndexColumn : os .Getenv ("ES_INDEX_COLUMN" ),
6979 DocIDColumn : os .Getenv ("ES_DOC_ID_COLUMN" ),
Original file line number Diff line number Diff line change @@ -40,7 +40,10 @@ func (d recordDatabase) GetClient() *elastic.Client {
4040 }
4141 opts := []elastic.ClientOptionFunc {elastic .SetURL (d .config .Host ), elastic .SetBasicAuth (d .config .User , d .config .Pwd )}
4242 if d .config .IgnoreCertificate {
43- opts = append (opts , elastic .SetScheme ("https" ), elastic .SetHttpClient (& http.Client {Transport : insecureTr }))
43+ opts = append (opts , elastic .SetHttpClient (& http.Client {Transport : insecureTr }))
44+ }
45+ if d .config .Scheme == "https" { // http is default
46+ elastic .SetScheme (d .config .Scheme )
4447 }
4548 client , err := elastic .NewClient (opts ... )
4649 if err != nil {
You can’t perform that action at this time.
0 commit comments