代码拉取完成,页面将自动刷新
package manager
import (
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/sirupsen/logrus"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func (m *Manager) Sync(key string, obj *v3.Catalog) error {
if obj == nil {
templates, err := m.getTemplateMap(key)
if err != nil {
return err
}
tvToDelete := map[string]struct{}{}
for _, t := range templates {
tvs, err := m.getTemplateVersion(t.Name)
if err != nil {
return err
}
for k := range tvs {
tvToDelete[k] = struct{}{}
}
}
go func() {
for {
for k := range templates {
if err := m.templateClient.Delete(k, &metav1.DeleteOptions{}); err != nil && !kerrors.IsNotFound(err) {
logrus.Warnf("Deleting template %v doesn't succeed. Continue loop", k)
continue
}
}
for k := range tvToDelete {
if err := m.templateVersionClient.Delete(k, &metav1.DeleteOptions{}); err != nil && !kerrors.IsNotFound(err) {
logrus.Warnf("Deleting templateVersion %v doesn't succeed. Continue loop", k)
continue
}
}
break
}
}()
return nil
}
// always get a refresh catalog from etcd
catalog, err := m.catalogClient.Get(key, metav1.GetOptions{})
if err != nil {
return err
}
repoPath, commit, err := m.prepareRepoPath(*catalog)
if err != nil {
v3.CatalogConditionRefreshed.False(catalog)
v3.CatalogConditionRefreshed.ReasonAndMessageFromError(catalog, err)
m.catalogClient.Update(catalog)
return err
}
if commit == catalog.Status.Commit {
logrus.Debugf("Catalog %s is already up to date", catalog.Name)
if v3.CatalogConditionRefreshed.IsUnknown(catalog) {
v3.CatalogConditionRefreshed.True(catalog)
v3.CatalogConditionRefreshed.Reason(catalog, "")
m.catalogClient.Update(catalog)
}
return nil
}
logrus.Infof("Updating catalog %s", catalog.Name)
return m.traverseAndUpdate(repoPath, commit, catalog)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。