Skip to content

Commit

Permalink
[receiver/pulsar] Change the types of Token and PrivateKey to be …
Browse files Browse the repository at this point in the history
…`configopaque.String` (#23894)

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

**Link to tracking Issue:** #17273
  • Loading branch information
mackjmr authored Jul 10, 2023
1 parent 4341e10 commit cd5c49b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
20 changes: 20 additions & 0 deletions .chloggen/pulsar-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/pulsar

# 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.Authentication.Token.Token` and `Config.Authentication.Athenz.PrivateKey` 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:
21 changes: 11 additions & 10 deletions receiver/pulsarreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/apache/pulsar-client-go/pulsar"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/configopaque"
)

type Config struct {
Expand Down Expand Up @@ -42,17 +43,17 @@ type TLS struct {
}

type Token struct {
Token string `mapstructure:"token"`
Token configopaque.String `mapstructure:"token"`
}

type Athenz struct {
ProviderDomain string `mapstructure:"provider_domain"`
TenantDomain string `mapstructure:"tenant_domain"`
TenantService string `mapstructure:"tenant_service"`
PrivateKey string `mapstructure:"private_key"`
KeyID string `mapstructure:"key_id"`
PrincipalHeader string `mapstructure:"principal_header"`
ZtsURL string `mapstructure:"zts_url"`
ProviderDomain string `mapstructure:"provider_domain"`
TenantDomain string `mapstructure:"tenant_domain"`
TenantService string `mapstructure:"tenant_service"`
PrivateKey configopaque.String `mapstructure:"private_key"`
KeyID string `mapstructure:"key_id"`
PrincipalHeader string `mapstructure:"principal_header"`
ZtsURL string `mapstructure:"zts_url"`
}

type OAuth2 struct {
Expand All @@ -74,7 +75,7 @@ func (cfg *Config) auth() pulsar.Authentication {
return pulsar.NewAuthenticationTLS(authentication.TLS.CertFile, authentication.TLS.KeyFile)
}
if authentication.Token != nil {
return pulsar.NewAuthenticationToken(authentication.Token.Token)
return pulsar.NewAuthenticationToken(string(authentication.Token.Token))
}
if authentication.OAuth2 != nil {
return pulsar.NewAuthenticationOAuth2(map[string]string{
Expand All @@ -88,7 +89,7 @@ func (cfg *Config) auth() pulsar.Authentication {
"providerDomain": authentication.Athenz.ProviderDomain,
"tenantDomain": authentication.Athenz.TenantDomain,
"tenantService": authentication.Athenz.TenantService,
"privateKey": authentication.Athenz.PrivateKey,
"privateKey": string(authentication.Athenz.PrivateKey),
"keyId": authentication.Athenz.KeyID,
"principalHeader": authentication.Athenz.PrincipalHeader,
"ztsUrl": authentication.Athenz.ZtsURL,
Expand Down
1 change: 1 addition & 0 deletions receiver/pulsarreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/openzipkin/zipkin-go v0.4.1
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector/component 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/pdata v1.0.0-rcv0013
Expand Down
2 changes: 2 additions & 0 deletions receiver/pulsarreceiver/go.sum

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

0 comments on commit cd5c49b

Please sign in to comment.