forked from openshift/oc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
templateconfig.go
33 lines (27 loc) · 973 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 templateprocessorclient
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
}