37 Star 396 Fork 71

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
store.go 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
Darren Shepherd 提交于 2018-01-26 09:06 . Refactor imports
package ingress
import (
"github.com/rancher/norman/store/proxy"
"github.com/rancher/norman/types"
"github.com/rancher/rancher/pkg/workload/controller/ingress"
"github.com/rancher/types/config"
"github.com/satori/uuid"
)
type Store struct {
types.Store
proxyStore *proxy.Store
controller *ingress.Controller
}
func NewStore(workload *config.WorkloadContext) *Store {
return &Store{
Store: proxy.NewProxyStore(workload.UnversionedClient,
[]string{"apis"},
"extensions",
"v1beta1",
"Ingress",
"ingresses"),
proxyStore: proxy.NewRawProxyStore(workload.UnversionedClient,
[]string{"apis"},
"extensions",
"v1beta1",
"Ingress",
"ingresses"),
controller: ingress.NewIngressWorkloadController(workload),
}
}
func (s *Store) Create(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}) (map[string]interface{}, error) {
data["uuid"] = uuid.NewV4().String()
_, err := s.controller.Reconcile(data, true)
if err != nil {
return nil, err
}
return s.Store.Create(apiContext, schema, data)
}
func (s *Store) Update(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}, id string) (map[string]interface{}, error) {
existing, err := s.Store.ByID(apiContext, schema, id)
if err != nil {
return existing, err
}
for k, v := range data {
existing[k] = v
}
_, err = s.controller.Reconcile(existing, true)
if err != nil {
return nil, err
}
return s.Store.Update(apiContext, schema, data, id)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.0.0-alpha16

搜索帮助

344bd9b3 5694891 D2dac590 5694891