diff --git a/.chloggen/mysql-use-configopaque.yaml b/.chloggen/mysql-use-configopaque.yaml new file mode 100755 index 000000000000..a962a3c63a1f --- /dev/null +++ b/.chloggen/mysql-use-configopaque.yaml @@ -0,0 +1,20 @@ +# Use this changelog template to create an entry for release notes. +# If your change doesn't affect end users, such as a test fix or a tooling change, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: receiver/mysql + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Change the type of `Config.Password` to be `configopaque.String` + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [17273] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/receiver/mysqlreceiver/client.go b/receiver/mysqlreceiver/client.go index db36ea63534c..53b72f44601a 100644 --- a/receiver/mysqlreceiver/client.go +++ b/receiver/mysqlreceiver/client.go @@ -166,7 +166,7 @@ var _ client = (*mySQLClient)(nil) func newMySQLClient(conf *Config) client { driverConf := mysql.Config{ User: conf.Username, - Passwd: conf.Password, + Passwd: string(conf.Password), Net: conf.Transport, Addr: conf.Endpoint, DBName: conf.Database, diff --git a/receiver/mysqlreceiver/config.go b/receiver/mysqlreceiver/config.go index ae1da13a7589..f4cbf0f0807b 100644 --- a/receiver/mysqlreceiver/config.go +++ b/receiver/mysqlreceiver/config.go @@ -7,6 +7,7 @@ import ( "time" "go.opentelemetry.io/collector/config/confignet" + "go.opentelemetry.io/collector/config/configopaque" "go.opentelemetry.io/collector/receiver/scraperhelper" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver/internal/metadata" @@ -20,10 +21,10 @@ const ( type Config struct { scraperhelper.ScraperControllerSettings `mapstructure:",squash"` - Username string `mapstructure:"username,omitempty"` - Password string `mapstructure:"password,omitempty"` - Database string `mapstructure:"database,omitempty"` - AllowNativePasswords bool `mapstructure:"allow_native_passwords,omitempty"` + Username string `mapstructure:"username,omitempty"` + Password configopaque.String `mapstructure:"password,omitempty"` + Database string `mapstructure:"database,omitempty"` + AllowNativePasswords bool `mapstructure:"allow_native_passwords,omitempty"` confignet.NetAddr `mapstructure:",squash"` MetricsBuilderConfig metadata.MetricsBuilderConfig `mapstructure:",squash"` StatementEvents StatementEventsConfig `mapstructure:"statement_events"` diff --git a/receiver/mysqlreceiver/go.mod b/receiver/mysqlreceiver/go.mod index 3676c4d33c72..555d00da7d0a 100644 --- a/receiver/mysqlreceiver/go.mod +++ b/receiver/mysqlreceiver/go.mod @@ -11,6 +11,7 @@ require ( github.com/testcontainers/testcontainers-go v0.21.0 go.opentelemetry.io/collector/component v0.80.1-0.20230629144634-c3f70bd1f8ea go.opentelemetry.io/collector/config/confignet v0.80.1-0.20230629144634-c3f70bd1f8ea + go.opentelemetry.io/collector/config/configopaque v0.80.1-0.20230629144634-c3f70bd1f8ea go.opentelemetry.io/collector/confmap v0.80.1-0.20230629144634-c3f70bd1f8ea go.opentelemetry.io/collector/consumer v0.80.1-0.20230629144634-c3f70bd1f8ea go.opentelemetry.io/collector/pdata v1.0.0-rcv0013.0.20230629144634-c3f70bd1f8ea diff --git a/receiver/mysqlreceiver/go.sum b/receiver/mysqlreceiver/go.sum index c8710c5423b5..21b8df0ac6ab 100644 --- a/receiver/mysqlreceiver/go.sum +++ b/receiver/mysqlreceiver/go.sum @@ -352,6 +352,8 @@ go.opentelemetry.io/collector/component v0.80.1-0.20230629144634-c3f70bd1f8ea h1 go.opentelemetry.io/collector/component v0.80.1-0.20230629144634-c3f70bd1f8ea/go.mod h1:90XoIDfewpei6xv5OjA2qBRMdjeZG4kuatCNtZ2342E= go.opentelemetry.io/collector/config/confignet v0.80.1-0.20230629144634-c3f70bd1f8ea h1:LortEJFE6fwOPbQbcEIRazMOHh+1sKeHf0BOSkSAZqk= go.opentelemetry.io/collector/config/confignet v0.80.1-0.20230629144634-c3f70bd1f8ea/go.mod h1:unOg7BZvpt6T5xsf+LyeOQvUhD8ld/2AbfOsmUZ/bPM= +go.opentelemetry.io/collector/config/configopaque v0.80.1-0.20230629144634-c3f70bd1f8ea h1:14awmqtjlsjo5PuV0Zt/e31vTAsU3CgwYA2eVV2fSL8= +go.opentelemetry.io/collector/config/configopaque v0.80.1-0.20230629144634-c3f70bd1f8ea/go.mod h1:pM1oy6gasukw3H6jAvc9Q9OtFaaY2IbfeuwCPAjOgXc= go.opentelemetry.io/collector/config/configtelemetry v0.80.1-0.20230629144634-c3f70bd1f8ea h1:rm+ojtY7gCRRBfY5DYKZrGm87jd5qLbvhRyVbFiC9/A= go.opentelemetry.io/collector/config/configtelemetry v0.80.1-0.20230629144634-c3f70bd1f8ea/go.mod h1:KEYQRiYJdx38iZkvcLKBZWH9fK4NeafxBwGRrRKMgyA= go.opentelemetry.io/collector/confmap v0.80.1-0.20230629144634-c3f70bd1f8ea h1:kcGEQM8KRx2H3Q/cdE9YXLTa3eMJHrA9fXQu3gFFLxw=