Skip to content

Commit

Permalink
feat: Support ClientID and Debug parameters (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
poom authored Jun 11, 2023
1 parent c48b800 commit 8faf564
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/shiftleft-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,19 @@ jobs:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-go@v2
- uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Configure ssh-key for private modules
env:
SSH_KEY: ${{ secrets.ENGINEERING_SSH_KEY }}
run: |
mkdir -p ~/.ssh; echo "$SSH_KEY" > ~/.ssh/id_rsa; chmod 600 ~/.ssh/id_rsa; git config --global url."git@github.com:".insteadOf "https://github.com/"
- name: Download dependencies
run: make generate

- name: Download ShiftLeft CLI
run: |
curl https://cdn.shiftleft.io/download/sl > ${GITHUB_WORKSPACE}/sl && chmod a+rx ${GITHUB_WORKSPACE}/sl
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
- id: detect-aws-credentials
args: [ '--allow-missing-credentials' ]
- repo: https://github.com/golangci/golangci-lint
rev: v1.50.1
rev: v1.52.2
hooks:
- id: golangci-lint
- repo: https://github.com/TekWizely/pre-commit-golang
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
generate: mocks
generate: interface_mocks
@echo "generated"

mocks:
interface_mocks:
go get github.com/golang/mock/mockgen/model
go install github.com/golang/mock/mockgen@v1.6.0
mockgen -destination=./mocks/mock_kpprocessor.go -package=mocks github.com/honestbank/kp KPProducer
Expand Down
6 changes: 4 additions & 2 deletions mocks/mock_kafkaprocessor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion mocks/mock_kpprocessor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions v2/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Kafka struct {
Password *string
ConsumerSessionTimeoutMs *int
ConsumerAutoOffsetReset *string
ClientID *string
Debug *string
}

func (s Kafka) WithDefaults() Kafka {
Expand All @@ -28,6 +30,8 @@ func (s Kafka) WithDefaults() Kafka {
Password: s.Password,
ConsumerSessionTimeoutMs: defaultIfNil(s.ConsumerSessionTimeoutMs, 6000),
ConsumerAutoOffsetReset: defaultIfNil(s.ConsumerAutoOffsetReset, "earliest"),
ClientID: defaultIfNil(s.ClientID, "rdkafka"),
Debug: s.Debug,
}
}

Expand All @@ -53,6 +57,8 @@ func GetKafkaConfig(kafkaConfig Kafka) *kafka.ConfigMap {
hydrateIfNotNil(cfg, "security.protocol", kafkaConfig.SecurityProtocol)
hydrateIfNotNil(cfg, "sasl.username", kafkaConfig.Username)
hydrateIfNotNil(cfg, "sasl.password", kafkaConfig.Password)
hydrateIfNotNil(cfg, "debug", kafkaConfig.Debug)
hydrateIfNotNil(cfg, "client.id", kafkaConfig.ClientID)

return cfg
}
Expand All @@ -62,6 +68,7 @@ func GetKafkaConsumerConfig(config Kafka) *kafka.ConfigMap {
hydrateIfNotNil(cfg, "group.id", &config.ConsumerGroupName)
hydrateIfNotNil(cfg, "auto.offset.reset", config.ConsumerAutoOffsetReset)
hydrateIfNotNil(cfg, "session.timeout.ms", config.ConsumerSessionTimeoutMs)
hydrateIfNotNil(cfg, "debug", config.Debug)

return cfg
}
Expand Down

0 comments on commit 8faf564

Please sign in to comment.