opensearch 계정이 없을 때 헤더 처리

This commit is contained in:
2025-09-10 10:58:38 +09:00
parent 892392466f
commit c652c2a311

View File

@ -328,13 +328,13 @@ func NewClient(ctx context.Context, cfg Config) (Client, error) {
indexPrefix = "ds-logs-" + indexPrefix
}
authHeader := fmt.Sprintf("Basic %s", base64.RawURLEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", cfg.Username, cfg.Password))))
bulkHeader := make(http.Header)
bulkHeader.Set("Authorization", authHeader)
singleHeader := make(http.Header)
singleHeader.Set("Authorization", authHeader)
if len(cfg.Username) > 0 && len(cfg.Password) > 0 {
authHeader := fmt.Sprintf("Basic %s", base64.RawURLEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", cfg.Username, cfg.Password))))
bulkHeader.Set("Authorization", authHeader)
singleHeader.Set("Authorization", authHeader)
}
out := Client{
Client: client,