代码拉取完成,页面将自动刷新
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
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。