From 58f3e14b948d6b05dd378a9a053bf3ac98d5f0e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lovro=20Ma=C5=BEgon?= Date: Fri, 24 May 2024 16:16:41 +0200 Subject: [PATCH] add generated constants for each specification parameter --- .golangci.yml | 2 - go.mod | 2 +- paramgen/internal/integration_test.go | 55 ++++++ paramgen/internal/template.go | 65 +++++-- paramgen/internal/template_test.go | 26 ++- paramgen/internal/testdata/basic/go.mod | 10 +- paramgen/internal/testdata/basic/go.sum | 12 ++ paramgen/internal/testdata/basic/want.go | 189 +++++++++++++++++++++ paramgen/internal/testdata/complex/go.mod | 10 +- paramgen/internal/testdata/complex/go.sum | 4 + paramgen/internal/testdata/complex/want.go | 67 ++++++++ paramgen/internal/testdata/tags/go.mod | 10 +- paramgen/internal/testdata/tags/go.sum | 4 + paramgen/internal/testdata/tags/want.go | 58 +++++++ 14 files changed, 489 insertions(+), 25 deletions(-) create mode 100644 paramgen/internal/integration_test.go create mode 100644 paramgen/internal/testdata/basic/go.sum create mode 100644 paramgen/internal/testdata/basic/want.go create mode 100644 paramgen/internal/testdata/complex/go.sum create mode 100644 paramgen/internal/testdata/complex/want.go create mode 100644 paramgen/internal/testdata/tags/go.sum create mode 100644 paramgen/internal/testdata/tags/want.go diff --git a/.golangci.yml b/.golangci.yml index fc363bc..b4eb038 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,8 +6,6 @@ linters-settings: allow-unused: false # report any unused nolint directives require-explanation: true # require an explanation for nolint directives require-specific: true # require nolint directives to mention the specific linter being suppressed - gocyclo: - min-complexity: 20 goconst: ignore-tests: true goheader: diff --git a/go.mod b/go.mod index 0029a38..18ef57c 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 go.uber.org/goleak v1.3.0 golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f + golang.org/x/text v0.15.0 golang.org/x/tools v0.21.0 google.golang.org/protobuf v1.34.1 mvdan.cc/gofumpt v0.6.0 @@ -239,7 +240,6 @@ require ( golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.20.0 // indirect golang.org/x/term v0.20.0 // indirect - golang.org/x/text v0.15.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240415180920-8c6c420018be // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240415180920-8c6c420018be // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/paramgen/internal/integration_test.go b/paramgen/internal/integration_test.go new file mode 100644 index 0000000..c3d906e --- /dev/null +++ b/paramgen/internal/integration_test.go @@ -0,0 +1,55 @@ +// Copyright © 2024 Meroxa, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import ( + "os" + "testing" + + "github.com/google/go-cmp/cmp" + "github.com/matryer/is" +) + +func TestIntegration(t *testing.T) { + testCases := []struct { + havePath string + structName string + wantPath string + }{{ + havePath: "./testdata/basic", + structName: "SourceConfig", + wantPath: "./testdata/basic/want.go", + }, { + havePath: "./testdata/complex", + structName: "SourceConfig", + wantPath: "./testdata/complex/want.go", + }, { + havePath: "./testdata/tags", + structName: "Config", + wantPath: "./testdata/tags/want.go", + }} + + for _, tc := range testCases { + t.Run(tc.havePath, func(t *testing.T) { + is := is.New(t) + params, pkg, err := ParseParameters(tc.havePath, tc.structName) + is.NoErr(err) + want, err := os.ReadFile(tc.wantPath) + is.NoErr(err) + got := GenerateCode(params, pkg, tc.structName) + is.Equal("", cmp.Diff(string(want), got)) + }) + } +} diff --git a/paramgen/internal/template.go b/paramgen/internal/template.go index be04fff..c7aaf07 100644 --- a/paramgen/internal/template.go +++ b/paramgen/internal/template.go @@ -21,6 +21,7 @@ import ( "log" "reflect" "strconv" + "strings" "text/template" "github.com/conduitio/conduit-commons/config" @@ -39,10 +40,16 @@ import ( "github.com/conduitio/conduit-commons/config" ) +const ( + {{- range $name, $parameter := $.Parameters }} + {{ $.Constant $name }} = {{ $.Quote $name }} + {{- end }} +) + func ({{ $.Struct }}) Parameters() map[string]config.Parameter { return map[string]config.Parameter{ {{- range $name, $parameter := .Parameters }} - {{ $.Quote $name }}: { + {{ $.Constant $name }}: { Default: {{ $.Quote .Default }}, Description: {{ $.Quote .Description }}, Type: config.{{ .GetTypeConstant }}, @@ -67,6 +74,51 @@ type templateData struct { func (templateData) Quote(s string) string { return strconv.Quote(s) } +func (t templateData) Constant(s string) string { + key := toCamelCase(s) + return t.Struct + key +} + +func (t templateData) HasRegex() bool { + for _, p := range t.Parameters { + for _, v := range p.Validations { + if _, ok := v.(config.ValidationRegex); ok { + return true + } + } + } + return false +} + +func toCamelCase(s string) string { + s = strings.TrimSpace(s) + if s == "" { + return s + } + + n := strings.Builder{} + n.Grow(len(s)) + capNext := true // cap first letter + for _, v := range []byte(s) { + vIsCap := v >= 'A' && v <= 'Z' + vIsLow := v >= 'a' && v <= 'z' + if capNext && vIsLow { + v += 'A' + v -= 'a' + } + + if vIsCap || vIsLow { + n.WriteByte(v) + capNext = false + } else if vIsNum := v >= '0' && v <= '9'; vIsNum { + n.WriteByte(v) + capNext = true + } else { + capNext = v == '_' || v == ' ' || v == '-' || v == '.' + } + } + return n.String() +} var parameterTypeConstantMapping = map[config.ParameterType]string{ config.ParameterTypeString: "ParameterTypeString", @@ -97,17 +149,6 @@ func (p parameter) GetValidation(index int) string { return fmt.Sprintf("%s{%s}", validationType, validationParameters) } -func (t templateData) HasRegex() bool { - for _, p := range t.Parameters { - for _, v := range p.Validations { - if _, ok := v.(config.ValidationRegex); ok { - return true - } - } - } - return false -} - func GenerateCode(parameters map[string]config.Parameter, packageName string, structName string) string { // create the go template t := template.Must(template.New("").Parse(tmpl)) diff --git a/paramgen/internal/template_test.go b/paramgen/internal/template_test.go index 63ac45b..f4023b6 100644 --- a/paramgen/internal/template_test.go +++ b/paramgen/internal/template_test.go @@ -19,6 +19,7 @@ import ( "testing" "github.com/conduitio/conduit-commons/config" + "github.com/google/go-cmp/cmp" "github.com/matryer/is" ) @@ -61,9 +62,15 @@ import ( "github.com/conduitio/conduit-commons/config" ) +const ( + SourceConfigBoolParam = "bool.param" + SourceConfigIntParam = "int.param" + SourceConfigStringParam = "string.param" +) + func (SourceConfig) Parameters() map[string]config.Parameter { return map[string]config.Parameter{ - "bool.param": { + SourceConfigBoolParam: { Default: "true", Description: "my bool param", Type: config.ParameterTypeBool, @@ -71,7 +78,7 @@ func (SourceConfig) Parameters() map[string]config.Parameter { config.ValidationRegex{Regex: regexp.MustCompile(".*")}, }, }, - "int.param": { + SourceConfigIntParam: { Default: "1", Description: "my int param with \"quotes\"", Type: config.ParameterTypeInt, @@ -82,7 +89,7 @@ func (SourceConfig) Parameters() map[string]config.Parameter { config.ValidationLessThan{V: 3}, }, }, - "string.param": { + SourceConfigStringParam: { Default: "", Description: "simple string param", Type: config.ParameterTypeString, @@ -91,7 +98,7 @@ func (SourceConfig) Parameters() map[string]config.Parameter { } } ` - is.Equal(got, want) + is.Equal("", cmp.Diff(got, want)) } func TestGenerateCodeWithoutRegex(t *testing.T) { @@ -122,9 +129,14 @@ import ( "github.com/conduitio/conduit-commons/config" ) +const ( + ConfigDurationParam = "duration.param" + ConfigIntParam = "int.param" +) + func (Config) Parameters() map[string]config.Parameter { return map[string]config.Parameter{ - "duration.param": { + ConfigDurationParam: { Default: "1s", Description: "my duration param", Type: config.ParameterTypeDuration, @@ -132,7 +144,7 @@ func (Config) Parameters() map[string]config.Parameter { config.ValidationInclusion{List: []string{"1s", "2s", "3s"}}, }, }, - "int.param": { + ConfigIntParam: { Default: "1", Description: "my int param", Type: config.ParameterTypeInt, @@ -141,5 +153,5 @@ func (Config) Parameters() map[string]config.Parameter { } } ` - is.Equal(got, want) + is.Equal("", cmp.Diff(got, want)) } diff --git a/paramgen/internal/testdata/basic/go.mod b/paramgen/internal/testdata/basic/go.mod index 04fcff9..01c8603 100644 --- a/paramgen/internal/testdata/basic/go.mod +++ b/paramgen/internal/testdata/basic/go.mod @@ -1,3 +1,11 @@ module example.com/test -go 1.18 +go 1.22.3 + +require github.com/conduitio/conduit-commons v0.2.0 + +require ( + github.com/goccy/go-json v0.10.2 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect +) diff --git a/paramgen/internal/testdata/basic/go.sum b/paramgen/internal/testdata/basic/go.sum new file mode 100644 index 0000000..a4534be --- /dev/null +++ b/paramgen/internal/testdata/basic/go.sum @@ -0,0 +1,12 @@ +github.com/conduitio/conduit-commons v0.2.0 h1:TMpVGXi0Wski537qLAyQWdGjuGHEhaZxOS5L90pZJSQ= +github.com/conduitio/conduit-commons v0.2.0/go.mod h1:i7Q2jm7FBSi2zj1/4MCsFD1hIKAbvamlNtSQfkhUTiY= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ= +github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/paramgen/internal/testdata/basic/want.go b/paramgen/internal/testdata/basic/want.go new file mode 100644 index 0000000..c7970fb --- /dev/null +++ b/paramgen/internal/testdata/basic/want.go @@ -0,0 +1,189 @@ +// Code generated by paramgen. DO NOT EDIT. +// Source: github.com/ConduitIO/conduit-commons/tree/main/paramgen + +package example + +import ( + "github.com/conduitio/conduit-commons/config" +) + +const ( + SourceConfigFoo = "foo" + SourceConfigMyBool = "myBool" + SourceConfigMyByte = "myByte" + SourceConfigMyDurSlice = "myDurSlice" + SourceConfigMyDuration = "myDuration" + SourceConfigMyFloat32 = "myFloat32" + SourceConfigMyFloat64 = "myFloat64" + SourceConfigMyFloatSlice = "myFloatSlice" + SourceConfigMyInt = "myInt" + SourceConfigMyInt16 = "myInt16" + SourceConfigMyInt32 = "myInt32" + SourceConfigMyInt64 = "myInt64" + SourceConfigMyInt8 = "myInt8" + SourceConfigMyIntSlice = "myIntSlice" + SourceConfigMyRune = "myRune" + SourceConfigMyString = "myString" + SourceConfigMyStringMap = "myStringMap.*" + SourceConfigMyStructMapMyInt = "myStructMap.*.myInt" + SourceConfigMyStructMapMyString = "myStructMap.*.myString" + SourceConfigMyUint = "myUint" + SourceConfigMyUint16 = "myUint16" + SourceConfigMyUint32 = "myUint32" + SourceConfigMyUint64 = "myUint64" + SourceConfigMyUint8 = "myUint8" +) + +func (SourceConfig) Parameters() map[string]config.Parameter { + return map[string]config.Parameter{ + SourceConfigFoo: { + Default: "bar", + Description: "MyGlobalString is a required field in the global config with the name\n\"foo\" and default value \"bar\".", + Type: config.ParameterTypeString, + Validations: []config.Validation{ + config.ValidationRequired{}, + }, + }, + SourceConfigMyBool: { + Default: "", + Description: "", + Type: config.ParameterTypeBool, + Validations: []config.Validation{}, + }, + SourceConfigMyByte: { + Default: "", + Description: "", + Type: config.ParameterTypeString, + Validations: []config.Validation{}, + }, + SourceConfigMyDurSlice: { + Default: "", + Description: "", + Type: config.ParameterTypeString, + Validations: []config.Validation{}, + }, + SourceConfigMyDuration: { + Default: "", + Description: "", + Type: config.ParameterTypeDuration, + Validations: []config.Validation{}, + }, + SourceConfigMyFloat32: { + Default: "", + Description: "", + Type: config.ParameterTypeFloat, + Validations: []config.Validation{}, + }, + SourceConfigMyFloat64: { + Default: "", + Description: "", + Type: config.ParameterTypeFloat, + Validations: []config.Validation{}, + }, + SourceConfigMyFloatSlice: { + Default: "", + Description: "", + Type: config.ParameterTypeString, + Validations: []config.Validation{}, + }, + SourceConfigMyInt: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{ + config.ValidationLessThan{V: 100}, + config.ValidationGreaterThan{V: 0}, + }, + }, + SourceConfigMyInt16: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + SourceConfigMyInt32: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + SourceConfigMyInt64: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + SourceConfigMyInt8: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + SourceConfigMyIntSlice: { + Default: "", + Description: "", + Type: config.ParameterTypeString, + Validations: []config.Validation{}, + }, + SourceConfigMyRune: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + SourceConfigMyString: { + Default: "", + Description: "MyString my string description", + Type: config.ParameterTypeString, + Validations: []config.Validation{}, + }, + SourceConfigMyStringMap: { + Default: "", + Description: "", + Type: config.ParameterTypeString, + Validations: []config.Validation{}, + }, + SourceConfigMyStructMapMyInt: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + SourceConfigMyStructMapMyString: { + Default: "", + Description: "", + Type: config.ParameterTypeString, + Validations: []config.Validation{}, + }, + SourceConfigMyUint: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + SourceConfigMyUint16: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + SourceConfigMyUint32: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + SourceConfigMyUint64: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + SourceConfigMyUint8: { + Default: "", + Description: "", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + } +} diff --git a/paramgen/internal/testdata/complex/go.mod b/paramgen/internal/testdata/complex/go.mod index 04fcff9..01c8603 100644 --- a/paramgen/internal/testdata/complex/go.mod +++ b/paramgen/internal/testdata/complex/go.mod @@ -1,3 +1,11 @@ module example.com/test -go 1.18 +go 1.22.3 + +require github.com/conduitio/conduit-commons v0.2.0 + +require ( + github.com/goccy/go-json v0.10.2 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect +) diff --git a/paramgen/internal/testdata/complex/go.sum b/paramgen/internal/testdata/complex/go.sum new file mode 100644 index 0000000..71e523c --- /dev/null +++ b/paramgen/internal/testdata/complex/go.sum @@ -0,0 +1,4 @@ +github.com/conduitio/conduit-commons v0.2.0/go.mod h1:i7Q2jm7FBSi2zj1/4MCsFD1hIKAbvamlNtSQfkhUTiY= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/paramgen/internal/testdata/complex/want.go b/paramgen/internal/testdata/complex/want.go new file mode 100644 index 0000000..3986771 --- /dev/null +++ b/paramgen/internal/testdata/complex/want.go @@ -0,0 +1,67 @@ +// Code generated by paramgen. DO NOT EDIT. +// Source: github.com/ConduitIO/conduit-commons/tree/main/paramgen + +package example + +import ( + "github.com/conduitio/conduit-commons/config" +) + +const ( + SourceConfigCustomType = "customType" + SourceConfigGlobalDuration = "global.duration" + SourceConfigGlobalRenamed = "global.renamed.*" + SourceConfigGlobalWildcardStrings = "global.wildcardStrings.*" + SourceConfigGlobalWildcardStructsName = "global.wildcardStructs.*.name" + SourceConfigNestMeHereAnotherNested = "nestMeHere.anotherNested" + SourceConfigNestMeHereFormatThisName = "nestMeHere.formatThisName" +) + +func (SourceConfig) Parameters() map[string]config.Parameter { + return map[string]config.Parameter{ + SourceConfigCustomType: { + Default: "", + Description: "CustomType uses a custom type that is convertible to a supported type. Line comments are allowed.", + Type: config.ParameterTypeDuration, + Validations: []config.Validation{}, + }, + SourceConfigGlobalDuration: { + Default: "1s", + Description: "Duration does not have a name so the type name is used.", + Type: config.ParameterTypeDuration, + Validations: []config.Validation{}, + }, + SourceConfigGlobalRenamed: { + Default: "1s", + Description: "", + Type: config.ParameterTypeDuration, + Validations: []config.Validation{}, + }, + SourceConfigGlobalWildcardStrings: { + Default: "foo", + Description: "", + Type: config.ParameterTypeString, + Validations: []config.Validation{ + config.ValidationRequired{}, + }, + }, + SourceConfigGlobalWildcardStructsName: { + Default: "", + Description: "", + Type: config.ParameterTypeString, + Validations: []config.Validation{}, + }, + SourceConfigNestMeHereAnotherNested: { + Default: "", + Description: "AnotherNested is also nested under nestMeHere.\nThis is a block comment.", + Type: config.ParameterTypeInt, + Validations: []config.Validation{}, + }, + SourceConfigNestMeHereFormatThisName: { + Default: "this is not a float", + Description: "FORMATThisName should stay \"FORMATThisName\". Default is not a float\nbut that's not a problem, paramgen does not validate correctness.", + Type: config.ParameterTypeFloat, + Validations: []config.Validation{}, + }, + } +} diff --git a/paramgen/internal/testdata/tags/go.mod b/paramgen/internal/testdata/tags/go.mod index 04fcff9..01c8603 100644 --- a/paramgen/internal/testdata/tags/go.mod +++ b/paramgen/internal/testdata/tags/go.mod @@ -1,3 +1,11 @@ module example.com/test -go 1.18 +go 1.22.3 + +require github.com/conduitio/conduit-commons v0.2.0 + +require ( + github.com/goccy/go-json v0.10.2 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect +) diff --git a/paramgen/internal/testdata/tags/go.sum b/paramgen/internal/testdata/tags/go.sum new file mode 100644 index 0000000..71e523c --- /dev/null +++ b/paramgen/internal/testdata/tags/go.sum @@ -0,0 +1,4 @@ +github.com/conduitio/conduit-commons v0.2.0/go.mod h1:i7Q2jm7FBSi2zj1/4MCsFD1hIKAbvamlNtSQfkhUTiY= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/paramgen/internal/testdata/tags/want.go b/paramgen/internal/testdata/tags/want.go new file mode 100644 index 0000000..2e2abd7 --- /dev/null +++ b/paramgen/internal/testdata/tags/want.go @@ -0,0 +1,58 @@ +// Code generated by paramgen. DO NOT EDIT. +// Source: github.com/ConduitIO/conduit-commons/tree/main/paramgen + +package tags + +import ( + "regexp" + + "github.com/conduitio/conduit-commons/config" +) + +const ( + ConfigMyName = "my-name" + ConfigMyParam = "my-param" + ConfigParam2 = "param2" + ConfigParam3 = "param3" +) + +func (Config) Parameters() map[string]config.Parameter { + return map[string]config.Parameter{ + ConfigMyName: { + Default: "", + Description: "", + Type: config.ParameterTypeString, + Validations: []config.Validation{ + config.ValidationRequired{}, + }, + }, + ConfigMyParam: { + Default: "3", + Description: "Param1 i am a parameter comment", + Type: config.ParameterTypeInt, + Validations: []config.Validation{ + config.ValidationRequired{}, + config.ValidationGreaterThan{V: 0}, + config.ValidationLessThan{V: 100}, + }, + }, + ConfigParam2: { + Default: "t", + Description: "", + Type: config.ParameterTypeBool, + Validations: []config.Validation{ + config.ValidationInclusion{List: []string{"true", "t"}}, + config.ValidationExclusion{List: []string{"false", "f"}}, + }, + }, + ConfigParam3: { + Default: "yes", + Description: "", + Type: config.ParameterTypeString, + Validations: []config.Validation{ + config.ValidationRequired{}, + config.ValidationRegex{Regex: regexp.MustCompile(".*")}, + }, + }, + } +}