代码拉取完成,页面将自动刷新
package manager
import (
"github.com/pkg/errors"
"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 {
return nil
}
if obj.DeletionTimestamp != nil {
templates, err := m.getTemplateMap(obj.Name)
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
}
catalog := obj.DeepCopy()
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)
m.catalogClient.Update(catalog)
}
return nil
}
catalog.Status.Commit = commit
templates, toDeleteTemplate, versionCommits, errs, err := traverseFiles(repoPath, catalog)
if err != nil {
return errors.Wrap(err, "Repo traversal failed")
}
if len(errs) != 0 {
logrus.Errorf("Errors while parsing repo: %v", errs)
}
logrus.Infof("Updating catalog %s", catalog.Name)
return m.update(catalog, templates, toDeleteTemplate, versionCommits, commit)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。