-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.go
34 lines (29 loc) · 1020 Bytes
/
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
33
34
package namespace
import (
"github.com/rancher/norman/store/transform"
"github.com/rancher/norman/types"
"github.com/rancher/norman/types/values"
)
func New(store types.Store) types.Store {
t := &transform.Store{
Store: store,
Transformer: func(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}, opt *types.QueryOptions) (map[string]interface{}, error) {
anns, _ := data["annotations"].(map[string]interface{})
if anns["management.cattle.io/system-namespace"] == "true" {
return nil, nil
}
return data, nil
},
}
return &Store{
Store: t,
}
}
type Store struct {
types.Store
}
func (p *Store) Create(apiContext *types.APIContext, schema *types.Schema, data map[string]interface{}) (map[string]interface{}, error) {
values.PutValue(data, "{\"conditions\": [{\"type\": \"InitialRolesPopulated\", \"status\": \"Unknown\", \"message\": \"Populating initial roles\"}]}",
"annotations", "cattle.io/status")
return p.Store.Create(apiContext, schema, data)
}