37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
catalog_data.go 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
Craig Jellick 提交于 2019-05-09 19:20 . system-charts branch v2.3-preview1
package app
import (
"github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
)
const (
libraryURL = "https://git.rancher.io/charts"
libraryBranch = "master"
libraryName = "library"
systemLibraryURL = "https://git.rancher.io/system-charts"
systemLibraryBranch = "v2.3-preview1"
systemLibraryName = "system-library"
)
func addCatalogs(management *config.ManagementContext) error {
return utilerrors.AggregateGoroutines(
// add charts
func() error {
return doAddCatalogs(management, libraryName, libraryURL, libraryBranch)
},
// add rancher-charts
func() error {
return doAddCatalogs(management, systemLibraryName, systemLibraryURL, systemLibraryBranch)
},
)
}
func doAddCatalogs(management *config.ManagementContext, name, url, branch string) error {
catalogClient := management.Management.Catalogs("")
_, err := catalogClient.Get(name, metav1.GetOptions{})
if err != nil && !errors.IsNotFound(err) {
return err
} else if errors.IsNotFound(err) {
obj := &v3.Catalog{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: v3.CatalogSpec{
URL: url,
CatalogKind: "helm",
Branch: branch,
},
}
if _, err := catalogClient.Create(obj); err != nil {
return err
}
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.3.0-alpha2

搜索帮助