Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ jobs:
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version: '1.24'
go-version: '1.26'
cache: true
cache-dependency-path: go.sum

- name: Install golangci-lint
uses: golangci/golangci-lint-action@8564da7cb3c6866ed1da648ca8f00a258ef0c802 # v6.5.2
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20
# v9.2.0
with:
version: v2.11.4
skip-install: true
install-only: true

- name: Run linter
run: make lint
Expand All @@ -43,7 +44,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version: '1.24'
go-version: '1.26'
cache: true
cache-dependency-path: go.sum

Expand All @@ -63,7 +64,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version: '1.24'
go-version: '1.26'
cache: true
cache-dependency-path: go.sum

Expand Down
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.exe
*.exe~
*.dll
*.so
*.dylib
kmir
*.test
*.out
coverage.*
coverage.html

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# syntax=docker/dockerfile:1
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ test-short: ## Run short tests only

lint: ## Run linters
@echo "Running linters..."
$(LINTER) run --timeout 5m ./...; \
$(LINTER) run --timeout 5m ./...

fix: ## Auto-fix linting issues
@echo "Fixing linting issues..."
$(LINTER) run --fix --timeout 5m ./...; \
$(LINTER) run --fix --timeout 5m ./...

coverage: ## Generate coverage report
@echo "Generating coverage report..."
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ kmir --source-brokers=localhost:9092 --sink-brokers=localhost:9093 --client-id=m

### Prerequisites

- Go 1.24 or later
- Go 1.26 or later
- golangci-lint v2.11.4 or later

### Setup
Expand Down
9 changes: 5 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package main provides functionality for mirroring Kafka topics.
package main

import (
Expand Down Expand Up @@ -76,16 +77,16 @@ func toFranzOptions(brokerOpts BrokerOptions) ([]kgo.Opt, error) {
out = append(out, kgo.SeedBrokers(brokerOpts.Brokers...))
out = append(out, kgo.DialTimeout(brokerOpts.Timeout))

if brokerOpts.Tls.Enabled {
if brokerOpts.TLS.Enabled {
tlsConfig := &tls.Config{
MinVersion: tls.VersionTLS12,
Renegotiation: tls.RenegotiateFreelyAsClient,
RootCAs: x509.NewCertPool(),
InsecureSkipVerify: brokerOpts.Tls.Insecure,
InsecureSkipVerify: brokerOpts.TLS.Insecure, // #nosec G402
}

if brokerOpts.Tls.Cert != "" {
if ok := tlsConfig.RootCAs.AppendCertsFromPEM([]byte(brokerOpts.Tls.Cert)); !ok {
if brokerOpts.TLS.Cert != "" {
if ok := tlsConfig.RootCAs.AppendCertsFromPEM([]byte(brokerOpts.TLS.Cert)); !ok {
return nil, fmt.Errorf("failed to append cert to root CAs")
}
}
Expand Down
4 changes: 2 additions & 2 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func BenchmarkParseTopicOffset(b *testing.B) {
for _, tt := range tests {
b.Run(tt, func(b *testing.B) {
for i := 0; i < b.N; i++ {
parseTopicOffset(tt)
_, _ = parseTopicOffset(tt)
}
})
}
Expand All @@ -264,7 +264,7 @@ func BenchmarkToTopic(b *testing.B) {
for _, tt := range tests {
b.Run(tt, func(b *testing.B) {
for i := 0; i < b.N; i++ {
toTopic(tt)
_, _, _ = toTopic(tt)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mortezaPRK/kmir

go 1.24.0
go 1.26.0

tool golang.org/x/vuln/cmd/govulncheck

Expand Down
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"log/slog"
"math"
"time"

"github.com/twmb/franz-go/pkg/kadm"
Expand Down Expand Up @@ -211,7 +212,11 @@ func createTopic(rootCtx context.Context, client *kadm.Client, dt kadm.TopicDeta
ctx, cancel := context.WithTimeout(rootCtx, config.Timeout)
defer cancel()

partitions := int32(len(dt.Partitions))
numPartitions := len(dt.Partitions)
if numPartitions > int(math.MaxInt32) {
return fmt.Errorf("number of partitions %d exceeds maximum int32 value", numPartitions)
}
partitions := int32(numPartitions) // #nosec G115

if _, err := client.CreateTopic(ctx, partitions, -1, nil, topic); err != nil {
return fmt.Errorf("failed to create topic %q: %w", topic, err)
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ func BenchmarkWait(b *testing.B) {

b.ResetTimer()
for i := 0; i < b.N; i++ {
wait(time.Second, fn)
_ = wait(time.Second, fn)
}
}
6 changes: 3 additions & 3 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type Sasl struct {
Mechanism string `long:"mechanism" env:"MECHANISM" description:"SASL mechanism"`
}

// Tls defines the TLS configuration for a broker.
type Tls struct {
// TLS defines the TLS configuration for a broker.
type TLS struct {
Enabled bool `long:"enabled" env:"ENABLED" description:"Enable TLS"`
Cert string `long:"cert" env:"CERT" description:"TLS certificate"`
Insecure bool `long:"insecure" env:"INSECURE" description:"Skip TLS verification"`
Expand All @@ -25,7 +25,7 @@ type Tls struct {
// BrokerOptions defines the configuration for a Kafka broker.
type BrokerOptions struct {
Brokers []string `long:"brokers" env:"BROKERS" env-delim:"," description:"Comma-separated list of Kafka brokers" required:"true"`
Tls Tls `group:"TLS" namespace:"tls" env-namespace:"TLS"`
TLS TLS `group:"TLS" namespace:"tls" env-namespace:"TLS"`
Sasl Sasl `group:"SASL" namespace:"sasl" env-namespace:"SASL"`
Timeout time.Duration `long:"timeout" env:"TIMEOUT" description:"Timeout for Kafka" default:"10s"`
}
Expand Down
Loading