forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster_data.go
37 lines (33 loc) · 864 Bytes
/
cluster_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 (
v3 "github.com/rancher/types/apis/management.cattle.io/v3"
"github.com/rancher/types/config"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func addLocalCluster(embedded bool, adminName string, management *config.ManagementContext) error {
c := &v3.Cluster{
ObjectMeta: v1.ObjectMeta{
Name: "local",
Annotations: map[string]string{
"field.cattle.io/creatorId": adminName,
},
},
Spec: v3.ClusterSpec{
Internal: true,
DisplayName: "local",
},
Status: v3.ClusterStatus{
Driver: v3.ClusterDriverImported,
},
}
if embedded {
c.Status.Driver = v3.ClusterDriverLocal
}
// Ignore error
management.Management.Clusters("").Create(c)
return nil
}
func removeLocalCluster(management *config.ManagementContext) error {
management.Management.Clusters("").Delete("local", &v1.DeleteOptions{})
return nil
}