-
Notifications
You must be signed in to change notification settings - Fork 0
/
workload_store.go
32 lines (27 loc) · 1.16 KB
/
workload_store.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
package workload
import (
"github.com/rancher/norman/types"
"github.com/rancher/types/apis/project.cattle.io/v3/schema"
)
func ConfigureStore(schemas *types.Schemas) {
workloadSchema := schemas.Schema(&schema.Version, "workload")
store := NewAggregateStore(
schemas.Schema(&schema.Version, "deployment"),
schemas.Schema(&schema.Version, "replicaSet"),
schemas.Schema(&schema.Version, "replicationController"),
schemas.Schema(&schema.Version, "daemonSet"),
schemas.Schema(&schema.Version, "statefulSet"),
schemas.Schema(&schema.Version, "job"),
schemas.Schema(&schema.Version, "cronJob"))
for _, s := range store.Schemas {
s.Formatter = workloadFormatter
}
workloadSchema.Store = store
}
func workloadFormatter(apiContext *types.APIContext, resource *types.RawResource) {
workloadID := resource.ID
workloadSchema := apiContext.Schemas.Schema(&schema.Version, "workload")
resource.Links["self"] = apiContext.URLBuilder.ResourceLinkByID(workloadSchema, workloadID)
resource.Links["remove"] = apiContext.URLBuilder.ResourceLinkByID(workloadSchema, workloadID)
resource.Links["update"] = apiContext.URLBuilder.ResourceLinkByID(workloadSchema, workloadID)
}