Skip to content

Commit

Permalink
feat(controller/pod): 添加获取 Pod 关联环境变量信息的功能
Browse files Browse the repository at this point in the history
- 新增 LinksEnvFromPod 函数,用于获取指定 Pod 的关联环境变量
- 通过 Cluster、Namespace、Pod 名称进行查询
- 结果以 JSON 格式返回
  • Loading branch information
weibaohui committed Jan 8, 2025
1 parent 663dce5 commit 86443dc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/controller/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,24 @@ func LinksEnv(c *gin.Context) {
amis.WriteJsonList(c, env)
}

func LinksEnvFromPod(c *gin.Context) {
name := c.Param("name")
ns := c.Param("ns")
ctx := c.Request.Context()
selectedCluster := amis.GetSelectedCluster(c)

env, err := kom.Cluster(selectedCluster).WithContext(ctx).
Resource(&v1.Pod{}).
Namespace(ns).
Name(name).
WithCache(linkCacheTTL).Ctl().Pod().LinkedEnvFromPod()
if err != nil {
amis.WriteJsonError(c, err)
return
}
amis.WriteJsonList(c, env)
}

func LinksConfigMap(c *gin.Context) {
name := c.Param("name")
ns := c.Param("ns")
Expand Down

0 comments on commit 86443dc

Please sign in to comment.