forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplateconfig.go
33 lines (27 loc) · 952 Bytes
/
templateconfig.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
package v1
import (
"k8s.io/client-go/rest"
templatev1 "github.com/openshift/api/template/v1"
)
// TemplateConfigInterface is an interface for processing template client.
type TemplateProcessorInterface interface {
Process(*templatev1.Template) (*templatev1.Template, error)
}
// NewTemplateProcessorClient returns a client capable of processing the templates.
func NewTemplateProcessorClient(c rest.Interface, ns string) TemplateProcessorInterface {
return &templateProcessor{client: c, ns: ns}
}
type templateProcessor struct {
client rest.Interface
ns string
}
// Process takes an unprocessed template and returns a processed
// template with all parameters substituted.
func (c *templateProcessor) Process(in *templatev1.Template) (*templatev1.Template, error) {
template := &templatev1.Template{}
err := c.client.Post().
Namespace(c.ns).
Resource("processedTemplates").
Body(in).Do().Into(template)
return template, err
}