diff --git a/.gitignore b/.gitignore index 105c855..e8d265f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ docs dist kafkactl +kafkactl.exe ### Configs .kafkactl.yml diff --git a/.goreleaser.yml b/.goreleaser.yml index b717dd9..33de3ae 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -82,6 +82,25 @@ brews: skip_upload: false +winget: + - name: kafkactl + publisher: Device Insight GmbH + short_description: A command-line interface for interaction with Apache Kafka + license: Apache-2.0 + publisher_support_url: https://github.com/deviceinsight/kafkactl/issues + package_identifier: deviceinsight.kafkactl + homepage: https://www.device-insight.com/ + repository: + owner: deviceinsight + name: winget-pkgs + branch: "kafkactl-{{.Version}}" + pull_request: + enabled: true + base: + owner: microsoft + name: winget-pkgs + branch: master + dockers: - skip_push: false diff --git a/CHANGELOG.md b/CHANGELOG.md index ea64acd..d8fcdd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## 5.0.6 - 2024-03-14 + ## 5.0.5 - 2024-03-12 ## 5.0.4 - 2024-03-12 diff --git a/Makefile b/Makefile index bc87f73..8e59911 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,14 @@ BUILD_TS := $(shell date -Iseconds --utc) COMMIT_SHA := $(shell git rev-parse HEAD) VERSION := $(shell git describe --abbrev=0 --tags || echo "latest") +OS ?= linux export CGO_ENABLED=0 -export GOOS=linux +export GOOS=$(OS) export GO111MODULE=on +binary := $(if $(filter-out windows,$(OS)),kafkactl,kafkactl.exe) + module=$(shell go list -m) ld_flags := "-X $(module)/cmd.Version=$(VERSION) -X $(module)/cmd.GitCommit=$(COMMIT_SHA) -X $(module)/cmd.BuildTime=$(BUILD_TS)" @@ -43,7 +46,7 @@ integration_test: .PHONY: build build: - go build -ldflags $(ld_flags) -o kafkactl + go build -ldflags $(ld_flags) -o $(binary) .PHONY: docs docs: build @@ -52,7 +55,7 @@ docs: build .PHONY: clean clean: - rm -f kafkactl + rm -f $(binary) go clean -testcache # usage make version=2.5.0 release diff --git a/docs/kafkactl_docs.md b/docs/kafkactl_docs.md index a1037a4..bc4edb3 100644 --- a/docs/kafkactl_docs.md +++ b/docs/kafkactl_docs.md @@ -9,7 +9,7 @@ A command-line interface the simplifies interaction with Kafka. ### Options ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -h, --help help for kafkactl -V, --verbose verbose output ``` @@ -44,7 +44,7 @@ alter topics, partitions #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -74,7 +74,7 @@ kafkactl alter partition TOPIC PARTITION [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -104,7 +104,7 @@ kafkactl alter topic TOPIC [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -130,7 +130,7 @@ kafkactl attach [flags] #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -152,7 +152,7 @@ clone topics, consumerGroups #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -180,7 +180,7 @@ kafkactl clone consumer-group SOURCE_GROUP TARGET_GROUP [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -206,7 +206,7 @@ kafkactl clone topic SOURCE_TOPIC TARGET_TOPIC [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -261,7 +261,7 @@ kafkactl completion [bash|zsh|fish|powershell] #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -283,7 +283,7 @@ show and edit configurations #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -317,7 +317,7 @@ kafkactl config current-context [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -348,7 +348,7 @@ kafkactl config get-contexts [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -378,7 +378,7 @@ kafkactl config use-context [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -408,7 +408,7 @@ kafkactl config view [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -458,7 +458,7 @@ kafkactl consume TOPIC [flags] #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -480,7 +480,7 @@ create topics, consumerGroups, acls #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -519,7 +519,7 @@ kafkactl create access-control-list [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -550,7 +550,7 @@ kafkactl create consumer-group GROUP [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -580,7 +580,7 @@ kafkactl create topic TOPIC [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -602,7 +602,7 @@ delete topics, consumerGroups, consumer-group-offset, acls, records #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -641,7 +641,7 @@ kafkactl delete access-control-list [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -669,7 +669,7 @@ kafkactl delete consumer-group-offset CONSUMER-GROUP --topic=TOPIC --partition=P ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -695,7 +695,7 @@ kafkactl delete consumer-group CONSUMER-GROUP [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -722,7 +722,7 @@ kafkactl delete records TOPIC [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -748,7 +748,7 @@ kafkactl delete topic TOPIC [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -770,7 +770,7 @@ describe topics, consumerGroups, brokers #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -800,7 +800,7 @@ kafkactl describe broker ID [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -831,7 +831,7 @@ kafkactl describe consumer-group GROUP [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -860,7 +860,7 @@ kafkactl describe topic TOPIC [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -882,7 +882,7 @@ get info about topics, consumerGroups, acls, brokers #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -920,7 +920,7 @@ kafkactl get access-control-list [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -947,7 +947,7 @@ kafkactl get brokers [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -975,7 +975,7 @@ kafkactl get consumer-groups [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -1002,7 +1002,7 @@ kafkactl get topics [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -1051,7 +1051,7 @@ kafkactl produce TOPIC [flags] #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -1073,7 +1073,7 @@ reset consumerGroupsOffset #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -1109,7 +1109,7 @@ kafkactl reset consumer-group-offset GROUP [flags] ##### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` @@ -1135,7 +1135,7 @@ kafkactl version [flags] #### Options inherited from parent commands ``` - -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] + -C, --config-file string config file. default locations: [$HOME/.config/kafkactl $HOME/.kafkactl $APPDATA/kafkactl $SNAP_REAL_HOME/.config/kafkactl $SNAP_DATA/kafkactl /etc/kafkactl] -V, --verbose verbose output ``` diff --git a/internal/global/config.go b/internal/global/config.go index 2e6a792..e7f77cd 100644 --- a/internal/global/config.go +++ b/internal/global/config.go @@ -4,6 +4,7 @@ import ( "errors" "os" "path/filepath" + "runtime" "strings" "github.com/deviceinsight/kafkactl/v5/internal/output" @@ -23,6 +24,7 @@ var projectConfigNames = []string{"kafkactl.yml", ".kafkactl.yml"} var configPaths = []string{ "$HOME/.config/kafkactl", "$HOME/.kafkactl", + "$APPDATA/kafkactl", "$SNAP_REAL_HOME/.config/kafkactl", "$SNAP_DATA/kafkactl", "/etc/kafkactl", @@ -83,6 +85,10 @@ func (c *config) Init() { viper.Reset() + if c.flags.Verbose { + output.IoStreams.EnableDebug() + } + configFile := resolveProjectConfigFileFromWorkingDir() switch { @@ -93,10 +99,6 @@ func (c *config) Init() { configFile = &envConfig } - if c.flags.Verbose { - output.IoStreams.EnableDebug() - } - if c.flags.Verbose && os.Getenv("SNAP_NAME") != "" { output.Debugf("Running snap version %s on %s", os.Getenv("SNAP_VERSION"), os.Getenv("SNAP_ARCH")) } @@ -177,13 +179,16 @@ func (c *config) loadConfig(viperInstance *viper.Viper, configFile *string) erro func resolveProjectConfigFileFromWorkingDir() *string { - path, err := os.Getwd() + workDir, err := os.Getwd() if err != nil { output.Debugf("cannot find project config file. unable to get working dir") return nil } for _, projectConfigName := range projectConfigNames { + + path := workDir + _, err = os.Stat(filepath.Join(path, projectConfigName)) found := true @@ -249,6 +254,14 @@ func generateDefaultConfig() error { break } } + } else if runtime.GOOS == "windows" { + // use different configFile when running on windows + for _, configPath := range configPaths { + if strings.Contains(configPath, "$APPDATA") { + cfgFile = filepath.Join(os.ExpandEnv(configPath), "config.yml") + break + } + } } if err := os.MkdirAll(filepath.Dir(cfgFile), os.FileMode(0700)); err != nil { diff --git a/internal/util/plugin.go b/internal/util/plugin.go index b8ac14e..7ed5da7 100644 --- a/internal/util/plugin.go +++ b/internal/util/plugin.go @@ -22,6 +22,8 @@ func LoadPlugin[P plugin.Plugin, I any](pluginName string, pluginSpec plugins.Pl return impl, err } + output.Debugf("using plugin=%s location=%s", pluginName, pluginPath) + pluginLogger := output.CreateVerboseLogger(pluginName, global.GetFlags().Verbose) logger := hclog.FromStandardLogger(pluginLogger, &hclog.LoggerOptions{ @@ -69,7 +71,7 @@ func resolvePluginPath(pluginName string) (string, error) { pluginExecutable := fmt.Sprintf("kafkactl-%s-plugin%s", pluginName, extension) // search in path - if _, err := os.Stat(pluginExecutable); err == nil { + if _, err := exec.LookPath(pluginExecutable); err == nil { return pluginExecutable, nil } @@ -95,7 +97,7 @@ func resolvePluginPath(pluginName string) (string, error) { pluginPath := filepath.Join(workingDir, "../kafkactl-plugins/"+pluginName) pluginLocationWorkingDir := filepath.Join(pluginPath, pluginExecutable) - if _, err := os.Stat(pluginLocationWorkingDir); err == nil { + if _, err = os.Stat(pluginLocationWorkingDir); err == nil { return pluginLocationWorkingDir, nil }