Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Commit

Permalink
Rename Template -> TemplateBuilder, so it's not confused with VM temp…
Browse files Browse the repository at this point in the history
…lates
  • Loading branch information
Jaime Melis committed Oct 1, 2015
1 parent ad855a5 commit 897debc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions template_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,35 @@ import (
"strings"
)

type Template struct {
elements []TemplateElement
type TemplateBuilder struct {
elements []TemplateBuilderElement
}

type TemplateElement interface {
type TemplateBuilderElement interface {
String() string
}

type TemplatePair struct {
type TemplateBuilderPair struct {
key string
value string
}

type TemplateVector struct {
type TemplateBuilderVector struct {
key string
pairs []TemplatePair
pairs []TemplateBuilderPair
}

func NewTemplate() *Template {
return &Template{}
func NewTemplateBuilder() *TemplateBuilder {
return &TemplateBuilder{}
}

func (t *Template) NewVector(key string) *TemplateVector {
vector := &TemplateVector{key: key}
func (t *TemplateBuilder) NewVector(key string) *TemplateBuilderVector {
vector := &TemplateBuilderVector{key: key}
t.elements = append(t.elements, vector)
return vector
}

func (t *Template) String() string {
func (t *TemplateBuilder) String() string {
s := ""
endToken := "\n"

Expand All @@ -47,11 +47,11 @@ func (t *Template) String() string {
return s
}

func (t *TemplatePair) String() string {
func (t *TemplateBuilderPair) String() string {
return fmt.Sprintf("%s=\"%s\"", t.key, t.value)
}

func (t *TemplateVector) String() string {
func (t *TemplateBuilderVector) String() string {
s := fmt.Sprintf("%s=[\n", strings.ToUpper(t.key))

endToken := ",\n"
Expand All @@ -68,15 +68,15 @@ func (t *TemplateVector) String() string {
return s
}

func (t *Template) AddValue(key, val string) error {
pair := &TemplatePair{strings.ToUpper(key), val}
func (t *TemplateBuilder) AddValue(key, val string) error {
pair := &TemplateBuilderPair{strings.ToUpper(key), val}
t.elements = append(t.elements, pair)

return nil
}

func (t *TemplateVector) AddValue(key, val string) error {
pair := TemplatePair{strings.ToUpper(key), val}
func (t *TemplateBuilderVector) AddValue(key, val string) error {
pair := TemplateBuilderPair{strings.ToUpper(key), val}
t.pairs = append(t.pairs, pair)

return nil
Expand Down
2 changes: 1 addition & 1 deletion template_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
)

func Example() {
template := NewTemplate()
template := NewTemplateBuilder()

template.AddValue("cpu", "1")
template.AddValue("memory", "64")
Expand Down

0 comments on commit 897debc

Please sign in to comment.