move config -> internal.config and config.datatype to datatype

This commit is contained in:
Adrien Marquès 2020-03-16 09:20:00 +01:00
parent 4e0d669029
commit 1b4922693b
Signed by: xdrm-brackets
GPG Key ID: D75243CA236D825E
20 changed files with 25 additions and 25 deletions

View File

@ -1,6 +1,6 @@
package builtin
import "git.xdrm.io/go/aicra/config/datatype"
import "git.xdrm.io/go/aicra/datatype"
// AnyDataType is what its name tells
type AnyDataType struct{}

View File

@ -4,7 +4,7 @@ import (
"fmt"
"testing"
"git.xdrm.io/go/aicra/config/datatype/builtin"
"git.xdrm.io/go/aicra/datatype/builtin"
)
func TestAny_AvailableTypes(t *testing.T) {

View File

@ -1,6 +1,6 @@
package builtin
import "git.xdrm.io/go/aicra/config/datatype"
import "git.xdrm.io/go/aicra/datatype"
// BoolDataType is what its name tells
type BoolDataType struct{}

View File

@ -4,7 +4,7 @@ import (
"fmt"
"testing"
"git.xdrm.io/go/aicra/config/datatype/builtin"
"git.xdrm.io/go/aicra/datatype/builtin"
)
func TestBool_AvailableTypes(t *testing.T) {

View File

@ -3,7 +3,7 @@ package builtin
import (
"encoding/json"
"git.xdrm.io/go/aicra/config/datatype"
"git.xdrm.io/go/aicra/datatype"
)
// FloatDataType is what its name tells

View File

@ -5,7 +5,7 @@ import (
"math"
"testing"
"git.xdrm.io/go/aicra/config/datatype/builtin"
"git.xdrm.io/go/aicra/datatype/builtin"
)
func TestFloat64_AvailableTypes(t *testing.T) {

View File

@ -4,7 +4,7 @@ import (
"encoding/json"
"math"
"git.xdrm.io/go/aicra/config/datatype"
"git.xdrm.io/go/aicra/datatype"
)
// IntDataType is what its name tells

View File

@ -5,7 +5,7 @@ import (
"math"
"testing"
"git.xdrm.io/go/aicra/config/datatype/builtin"
"git.xdrm.io/go/aicra/datatype/builtin"
)
func TestInt_AvailableTypes(t *testing.T) {

View File

@ -4,7 +4,7 @@ import (
"regexp"
"strconv"
"git.xdrm.io/go/aicra/config/datatype"
"git.xdrm.io/go/aicra/datatype"
)
var fixedLengthRegex = regexp.MustCompile(`^string\((\d+)\)$`)

View File

@ -4,7 +4,7 @@ import (
"fmt"
"testing"
"git.xdrm.io/go/aicra/config/datatype/builtin"
"git.xdrm.io/go/aicra/datatype/builtin"
)
func TestString_AvailableTypes(t *testing.T) {

View File

@ -4,7 +4,7 @@ import (
"encoding/json"
"math"
"git.xdrm.io/go/aicra/config/datatype"
"git.xdrm.io/go/aicra/datatype"
)
// UintDataType is what its name tells

View File

@ -5,7 +5,7 @@ import (
"math"
"testing"
"git.xdrm.io/go/aicra/config/datatype/builtin"
"git.xdrm.io/go/aicra/datatype/builtin"
)
func TestUint_AvailableTypes(t *testing.T) {

View File

@ -4,9 +4,9 @@ package datatype
// and casts the value into a compatible type
type Validator func(value interface{}) (cast interface{}, valid bool)
// DataType builds a DataType from the type definition (from the
// T builds a T from the type definition (from the
// configuration field "type") and returns NIL if the type
// definition does not match this DataType
type DataType interface {
// definition does not match this T
type T interface {
Build(typeDefinition string) Validator
}

View File

@ -8,7 +8,7 @@ import (
"strings"
"testing"
"git.xdrm.io/go/aicra/config/datatype/builtin"
"git.xdrm.io/go/aicra/datatype/builtin"
)
func TestLegalServiceName(t *testing.T) {

View File

@ -1,6 +1,6 @@
package config
import "git.xdrm.io/go/aicra/config/datatype"
import "git.xdrm.io/go/aicra/datatype"
func (param *Parameter) checkAndFormat() error {
@ -24,7 +24,7 @@ func (param *Parameter) checkAndFormat() error {
}
// assigns the first matching data type from the type definition
func (param *Parameter) assignDataType(types []datatype.DataType) bool {
func (param *Parameter) assignDataType(types []datatype.T) bool {
for _, dtype := range types {
param.Validator = dtype.Build(param.Type)
if param.Validator != nil {

View File

@ -7,14 +7,14 @@ import (
"net/http"
"strings"
"git.xdrm.io/go/aicra/config/datatype"
"git.xdrm.io/go/aicra/datatype"
)
// Parse builds a server configuration from a json reader and checks for most format errors.
// you can provide additional DataTypes as variadic arguments
func Parse(r io.Reader, dtypes ...datatype.DataType) (*Server, error) {
func Parse(r io.Reader, dtypes ...datatype.T) (*Server, error) {
server := &Server{
Types: make([]datatype.DataType, 0),
Types: make([]datatype.T, 0),
Services: make([]*Service, 0),
}
// add data types

View File

@ -6,7 +6,7 @@ import (
"regexp"
"strings"
"git.xdrm.io/go/aicra/config/datatype"
"git.xdrm.io/go/aicra/datatype"
)
var braceRegex = regexp.MustCompile(`^{([a-z_-]+)}$`)
@ -86,7 +86,7 @@ func (svc *Service) checkPattern() error {
return nil
}
func (svc *Service) checkAndFormatInput(types []datatype.DataType) error {
func (svc *Service) checkAndFormatInput(types []datatype.T) error {
// ignore no parameter
if svc.Input == nil || len(svc.Input) < 1 {

View File

@ -3,14 +3,14 @@ package config
import (
"net/http"
"git.xdrm.io/go/aicra/config/datatype"
"git.xdrm.io/go/aicra/datatype"
)
var availableHTTPMethods = []string{http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete}
// Server represents a full server configuration
type Server struct {
Types []datatype.DataType
Types []datatype.T
Services []*Service
}