Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ import (
)

const (
EnvFormat = "env"
JSONFormat = "json"
PropertiesFormat = "properties"
SecretFormat = "secret"
EnvFormat = "env"
JSONFormat = "json"
PropertiesFormat = "properties"
SecretFormat = "secret"
JavaPropertiesFormat = "java-kafka-properties"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just call it java-properties

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That did occur to me. But since .properties file are primarily used for java-related technologies, this name sounded redundant.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is java-kafka specific, so the name you've chosen seems reasonable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the verifying.

)

// Templates
Expand All @@ -28,6 +29,20 @@ var (
rhoas.service-account.oauthTokenUrl=%v
`)

templateJavaProperties = heredoc.Doc(`
## Generated by rhoas cli
sasl.mechanism=OAUTHBEARER
security.protocol=SASL_SSL

sasl.jaas.config=org.apache.kafka.common.security.oauthbearer.OAuthBearerLoginModule required \
clientId="%v" \
clientSecret="%v" ;

sasl.oauthbearer.token.endpoint.url=%v

sasl.login.callback.handler.class=org.apache.kafka.common.security.oauthbearer.secured.OAuthBearerLoginCallbackHandler
`)

templateEnv = heredoc.Doc(`
## Generated by rhoas cli
RHOAS_SERVICE_ACCOUNT_CLIENT_ID=%v
Expand Down Expand Up @@ -68,7 +83,7 @@ func GetDefaultPath(outputFormat string) (filePath string) {
switch outputFormat {
case EnvFormat:
filePath = ".env"
case PropertiesFormat:
case PropertiesFormat, JavaPropertiesFormat:
filePath = "credentials.properties"
case JSONFormat:
filePath = "credentials.json"
Expand Down Expand Up @@ -111,6 +126,8 @@ func getFileFormat(output string) (format string) {
format = templateJSON
case SecretFormat:
format = templateSecret
case JavaPropertiesFormat:
format = templateJavaProperties
}

return format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import (
)

var (
CredentialsOutputFormats = []string{credentials.EnvFormat, credentials.JSONFormat, credentials.PropertiesFormat, credentials.SecretFormat}
CredentialsOutputFormats = []string{credentials.EnvFormat, credentials.JSONFormat, credentials.PropertiesFormat, credentials.SecretFormat, credentials.JavaPropertiesFormat}
)