Skip to content

Commit

Permalink
[chore] sanitize use of configopaque.String (open-telemetry#30304)
Browse files Browse the repository at this point in the history
**Description:**
Sanitize the use of configopaque.String ahead of its change to implement
fmt.Stringer.

**Link to tracking Issue:**
See open-telemetry/opentelemetry-collector#9214
  • Loading branch information
atoulme authored Jan 5, 2024
1 parent ec5fa31 commit b275884
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions exporter/logzioexporter/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ func getListenerURL(region string) string {
}

func generateEndpoint(cfg *Config) (string, error) {
defaultURL := fmt.Sprintf("%s/?token=%s", getListenerURL(""), cfg.Token)
defaultURL := fmt.Sprintf("%s/?token=%s", getListenerURL(""), string(cfg.Token))
switch {
case cfg.HTTPClientSettings.Endpoint != "":
return cfg.HTTPClientSettings.Endpoint, nil
case cfg.Region != "":
return fmt.Sprintf("%s/?token=%s", getListenerURL(cfg.Region), cfg.Token), nil
return fmt.Sprintf("%s/?token=%s", getListenerURL(cfg.Region), string(cfg.Token)), nil
case cfg.HTTPClientSettings.Endpoint == "" && cfg.Region == "":
return defaultURL, errors.New("failed to generate endpoint, Endpoint or Region must be set")
default:
Expand Down
2 changes: 1 addition & 1 deletion receiver/elasticsearchreceiver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func newElasticsearchClient(settings component.TelemetrySettings, c Config, h co

var authHeader string
if c.Username != "" && c.Password != "" {
userPass := fmt.Sprintf("%s:%s", c.Username, c.Password)
userPass := fmt.Sprintf("%s:%s", c.Username, string(c.Password))
authb64 := base64.StdEncoding.EncodeToString([]byte(userPass))
authHeader = fmt.Sprintf("Basic %s", authb64)
}
Expand Down
2 changes: 1 addition & 1 deletion receiver/saphanareceiver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func newSapHanaClient(cfg *Config, factory sapHanaConnectionFactory) client {
}

func (c *sapHanaClient) Connect(ctx context.Context) error {
connector, err := sapdriver.NewDSNConnector(fmt.Sprintf("hdb://%s:%s@%s", c.receiverConfig.Username, c.receiverConfig.Password, c.receiverConfig.TCPAddr.Endpoint))
connector, err := sapdriver.NewDSNConnector(fmt.Sprintf("hdb://%s:%s@%s", c.receiverConfig.Username, string(c.receiverConfig.Password), c.receiverConfig.TCPAddr.Endpoint))
if err != nil {
return fmt.Errorf("error generating DSN for SAP HANA connection: %w", err)
}
Expand Down

0 comments on commit b275884

Please sign in to comment.