Skip to content

Commit

Permalink
Deploying to gh-pages from @ 815d2af 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
d-rk committed Mar 14, 2024
1 parent c9254ab commit e3d7367
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 48 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
docs
dist
kafkactl
kafkactl.exe

### Configs
.kafkactl.yml
Expand Down
19 changes: 19 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)"

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
76 changes: 38 additions & 38 deletions docs/kafkactl_docs.md

Large diffs are not rendered by default.

23 changes: 18 additions & 5 deletions internal/global/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"os"
"path/filepath"
"runtime"
"strings"

"github.com/deviceinsight/kafkactl/v5/internal/output"
Expand All @@ -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",
Expand Down Expand Up @@ -83,6 +85,10 @@ func (c *config) Init() {

viper.Reset()

if c.flags.Verbose {
output.IoStreams.EnableDebug()
}

configFile := resolveProjectConfigFileFromWorkingDir()

switch {
Expand All @@ -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"))
}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions internal/util/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down

0 comments on commit e3d7367

Please sign in to comment.