Skip to content

Commit

Permalink
add TLS options for kafka executor plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Hossein-s committed Sep 13, 2023
1 parent 10bdfc7 commit 2e998d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 10 additions & 0 deletions builtin/bins/dkron-executor-kafka/kafka.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"crypto/tls"
"errors"
"log"
"strings"
Expand Down Expand Up @@ -66,6 +67,15 @@ func (s *Kafka) ExecuteImpl(args *dktypes.ExecuteRequest) ([]byte, error) {
config.Producer.Return.Successes = true
config.Producer.Return.Errors = true

if args.Config["tlsEnable"] == "true" {
config.Net.TLS.Enable = true

config.Net.TLS.Config = &tls.Config{}
if args.Config["tlsInsecureSkipVerify"] == "true" {
config.Net.TLS.Config.InsecureSkipVerify = true
}
}

brokers := strings.Split(args.Config["brokerAddress"], ",")
producer, err := sarama.NewSyncProducer(brokers, config)
if err != nil {
Expand Down
12 changes: 7 additions & 5 deletions website/docs/usage/executors/kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ A basic Kafka executor that produces a message on a Kafka broker.
Params

```
brokerAddress: Comma separated string containing "IP:port" of the brokers
key: The key of the message to produce
message: The body of the message to produce
topic: The Kafka topic for this message
debug: Turns on debugging output if not empty
brokerAddress: Comma separated string containing "IP:port" of the brokers
key: The key of the message to produce
message: The body of the message to produce
topic: The Kafka topic for this message
tlsEnable: Enables TLS if set to true. Optional
tlsInsecureSkipVerify: Disables verification of the remote SSL certificate's validity if set to true. Optional
debug: Turns on debugging output if not empty
```

Example
Expand Down

0 comments on commit 2e998d6

Please sign in to comment.