Skip to content

Commit

Permalink
[receiver/cloudfoundry] Change the type of Config.UAA.Password to b…
Browse files Browse the repository at this point in the history
…e `configopaque.String` (#23832)

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

**Link to tracking Issue:**
#17273
  • Loading branch information
mackjmr committed Jul 11, 2023
1 parent 676559a commit 71983a4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 8 deletions.
20 changes: 20 additions & 0 deletions .chloggen/cloudfoundry-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/cloudfoundry

# 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.UAA.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:
5 changes: 3 additions & 2 deletions receiver/cloudfoundryreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/url"

"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/config/configopaque"
)

type RLPGatewayConfig struct {
Expand All @@ -30,8 +31,8 @@ type LimitedHTTPClientSettings struct {

type UAAConfig struct {
LimitedHTTPClientSettings `mapstructure:",squash"`
Username string `mapstructure:"username"`
Password string `mapstructure:"password"`
Username string `mapstructure:"username"`
Password configopaque.String `mapstructure:"password"`
}

// Config defines configuration for Collectd receiver.
Expand Down
2 changes: 1 addition & 1 deletion receiver/cloudfoundryreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
go.opentelemetry.io/collector v0.81.0
go.opentelemetry.io/collector/component v0.81.0
go.opentelemetry.io/collector/config/confighttp v0.81.0
go.opentelemetry.io/collector/config/configopaque v0.81.0
go.opentelemetry.io/collector/config/configtls v0.81.0
go.opentelemetry.io/collector/confmap v0.81.0
go.opentelemetry.io/collector/consumer v0.81.0
Expand Down Expand Up @@ -44,7 +45,6 @@ require (
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector/config/configauth v0.81.0 // indirect
go.opentelemetry.io/collector/config/configcompression 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/internal v0.81.0 // indirect
go.opentelemetry.io/collector/exporter v0.81.0 // indirect
Expand Down
2 changes: 1 addition & 1 deletion receiver/cloudfoundryreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func newCloudFoundryReceiver(
}

func (cfr *cloudFoundryReceiver) Start(ctx context.Context, host component.Host) error {
tokenProvider, tokenErr := newUAATokenProvider(cfr.settings.Logger, cfr.config.UAA.LimitedHTTPClientSettings, cfr.config.UAA.Username, cfr.config.UAA.Password)
tokenProvider, tokenErr := newUAATokenProvider(cfr.settings.Logger, cfr.config.UAA.LimitedHTTPClientSettings, cfr.config.UAA.Username, string(cfr.config.UAA.Password))
if tokenErr != nil {
return fmt.Errorf("create cloud foundry UAA token provider: %w", tokenErr)
}
Expand Down
4 changes: 2 additions & 2 deletions receiver/cloudfoundryreceiver/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestValidStream(t *testing.T) {
zap.NewNop(),
cfg.UAA.LimitedHTTPClientSettings,
cfg.UAA.Username,
cfg.UAA.Password)
string(cfg.UAA.Password))

require.NoError(t, err)
require.NotNil(t, uaa)
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestInvalidStream(t *testing.T) {
zap.NewNop(),
cfg.UAA.LimitedHTTPClientSettings,
cfg.UAA.Username,
cfg.UAA.Password)
string(cfg.UAA.Password))

require.NoError(t, err)
require.NotNil(t, uaa)
Expand Down
4 changes: 2 additions & 2 deletions receiver/cloudfoundryreceiver/uaa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestValidAuthentication(t *testing.T) {
zap.NewNop(),
cfg.UAA.LimitedHTTPClientSettings,
cfg.UAA.Username,
cfg.UAA.Password)
string(cfg.UAA.Password))

require.NoError(t, err)
require.NotNil(t, uaa)
Expand All @@ -46,7 +46,7 @@ func TestInvalidAuthentication(t *testing.T) {
zap.NewNop(),
cfg.UAA.LimitedHTTPClientSettings,
cfg.UAA.Username,
cfg.UAA.Password)
string(cfg.UAA.Password))

require.EqualError(t, err, "client: missing url")
require.Nil(t, uaa)
Expand Down

0 comments on commit 71983a4

Please sign in to comment.