Skip to content

Commit

Permalink
[receiver/jmx] Change the types of `Config.{Password,KeystorePassword…
Browse files Browse the repository at this point in the history
…,TruststorePassword}` to be `configopaque.String` (#23864)

**Description:**
Split out from: #17353

**Link to tracking Issue:**
#17273
  • Loading branch information
mackjmr committed Jul 19, 2023
1 parent e8ffc51 commit d715dab
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
20 changes: 20 additions & 0 deletions .chloggen/jmx-use-configopaque.yaml
Original file line number Diff line number Diff line change
@@ -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/jmx

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Change the types of `Config.{Password,KeystorePassword,TruststorePassword}` 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:
7 changes: 4 additions & 3 deletions receiver/jmxreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"strings"
"time"

"go.opentelemetry.io/collector/config/configopaque"
"go.opentelemetry.io/collector/exporter/exporterhelper"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand All @@ -34,17 +35,17 @@ type Config struct {
// The JMX username
Username string `mapstructure:"username"`
// The JMX password
Password string `mapstructure:"password"`
Password configopaque.String `mapstructure:"password"`
// The keystore path for SSL
KeystorePath string `mapstructure:"keystore_path"`
// The keystore password for SSL
KeystorePassword string `mapstructure:"keystore_password"`
KeystorePassword configopaque.String `mapstructure:"keystore_password"`
// The keystore type for SSL
KeystoreType string `mapstructure:"keystore_type"`
// The truststore path for SSL
TruststorePath string `mapstructure:"truststore_path"`
// The truststore password for SSL
TruststorePassword string `mapstructure:"truststore_password"`
TruststorePassword configopaque.String `mapstructure:"truststore_password"`
// The truststore type for SSL
TruststoreType string `mapstructure:"truststore_type"`
// The JMX remote profile. Should be one of:
Expand Down
2 changes: 1 addition & 1 deletion receiver/jmxreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/testcontainers/testcontainers-go v0.21.0
go.opentelemetry.io/collector/component v0.81.0
go.opentelemetry.io/collector/config/confignet v0.81.0
go.opentelemetry.io/collector/config/configopaque v0.81.0
go.opentelemetry.io/collector/confmap v0.81.0
go.opentelemetry.io/collector/consumer v0.81.0
go.opentelemetry.io/collector/exporter v0.81.0
Expand Down Expand Up @@ -76,7 +77,6 @@ require (
go.opentelemetry.io/collector/config/configcompression v0.81.0 // indirect
go.opentelemetry.io/collector/config/configgrpc v0.81.0 // indirect
go.opentelemetry.io/collector/config/confighttp v0.81.0 // indirect
go.opentelemetry.io/collector/config/configopaque v0.81.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.81.0 // indirect
go.opentelemetry.io/collector/config/configtls v0.81.0 // indirect
go.opentelemetry.io/collector/config/internal v0.81.0 // indirect
Expand Down
6 changes: 3 additions & 3 deletions receiver/jmxreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (jmx *jmxMetricReceiver) buildJMXMetricGathererConfig() (string, error) {
}

if jmx.config.Password != "" {
config["otel.jmx.password"] = jmx.config.Password
config["otel.jmx.password"] = string(jmx.config.Password)
}

if jmx.config.RemoteProfile != "" {
Expand All @@ -211,7 +211,7 @@ func (jmx *jmxMetricReceiver) buildJMXMetricGathererConfig() (string, error) {
config["javax.net.ssl.keyStore"] = jmx.config.KeystorePath
}
if jmx.config.KeystorePassword != "" {
config["javax.net.ssl.keyStorePassword"] = jmx.config.KeystorePassword
config["javax.net.ssl.keyStorePassword"] = string(jmx.config.KeystorePassword)
}
if jmx.config.KeystoreType != "" {
config["javax.net.ssl.keyStoreType"] = jmx.config.KeystoreType
Expand All @@ -220,7 +220,7 @@ func (jmx *jmxMetricReceiver) buildJMXMetricGathererConfig() (string, error) {
config["javax.net.ssl.trustStore"] = jmx.config.TruststorePath
}
if jmx.config.TruststorePassword != "" {
config["javax.net.ssl.trustStorePassword"] = jmx.config.TruststorePassword
config["javax.net.ssl.trustStorePassword"] = string(jmx.config.TruststorePassword)
}
if jmx.config.TruststoreType != "" {
config["javax.net.ssl.trustStoreType"] = jmx.config.TruststoreType
Expand Down

0 comments on commit d715dab

Please sign in to comment.