From 7ffd4ba0ac0be1a9a391ca783c409167ea0422b4 Mon Sep 17 00:00:00 2001 From: weibaohui Date: Sat, 19 Oct 2024 21:12:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=B0=86=E5=86=85=E9=83=A8?= =?UTF-8?q?=E5=8C=85=E6=94=B9=E4=B8=BA=E5=85=AC=E5=85=B1=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 internal/kubectl 改为 pkg/comm/kubectl - 将 internal/utils改为 pkg/comm/utils - 更新相关文件的导入路径 - 重命名部分文件以适应新路径 --- main.go | 2 +- pkg/callback/cb.go | 2 +- {internal => pkg/comm}/kubectl/apply.go | 0 {internal => pkg/comm}/kubectl/callback.go | 0 {internal => pkg/comm}/kubectl/client.go | 0 {internal => pkg/comm}/kubectl/configmap.go | 0 {internal => pkg/comm}/kubectl/deploy.go | 0 {internal => pkg/comm}/kubectl/doc.go | 2 +- {internal => pkg/comm}/kubectl/dynamic.go | 0 {internal => pkg/comm}/kubectl/dynamic_comm.go | 0 {internal => pkg/comm}/kubectl/dynamic_crd.go | 0 {internal => pkg/comm}/kubectl/dynamic_gvr.go | 0 {internal => pkg/comm}/kubectl/image_pull_secret.go | 0 {internal => pkg/comm}/kubectl/ingress.go | 0 {internal => pkg/comm}/kubectl/kubectl.go | 0 {internal => pkg/comm}/kubectl/node.go | 0 {internal => pkg/comm}/kubectl/ns.go | 0 {internal => pkg/comm}/kubectl/pod.go | 0 {internal => pkg/comm}/kubectl/pod_file.go | 2 +- {internal => pkg/comm}/kubectl/pvc.go | 0 {internal => pkg/comm}/kubectl/secret.go | 0 {internal => pkg/comm}/kubectl/service_account.go | 0 {internal => pkg/comm}/kubectl/statement.go | 2 +- {internal => pkg/comm}/kubectl/svc.go | 0 {internal => pkg/comm}/utils/amis/amis_list_result.go | 0 {internal => pkg/comm}/utils/amis/amis_ok_result.go | 0 {internal => pkg/comm}/utils/amis/amis_ui.go | 0 {internal => pkg/comm}/utils/base64.go | 0 {internal => pkg/comm}/utils/git_url_parser.go | 0 {internal => pkg/comm}/utils/git_url_parser_test.go | 0 {internal => pkg/comm}/utils/harbor.go | 0 {internal => pkg/comm}/utils/harbor_test.go | 0 {internal => pkg/comm}/utils/json.go | 0 {internal => pkg/comm}/utils/json_test.go | 0 {internal => pkg/comm}/utils/label.go | 0 {internal => pkg/comm}/utils/ptr.go | 0 {internal => pkg/comm}/utils/random.go | 0 {internal => pkg/comm}/utils/strings.go | 0 pkg/controller/chat/chat.go | 2 +- pkg/controller/deploy/deploy.go | 4 ++-- pkg/controller/doc/doc.go | 6 +++--- pkg/controller/dynamic/dynamic.go | 4 ++-- pkg/controller/ns/ns.go | 4 ++-- pkg/controller/pod/pod.go | 4 ++-- pkg/controller/pod/pod_file.go | 6 +++--- pkg/controller/sse/download.go | 2 +- 46 files changed, 21 insertions(+), 21 deletions(-) rename {internal => pkg/comm}/kubectl/apply.go (100%) rename {internal => pkg/comm}/kubectl/callback.go (100%) rename {internal => pkg/comm}/kubectl/client.go (100%) rename {internal => pkg/comm}/kubectl/configmap.go (100%) rename {internal => pkg/comm}/kubectl/deploy.go (100%) rename {internal => pkg/comm}/kubectl/doc.go (99%) rename {internal => pkg/comm}/kubectl/dynamic.go (100%) rename {internal => pkg/comm}/kubectl/dynamic_comm.go (100%) rename {internal => pkg/comm}/kubectl/dynamic_crd.go (100%) rename {internal => pkg/comm}/kubectl/dynamic_gvr.go (100%) rename {internal => pkg/comm}/kubectl/image_pull_secret.go (100%) rename {internal => pkg/comm}/kubectl/ingress.go (100%) rename {internal => pkg/comm}/kubectl/kubectl.go (100%) rename {internal => pkg/comm}/kubectl/node.go (100%) rename {internal => pkg/comm}/kubectl/ns.go (100%) rename {internal => pkg/comm}/kubectl/pod.go (100%) rename {internal => pkg/comm}/kubectl/pod_file.go (99%) rename {internal => pkg/comm}/kubectl/pvc.go (100%) rename {internal => pkg/comm}/kubectl/secret.go (100%) rename {internal => pkg/comm}/kubectl/service_account.go (100%) rename {internal => pkg/comm}/kubectl/statement.go (97%) rename {internal => pkg/comm}/kubectl/svc.go (100%) rename {internal => pkg/comm}/utils/amis/amis_list_result.go (100%) rename {internal => pkg/comm}/utils/amis/amis_ok_result.go (100%) rename {internal => pkg/comm}/utils/amis/amis_ui.go (100%) rename {internal => pkg/comm}/utils/base64.go (100%) rename {internal => pkg/comm}/utils/git_url_parser.go (100%) rename {internal => pkg/comm}/utils/git_url_parser_test.go (100%) rename {internal => pkg/comm}/utils/harbor.go (100%) rename {internal => pkg/comm}/utils/harbor_test.go (100%) rename {internal => pkg/comm}/utils/json.go (100%) rename {internal => pkg/comm}/utils/json_test.go (100%) rename {internal => pkg/comm}/utils/label.go (100%) rename {internal => pkg/comm}/utils/ptr.go (100%) rename {internal => pkg/comm}/utils/random.go (100%) rename {internal => pkg/comm}/utils/strings.go (100%) diff --git a/main.go b/main.go index 912625f..0da2f68 100644 --- a/main.go +++ b/main.go @@ -10,8 +10,8 @@ import ( "github.com/gin-contrib/gzip" "github.com/gin-gonic/gin" "github.com/weibaohui/k8m/flag" - "github.com/weibaohui/k8m/internal/kubectl" "github.com/weibaohui/k8m/pkg/callback" + "github.com/weibaohui/k8m/pkg/comm/kubectl" "github.com/weibaohui/k8m/pkg/controller/chat" "github.com/weibaohui/k8m/pkg/controller/deploy" "github.com/weibaohui/k8m/pkg/controller/doc" diff --git a/pkg/callback/cb.go b/pkg/callback/cb.go index 01422bb..c2940d0 100644 --- a/pkg/callback/cb.go +++ b/pkg/callback/cb.go @@ -3,7 +3,7 @@ package callback import ( "context" - "github.com/weibaohui/k8m/internal/kubectl" + "github.com/weibaohui/k8m/pkg/comm/kubectl" "k8s.io/klog/v2" ) diff --git a/internal/kubectl/apply.go b/pkg/comm/kubectl/apply.go similarity index 100% rename from internal/kubectl/apply.go rename to pkg/comm/kubectl/apply.go diff --git a/internal/kubectl/callback.go b/pkg/comm/kubectl/callback.go similarity index 100% rename from internal/kubectl/callback.go rename to pkg/comm/kubectl/callback.go diff --git a/internal/kubectl/client.go b/pkg/comm/kubectl/client.go similarity index 100% rename from internal/kubectl/client.go rename to pkg/comm/kubectl/client.go diff --git a/internal/kubectl/configmap.go b/pkg/comm/kubectl/configmap.go similarity index 100% rename from internal/kubectl/configmap.go rename to pkg/comm/kubectl/configmap.go diff --git a/internal/kubectl/deploy.go b/pkg/comm/kubectl/deploy.go similarity index 100% rename from internal/kubectl/deploy.go rename to pkg/comm/kubectl/deploy.go diff --git a/internal/kubectl/doc.go b/pkg/comm/kubectl/doc.go similarity index 99% rename from internal/kubectl/doc.go rename to pkg/comm/kubectl/doc.go index 7b87186..8d397aa 100644 --- a/internal/kubectl/doc.go +++ b/pkg/comm/kubectl/doc.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/weibaohui/k8m/internal/utils" + "github.com/weibaohui/k8m/pkg/comm/utils" "k8s.io/klog/v2" ) diff --git a/internal/kubectl/dynamic.go b/pkg/comm/kubectl/dynamic.go similarity index 100% rename from internal/kubectl/dynamic.go rename to pkg/comm/kubectl/dynamic.go diff --git a/internal/kubectl/dynamic_comm.go b/pkg/comm/kubectl/dynamic_comm.go similarity index 100% rename from internal/kubectl/dynamic_comm.go rename to pkg/comm/kubectl/dynamic_comm.go diff --git a/internal/kubectl/dynamic_crd.go b/pkg/comm/kubectl/dynamic_crd.go similarity index 100% rename from internal/kubectl/dynamic_crd.go rename to pkg/comm/kubectl/dynamic_crd.go diff --git a/internal/kubectl/dynamic_gvr.go b/pkg/comm/kubectl/dynamic_gvr.go similarity index 100% rename from internal/kubectl/dynamic_gvr.go rename to pkg/comm/kubectl/dynamic_gvr.go diff --git a/internal/kubectl/image_pull_secret.go b/pkg/comm/kubectl/image_pull_secret.go similarity index 100% rename from internal/kubectl/image_pull_secret.go rename to pkg/comm/kubectl/image_pull_secret.go diff --git a/internal/kubectl/ingress.go b/pkg/comm/kubectl/ingress.go similarity index 100% rename from internal/kubectl/ingress.go rename to pkg/comm/kubectl/ingress.go diff --git a/internal/kubectl/kubectl.go b/pkg/comm/kubectl/kubectl.go similarity index 100% rename from internal/kubectl/kubectl.go rename to pkg/comm/kubectl/kubectl.go diff --git a/internal/kubectl/node.go b/pkg/comm/kubectl/node.go similarity index 100% rename from internal/kubectl/node.go rename to pkg/comm/kubectl/node.go diff --git a/internal/kubectl/ns.go b/pkg/comm/kubectl/ns.go similarity index 100% rename from internal/kubectl/ns.go rename to pkg/comm/kubectl/ns.go diff --git a/internal/kubectl/pod.go b/pkg/comm/kubectl/pod.go similarity index 100% rename from internal/kubectl/pod.go rename to pkg/comm/kubectl/pod.go diff --git a/internal/kubectl/pod_file.go b/pkg/comm/kubectl/pod_file.go similarity index 99% rename from internal/kubectl/pod_file.go rename to pkg/comm/kubectl/pod_file.go index f336fb1..2d3fd0d 100644 --- a/internal/kubectl/pod_file.go +++ b/pkg/comm/kubectl/pod_file.go @@ -8,7 +8,7 @@ import ( "os" "strings" - "github.com/weibaohui/k8m/internal/utils" + "github.com/weibaohui/k8m/pkg/comm/utils" "k8s.io/client-go/tools/remotecommand" "k8s.io/klog/v2" ) diff --git a/internal/kubectl/pvc.go b/pkg/comm/kubectl/pvc.go similarity index 100% rename from internal/kubectl/pvc.go rename to pkg/comm/kubectl/pvc.go diff --git a/internal/kubectl/secret.go b/pkg/comm/kubectl/secret.go similarity index 100% rename from internal/kubectl/secret.go rename to pkg/comm/kubectl/secret.go diff --git a/internal/kubectl/service_account.go b/pkg/comm/kubectl/service_account.go similarity index 100% rename from internal/kubectl/service_account.go rename to pkg/comm/kubectl/service_account.go diff --git a/internal/kubectl/statement.go b/pkg/comm/kubectl/statement.go similarity index 97% rename from internal/kubectl/statement.go rename to pkg/comm/kubectl/statement.go index 49bc5ca..3e24ca5 100644 --- a/internal/kubectl/statement.go +++ b/pkg/comm/kubectl/statement.go @@ -1,7 +1,7 @@ package kubectl import ( - "github.com/weibaohui/k8m/internal/utils" + "github.com/weibaohui/k8m/pkg/comm/utils" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" ) diff --git a/internal/kubectl/svc.go b/pkg/comm/kubectl/svc.go similarity index 100% rename from internal/kubectl/svc.go rename to pkg/comm/kubectl/svc.go diff --git a/internal/utils/amis/amis_list_result.go b/pkg/comm/utils/amis/amis_list_result.go similarity index 100% rename from internal/utils/amis/amis_list_result.go rename to pkg/comm/utils/amis/amis_list_result.go diff --git a/internal/utils/amis/amis_ok_result.go b/pkg/comm/utils/amis/amis_ok_result.go similarity index 100% rename from internal/utils/amis/amis_ok_result.go rename to pkg/comm/utils/amis/amis_ok_result.go diff --git a/internal/utils/amis/amis_ui.go b/pkg/comm/utils/amis/amis_ui.go similarity index 100% rename from internal/utils/amis/amis_ui.go rename to pkg/comm/utils/amis/amis_ui.go diff --git a/internal/utils/base64.go b/pkg/comm/utils/base64.go similarity index 100% rename from internal/utils/base64.go rename to pkg/comm/utils/base64.go diff --git a/internal/utils/git_url_parser.go b/pkg/comm/utils/git_url_parser.go similarity index 100% rename from internal/utils/git_url_parser.go rename to pkg/comm/utils/git_url_parser.go diff --git a/internal/utils/git_url_parser_test.go b/pkg/comm/utils/git_url_parser_test.go similarity index 100% rename from internal/utils/git_url_parser_test.go rename to pkg/comm/utils/git_url_parser_test.go diff --git a/internal/utils/harbor.go b/pkg/comm/utils/harbor.go similarity index 100% rename from internal/utils/harbor.go rename to pkg/comm/utils/harbor.go diff --git a/internal/utils/harbor_test.go b/pkg/comm/utils/harbor_test.go similarity index 100% rename from internal/utils/harbor_test.go rename to pkg/comm/utils/harbor_test.go diff --git a/internal/utils/json.go b/pkg/comm/utils/json.go similarity index 100% rename from internal/utils/json.go rename to pkg/comm/utils/json.go diff --git a/internal/utils/json_test.go b/pkg/comm/utils/json_test.go similarity index 100% rename from internal/utils/json_test.go rename to pkg/comm/utils/json_test.go diff --git a/internal/utils/label.go b/pkg/comm/utils/label.go similarity index 100% rename from internal/utils/label.go rename to pkg/comm/utils/label.go diff --git a/internal/utils/ptr.go b/pkg/comm/utils/ptr.go similarity index 100% rename from internal/utils/ptr.go rename to pkg/comm/utils/ptr.go diff --git a/internal/utils/random.go b/pkg/comm/utils/random.go similarity index 100% rename from internal/utils/random.go rename to pkg/comm/utils/random.go diff --git a/internal/utils/strings.go b/pkg/comm/utils/strings.go similarity index 100% rename from internal/utils/strings.go rename to pkg/comm/utils/strings.go diff --git a/pkg/controller/chat/chat.go b/pkg/controller/chat/chat.go index ebb9e9e..ea59ca9 100644 --- a/pkg/controller/chat/chat.go +++ b/pkg/controller/chat/chat.go @@ -10,7 +10,7 @@ import ( "github.com/gin-gonic/gin" "github.com/sashabaranov/go-openai" - "github.com/weibaohui/k8m/internal/utils/amis" + "github.com/weibaohui/k8m/pkg/comm/utils/amis" "github.com/weibaohui/k8m/pkg/service" "k8s.io/klog/v2" ) diff --git a/pkg/controller/deploy/deploy.go b/pkg/controller/deploy/deploy.go index 9be9ee4..c68069c 100644 --- a/pkg/controller/deploy/deploy.go +++ b/pkg/controller/deploy/deploy.go @@ -2,8 +2,8 @@ package deploy import ( "github.com/gin-gonic/gin" - "github.com/weibaohui/k8m/internal/kubectl" - "github.com/weibaohui/k8m/internal/utils/amis" + "github.com/weibaohui/k8m/pkg/comm/kubectl" + "github.com/weibaohui/k8m/pkg/comm/utils/amis" ) func UpdateImageTag(c *gin.Context) { diff --git a/pkg/controller/doc/doc.go b/pkg/controller/doc/doc.go index 08cdf3e..30038ca 100644 --- a/pkg/controller/doc/doc.go +++ b/pkg/controller/doc/doc.go @@ -4,9 +4,9 @@ import ( "fmt" "github.com/gin-gonic/gin" - "github.com/weibaohui/k8m/internal/kubectl" - "github.com/weibaohui/k8m/internal/utils" - "github.com/weibaohui/k8m/internal/utils/amis" + "github.com/weibaohui/k8m/pkg/comm/kubectl" + "github.com/weibaohui/k8m/pkg/comm/utils" + "github.com/weibaohui/k8m/pkg/comm/utils/amis" "github.com/weibaohui/k8m/pkg/service" ) diff --git a/pkg/controller/dynamic/dynamic.go b/pkg/controller/dynamic/dynamic.go index fcec2fc..5ac6dd4 100644 --- a/pkg/controller/dynamic/dynamic.go +++ b/pkg/controller/dynamic/dynamic.go @@ -4,8 +4,8 @@ import ( "context" "github.com/gin-gonic/gin" - "github.com/weibaohui/k8m/internal/kubectl" - "github.com/weibaohui/k8m/internal/utils/amis" + "github.com/weibaohui/k8m/pkg/comm/kubectl" + "github.com/weibaohui/k8m/pkg/comm/utils/amis" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "sigs.k8s.io/yaml" ) diff --git a/pkg/controller/ns/ns.go b/pkg/controller/ns/ns.go index 0f9258c..90313af 100644 --- a/pkg/controller/ns/ns.go +++ b/pkg/controller/ns/ns.go @@ -2,8 +2,8 @@ package ns import ( "github.com/gin-gonic/gin" - "github.com/weibaohui/k8m/internal/kubectl" - "github.com/weibaohui/k8m/internal/utils/amis" + "github.com/weibaohui/k8m/pkg/comm/kubectl" + "github.com/weibaohui/k8m/pkg/comm/utils/amis" ) func OptionList(c *gin.Context) { diff --git a/pkg/controller/pod/pod.go b/pkg/controller/pod/pod.go index 30531c5..ab069f2 100644 --- a/pkg/controller/pod/pod.go +++ b/pkg/controller/pod/pod.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/gin-gonic/gin" - "github.com/weibaohui/k8m/internal/kubectl" - "github.com/weibaohui/k8m/internal/utils/amis" + "github.com/weibaohui/k8m/pkg/comm/kubectl" + "github.com/weibaohui/k8m/pkg/comm/utils/amis" "github.com/weibaohui/k8m/pkg/controller/sse" ) diff --git a/pkg/controller/pod/pod_file.go b/pkg/controller/pod/pod_file.go index bc5fe30..c1f2543 100644 --- a/pkg/controller/pod/pod_file.go +++ b/pkg/controller/pod/pod_file.go @@ -6,9 +6,9 @@ import ( "path/filepath" "github.com/gin-gonic/gin" - "github.com/weibaohui/k8m/internal/kubectl" - "github.com/weibaohui/k8m/internal/utils" - "github.com/weibaohui/k8m/internal/utils/amis" + "github.com/weibaohui/k8m/pkg/comm/kubectl" + "github.com/weibaohui/k8m/pkg/comm/utils" + "github.com/weibaohui/k8m/pkg/comm/utils/amis" "k8s.io/klog/v2" ) diff --git a/pkg/controller/sse/download.go b/pkg/controller/sse/download.go index 54024e1..08cd1a1 100644 --- a/pkg/controller/sse/download.go +++ b/pkg/controller/sse/download.go @@ -5,7 +5,7 @@ import ( "io" "github.com/gin-gonic/gin" - "github.com/weibaohui/k8m/internal/utils/amis" + "github.com/weibaohui/k8m/pkg/comm/utils/amis" v1 "k8s.io/api/core/v1" "k8s.io/klog/v2" )