Skip to content

Commit

Permalink
refactor: password
Browse files Browse the repository at this point in the history
  • Loading branch information
joker-star-l committed Aug 14, 2024
1 parent 0854933 commit c458550
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion exporter/dorisexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"errors"
"time"

"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/config/configretry"
"go.opentelemetry.io/collector/exporter/exporterhelper"
)
Expand All @@ -26,7 +27,7 @@ type Config struct {
// Username is the authentication username.
Username string `mapstructure:"username"`
// Password is the authentication password.
Password string `mapstructure:"password"`
Password configopaque.String `mapstructure:"password"`
// CreateSchema is whether databases and tables are created automatically.
CreateSchema bool `mapstructure:"create_schema"`
// MySQLEndpoint is the mysql protocol address to create the schema; ignored if create_schema is false.
Expand Down
4 changes: 2 additions & 2 deletions exporter/dorisexporter/exporter_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type commonExporter struct {
func newExporter(logger *zap.Logger, cfg *Config) (*commonExporter, error) {
client := &http.Client{
CheckRedirect: func(req *http.Request, via []*http.Request) error {
req.SetBasicAuth(cfg.Username, cfg.Password)
req.SetBasicAuth(cfg.Username, string(cfg.Password))
return nil
},
}
Expand Down Expand Up @@ -89,7 +89,7 @@ func streamLoadRequest(ctx context.Context, cfg *Config, table string, data []by
req.Header.Set("Expect", "100-continue")
req.Header.Set("strip_outer_array", "true")
req.Header.Set("timezone", cfg.TimeZone)
req.SetBasicAuth(cfg.Username, cfg.Password)
req.SetBasicAuth(cfg.Username, string(cfg.Password))

return req, nil
}
Expand Down
1 change: 1 addition & 0 deletions exporter/dorisexporter/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/internal/coreinternal v0.103.0
github.com/stretchr/testify v1.9.0
go.opentelemetry.io/collector/component v0.103.0
go.opentelemetry.io/collector/config/configopaque v1.10.0
go.opentelemetry.io/collector/config/configretry v0.103.0
go.opentelemetry.io/collector/confmap v0.103.0
go.opentelemetry.io/collector/exporter v0.103.0
Expand Down
2 changes: 2 additions & 0 deletions exporter/dorisexporter/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions exporter/dorisexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
doris:
endpoint: http://localhost:8030
database: otel
username: root
password:
username: admin
password: admin
table:
logs: otel_logs
traces: otel_traces
Expand Down

0 comments on commit c458550

Please sign in to comment.