forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 1
/
catalog_data.go
37 lines (34 loc) · 869 Bytes
/
catalog_data.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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"
)
const (
defaultURL = "https://git.rancher.io/charts"
defaultBranch = "master"
name = "library"
)
func addCatalogs(management *config.ManagementContext) 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: defaultURL,
CatalogKind: "helm",
Branch: defaultBranch,
},
}
if _, err := catalogClient.Create(obj); err != nil {
return err
}
}
return nil
}