From b81089aada5d2a9c9568a69d843b9246501021a1 Mon Sep 17 00:00:00 2001 From: Vlad Gorodetsky Date: Mon, 10 Dec 2018 21:53:31 +0200 Subject: [PATCH 1/4] Add support for Kafka 2.1.0 --- Gopkg.toml | 2 +- core/internal/helpers/sarama.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Gopkg.toml b/Gopkg.toml index 34e16615..f3983b0d 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -1,6 +1,6 @@ [[constraint]] name = "github.com/Shopify/sarama" - version = "1.18.0" + version = "1.20.0" [[constraint]] name = "go.uber.org/zap" diff --git a/core/internal/helpers/sarama.go b/core/internal/helpers/sarama.go index 21548e1f..7f93ca22 100644 --- a/core/internal/helpers/sarama.go +++ b/core/internal/helpers/sarama.go @@ -48,6 +48,8 @@ func parseKafkaVersion(kafkaVersion string) sarama.KafkaVersion { return sarama.V1_1_0_0 case "2.0.0": return sarama.V2_0_0_0 + case "2.1.0": + return sarama.V2_1_0_0 default: panic("Unknown Kafka Version: " + kafkaVersion) } From 6898a8de26fe5cc202b9878d1d9f7784d48d9eb7 Mon Sep 17 00:00:00 2001 From: Vlad Gorodetsky Date: Mon, 10 Dec 2018 22:00:30 +0200 Subject: [PATCH 2/4] Add libc-dev to build zstd --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index bfb56a6d..e64ccb83 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM golang:1.11-alpine as builder ENV DEP_VERSION="0.5.0" -RUN apk add --no-cache git curl && \ +RUN apk add --no-cache git curl libc-dev && \ curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o $GOPATH/bin/dep && \ chmod +x $GOPATH/bin/dep && \ mkdir -p $GOPATH/src/github.com/linkedin/Burrow From b0440f9deaade28748df959dc565a202a47d5514 Mon Sep 17 00:00:00 2001 From: Vlad Gorodetsky Date: Mon, 10 Dec 2018 22:20:52 +0200 Subject: [PATCH 3/4] Add gcc to build zstd --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e64ccb83..f97dc9d1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM golang:1.11-alpine as builder ENV DEP_VERSION="0.5.0" -RUN apk add --no-cache git curl libc-dev && \ +RUN apk add --no-cache git curl gcc libc-dev && \ curl -L -s https://github.com/golang/dep/releases/download/v${DEP_VERSION}/dep-linux-amd64 -o $GOPATH/bin/dep && \ chmod +x $GOPATH/bin/dep && \ mkdir -p $GOPATH/src/github.com/linkedin/Burrow From 52606499a6ffb7386c7946a224174edbc8eb6bb3 Mon Sep 17 00:00:00 2001 From: Vlad Gorodetsky Date: Tue, 11 Dec 2018 07:10:42 +0200 Subject: [PATCH 4/4] Refactor parseKafkaVersion to reduce method complexity (gocyclo) --- core/internal/helpers/sarama.go | 64 +++++++++++++++++---------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/core/internal/helpers/sarama.go b/core/internal/helpers/sarama.go index 7f93ca22..0fb938cd 100644 --- a/core/internal/helpers/sarama.go +++ b/core/internal/helpers/sarama.go @@ -20,39 +20,43 @@ import ( "github.com/stretchr/testify/mock" ) +var kafkaVersions = map[string]sarama.KafkaVersion{ + "": sarama.V0_10_2_0, + "0.8.0": sarama.V0_8_2_0, + "0.8.1": sarama.V0_8_2_1, + "0.8.2": sarama.V0_8_2_2, + "0.8": sarama.V0_8_2_0, + "0.9.0.0": sarama.V0_9_0_0, + "0.9.0.1": sarama.V0_9_0_1, + "0.9.0": sarama.V0_9_0_0, + "0.9": sarama.V0_9_0_0, + "0.10.0.0": sarama.V0_10_0_0, + "0.10.0.1": sarama.V0_10_0_1, + "0.10.0": sarama.V0_10_0_0, + "0.10.1.0": sarama.V0_10_1_0, + "0.10.1": sarama.V0_10_1_0, + "0.10.2.0": sarama.V0_10_2_0, + "0.10.2.1": sarama.V0_10_2_0, + "0.10.2": sarama.V0_10_2_0, + "0.10": sarama.V0_10_0_0, + "0.11.0.1": sarama.V0_11_0_0, + "0.11.0.2": sarama.V0_11_0_0, + "0.11.0": sarama.V0_11_0_0, + "1.0.0": sarama.V1_0_0_0, + "1.1.0": sarama.V1_1_0_0, + "1.1.1": sarama.V1_1_0_0, + "2.0.0": sarama.V2_0_0_0, + "2.0.1": sarama.V2_0_0_0, + "2.1.0": sarama.V2_1_0_0, +} + func parseKafkaVersion(kafkaVersion string) sarama.KafkaVersion { - switch kafkaVersion { - case "0.8", "0.8.0": - return sarama.V0_8_2_0 - case "0.8.1": - return sarama.V0_8_2_1 - case "0.8.2": - return sarama.V0_8_2_2 - case "0.9", "0.9.0", "0.9.0.0": - return sarama.V0_9_0_0 - case "0.9.0.1": - return sarama.V0_9_0_1 - case "0.10", "0.10.0", "0.10.0.0": - return sarama.V0_10_0_0 - case "0.10.0.1": - return sarama.V0_10_0_1 - case "0.10.1", "0.10.1.0": - return sarama.V0_10_1_0 - case "", "0.10.2", "0.10.2.0", "0.10.2.1": - return sarama.V0_10_2_0 - case "0.11.0", "0.11.0.1", "0.11.0.2": - return sarama.V0_11_0_0 - case "1.0.0": - return sarama.V1_0_0_0 - case "1.1.0": - return sarama.V1_1_0_0 - case "2.0.0": - return sarama.V2_0_0_0 - case "2.1.0": - return sarama.V2_1_0_0 - default: + version, ok := kafkaVersions[string(kafkaVersion)] + if !ok { panic("Unknown Kafka Version: " + kafkaVersion) } + + return version } // GetSaramaConfigFromClientProfile takes the name of a client-profile configuration entry and returns a sarama.Config