Skip to content

Commit 547c756

Browse files
authored
feat: optional interactive shell after duplication (#14)
* chore: update golanci-lint * optional interactive shell after duplication * linting * update readme * refactor: pkg -> internal
1 parent a92ab63 commit 547c756

29 files changed

+263
-69
lines changed

.golangci.yaml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
# Golang CI configuration
22
# Reference: https://golangci-lint.run/usage/configuration/
33

4+
version: "2"
5+
46
run:
57
timeout: 3m
68
issues-exit-code: 1
7-
8-
linters:
9-
disable-all: true
10-
enable:
11-
- unused
12-
- errcheck
13-
- gosimple
14-
- govet
15-
- ineffassign
16-
- staticcheck
17-
- typecheck
18-
- unused

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ LICENSE_EYE ?= $(LOCALBIN)/license-eye
8080
VHS ?= $(LOCALBIN)/vhs
8181

8282
## Tool Versions
83-
GOLANGCI_LINT_VERSION ?= 1.64.8
83+
GOLANGCI_LINT_VERSION ?= 2.1.6
8484
GORELEASER_VERSION ?= 1.26.1
8585

8686
.PHONY: golangci-lint ## Download golanci-lint if necessary
8787
golangci-lint: $(GOLANGCI_LINT)
8888
$(GOLANGCI_LINT): $(LOCALBIN)
89-
test -s $(LOCALBIN)/golanci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCI_LINT_VERSION}
89+
test -s $(LOCALBIN)/golanci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v${GOLANGCI_LINT_VERSION}
9090

9191
.PHONY: goreleaser ## Download goreleaser if necessary
9292
goreleaser: $(GORELEASER)

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ $ kubectl duplicate pod
122122

123123
The command will prompt you to select a Pod from the list of available Pods in the specified namespace.
124124

125+
### Duplicate a Pod and open a shell in the cloned Pod
126+
127+
```sh
128+
kubectl duplicate pod my-pod --shell
129+
```
130+
131+
This command will duplicate the Pod and open an interactive shell inside it.
132+
After you exit the shell, you'll be prompted to confirm whether you want to delete the duplicated Pod.
133+
125134
### Duplicate a Deployment
126135

127136
```sh
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package clients
1818

1919
import (
2020
"context"
21-
"github.com/telemaco019/duplik8s/pkg/core"
22-
"github.com/telemaco019/duplik8s/pkg/utils"
21+
"github.com/telemaco019/duplik8s/internal/core"
22+
"github.com/telemaco019/duplik8s/internal/utils"
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
"k8s.io/apimachinery/pkg/runtime/schema"
2525
"k8s.io/client-go/discovery"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ package clients
1818

1919
import (
2020
"context"
21-
"github.com/telemaco019/duplik8s/pkg/core"
21+
"github.com/telemaco019/duplik8s/internal/core"
2222
v1 "k8s.io/api/core/v1"
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
"k8s.io/client-go/kubernetes"
2525
)
2626

2727
type PodConfigurator struct {
2828
clientset *kubernetes.Clientset
29-
options core.PodOverrideOptions
29+
options core.DuplicateOpts
3030
}
3131

3232
func NewConfigurator(
3333
clientset *kubernetes.Clientset,
34-
options core.PodOverrideOptions,
34+
options core.DuplicateOpts,
3535
) PodConfigurator {
3636
return PodConfigurator{
3737
clientset: clientset,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"fmt"
2222
"github.com/charmbracelet/huh"
2323
"github.com/spf13/cobra"
24-
"github.com/telemaco019/duplik8s/pkg/clients"
25-
"github.com/telemaco019/duplik8s/pkg/core"
24+
"github.com/telemaco019/duplik8s/internal/clients"
25+
"github.com/telemaco019/duplik8s/internal/core"
2626
)
2727

2828
func cleanup(client core.Client, namespace string) error {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ package cmd
1818

1919
import (
2020
"github.com/spf13/cobra"
21-
"github.com/telemaco019/duplik8s/pkg/cmd/flags"
22-
"github.com/telemaco019/duplik8s/pkg/utils"
21+
"github.com/telemaco019/duplik8s/internal/cmd/flags"
22+
"github.com/telemaco019/duplik8s/internal/utils"
2323
)
2424

2525
func NewKubeOptions(cmd *cobra.Command, _ []string) (utils.KubeOptions, error) {
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ package cmd
1818

1919
import (
2020
"github.com/spf13/cobra"
21-
"github.com/telemaco019/duplik8s/pkg/core"
22-
"github.com/telemaco019/duplik8s/pkg/duplicators"
23-
"github.com/telemaco019/duplik8s/pkg/utils"
21+
"github.com/telemaco019/duplik8s/internal/core"
22+
"github.com/telemaco019/duplik8s/internal/duplicators"
23+
"github.com/telemaco019/duplik8s/internal/utils"
2424
"k8s.io/apimachinery/pkg/runtime/schema"
2525
)
2626

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const (
2121
NAMESPACE = "namespace"
2222
KUBECONTEXT = "context"
2323

24-
COMMAND_OVERRIDE = "command-override"
25-
ARGS_OVERRIDE = "args-override"
24+
COMMAND_OVERRIDE = "command-override"
25+
ARGS_OVERRIDE = "args-override"
26+
INTERACTIVE_SHELL = "shell"
2627
)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020
"context"
2121
"fmt"
2222
"github.com/spf13/cobra"
23-
"github.com/telemaco019/duplik8s/pkg/clients"
24-
"github.com/telemaco019/duplik8s/pkg/core"
23+
"github.com/telemaco019/duplik8s/internal/clients"
24+
"github.com/telemaco019/duplik8s/internal/core"
2525
)
2626

2727
func listDuplicatedResources(client core.Client, namespace string) error {

0 commit comments

Comments
 (0)