mirror of
https://github.com/rancher/steve.git
synced 2025-09-17 07:48:52 +00:00
testing
This commit is contained in:
@@ -23,6 +23,7 @@ type Factory interface {
|
||||
ByGVR(gvr schema.GroupVersionResource) string
|
||||
ByGVK(gvr schema.GroupVersionKind) string
|
||||
OnChange(ctx context.Context, cb func())
|
||||
AddTemplate(template ...Template)
|
||||
}
|
||||
|
||||
type Collection struct {
|
||||
@@ -210,17 +211,19 @@ func (c *Collection) ByGVK(gvk schema.GroupVersionKind) string {
|
||||
return c.byGVK[gvk]
|
||||
}
|
||||
|
||||
func (c *Collection) AddTemplate(template *Template) {
|
||||
func (c *Collection) AddTemplate(templates ...Template) {
|
||||
c.lock.RLock()
|
||||
defer c.lock.RUnlock()
|
||||
|
||||
if template.Kind != "" {
|
||||
c.templates[template.Group+"/"+template.Kind] = template
|
||||
}
|
||||
if template.ID != "" {
|
||||
c.templates[template.ID] = template
|
||||
}
|
||||
if template.Kind == "" && template.Group == "" && template.ID == "" {
|
||||
c.templates[""] = template
|
||||
for i, template := range templates {
|
||||
if template.Kind != "" {
|
||||
c.templates[template.Group+"/"+template.Kind] = &templates[i]
|
||||
}
|
||||
if template.ID != "" {
|
||||
c.templates[template.ID] = &templates[i]
|
||||
}
|
||||
if template.Kind == "" && template.Group == "" && template.ID == "" {
|
||||
c.templates[""] = &templates[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user