Skip to content

Commit

Permalink
feat(kom): 添加 PVC 关联信息
Browse files Browse the repository at this point in the history
- 在 LinkedPVC 函数中增加 PVC 关联的 Pod Mount 信息
- 为每个 PVC 添加 pvcMounts 注解,包含挂载路径和权限等信息
  • Loading branch information
weibaohui committed Jan 21, 2025
1 parent c9974e9 commit 4791ed3
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions example/pod_link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,25 +170,20 @@ spec:
claimName: my-pod-pvc
`
kom.DefaultCluster().Applier().Apply(yaml)
time.Sleep(10 * time.Second)
name := "nginx-pv-pvc-test-deployment-c9b6d49bc-q45mt"

pvcs, err := kom.DefaultCluster().Resource(&v1.Pod{}).
Namespace("default").
Name("my-pod-pvc").Ctl().Pod().LinkedPVC()
Name(name).Ctl().Pod().LinkedPVC()
if err != nil {
t.Logf("get pod linked pvc error %v\n", err.Error())
return
}
for _, pvc := range pvcs {
t.Logf("pvc name %v\n", pvc.Name)
t.Logf("pvcMounts %s %v\n", pvc.Name, pvc.Annotations["pvcMounts"])
}
pvcNames := []string{}
for _, pvc := range pvcs {
pvcNames = append(pvcNames, pvc.Name)
}
// 检查pvcs列表是否包含my-pvc
if !slices.Contains(pvcNames, "my-pod-pvc") {
t.Errorf("my-pod-pvc not found in pvcs")
}

}
func TestPodLinkPV(t *testing.T) {

Expand Down

0 comments on commit 4791ed3

Please sign in to comment.