Commit 8cc12df0 authored by orangedeng's avatar orangedeng Committed by Alena Prokharchyk
Browse files

Operator workload Should be displayed in Rancher UI

parent cc0d9af6
Showing with 18 additions and 0 deletions
+18 -0
......@@ -12,6 +12,10 @@ import (
"github.com/sirupsen/logrus"
)
var (
hideOwnerReferenceKinds = map[string]bool{"CronJob": true, "Deployment": true}
)
func NewTransformStore(store types.Store) types.Store {
return &transform.Store{
Store: store,
......@@ -24,6 +28,7 @@ func NewTransformStore(store types.Store) types.Store {
hide = false
}
typeName := definition.GetType(data)
hide = hideByOwner(data)
name, _ := data["name"].(string)
if hide && data["ownerReferences"] != nil {
pod.SaveOwner(apiContext, typeName, name, data)
......@@ -89,3 +94,16 @@ func update(data map[string]interface{}, statusField string, desiredField string
}
}
}
func hideByOwner(data map[string]interface{}) bool {
if data["ownerReferences"] != nil {
owners := convert.ToMapSlice(data["ownerReferences"])
for _, owner := range owners {
ownerKind := convert.ToString(owner["kind"])
if _, ok := hideOwnerReferenceKinds[ownerKind]; ok {
return true
}
}
}
return false
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment