Skip to content

Commit

Permalink
updated samara lib to use latest commit on master, and refactored scr…
Browse files Browse the repository at this point in the history
…am config into kafka/config.go
  • Loading branch information
squ1d123 authored and Mongey committed Apr 14, 2019
1 parent 66e01ca commit 0309160
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ jobs:
docker:
- image: circleci/golang:1.12
environment:
GO111MODULE: "on"
TEST_RESULTS: /tmp/test-results
steps:
- checkout
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/Mongey/terraform-provider-kafka
go 1.12

require (
github.com/DataDog/zstd v1.3.5
github.com/Shopify/sarama v1.22.0
github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798
github.com/Shopify/sarama v1.22.1-0.20190412022128-c14cccae56fa
github.com/agext/levenshtein v1.2.1
github.com/apparentlymart/go-cidr v1.0.0
github.com/apparentlymart/go-textseg v1.0.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ github.com/DataDog/zstd v1.3.4 h1:LAGHkXuvC6yky+C2CUG2tD7w8QlrUwpue8XwIh0X4AY=
github.com/DataDog/zstd v1.3.4/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/DataDog/zstd v1.3.5 h1:DtpNbljikUepEPD16hD4LvIcmhnhdLTiW/5pHgbmp14=
github.com/DataDog/zstd v1.3.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798 h1:2T/jmrHeTezcCM58lvEQXs0UpQJCo5SoGAcg+mbSTIg=
github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/Shopify/sarama v0.0.0-20181210205339-861a752af503 h1:ybsAee3Zpx06afkJhbcYZhOzgdbOF5Vd9SeyucR4KWg=
github.com/Shopify/sarama v0.0.0-20181210205339-861a752af503/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/sarama v1.22.0 h1:rtiODsvY4jW6nUV6n3K+0gx/8WlAwVt+Ixt6RIvpYyo=
github.com/Shopify/sarama v1.22.0/go.mod h1:lm3THZ8reqBDBQKQyb5HB3sY1lKp3grEbQ81aWSgPp4=
github.com/Shopify/sarama v1.22.1-0.20190412022128-c14cccae56fa h1:UMPk5t5qV+uZE+TtnTJTqvr0y97abIrqnQNFgDY/ymY=
github.com/Shopify/sarama v1.22.1-0.20190412022128-c14cccae56fa/go.mod h1:FRzlvRpMFO/639zY1SDxUxkqH97Y0ndM5CbGj6oG3As=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
Expand Down
12 changes: 12 additions & 0 deletions kafka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Config struct {
SkipTLSVerify bool
SASLUsername string
SASLPassword string
SASLMechanism string
}

func (c *Config) newKafkaConfig() (*sarama.Config, error) {
Expand All @@ -27,6 +28,17 @@ func (c *Config) newKafkaConfig() (*sarama.Config, error) {
kafkaConfig.ClientID = "terraform-provider-kafka"

if c.saslEnabled() {
switch c.SASLMechanism {
case "scram-sha512":
kafkaConfig.Net.SASL.SCRAMClient = &XDGSCRAMClient{HashGeneratorFcn: SHA512}
kafkaConfig.Net.SASL.Mechanism = sarama.SASLMechanism(sarama.SASLTypeSCRAMSHA512)
case "scram-sha256":
kafkaConfig.Net.SASL.SCRAMClient = &XDGSCRAMClient{HashGeneratorFcn: SHA256}
kafkaConfig.Net.SASL.Mechanism = sarama.SASLMechanism(sarama.SASLTypeSCRAMSHA256)
case "plain":
default:
log.Fatalf("[ERROR] Invalid sasl mechanism \"%s\": can only be \"scram-sha256\", \"scram-sha512\" or \"plain\"", c.SASLMechanism)
}
kafkaConfig.Net.SASL.Enable = true
kafkaConfig.Net.SASL.Password = c.SASLPassword
kafkaConfig.Net.SASL.User = c.SASLUsername
Expand Down

0 comments on commit 0309160

Please sign in to comment.