forked from rancher/rancher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node.go
31 lines (26 loc) · 923 Bytes
/
node.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
package node
import (
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/convert"
"github.com/rancher/types/client/management/v3"
)
// Formatter for Node
func Formatter(apiContext *types.APIContext, resource *types.RawResource) {
etcd := convert.ToBool(resource.Values[client.NodeFieldEtcd])
cp := convert.ToBool(resource.Values[client.NodeFieldControlPlane])
worker := convert.ToBool(resource.Values[client.NodeFieldWorker])
if !etcd && !cp && !worker {
resource.Values[client.NodeFieldWorker] = true
}
// add nodeConfig action
resource.Links["nodeConfig"] = apiContext.URLBuilder.Link("nodeConfig", resource)
// remove link
nodeTemplateID := resource.Values["nodeTemplateId"]
customConfig := resource.Values["customConfig"]
if nodeTemplateID == nil {
delete(resource.Links, "nodeConfig")
}
if nodeTemplateID == nil && customConfig == nil {
delete(resource.Links, "remove")
}
}