35 Star 389 Fork 70

GVPrancher / rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
cluster_catalog_sync.go 1.45 KB
一键复制 编辑 原始数据 按行查看 历史
Dan Ramich 提交于 2019-06-12 13:38 . goimport linting changes
package manager
import (
helmlib "github.com/rancher/rancher/pkg/catalog/helm"
v3 "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) updateClusterCatalogError(clusterCatalog *v3.ClusterCatalog, err error) (runtime.Object, error) {
setRefreshedError(&clusterCatalog.Catalog, err)
m.clusterCatalogClient.Update(clusterCatalog)
return nil, err
}
func (m *Manager) ClusterCatalogSync(key string, obj *v3.ClusterCatalog) (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
clusterCatalog, err := m.clusterCatalogClient.GetNamespaced(ns, name, metav1.GetOptions{})
if err != nil {
return nil, err
}
commit, helm, err := helmlib.NewForceUpdate(&clusterCatalog.Catalog)
if err != nil {
return m.updateClusterCatalogError(clusterCatalog, err)
}
if isUpToDate(commit, &clusterCatalog.Catalog) {
if setRefreshed(&clusterCatalog.Catalog) {
m.clusterCatalogClient.Update(clusterCatalog)
}
return nil, nil
}
cmt := &CatalogInfo{
catalog: &clusterCatalog.Catalog,
clusterCatalog: clusterCatalog,
}
logrus.Infof("Updating cluster catalog %s", clusterCatalog.Name)
return nil, m.traverseAndUpdate(helm, commit, cmt)
}
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.2.13

搜索帮助