37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
store.go 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
Dan Ramich 提交于 2019-06-12 13:38 . goimport linting changes
package app
import (
"fmt"
"github.com/rancher/norman/types"
pv3app "github.com/rancher/rancher/pkg/api/customization/app"
"github.com/rancher/rancher/pkg/ref"
pv3 "github.com/rancher/types/apis/project.cattle.io/v3"
"k8s.io/apimachinery/pkg/api/errors"
)
type Store struct {
types.Store
Apps pv3.AppLister
}
func (s *Store) Delete(apiContext *types.APIContext, schema *types.Schema, id string) (map[string]interface{}, error) {
if err := s.validateForMultiClusterApp(id, "delete"); err != nil {
return nil, err
}
return s.Store.Delete(apiContext, schema, id)
}
func (s *Store) Update(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}, id string) (map[string]interface{}, error) {
if err := s.validateForMultiClusterApp(id, "update"); err != nil {
return nil, err
}
return s.Store.Update(apiContext, schema, data, id)
}
func (s *Store) validateForMultiClusterApp(id string, msg string) error {
ns, name := ref.Parse(id)
if ns == "" || name == "" {
return fmt.Errorf("invalid app id %s", id)
}
app, err := s.Apps.Get(ns, name)
if err != nil {
if !errors.IsNotFound(err) {
return fmt.Errorf("error getting app %s: %v", id, err)
}
return nil
}
if label, ok := app.Labels[pv3app.MCappLabel]; ok && label != "" {
return fmt.Errorf("app %s is controlled by mcapp %s : cannot be %sd", id, label, msg)
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.12-rc2

搜索帮助

0d507c66 1850385 C8b1a773 1850385