Skip to content

Commit

Permalink
Do not deprecate the second auth method
Browse files Browse the repository at this point in the history
Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
  • Loading branch information
dttung2905 committed Mar 8, 2023
1 parent da56ae2 commit 76f6972
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
6 changes: 0 additions & 6 deletions pkg/scalers/kafka_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,7 @@ func parseKafkaAuthParams(config *ScalerConfig, meta *kafkaMetadata, logger logr
saslAuthType = ""
}

// FIXME: DEPRECATED, to be removed in version 2.12
if val, ok := config.AuthParams["sasl"]; ok {
logger.V(1).Info("Setting `sasl` in TriggerAuthentication is " +
"going to be deprecated in version 2.12. Please use `saslAuthType` in ScaleObject")
if saslAuthType != "" {
return errors.New("unable to set `saslAuthType` in ScaledObject and `sasl` in TriggerAuthentication together")
}
Expand Down Expand Up @@ -177,7 +174,6 @@ func parseKafkaAuthParams(config *ScalerConfig, meta *kafkaMetadata, logger logr
enableTLS = t
}

// FIXME: DEPRECATED, to be removed in version 2.12
if val, ok := config.AuthParams["tls"]; ok {
val = strings.TrimSpace(val)
if enableTLS {
Expand All @@ -191,8 +187,6 @@ func parseKafkaAuthParams(config *ScalerConfig, meta *kafkaMetadata, logger logr
default:
return fmt.Errorf("err incorrect TLS value given, got %s", val)
}
logger.V(1).Info("Setting `tls` in TriggerAuthentication is " +
"going to be deprecated in version 2.12. Please use `enableTls` in ScaleObject")
}

if enableTLS {
Expand Down
12 changes: 5 additions & 7 deletions pkg/scalers/kafka_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ type parseKafkaMetadataTestData struct {
excludePersistentLag bool
}

// FIXME: DEPRECATED, to be removed in version 2.12
type parseKafkaAuthParamsTestData struct {
authParams map[string]string
isError bool
enableTLS bool
}

type parseAuthParamsTestData struct {
// Testing the case where `enableTls` and `saslAuthType` are specified in ScaledObject
type parseAuthParamsTestDataSecondAuthMethod struct {
metadata map[string]string
authParams map[string]string
isError bool
Expand All @@ -53,7 +53,6 @@ var validKafkaMetadata = map[string]string{

// A complete valid authParams example for sasl, with username and passwd
var validWithAuthParams = map[string]string{
// FIXME: DEPRECATED, to be removed in version 2.12
"sasl": "plaintext",
"username": "admin",
"password": "admin",
Expand Down Expand Up @@ -115,7 +114,6 @@ var parseKafkaMetadataTestDataset = []parseKafkaMetadataTestData{
{map[string]string{"bootstrapServers": "foobar:9092", "consumerGroup": "my-group", "topic": "my-topic", "allowIdleConsumers": "true", "version": "1.0.0"}, false, 1, []string{"foobar:9092"}, "my-group", "my-topic", nil, offsetResetPolicy("latest"), true, false},
}

// FIXME: DEPRECATED, to be removed in version 2.12
var parseKafkaAuthParamsTestDataset = []parseKafkaAuthParamsTestData{
// success, SASL only
{map[string]string{"sasl": "plaintext", "username": "admin", "password": "admin"}, false, false},
Expand Down Expand Up @@ -168,7 +166,7 @@ var parseKafkaAuthParamsTestDataset = []parseKafkaAuthParamsTestData{
// failure, SASL + TLS, missing key
{map[string]string{"sasl": "plaintext", "username": "admin", "password": "admin", "tls": "enable", "ca": "caaa", "cert": "ceert"}, true, false},
}
var parseAuthParamsTestDataset = []parseAuthParamsTestData{
var parseAuthParamsTestDataset = []parseAuthParamsTestDataSecondAuthMethod{
// success, SASL plaintext
{map[string]string{"saslAuthType": "plaintext", "bootstrapServers": "foobar:9092", "consumerGroup": "my-group", "topic": "my-topic", "allowIdleConsumers": "true", "version": "1.0.0"}, map[string]string{"username": "admin", "password": "admin"}, false, false},
// success, SASL scram_sha256
Expand Down Expand Up @@ -220,7 +218,6 @@ var parseAuthParamsTestDataset = []parseAuthParamsTestData{
// failure, SASL + TLS, missing key
{map[string]string{"saslAuthType": "plaintext", "enableTls": "true", "bootstrapServers": "foobar:9092", "consumerGroup": "my-group", "topic": "my-topic", "allowIdleConsumers": "true", "version": "1.0.0"}, map[string]string{"sasl": "plaintext", "username": "admin", "password": "admin", "ca": "caaa", "cert": "ceert"}, true, false},

// FIXME: DEPRECATED, to be removed in version 2.12
// failure, setting SASL values in both places
{map[string]string{"saslAuthType": "scram_sha512", "bootstrapServers": "foobar:9092", "consumerGroup": "my-group", "topic": "my-topic", "allowIdleConsumers": "true", "version": "1.0.0"}, map[string]string{"sasl": "scram_sha512", "username": "admin", "password": "admin"}, true, false},
// failure, setting TLS values in both places
Expand Down Expand Up @@ -311,7 +308,7 @@ func TestGetBrokers(t *testing.T) {
}

func TestKafkaAuthParams(t *testing.T) {
// FIXME: DEPRECATED, to be removed in version 2.12
// Testing tls and sasl value in TriggerAuthentication
for _, testData := range parseKafkaAuthParamsTestDataset {
meta, err := parseKafkaMetadata(&ScalerConfig{TriggerMetadata: validKafkaMetadata, AuthParams: testData.authParams}, logr.Discard())

Expand Down Expand Up @@ -340,6 +337,7 @@ func TestKafkaAuthParams(t *testing.T) {
}
}

// Testing tls and sasl value in scaledObject
for id, testData := range parseAuthParamsTestDataset {
meta, err := parseKafkaMetadata(&ScalerConfig{TriggerMetadata: testData.metadata, AuthParams: testData.authParams}, logr.Discard())

Expand Down

0 comments on commit 76f6972

Please sign in to comment.