37 Star 407 Fork 74

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
store.go 718 Bytes
一键复制 编辑 原始数据 按行查看 历史
package nodetemplate
import (
"github.com/rancher/norman/httperror"
"github.com/rancher/norman/types"
"github.com/rancher/types/apis/management.cattle.io/v3"
"k8s.io/apimachinery/pkg/labels"
)
type Store struct {
types.Store
NodePoolLister v3.NodePoolLister
}
func (s *Store) Delete(apiContext *types.APIContext, schema *types.Schema, id string) (map[string]interface{}, error) {
pools, err := s.NodePoolLister.List("", labels.Everything())
if err != nil {
return nil, err
}
for _, pool := range pools {
if pool.Spec.NodeTemplateName == id {
return nil, httperror.NewAPIError(httperror.MethodNotAllowed, "Template is in use by a node pool.")
}
}
return s.Store.Delete(apiContext, schema, id)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.1.12-rc2

搜索帮助