forked from garetht/amanar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amanar_interfaces.go
55 lines (43 loc) · 1.35 KB
/
amanar_interfaces.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// This file was generated from JSON Schema using quicktype, do not modify it directly.
// To parse and unparse this JSON data, add this code to your project and do:
//
// amanar, err := UnmarshalAmanar(bytes)
// bytes, err = amanar.Marshal()
package amanar
import (
"fmt"
"io"
)
type TemplateDefiner interface {
GetTemplate() *string
GetTemplatePath() *string
}
func NewTemplateSource(definer TemplateDefiner, writer io.Writer) (source *TemplateSource, err error) {
if definer.GetTemplate() == nil && definer.GetTemplatePath() == nil {
return nil, fmt.Errorf("neither template nor template path were provided")
}
if definer.GetTemplate() != nil && definer.GetTemplatePath() != nil {
return nil, fmt.Errorf("provide at most one of template or template path")
}
if definer.GetTemplate() != nil {
source, err = NewTemplateSourceFromString(definer.GetTemplate(), writer)
} else {
source, err = NewTemplateSourceFromFile(definer.GetTemplatePath(), writer)
}
if err != nil {
return nil, fmt.Errorf("could not parse template: %w", err)
}
return
}
func (tds *TemplateDatasource) GetTemplate() *string {
return tds.Template
}
func (tds *TemplateDatasource) GetTemplatePath() *string {
return tds.TemplatePath
}
func (c *Constant) GetTemplate() *string {
return c.Template
}
func (c *Constant) GetTemplatePath() *string {
return c.TemplatePath
}