Skip to content

Commit

Permalink
Update krew with login option
Browse files Browse the repository at this point in the history
Signed-off-by: chenliu1993 <[email protected]>
  • Loading branch information
chenliu1993 committed Mar 9, 2023
1 parent 493e434 commit 4d3f40c
Show file tree
Hide file tree
Showing 15 changed files with 288 additions and 202 deletions.
1 change: 1 addition & 0 deletions krew/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ deploy: build install #### build + install
build: #### build the plugin
@go vet ./... && \
go fmt ./... && \
echo "build on ${GOOS}/${GOARCH}" && \
cd ${ROOT_DIR}/krew/cmd && \
GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -ldflags "-X github.com/RayWangQvQ/BiliBiliToolPro/krew/pkg/cmd.Version=${GITCOMMIT}" -o $(BIN_NAME) kubectl-bilipro.go

Expand Down
14 changes: 7 additions & 7 deletions krew/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@
## Install Plugin

Command: `cd ./krew && make deploy`
The binary will be generated in cmd/ install it alonside the kubectl binary.
The binary will be generated in cmd/ install it alonside the kubectl binary.

For example: the kubectl is installed under `/usr/bin`, then put the bilibilipro plugin under `/usr/bin` too.

## Plugin Commands

### Deployment && Update

Command: `kubectl bilipro init --config config.yaml`

Creates Deployment with the needed environments.
Command: `kubectl bilipro init --config config.yaml [optional]--login`

Creates Deployment with the needed environments.

Optional Options:

- `--image=zai7lou/bilibili_tool_pro:0.2.1`
- `--image=zai7lou/bilibili_tool_pro:1.0.1`
- `--namespace=bilipro`
- `--image-pull-secret=`

Expand All @@ -36,6 +35,7 @@ Required Options:
The content of <config.yaml> is a yaml array, please refer to the example config yaml under the krew directory.

For example

````yaml
- name: Ray_BiliBiliCookies__2
value: "cookie"
Expand All @@ -44,10 +44,8 @@ For example
value: "11 11 * * *"
````


Suggestions: Deploy this workload in namespace other than default or kube-* namespace, because the delete logic should be improved


### Deletion

Command: `kubectl bilipro delete [options]`
Expand All @@ -65,4 +63,6 @@ Command: `kubectl bilipro version`

Output the plugin version.

## Package

Pls refer to [installation](https://krew.sigs.k8s.io/docs), you can package your own krew plugin
3 changes: 3 additions & 0 deletions krew/cmd/kubectl-bilipro.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import (
"github.com/spf13/pflag"

"github.com/RayWangQvQ/BiliBiliToolPro/krew/pkg/cmd"
helper "github.com/RayWangQvQ/BiliBiliToolPro/krew/pkg/utils"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/klog/v2"
)

func main() {
Expand All @@ -15,6 +17,7 @@ func main() {

cmd := cmd.NewExecutor(genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr})
if err := cmd.Execute(); err != nil {
klog.Error(helper.GenErrorMsg(helper.SERVER_ERROR, err.Error()).Error())
os.Exit(1)
}
}
2 changes: 1 addition & 1 deletion krew/config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- name: Ray_BiliBiliCookies__2
- name: Ray_BiliBiliCookies__1
value: "cookie"
# DailyTrigger - required
- name: Ray_DailyTaskConfig__Cron
Expand Down
33 changes: 16 additions & 17 deletions krew/go.mod
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
module github.com/RayWangQvQ/BiliBiliToolPro/krew

go 1.18
go 1.20

require (
github.com/spf13/cobra v1.4.0
github.com/spf13/pflag v1.0.5
k8s.io/api v0.25.4
k8s.io/apimachinery v0.25.4
k8s.io/cli-runtime v0.25.4
k8s.io/klog/v2 v2.70.1
k8s.io/client-go v0.25.4
k8s.io/klog/v2 v2.80.1
sigs.k8s.io/kustomize/api v0.12.1
sigs.k8s.io/kustomize/kyaml v0.13.9
sigs.k8s.io/yaml v1.2.0
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.1.2 // indirect
Expand All @@ -46,21 +47,19 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/xlab/treeprint v1.1.0 // indirect
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.0 // indirect
google.golang.org/protobuf v1.28.1 // 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/apimachinery v0.25.4 // indirect
k8s.io/client-go v0.25.4 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed // indirect
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 // indirect
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)
Expand Down
Loading

0 comments on commit 4d3f40c

Please sign in to comment.