Let ks-apiserver optionally support authentication enabled and es without authentication enabled
Signed-off-by: Daniel Hu <farmer.hutao@outlook.com>
This commit is contained in:
@@ -33,9 +33,19 @@ type Elastic struct {
|
||||
index string
|
||||
}
|
||||
|
||||
func New(address string, index string) (*Elastic, error) {
|
||||
client, err := elasticsearch.NewClient(elasticsearch.Config{
|
||||
func New(address string, basicAuth bool, username, password, index string) (*Elastic, error) {
|
||||
var client *elasticsearch.Client
|
||||
var err error
|
||||
|
||||
if !basicAuth {
|
||||
username = ""
|
||||
password = ""
|
||||
}
|
||||
|
||||
client, err = elasticsearch.NewClient(elasticsearch.Config{
|
||||
Addresses: []string{address},
|
||||
Username: username,
|
||||
Password: password,
|
||||
})
|
||||
|
||||
return &Elastic{client: client, index: index}, err
|
||||
|
||||
Reference in New Issue
Block a user