37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
project_catalog_sync.go 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
Erik Wilson 提交于 2018-11-06 18:04 . Store templateContent cache on disk
package manager
import (
helmlib "github.com/rancher/rancher/pkg/catalog/helm"
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/tools/cache"
)
func (m *Manager) updateProjectCatalogError(projectCatalog *v3.ProjectCatalog, err error) (runtime.Object, error) {
setRefreshedError(&projectCatalog.Catalog, err)
m.projectCatalogClient.Update(projectCatalog)
return nil, err
}
func (m *Manager) ProjectCatalogSync(key string, obj *v3.ProjectCatalog) (runtime.Object, error) {
ns, name, err := cache.SplitMetaNamespaceKey(key)
if err != nil {
return nil, err
}
if obj == nil {
return nil, m.deleteTemplates(name, ns)
}
// always get a refresh catalog from etcd
projectCatalog, err := m.projectCatalogClient.GetNamespaced(ns, name, metav1.GetOptions{})
if err != nil {
return nil, err
}
commit, helm, err := helmlib.NewForceUpdate(&projectCatalog.Catalog)
if err != nil {
return m.updateProjectCatalogError(projectCatalog, err)
}
if isUpToDate(commit, &projectCatalog.Catalog) {
if setRefreshed(&projectCatalog.Catalog) {
m.projectCatalogClient.Update(projectCatalog)
}
return nil, nil
}
cmt := &CatalogInfo{
catalog: &projectCatalog.Catalog,
projectCatalog: projectCatalog,
}
logrus.Infof("Updating project catalog %s", projectCatalog.Name)
return nil, m.traverseAndUpdate(helm, commit, cmt)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.0-rc14

搜索帮助

0d507c66 1850385 C8b1a773 1850385