From a1f35ecc05fd1790f8b9c2da5d9bf5dab05fca6d Mon Sep 17 00:00:00 2001 From: yuemoxi <99347745@qq.com> Date: Tue, 31 Aug 2021 10:13:34 +0800 Subject: [PATCH] fix:rename kube to kubernetes (#1393) * fix:update config and registry readme * rename kute to kubernetes * fix * fix --- config/README.md | 28 ++++++++++++++++++--- config/{kube => kubernetes}/README.md | 0 config/{kube => kubernetes}/config.go | 22 ++++++++-------- config/{kube => kubernetes}/config_test.go | 2 +- config/{kube => kubernetes}/example.go | 2 +- config/{kube => kubernetes}/go.mod | 2 +- config/{kube => kubernetes}/go.sum | 0 config/{kube => kubernetes}/watcher.go | 6 ++--- config/{kube => kubernetes}/watcher_test.go | 2 +- registry/README.md | 5 ++++ registry/{kute => kubernetes}/go.mod | 2 +- registry/{kute => kubernetes}/go.sum | 0 registry/{kute => kubernetes}/registry.go | 2 +- 13 files changed, 50 insertions(+), 23 deletions(-) rename config/{kube => kubernetes}/README.md (100%) rename config/{kube => kubernetes}/config.go (85%) rename config/{kube => kubernetes}/config_test.go (94%) rename config/{kube => kubernetes}/example.go (97%) rename config/{kube => kubernetes}/go.mod (78%) rename config/{kube => kubernetes}/go.sum (100%) rename config/{kube => kubernetes}/watcher.go (89%) rename config/{kube => kubernetes}/watcher_test.go (97%) rename registry/{kute => kubernetes}/go.mod (60%) rename registry/{kute => kubernetes}/go.sum (100%) rename registry/{kute => kubernetes}/registry.go (99%) diff --git a/config/README.md b/config/README.md index 72a5b4df8..6a71de39b 100644 --- a/config/README.md +++ b/config/README.md @@ -1,5 +1,27 @@ # Config -* [Consul](https://github.com/go-kratos/consul) -* [Etcd](https://github.com/go-kratos/etcd) -* [Kube](https://github.com/go-kratos/kube) +## Consul +```shell +go get -u github.com/go-kratos/kratos/registry/consul/v2 +``` + +## Etcd +```shell +go get -u github.com/go-kratos/kratos/registry/etcd/v2 +``` + +## zookeeper +```shell +go get -u github.com/go-kratos/kratos/registry/zookeeper/v2 +``` + +## Nacos +```shell +go get -u github.com/go-kratos/kratos/registry/nacos/v2 +``` + +## kube + +```shell +go get -u github.com/go-kratos/kratos/config/kubernetes/v2 +``` \ No newline at end of file diff --git a/config/kube/README.md b/config/kubernetes/README.md similarity index 100% rename from config/kube/README.md rename to config/kubernetes/README.md diff --git a/config/kube/config.go b/config/kubernetes/config.go similarity index 85% rename from config/kube/config.go rename to config/kubernetes/config.go index 379fc17dd..1daaaea99 100644 --- a/config/kube/config.go +++ b/config/kubernetes/config.go @@ -1,4 +1,4 @@ -package main +package kubernetes import ( "context" @@ -13,15 +13,15 @@ import ( "k8s.io/client-go/tools/clientcmd" ) -// Option is kube option. +// Option is kubernetes option. type Option func(*options) type options struct { - // kube namespace + // kubernetes namespace Namespace string - // kube labelSelector example `app=test` + // kubernetes labelSelector example `app=test` LabelSelector string - // kube fieldSelector example `app=test` + // kubernetes fieldSelector example `app=test` FieldSelector string // set KubeConfig out-of-cluster Use outside cluster KubeConfig string @@ -29,35 +29,35 @@ type options struct { Master string } -// Namespace with kube namespace. +// Namespace with kubernetes namespace. func Namespace(ns string) Option { return func(o *options) { o.Namespace = ns } } -// LabelSelector with kube label selector. +// LabelSelector with kubernetes label selector. func LabelSelector(label string) Option { return func(o *options) { o.LabelSelector = label } } -// FieldSelector with kube field selector. +// FieldSelector with kubernetes field selector. func FieldSelector(field string) Option { return func(o *options) { o.FieldSelector = field } } -// KubeConfig with kube config. +// KubeConfig with kubernetes config. func KubeConfig(config string) Option { return func(o *options) { o.KubeConfig = config } } -// Master with kube master. +// Master with kubernetes master. func Master(master string) Option { return func(o *options) { o.Master = master @@ -69,7 +69,7 @@ type kube struct { client *kubernetes.Clientset } -// NewSource new a kube config source. +// NewSource new a kubernetes config source. func NewSource(opts ...Option) config.Source { options := options{} for _, o := range opts { diff --git a/config/kube/config_test.go b/config/kubernetes/config_test.go similarity index 94% rename from config/kube/config_test.go rename to config/kubernetes/config_test.go index 6bd3a5885..a66f59b9e 100644 --- a/config/kube/config_test.go +++ b/config/kubernetes/config_test.go @@ -1,4 +1,4 @@ -package main +package kubernetes import ( "path/filepath" diff --git a/config/kube/example.go b/config/kubernetes/example.go similarity index 97% rename from config/kube/example.go rename to config/kubernetes/example.go index 9636e456c..b2e1022ac 100644 --- a/config/kube/example.go +++ b/config/kubernetes/example.go @@ -1,4 +1,4 @@ -package main +package kubernetes import ( "log" diff --git a/config/kube/go.mod b/config/kubernetes/go.mod similarity index 78% rename from config/kube/go.mod rename to config/kubernetes/go.mod index bdf0f531f..4ba96ab71 100644 --- a/config/kube/go.mod +++ b/config/kubernetes/go.mod @@ -1,4 +1,4 @@ -module github.com/go-kratos/kratos/config/kube/v2 +module github.com/go-kratos/kratos/config/kubernetes/v2 go 1.15 diff --git a/config/kube/go.sum b/config/kubernetes/go.sum similarity index 100% rename from config/kube/go.sum rename to config/kubernetes/go.sum diff --git a/config/kube/watcher.go b/config/kubernetes/watcher.go similarity index 89% rename from config/kube/watcher.go rename to config/kubernetes/watcher.go index e3d237440..87872b8d7 100644 --- a/config/kube/watcher.go +++ b/config/kubernetes/watcher.go @@ -1,4 +1,4 @@ -package main +package kubernetes import ( "context" @@ -46,10 +46,10 @@ ResultChan: } cm, ok := ch.Object.(*v1.ConfigMap) if !ok { - return nil, fmt.Errorf("kube Object not ConfigMap") + return nil, fmt.Errorf("kubernetes Object not ConfigMap") } if ch.Type == "DELETED" { - return nil, fmt.Errorf("kube configmap delete %s", cm.Name) + return nil, fmt.Errorf("kubernetes configmap delete %s", cm.Name) } return w.k.configMap(*cm), nil } diff --git a/config/kube/watcher_test.go b/config/kubernetes/watcher_test.go similarity index 97% rename from config/kube/watcher_test.go rename to config/kubernetes/watcher_test.go index 0e6ec39d7..803449198 100644 --- a/config/kube/watcher_test.go +++ b/config/kubernetes/watcher_test.go @@ -1,4 +1,4 @@ -package main +package kubernetes import ( "context" diff --git a/registry/README.md b/registry/README.md index 2a58d5313..483472d0d 100644 --- a/registry/README.md +++ b/registry/README.md @@ -18,4 +18,9 @@ go get -u github.com/go-kratos/kratos/registry/zookeeper/v2 ## Nacos ```shell go get -u github.com/go-kratos/kratos/registry/nacos/v2 +``` + +## kubernetes +```shell +go get -u github.com/go-kratos/kratos/registry/kubernetes/v2 ``` \ No newline at end of file diff --git a/registry/kute/go.mod b/registry/kubernetes/go.mod similarity index 60% rename from registry/kute/go.mod rename to registry/kubernetes/go.mod index 878ba05f4..69bf9e843 100644 --- a/registry/kute/go.mod +++ b/registry/kubernetes/go.mod @@ -1,4 +1,4 @@ -module github.com/go-kratos/kratos/registry/kube/v2 +module github.com/go-kratos/kratos/registry/kubernetes/v2 go 1.17 diff --git a/registry/kute/go.sum b/registry/kubernetes/go.sum similarity index 100% rename from registry/kute/go.sum rename to registry/kubernetes/go.sum diff --git a/registry/kute/registry.go b/registry/kubernetes/registry.go similarity index 99% rename from registry/kute/registry.go rename to registry/kubernetes/registry.go index 12582102d..329f3bf1e 100644 --- a/registry/kute/registry.go +++ b/registry/kubernetes/registry.go @@ -1,5 +1,5 @@ // The package registry simply implements the Kubernetes-based Registry -package kute +package kubernetes import ( "context"