Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8s 0.30.3 #95

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
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
17 changes: 7 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,17 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
- uses: actions/setup-go@v5
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@master
with:
check-latest: true
go-version-file: go.mod

- name: Build
env:
GO111MODULE: on
GOPATH: /home/runner/work/
GOPATH: /home/runner/work
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export TAGNAME=$(jq --raw-output .ref "$GITHUB_EVENT_PATH" | sed -e "s/refs\/tags\///")
Expand All @@ -34,6 +31,6 @@ jobs:
echo "DEBUG: ls pkg/"
ls pkg/
echo "========================================================="
go get -u github.com/tcnksm/ghr
go install github.com/tcnksm/ghr@latest
$GOPATH/bin/ghr -n ${TAGNAME} -b "ʕ◔ϖ◔ʔ Release ${TAGNAME}" -draft ${TAGNAME} pkg/

2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test
on:
pull_request:
branches:
- master
- main

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ code-gen: ## Generate source codes.
cross: main.go ## Build binaries for cross platform.
mkdir -p pkg
@# darwin
@for arch in "amd64" "386"; do \
@for arch in "amd64" "386" "arm64"; do \
GOOS=darwin GOARCH=$${arch} make build; \
zip pkg/kube-prompt_$(VERSION)_darwin_$${arch}.zip kube-prompt; \
done;
Expand Down
57 changes: 51 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,56 @@
module github.com/c-bata/kube-prompt

require (
github.com/c-bata/go-prompt v0.2.5
github.com/googleapis/gnostic v0.2.0 // indirect
k8s.io/api v0.17.0
k8s.io/apimachinery v0.17.0
k8s.io/client-go v0.17.0
github.com/c-bata/go-prompt v0.2.6
k8s.io/api v0.30.3
k8s.io/apimachinery v0.30.3
k8s.io/client-go v0.30.3
)

go 1.15
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mattn/go-tty v0.0.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/term v1.2.0-beta.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

go 1.22.0

toolchain go1.22.5
308 changes: 129 additions & 179 deletions go.sum

Large diffs are not rendered by default.

192 changes: 94 additions & 98 deletions kube/arguments.go

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions kube/completer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package kube

import (
"context"
"os"
"strings"

Expand All @@ -13,7 +14,7 @@ import (
"k8s.io/client-go/tools/clientcmd"
)

func NewCompleter() (*Completer, error) {
func NewCompleter(ctx context.Context) (*Completer, error) {
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
loader := clientcmd.NewNonInteractiveDeferredLoadingClientConfig(
loadingRules,
Expand All @@ -35,7 +36,7 @@ func NewCompleter() (*Completer, error) {
return nil, err
}

namespaces, err := client.CoreV1().Namespaces().List(metav1.ListOptions{})
namespaces, err := client.CoreV1().Namespaces().List(ctx, metav1.ListOptions{})
if err != nil {
if statusError, ok := err.(*errors.StatusError); ok && statusError.Status().Code == 403 {
namespaces = nil
Expand Down Expand Up @@ -77,7 +78,7 @@ func (c *Completer) Complete(d prompt.Document) []prompt.Suggest {
}

// Return suggestions for option
if suggests, found := c.completeOptionArguments(d); found {
if suggests, found := c.completeOptionArguments(context.TODO(), d); found {
return suggests
}

Expand All @@ -91,7 +92,7 @@ func (c *Completer) Complete(d prompt.Document) []prompt.Suggest {
// So we need to skip argumentCompleter.
return []prompt.Suggest{}
}
return c.argumentsCompleter(namespace, commandArgs)
return c.argumentsCompleter(context.TODO(), namespace, commandArgs)
}

func checkNamespaceArg(d prompt.Document) string {
Expand Down Expand Up @@ -136,7 +137,7 @@ func getPreviousOption(d prompt.Document) (cmd, option string, found bool) {
return "", "", false
}

func (c *Completer) completeOptionArguments(d prompt.Document) ([]prompt.Suggest, bool) {
func (c *Completer) completeOptionArguments(ctx context.Context, d prompt.Document) ([]prompt.Suggest, bool) {
cmd, option, found := getPreviousOption(d)
if !found {
return []prompt.Suggest{}, false
Expand Down Expand Up @@ -168,9 +169,9 @@ func (c *Completer) completeOptionArguments(d prompt.Document) ([]prompt.Suggest
cmdArgs := getCommandArgs(d)
var suggestions []prompt.Suggest
if cmdArgs == nil || len(cmdArgs) < 2 {
suggestions = getContainerNamesFromCachedPods(c.client, c.namespace)
suggestions = getContainerNamesFromCachedPods(ctx, c.client, c.namespace)
} else {
suggestions = getContainerName(c.client, c.namespace, cmdArgs[1])
suggestions = getContainerName(ctx, c.client, c.namespace, cmdArgs[1])
}
return prompt.FilterHasPrefix(
suggestions,
Expand Down
Loading