代码拉取完成,页面将自动刷新
package k8s
import (
"sync"
)
var clusterSets IClusterSet
func GetClusterSets() IClusterSet {
return clusterSets
}
type IClusterSet interface {
Add(clusterName string, clientSets *ClientSets)
Update(clusterName string, clientSets *ClientSets)
Delete(clusterName string)
Get(clusterName string) *ClientSets
List() map[string]*ClientSets
}
var _ IClusterSet = (*ClusterSet)(nil)
func NewClusterSet() {
clusterSets = &ClusterSet{clientSets: map[string]*ClientSets{}}
}
type ClusterSet struct {
lock sync.RWMutex
clientSets map[string]*ClientSets
}
func (c *ClusterSet) Add(clusterName string, clientSets *ClientSets) {
c.lock.Lock()
defer c.lock.Unlock()
c.clientSets[clusterName] = clientSets
}
func (c *ClusterSet) Update(clusterName string, clientSets *ClientSets) {
c.lock.Lock()
defer c.lock.Unlock()
c.clientSets[clusterName] = clientSets
}
func (c *ClusterSet) Delete(clusterName string) {
c.lock.Lock()
defer c.lock.Unlock()
if _, ok := c.clientSets[clusterName]; ok {
delete(c.clientSets, clusterName)
}
}
func (c *ClusterSet) Get(clusterName string) *ClientSets {
c.lock.Lock()
defer c.lock.Unlock()
item, exists := c.clientSets[clusterName]
if !exists {
return &ClientSets{
K8sClient: nil,
MetricsClient: nil,
InformerClient: nil,
}
}
return item
}
func (c *ClusterSet) List() map[string]*ClientSets {
c.lock.Lock()
defer c.lock.Unlock()
return c.clientSets
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。