Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
Completed logging review and improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Baiguini committed Feb 8, 2022
1 parent 0c7e825 commit 458c9d6
Show file tree
Hide file tree
Showing 19 changed files with 159 additions and 172 deletions.
3 changes: 0 additions & 3 deletions cmd/completion/command.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package completion

import (
"github.com/bygui86/konf-sh/pkg/logging"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
)

func BuildCommand() *cli.Command {
logging.InitLogger()

zap.L().Debug("🐛 Create COMPLETION command")
return &cli.Command{
Name: "completion",
Expand Down
14 changes: 7 additions & 7 deletions cmd/delete/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,29 @@ func deleteCtx(ctx *cli.Context) error {
zap.S().Debugf("🐛 Kubernetes configuration file path: '%s'", kCfgFilePath)

zap.L().Debug("🐛 Get single Kubernetes konfigurations path")
singleKonfigsPath := ctx.String(commons.SingleKonfigsFlagName)
zap.S().Debugf("🐛 Single Kubernetes konfigurations path: '%s'", singleKonfigsPath)
singleKfgsPath := ctx.String(commons.SingleKonfigsFlagName)
zap.S().Debugf("🐛 Single Kubernetes konfigurations path: '%s'", singleKfgsPath)

zap.L().Debug("🐛 Get contexts to delete")
contextSlice, ctxErr := getContextList(ctx)
contexts, ctxErr := getContextList(ctx)
if ctxErr != nil {
return ctxErr
}
zap.S().Infof("📋 Contexts to delete: '%s'", strings.Join(contextSlice, ", "))
zap.S().Infof("📋 Contexts to delete: '%s'", strings.Join(contexts, ", "))

zap.L().Debug("🐛 Ask for user confirmation to delete contexts")
if userDeletionConfirm() {
kCfgErr := deleteFromKubeConfig(kCfgFilePath, contextSlice)
kCfgErr := deleteFromKubeConfig(kCfgFilePath, contexts)
if kCfgErr != nil {
return kCfgErr
}

kfgsErr := deleteFromKubeKonfigs(singleKonfigsPath, contextSlice)
kfgsErr := deleteFromKubeKonfigs(singleKfgsPath, contexts)
if kfgsErr != nil {
return kfgsErr
}

zap.S().Infof("✅ Removing contexts '%s' completed", strings.Join(contextSlice, ", "))
zap.S().Infof("✅ Removing contexts '%s' completed", strings.Join(contexts, ", "))

zap.L().Info("")

Expand Down
3 changes: 0 additions & 3 deletions cmd/delete/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ package delete
import (
"github.com/bygui86/konf-sh/pkg/commons"
"github.com/bygui86/konf-sh/pkg/kubeconfig"
"github.com/bygui86/konf-sh/pkg/logging"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
)

func BuildCommand() *cli.Command {
logging.InitLogger()

zap.L().Debug("🐛 Create DELETE command")
home := commons.GetHomeDirOrExit("delete")
return &cli.Command{
Expand Down
3 changes: 0 additions & 3 deletions cmd/list/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ package list
import (
"github.com/bygui86/konf-sh/pkg/commons"
"github.com/bygui86/konf-sh/pkg/kubeconfig"
"github.com/bygui86/konf-sh/pkg/logging"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
)

func BuildCommand() *cli.Command {
logging.InitLogger()

zap.L().Debug("🐛 Create LIST command")
home := commons.GetHomeDirOrExit("list")
return &cli.Command{
Expand Down
3 changes: 0 additions & 3 deletions cmd/rename/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ package rename
import (
"github.com/bygui86/konf-sh/pkg/commons"
"github.com/bygui86/konf-sh/pkg/kubeconfig"
"github.com/bygui86/konf-sh/pkg/logging"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
)

func BuildCommand() *cli.Command {
logging.InitLogger()

zap.L().Debug("🐛 Create RENAME command")
home := commons.GetHomeDirOrExit("rename")
return &cli.Command{
Expand Down
3 changes: 0 additions & 3 deletions cmd/reset/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ package reset
import (
"github.com/bygui86/konf-sh/pkg/commons"
"github.com/bygui86/konf-sh/pkg/kubeconfig"
"github.com/bygui86/konf-sh/pkg/logging"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
)

func BuildCommand() *cli.Command {
logging.InitLogger()

zap.L().Debug("🐛 Create RESET command")
home := commons.GetHomeDirOrExit("reset")
return &cli.Command{
Expand Down
3 changes: 0 additions & 3 deletions cmd/set/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ package set
import (
"github.com/bygui86/konf-sh/pkg/commons"
"github.com/bygui86/konf-sh/pkg/kubeconfig"
"github.com/bygui86/konf-sh/pkg/logging"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
)

func BuildCommand() *cli.Command {
logging.InitLogger()

zap.L().Debug("🐛 Create SET-CONFIG command")
home := commons.GetHomeDirOrExit("set")
return &cli.Command{
Expand Down
3 changes: 0 additions & 3 deletions cmd/split/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ package split
import (
"github.com/bygui86/konf-sh/pkg/commons"
"github.com/bygui86/konf-sh/pkg/kubeconfig"
"github.com/bygui86/konf-sh/pkg/logging"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
)

func BuildCommand() *cli.Command {
logging.InitLogger()

zap.L().Debug("🐛 Create SPLIT command")
home := commons.GetHomeDirOrExit("split")
return &cli.Command{
Expand Down
3 changes: 0 additions & 3 deletions cmd/view/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ package view
import (
"github.com/bygui86/konf-sh/pkg/commons"
"github.com/bygui86/konf-sh/pkg/kubeconfig"
"github.com/bygui86/konf-sh/pkg/logging"
"github.com/urfave/cli/v2"
"go.uber.org/zap"
)

func BuildCommand() *cli.Command {
logging.InitLogger()

zap.L().Debug("🐛 Create VIEW command")
home := commons.GetHomeDirOrExit("view")
return &cli.Command{
Expand Down
2 changes: 1 addition & 1 deletion docs/autocompletion.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# konf - Autocompletion
# konf-sh - Autocompletion

Current supported shells: zsh, bash

Expand Down
2 changes: 1 addition & 1 deletion docs/emoji.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# konf - Emoji in cli
# konf-sh - Emoji in cli

## Working

Expand Down
2 changes: 1 addition & 1 deletion docs/links.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# konf - Links
# konf-sh - Links

## Inspirations
- https://github.com/ahmetb/kubectx
Expand Down
28 changes: 14 additions & 14 deletions docs/makefile.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

# konf - Makefile targets
# konf-sh - Makefile targets

### Build binary
## Build binary

```sh
make build
```

### Run
## Run

```sh
# from source
Expand All @@ -17,67 +17,67 @@ make run
make run-bin
```

### Clean binary
## Clean binary

```sh
make clean-bin
```

### Split a sample Kubernetes configuration file
## Split a sample Kubernetes configuration file

```sh
make split
```

### List a set of sample Kubernetes konfigurations
## List a set of sample Kubernetes konfigurations

```sh
make list
```

### Set local Kubernetes context (current bash)
## Set local Kubernetes context (current bash)

```sh
make set-local
```

### Set global Kubernetes context
## Set global Kubernetes context

```sh
make set-global
```

### View local and global Kubernetes contexts
## View local and global Kubernetes contexts

```sh
make view
```

### View local Kubernetes context (current bash)
## View local Kubernetes context (current bash)

```sh
make view-local
```

### View global Kubernetes context
## View global Kubernetes context

```sh
make view-global
```

### Clean Kubernetes contexts
## Clean Kubernetes contexts

```sh
make delete
```

### Rename Kubernetes context
## Rename Kubernetes context

```sh
make rename
```

### Release
## Release

`WARN`: Be careful, this command triggers the `release` GitHub Action that results in a new release on GitHub repo

Expand Down
32 changes: 18 additions & 14 deletions docs/release.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

# konf - Release
# konf-sh - Release

`NEXT VERSION:` v0.5
`NEXT VERSION:` v0.5.0

### Automatic
## Automatic

```sh
make release NEW_VERSION=...
```

### Manual
## Manual

1. Choose a new version
```sh
NEW_VERSION="v0.5"
NEW_VERSION="v0.5.0"
```
2. Create a new tag with choosen version
```sh
Expand All @@ -24,33 +24,33 @@ make release NEW_VERSION=...
git push origin $NEW_VERSION
```

### Simulate
## Simulate

```sh
goreleaser --snapshot --skip-publish --rm-dist
```

### Available mechanisms
## Available mechanisms

- goreleaser
- GitHub Actions
- GitHub Package Registry
- PackagePublishing

### GitHub Actions
## GitHub Actions

| Action | Triggered by | Steps |
| --- | --- | --- |
| build | push to master, push to branch features/\*\*, PR to master, PR to branch features/\*\* | setup go, checkout, get dependencies, build, test |
| release | new tag creation | setup go, checkout, unshallow, run goreleaser |
| Action | Triggered by | Steps |
|---------|----------------------------------------------------------------------------------------|---------------------------------------------------|
| build | push to master, push to branch features/\*\*, PR to master, PR to branch features/\*\* | setup go, checkout, get dependencies, build, test |
| release | new tag creation | setup go, checkout, unshallow, run goreleaser |

### goreleaser
## goreleaser

`WARN`: The first three steps will trigger the `release` GitHub Action, performing the last step (goreleaser), so be careful if you want to release manually.

1. version
```sh
NEW_VERSION="v0.5"
NEW_VERSION="v0.5.0"
```
2. tag
```sh
Expand All @@ -64,3 +64,7 @@ goreleaser --snapshot --skip-publish --rm-dist
```sh
goreleaser release --rm-dist
```

## In code

Version is specified only in `pkg/app/utils.go`
Loading

0 comments on commit 458c9d6

Please sign in to comment.