Skip to content

Commit a247c01

Browse files
committed
feat(breaking): add struct to configmanager
1 parent d351516 commit a247c01

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
OWNER := dnitsch
33
NAME := configmanager
4-
GIT_TAG := "0.0.0"
5-
VERSION := "v0.9.2"
4+
GIT_TAG := "1.0.1"
5+
VERSION := "v1.0.1"
66
# VERSION := "$(shell git describe --tags --abbrev=0)"
77
REVISION := $(shell git rev-parse --short HEAD)
88

configmanager.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,33 @@ import (
88
"github.com/dnitsch/configmanager/pkg/generator"
99
)
1010

11-
type ConfigManager interface {
11+
type ConfigManageriface interface {
1212
Retrieve(tokens []string, config generator.GenVarsConfig) (generator.ParsedMap, error)
13+
RetrieveWithInputReplaced(input string, config generator.GenVarsConfig) (string, error)
1314
Insert()
1415
}
1516

17+
type ConfigManager struct{}
18+
1619
// Retrieve gets a rawMap from a set implementation
1720
// will be empty if no matches found
18-
func Retrieve(tokens []string, config generator.GenVarsConfig) (generator.ParsedMap, error) {
21+
func (c *ConfigManager) Retrieve(tokens []string, config generator.GenVarsConfig) (generator.ParsedMap, error) {
1922
gv := generator.NewGenerator()
2023
gv.WithConfig(&config)
2124
return gv.Generate(tokens)
2225
}
2326

2427
// RetrieveWithInputReplaced parses given input against all possible token strings
2528
// using regex to grab a list of found tokens in the given string
26-
func RetrieveWithInputReplaced(input string, config generator.GenVarsConfig) (string, error) {
29+
func (c *ConfigManager) RetrieveWithInputReplaced(input string, config generator.GenVarsConfig) (string, error) {
2730
tokens := []string{}
2831
for k := range generator.VarPrefix {
2932
matches := regexp.MustCompile(`(?s)`+regexp.QuoteMeta(k)+`.([^\"]+)`).FindAllString(input, -1)
3033
tokens = append(tokens, matches...)
3134
}
3235

3336
cnf := generator.GenVarsConfig{}
34-
m, err := Retrieve(tokens, cnf)
37+
m, err := c.Retrieve(tokens, cnf)
3538

3639
if err != nil {
3740
return "", err
@@ -47,6 +50,6 @@ func replaceString(inputMap generator.ParsedMap, inputString string) string {
4750
return inputString
4851
}
4952

50-
func Insert() error {
53+
func (c *ConfigManager) Insert() error {
5154
return fmt.Errorf("%s", "NotYetImplemented")
5255
}

0 commit comments

Comments
 (0)