appmanager: make app responsible for rendering its own resources
diff --git a/core/installer/app.go b/core/installer/app.go
index 384e54f..76acf74 100644
--- a/core/installer/app.go
+++ b/core/installer/app.go
@@ -2,6 +2,7 @@
import (
"archive/tar"
+ "bytes"
"compress/gzip"
"embed"
"fmt"
@@ -35,7 +36,7 @@
type App struct {
Name string
Namespaces []string
- Templates []*template.Template
+ templates []*template.Template
schema Schema
Readme *template.Template
}
@@ -44,6 +45,18 @@
return a.schema
}
+func (a App) Render(derived Derived) (map[string][]byte, error) {
+ ret := make(map[string][]byte)
+ for _, t := range a.templates {
+ var buf bytes.Buffer
+ if err := t.Execute(&buf, derived); err != nil {
+ return nil, err
+ }
+ ret[t.Name()] = buf.Bytes()
+ }
+ return ret, nil
+}
+
type StoreApp struct {
App
Icon htemplate.HTML
@@ -808,7 +821,7 @@
Readme: readmeTmpl,
schema: schema,
Namespaces: appCfg.Namespaces,
- Templates: tmpls,
+ templates: tmpls,
},
ShortDescription: appCfg.Description,
Icon: appCfg.Icon,