Skip to content

Commit

Permalink
feat(tools): 添加清除缓存功能并编写相关测试
Browse files Browse the repository at this point in the history
- 在 tools.go 文件中添加 ClearCache 方法,用于清除 kubectl 集群缓存
- 新增 tools_test.go 文件,实现对 ClearCache 功能的测试
  • Loading branch information
weibaohui committed Jan 17, 2025
1 parent dd1447a commit 418b221
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions example/tools_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package example

import (
"testing"

"github.com/weibaohui/kom/kom"
)

func TestToolCacheClear(t *testing.T) {

kom.DefaultCluster().Tools().ClearCache()

}
4 changes: 4 additions & 0 deletions kom/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ type tools struct {
kubectl *Kubectl
}

func (u *tools) ClearCache() {
u.kubectl.ClusterCache().Clear()
}

// ConvertRuntimeObjectToTypedObject 是一个通用的转换函数,将 runtime.Object 转换为指定的目标类型
func (u *tools) ConvertRuntimeObjectToTypedObject(obj runtime.Object, target interface{}) error {
// 将 obj 断言为 *unstructured.Unstructured 类型
Expand Down

0 comments on commit 418b221

Please sign in to comment.