Files
Alex ShtinandGitHub 8e8f1b0f7c Remove license header from every file (#7689)
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.

## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
2025-05-01 18:50:21 -07:00

104 lines
3.4 KiB
Go

package client
import (
"errors"
"fmt"
"net/http"
"net/url"
"time"
"go.temporal.io/server/common/auth"
)
const (
// VisibilityAppName is used to find ES indexName for visibility
VisibilityAppName = "visibility"
SecondaryVisibilityAppName = "secondary_visibility"
)
// Config for connecting to Elasticsearch
type (
Config struct {
Version string `yaml:"version"`
URL url.URL `yaml:"url"`
URLs []url.URL `yaml:"urls"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Indices map[string]string `yaml:"indices"`
LogLevel string `yaml:"logLevel"`
AWSRequestSigning ESAWSRequestSigningConfig `yaml:"aws-request-signing"`
CloseIdleConnectionsInterval time.Duration `yaml:"closeIdleConnectionsInterval"`
EnableSniff bool `yaml:"enableSniff"`
EnableHealthcheck bool `yaml:"enableHealthcheck"`
TLS *auth.TLS `yaml:"tls"`
// httpClient is the awsHttpClient to be used for creating esClient
httpClient *http.Client
}
// ESAWSRequestSigningConfig represents configuration for signing ES requests to AWS
ESAWSRequestSigningConfig struct {
Enabled bool `yaml:"enabled"`
Region string `yaml:"region"`
// Possible options for CredentialProvider include:
// 1) static (fill out static Credential Provider)
// 2) environment
// a) AccessKeyID from either AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY environment variable
// b) SecretAccessKey from either AWS_SECRET_ACCESS_KEY or AWS_SECRET_KEY environment variable
// 3) aws-sdk-default
// a) Follows aws-go-sdk default credential resolution for session.NewSession
CredentialProvider string `yaml:"credentialProvider"`
Static ESAWSStaticCredentialProvider `yaml:"static"`
}
// ESAWSStaticCredentialProvider represents static AWS credentials
ESAWSStaticCredentialProvider struct {
AccessKeyID string `yaml:"accessKeyID"`
SecretAccessKey string `yaml:"secretAccessKey"`
// Token only required for temporary security credentials retrieved via STS. Otherwise, this is optional.
Token string `yaml:"token"`
}
)
// GetVisibilityIndex return visibility index name from Elasticsearch config or empty string if it is not defined.
func (cfg *Config) GetVisibilityIndex() string {
if cfg == nil {
// Empty string is be used as default index name when Elasticsearch is not configured.
return ""
}
return cfg.Indices[VisibilityAppName]
}
func (cfg *Config) GetSecondaryVisibilityIndex() string {
if cfg == nil {
return ""
}
return cfg.Indices[SecondaryVisibilityAppName]
}
func (cfg *Config) SetHttpClient(httpClient *http.Client) {
cfg.httpClient = httpClient
}
func (cfg *Config) GetHttpClient() *http.Client {
if cfg == nil {
return nil
}
return cfg.httpClient
}
func (cfg *Config) Validate() error {
if cfg == nil {
return errors.New("elasticsearch config: config not found")
}
if len(cfg.Indices) < 1 {
return errors.New("elasticsearch config: missing indices")
}
if cfg.Indices[VisibilityAppName] == "" {
return fmt.Errorf("elasticsearch config: indices configuration: missing %q key", VisibilityAppName)
}
return nil
}