From aed9d98203b797c4764ff0af9980968a85b56300 Mon Sep 17 00:00:00 2001 From: Nicolas JUHEL Date: Tue, 29 Aug 2023 15:06:48 +0200 Subject: [PATCH] Add Aws Function & Fix Validotor Package aws - fix dive, use it only for slice - add function to version delete with bypass governance policy Package cluster - fix dive, use it only for slice Package config - fix missing close channel for waitnotify function Package errors - fix pattern %s with uint16 Package ioutils - fix liberr / Error type return Package nats - fix dive, use it only for slice Package nutsdb - fix dive, use it only for slice Package request - fix dive, use it only for slice Other - bump dependencies (validator v10.15.2) --- aws/configAws/models.go | 6 +++--- aws/configCustom/models.go | 6 +++--- aws/object/interface.go | 3 +++ aws/object/object.go | 4 ++++ aws/object/version.go | 41 ++++++++++++++++++++++++++++++++------ cluster/config.go | 4 ++-- cluster/configNode.go | 4 ++-- config/interface.go | 8 ++++++-- errors/errors.go | 4 ++-- go.mod | 20 +++++++++---------- ioutils/tempFile.go | 8 ++++---- nats/config.go | 20 +++++++++---------- nats/configPart.go | 22 ++++++++++---------- nutsdb/config.go | 8 ++++---- request/options.go | 16 +++++++-------- 15 files changed, 107 insertions(+), 67 deletions(-) diff --git a/aws/configAws/models.go b/aws/configAws/models.go index 56cb89c7..0f8c6f0b 100644 --- a/aws/configAws/models.go +++ b/aws/configAws/models.go @@ -45,9 +45,9 @@ type Model struct { } type ModelStatus struct { - Config Model `json:"config" yaml:"config" toml:"config" mapstructure:"config" validate:"required,dive"` - HTTPClient libhtc.Options `json:"http-client" yaml:"http-client" toml:"http-client" mapstructure:"http-client" validate:"required,dive"` - Monitor libreq.OptionsHealth `json:"health" yaml:"health" toml:"health" mapstructure:"health" validate:"required,dive"` + Config Model `json:"config" yaml:"config" toml:"config" mapstructure:"config" validate:"required"` + HTTPClient libhtc.Options `json:"http-client" yaml:"http-client" toml:"http-client" mapstructure:"http-client" validate:""` + Monitor libreq.OptionsHealth `json:"health" yaml:"health" toml:"health" mapstructure:"health" validate:""` } type awsModel struct { diff --git a/aws/configCustom/models.go b/aws/configCustom/models.go index 4c5c333a..f2b2f1fa 100644 --- a/aws/configCustom/models.go +++ b/aws/configCustom/models.go @@ -47,9 +47,9 @@ type Model struct { } type ModelStatus struct { - Config Model `json:"config" yaml:"config" toml:"config" mapstructure:"config" validate:"required,dive"` - HTTPClient libhtc.Options `json:"http-client" yaml:"http-client" toml:"http-client" mapstructure:"http-client" validate:"dive"` - Monitor libreq.OptionsHealth `json:"health" yaml:"health" toml:"health" mapstructure:"health" validate:"dive"` + Config Model `json:"config" yaml:"config" toml:"config" mapstructure:"config" validate:"required"` + HTTPClient libhtc.Options `json:"http-client" yaml:"http-client" toml:"http-client" mapstructure:"http-client" validate:""` + Monitor libreq.OptionsHealth `json:"health" yaml:"health" toml:"health" mapstructure:"health" validate:""` } type awsModel struct { diff --git a/aws/object/interface.go b/aws/object/interface.go index e102c9ba..8bf3bc25 100644 --- a/aws/object/interface.go +++ b/aws/object/interface.go @@ -63,6 +63,7 @@ type Object interface { Head(object string) (*sdksss.HeadObjectOutput, error) Get(object string) (*sdksss.GetObjectOutput, error) Put(object string, body io.Reader) error + Copy(source, destination string) error Delete(check bool, object string) error DeleteAll(objects *sdktps.Delete) ([]sdktps.DeletedObject, error) GetAttributes(object, version string) (*sdksss.GetObjectAttributesOutput, error) @@ -84,6 +85,8 @@ type Object interface { VersionHead(object, version string) (*sdksss.HeadObjectOutput, error) VersionSize(object, version string) (size int64, err error) VersionDelete(check bool, object, version string) error + VersionCopy(source, version, destination string) error + VersionDeleteLock(check bool, object, version string, byPassGovernance bool) error GetRetention(object, version string) (until time.Time, mode string, err error) SetRetention(object, version string, bypass bool, until time.Time, mode string) error diff --git a/aws/object/object.go b/aws/object/object.go index e4e00464..92d8d7fa 100644 --- a/aws/object/object.go +++ b/aws/object/object.go @@ -128,6 +128,10 @@ func (cli *client) Delete(check bool, object string) error { return cli.VersionDelete(check, object, "") } +func (cli *client) Copy(source, destination string) error { + return cli.VersionCopy(source, "", destination) +} + func (cli *client) Put(object string, body io.Reader) error { var tpe *string diff --git a/aws/object/version.go b/aws/object/version.go index e0203d50..3d8679fd 100644 --- a/aws/object/version.go +++ b/aws/object/version.go @@ -26,6 +26,7 @@ package object import ( + "path" "strings" sdkaws "github.com/aws/aws-sdk-go-v2/aws" @@ -186,6 +187,10 @@ func (cli *client) VersionSize(object, version string) (size int64, err error) { } func (cli *client) VersionDelete(check bool, object, version string) error { + return cli.VersionDeleteLock(check, object, version, false) +} + +func (cli *client) VersionDeleteLock(check bool, object, version string, byPassGovernance bool) error { if check { if _, err := cli.VersionHead(object, version); err != nil { return err @@ -201,14 +206,38 @@ func (cli *client) VersionDelete(check bool, object, version string) error { in.VersionId = sdkaws.String(version) } + if byPassGovernance { + in.BypassGovernanceRetention = true + } + _, err := cli.s3.DeleteObject(cli.GetContext(), &in) - if !check && err != nil { - e := err.Error() - if strings.Contains(e, "api error NoSuchKey") { - return nil - } + if !check && err != nil && strings.Contains(err.Error(), "api error NoSuchKey") { + return nil + } else if err != nil { + return cli.GetError(err) + } + + return nil +} + +func (cli *client) VersionCopy(source, version, destination string) error { + in := sdksss.CopyObjectInput{ + Bucket: cli.GetBucketAws(), + Key: sdkaws.String(destination), + } + + if version != "" { + in.CopySource = sdkaws.String(path.Join(*(cli.GetBucketAws()), source) + "?versionId=" + version) + } else { + in.CopySource = sdkaws.String(path.Join(*(cli.GetBucketAws()), source)) + } + + _, err := cli.s3.CopyObject(cli.GetContext(), &in) + + if err != nil { + return cli.GetError(err) } - return cli.GetError(err) + return nil } diff --git a/cluster/config.go b/cluster/config.go index 8f10d63c..7ce538c5 100644 --- a/cluster/config.go +++ b/cluster/config.go @@ -40,8 +40,8 @@ import ( ) type Config struct { - Node ConfigNode `mapstructure:"node" json:"node" yaml:"node" toml:"node" validate:"dive"` - Cluster ConfigCluster `mapstructure:"cluster" json:"cluster" yaml:"cluster" toml:"cluster" validate:"dive"` + Node ConfigNode `mapstructure:"node" json:"node" yaml:"node" toml:"node" validate:""` + Cluster ConfigCluster `mapstructure:"cluster" json:"cluster" yaml:"cluster" toml:"cluster" validate:""` InitMember map[uint64]string `mapstructure:"init_member" json:"init_member" yaml:"init_member" toml:"init_member"` } diff --git a/cluster/configNode.go b/cluster/configNode.go index a42cfefa..e5bd52a1 100644 --- a/cluster/configNode.go +++ b/cluster/configNode.go @@ -254,14 +254,14 @@ type ConfigNode struct { // points the local gossip service will try to talk to. The Seed field doesn't // need to include all gossip end points, a few well connected nodes in the // gossip network is enough. - Gossip ConfigGossip `mapstructure:"gossip" json:"gossip" yaml:"gossip" toml:"gossip" validate:"omitempty,dive"` + Gossip ConfigGossip `mapstructure:"gossip" json:"gossip" yaml:"gossip" toml:"gossip" validate:"omitempty"` // Expert contains options for expert users who are familiar with the internals // of Dragonboat. Users are recommended not to use this field unless // absoloutely necessary. It is important to note that any change to this field // may cause an existing instance unable to restart, it may also cause negative // performance impacts. - Expert ConfigExpert `mapstructure:"expert" json:"expert" yaml:"expert" toml:"expert" validate:"omitempty,dive"` + Expert ConfigExpert `mapstructure:"expert" json:"expert" yaml:"expert" toml:"expert" validate:"omitempty"` } func (c ConfigNode) GetDGBConfigNodeHost() dgbcfg.NodeHostConfig { diff --git a/config/interface.go b/config/interface.go index e90e5253..4234972d 100644 --- a/config/interface.go +++ b/config/interface.go @@ -146,15 +146,19 @@ func WaitNotify() { // Wait for interrupt signal to gracefully shutdown the server with // a timeout of 5 seconds. quit := make(chan os.Signal, 1) + defer func() { + close(quit) + }() + signal.Notify(quit, syscall.SIGINT) signal.Notify(quit, syscall.SIGTERM) signal.Notify(quit, syscall.SIGQUIT) select { case <-quit: - cnl() + Shutdown() case <-ctx.Done(): - cnl() + Shutdown() } } diff --git a/errors/errors.go b/errors/errors.go index a896aebb..d4aeaacb 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -34,8 +34,8 @@ import ( ) var ( - defaultPattern = "[Error #%s] %s" - defaultPatternTrace = "[Error #%s] %s (%s)" + defaultPattern = "[Error #%d] %s" + defaultPatternTrace = "[Error #%d] %s (%s)" ) // GetDefaultPatternTrace define the pattern to be used for string of error with code. diff --git a/go.mod b/go.mod index 33dc2ec5..4130dc97 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ toolchain go1.21.0 require ( github.com/aws/aws-sdk-go-v2 v1.21.0 - github.com/aws/aws-sdk-go-v2/config v1.18.36 + github.com/aws/aws-sdk-go-v2/config v1.18.37 github.com/aws/aws-sdk-go-v2/credentials v1.13.35 github.com/aws/aws-sdk-go-v2/service/iam v1.22.5 github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5 @@ -17,7 +17,7 @@ require ( github.com/fxamacker/cbor/v2 v2.5.0 github.com/gin-gonic/gin v1.9.1 github.com/go-ldap/ldap/v3 v3.4.5 - github.com/go-playground/validator/v10 v10.15.1 + github.com/go-playground/validator/v10 v10.15.2 github.com/google/go-github/v33 v33.0.0 github.com/hashicorp/go-hclog v1.5.0 github.com/hashicorp/go-retryablehttp v0.7.4 @@ -33,7 +33,7 @@ require ( github.com/nats-io/nats-server/v2 v2.9.21 github.com/nats-io/nats.go v1.28.0 github.com/nutsdb/nutsdb v0.13.1 - github.com/onsi/ginkgo/v2 v2.11.0 + github.com/onsi/ginkgo/v2 v2.12.0 github.com/onsi/gomega v1.27.10 github.com/pelletier/go-toml v1.9.5 github.com/prometheus/client_golang v1.16.0 @@ -47,7 +47,7 @@ require ( github.com/xanzy/go-gitlab v0.90.0 github.com/xhit/go-simple-mail v2.2.2+incompatible github.com/xujiajun/utils v0.0.0-20220904132955-5f7c5b914235 - golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 + golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 golang.org/x/net v0.14.0 golang.org/x/oauth2 v0.11.0 golang.org/x/sync v0.3.0 @@ -65,7 +65,7 @@ require ( require ( github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect github.com/ClickHouse/ch-go v0.58.2 // indirect - github.com/ClickHouse/clickhouse-go/v2 v2.13.2 // indirect + github.com/ClickHouse/clickhouse-go/v2 v2.13.3 // indirect github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver v1.5.0 // indirect github.com/Masterminds/sprig v2.22.0+incompatible // indirect @@ -96,7 +96,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/chenzhuoyu/iasm v0.9.0 // indirect - github.com/cockroachdb/errors v1.10.0 // indirect + github.com/cockroachdb/errors v1.11.1 // indirect github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect github.com/cockroachdb/pebble v0.0.0-20210331181633-27fc006b8bfb // indirect github.com/cockroachdb/redact v1.1.5 // indirect @@ -123,7 +123,7 @@ require ( github.com/google/btree v1.1.2 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-querystring v1.1.0 // indirect - github.com/google/pprof v0.0.0-20230821062121-407c9e7a662f // indirect + github.com/google/pprof v0.0.0-20230323073829-e72429f035bd // indirect github.com/google/uuid v1.3.1 // indirect github.com/gorilla/css v1.0.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -196,14 +196,14 @@ require ( github.com/x448/float16 v0.8.4 // indirect github.com/xujiajun/mmap-go v1.0.1 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect - go.opentelemetry.io/otel v1.16.0 // indirect - go.opentelemetry.io/otel/trace v1.16.0 // indirect + go.opentelemetry.io/otel v1.17.0 // indirect + go.opentelemetry.io/otel/trace v1.17.0 // indirect golang.org/x/arch v0.4.0 // indirect golang.org/x/crypto v0.12.0 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/text v0.12.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect + golang.org/x/tools v0.12.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/ioutils/tempFile.go b/ioutils/tempFile.go index 18115e1f..df294f47 100644 --- a/ioutils/tempFile.go +++ b/ioutils/tempFile.go @@ -29,10 +29,10 @@ import ( "os" "path/filepath" - . "github.com/nabbar/golib/errors" + liberr "github.com/nabbar/golib/errors" ) -func NewTempFile() (*os.File, Error) { +func NewTempFile() (*os.File, error) { f, e := os.CreateTemp(os.TempDir(), "") return f, ErrorIOFileTempNew.IfError(e) } @@ -45,7 +45,7 @@ func GetTempFilePath(f *os.File) string { return filepath.Join(os.TempDir(), filepath.Base(f.Name())) } -func DelTempFile(f *os.File) Error { +func DelTempFile(f *os.File) error { if f == nil { return nil } @@ -58,5 +58,5 @@ func DelTempFile(f *os.File) Error { b := os.Remove(n) e2 := ErrorIOFileTempRemove.IfError(b) - return MakeIfError(e2, e1) + return liberr.MakeIfError(e2, e1) } diff --git a/nats/config.go b/nats/config.go index a77caafe..f7f31e14 100644 --- a/nats/config.go +++ b/nats/config.go @@ -48,16 +48,16 @@ import ( ) type Config struct { - Server ConfigSrv `mapstructure:"server" json:"server" yaml:"server" toml:"server" validate:"dive,required"` - Cluster ConfigCluster `mapstructure:"cluster" json:"cluster" yaml:"cluster" toml:"cluster" validate:"dive,required"` - Gateways ConfigGateway `mapstructure:"gateways" json:"gateways" yaml:"gateways" toml:"gateways" validate:"dive,required"` - Leaf ConfigLeaf `mapstructure:"leaf" json:"leaf" yaml:"leaf" toml:"leaf" validate:"dive,required"` - Websockets ConfigWebsocket `mapstructure:"websockets" json:"websockets" yaml:"websockets" toml:"websockets" validate:"dive,required"` - MQTT ConfigMQTT `mapstructure:"mqtt" json:"mqtt" yaml:"mqtt" toml:"mqtt" validate:"dive,required"` - Limits ConfigLimits `mapstructure:"limits" json:"limits" yaml:"limits" toml:"limits" validate:"dive,required"` - Logs ConfigLogger `mapstructure:"logs" json:"logs" yaml:"logs" toml:"logs" validate:"dive,required"` - Auth ConfigAuth `mapstructure:"auth" json:"auth" yaml:"auth" toml:"auth" validate:"dive,required"` - Monitor moncfg.Config `mapstructure:"monitor" json:"monitor" yaml:"monitor" toml:"monitor" validate:"dive"` + Server ConfigSrv `mapstructure:"server" json:"server" yaml:"server" toml:"server" validate:"required"` + Cluster ConfigCluster `mapstructure:"cluster" json:"cluster" yaml:"cluster" toml:"cluster" validate:"required"` + Gateways ConfigGateway `mapstructure:"gateways" json:"gateways" yaml:"gateways" toml:"gateways" validate:"required"` + Leaf ConfigLeaf `mapstructure:"leaf" json:"leaf" yaml:"leaf" toml:"leaf" validate:"required"` + Websockets ConfigWebsocket `mapstructure:"websockets" json:"websockets" yaml:"websockets" toml:"websockets" validate:"required"` + MQTT ConfigMQTT `mapstructure:"mqtt" json:"mqtt" yaml:"mqtt" toml:"mqtt" validate:"required"` + Limits ConfigLimits `mapstructure:"limits" json:"limits" yaml:"limits" toml:"limits" validate:"required"` + Logs ConfigLogger `mapstructure:"logs" json:"logs" yaml:"logs" toml:"logs" validate:"required"` + Auth ConfigAuth `mapstructure:"auth" json:"auth" yaml:"auth" toml:"auth" validate:"required"` + Monitor moncfg.Config `mapstructure:"monitor" json:"monitor" yaml:"monitor" toml:"monitor" validate:""` //function / interface are not defined in config marshall Customs *ConfigCustom `mapstructure:"-" json:"-" yaml:"-" toml:"-"` diff --git a/nats/configPart.go b/nats/configPart.go index 28d9dfb0..73d91f3e 100644 --- a/nats/configPart.go +++ b/nats/configPart.go @@ -78,22 +78,22 @@ type ConfigUser struct { // ConfigPermissionsUser are the allowed subjects on a per publish or subscribe basis. type ConfigPermissionsUser struct { //Publish define the scope permission for publisher role. - Publish ConfigPermissionSubject `mapstructure:"publish" json:"publish" yaml:"publish" toml:"publish" validate:"dive,required"` + Publish ConfigPermissionSubject `mapstructure:"publish" json:"publish" yaml:"publish" toml:"publish" validate:"required"` //Subscribe define the scope permission for subscriber role. - Subscribe ConfigPermissionSubject `mapstructure:"subscribe" json:"subscribe" yaml:"subscribe" toml:"subscribe" validate:"dive,required"` + Subscribe ConfigPermissionSubject `mapstructure:"subscribe" json:"subscribe" yaml:"subscribe" toml:"subscribe" validate:"required"` //Response define the scope permission to allow response for a message. - Response ConfigPermissionResponse `mapstructure:"response" json:"response" yaml:"response" toml:"response" validate:"dive,required"` + Response ConfigPermissionResponse `mapstructure:"response" json:"response" yaml:"response" toml:"response" validate:"required"` } // ConfigPermissionsRoute are similar to user permissions but describe what a server can import/export from and to another server. type ConfigPermissionsRoute struct { //Import define the scope permission to import data from the route. - Import ConfigPermissionSubject `mapstructure:"import" json:"import" yaml:"import" toml:"import" validate:"dive,required"` + Import ConfigPermissionSubject `mapstructure:"import" json:"import" yaml:"import" toml:"import" validate:"required"` //Export define the scope permission to export data to the route. - Export ConfigPermissionSubject `mapstructure:"export" json:"export" yaml:"export" toml:"export" validate:"dive,required"` + Export ConfigPermissionSubject `mapstructure:"export" json:"export" yaml:"export" toml:"export" validate:"required"` } // ConfigPermissionResponse can be used to allow responses to any reply subject that is received on a valid subscription. @@ -120,7 +120,7 @@ type ConfigAccount struct { //Name define the name of the account. Name string `mapstructure:"name" json:"name" yaml:"name" toml:"name"` - Permission ConfigPermissionsUser `mapstructure:"permission" json:"permission" yaml:"permission" toml:"permission" validate:"dive,required"` + Permission ConfigPermissionsUser `mapstructure:"permission" json:"permission" yaml:"permission" toml:"permission" validate:"required"` } type ConfigAuth struct { @@ -311,7 +311,7 @@ type ConfigSrv struct { TLSTimeout time.Duration `mapstructure:"tls_timeout" json:"tls_timeout" yaml:"tls_timeout" toml:"tls_timeout"` //TLSConfig Configuration map for tls for client and http monitoring. - TLSConfig libtls.Config `mapstructure:"tls_config" json:"tls_config" yaml:"tls_config" toml:"tls_config" validate:"dive"` + TLSConfig libtls.Config `mapstructure:"tls_config" json:"tls_config" yaml:"tls_config" toml:"tls_config" validate:""` } type ConfigCluster struct { @@ -346,7 +346,7 @@ type ConfigCluster struct { AuthTimeout time.Duration `mapstructure:"auth_timeout" json:"auth_timeout" yaml:"auth_timeout" toml:"auth_timeout"` //Permissions define the scope permission assign to route connections. - Permissions ConfigPermissionsRoute `mapstructure:"permissions" json:"permissions" yaml:"permissions" toml:"permissions" validate:"dive"` + Permissions ConfigPermissionsRoute `mapstructure:"permissions" json:"permissions" yaml:"permissions" toml:"permissions" validate:""` //TLS Enable tls for cluster connection. TLS bool `mapstructure:"tls" json:"tls" yaml:"tls" toml:"tls"` @@ -355,7 +355,7 @@ type ConfigCluster struct { TLSTimeout time.Duration `mapstructure:"tls_timeout" json:"tls_timeout" yaml:"tls_timeout" toml:"tls_timeout"` //TLSConfig define the tls configuration for cluster connection. - TLSConfig libtls.Config `mapstructure:"tls_config" json:"tls_config" yaml:"tls_config" toml:"tls_config" validate:"dive"` + TLSConfig libtls.Config `mapstructure:"tls_config" json:"tls_config" yaml:"tls_config" toml:"tls_config" validate:""` } // ConfigGatewayRemote are options for connecting to a remote gateway @@ -374,7 +374,7 @@ type ConfigGatewayRemote struct { TLSTimeout time.Duration `mapstructure:"tls_timeout" json:"tls_timeout" yaml:"tls_timeout" toml:"tls_timeout"` //TLSConfig define the tls configuration for the current gateways destination. - TLSConfig libtls.Config `mapstructure:"tls_config" json:"tls_config" yaml:"tls_config" toml:"tls_config" validate:"dive"` + TLSConfig libtls.Config `mapstructure:"tls_config" json:"tls_config" yaml:"tls_config" toml:"tls_config" validate:""` } // ConfigGateway are options for gateways. @@ -417,7 +417,7 @@ type ConfigGateway struct { TLSTimeout time.Duration `mapstructure:"tls_timeout" json:"tls_timeout" yaml:"tls_timeout" toml:"tls_timeout"` //TLSConfig define the tls configuration for gateways connection. - TLSConfig libtls.Config `mapstructure:"tls_config" json:"tls_config" yaml:"tls_config" toml:"tls_config" validate:"dive"` + TLSConfig libtls.Config `mapstructure:"tls_config" json:"tls_config" yaml:"tls_config" toml:"tls_config" validate:""` } // ConfigLeaf are options for a given server to accept leaf node connections and/or connect to a remote cluster. diff --git a/nutsdb/config.go b/nutsdb/config.go index 258ca320..919043dc 100644 --- a/nutsdb/config.go +++ b/nutsdb/config.go @@ -42,10 +42,10 @@ import ( ) type Config struct { - DB NutsDBOptions `mapstructure:"db" json:"db" yaml:"db" toml:"db" validate:"dive"` - Cluster libclu.Config `mapstructure:"cluster" json:"cluster" yaml:"cluster" toml:"cluster" validate:"dive"` - Directory NutsDBFolder `mapstructure:"directories" json:"directories" yaml:"directories" toml:"directories" validate:"dive"` - Monitor moncfg.Config `mapstructure:"monitor" json:"monitor" yaml:"monitor" toml:"monitor" validate:"dive"` + DB NutsDBOptions `mapstructure:"db" json:"db" yaml:"db" toml:"db" validate:""` + Cluster libclu.Config `mapstructure:"cluster" json:"cluster" yaml:"cluster" toml:"cluster" validate:""` + Directory NutsDBFolder `mapstructure:"directories" json:"directories" yaml:"directories" toml:"directories" validate:""` + Monitor moncfg.Config `mapstructure:"monitor" json:"monitor" yaml:"monitor" toml:"monitor" validate:""` } func (c Config) GetConfigFolder() NutsDBFolder { diff --git a/request/options.go b/request/options.go index 26ed6274..1d3aca4e 100644 --- a/request/options.go +++ b/request/options.go @@ -53,16 +53,16 @@ type OptionsToken struct { } type OptionsAuth struct { - Basic OptionsCredentials `json:"basic" yaml:"basic" toml:"basic" mapstructure:"basic" validate:"dive"` - Bearer OptionsToken `json:"bearer" yaml:"bearer" toml:"bearer" mapstructure:"bearer" validate:"dive"` + Basic OptionsCredentials `json:"basic" yaml:"basic" toml:"basic" mapstructure:"basic" validate:""` + Bearer OptionsToken `json:"bearer" yaml:"bearer" toml:"bearer" mapstructure:"bearer" validate:""` } type OptionsHealth struct { Enable bool `json:"enable" yaml:"enable" toml:"enable" mapstructure:"enable"` Endpoint string `json:"endpoint" yaml:"endpoint" toml:"endpoint" mapstructure:"endpoint" validate:"url"` - Auth OptionsAuth `json:"auth" yaml:"auth" toml:"auth" mapstructure:"auth" validate:"dive"` - Result OptionsHealthResult `json:"result" yaml:"result" toml:"result" mapstructure:"result" validate:"dive"` - Monitor moncfg.Config `json:"monitor" yaml:"monitor" toml:"monitor" mapstructure:"monitor" validate:"required,dive"` + Auth OptionsAuth `json:"auth" yaml:"auth" toml:"auth" mapstructure:"auth" validate:""` + Result OptionsHealthResult `json:"result" yaml:"result" toml:"result" mapstructure:"result" validate:""` + Monitor moncfg.Config `json:"monitor" yaml:"monitor" toml:"monitor" mapstructure:"monitor" validate:"required"` } type OptionsHealthResult struct { @@ -74,9 +74,9 @@ type OptionsHealthResult struct { type Options struct { Endpoint string `json:"endpoint" yaml:"endpoint" toml:"endpoint" mapstructure:"endpoint" validate:"url"` - HttpClient libhtc.Options `json:"http_client" yaml:"http_client" toml:"http_client" mapstructure:"http_client" validate:"dive"` - Auth OptionsAuth `json:"auth" yaml:"auth" toml:"auth" mapstructure:"auth" validate:"dive"` - Health OptionsHealth `json:"health" yaml:"health" toml:"health" mapstructure:"health" validate:"dive"` + HttpClient libhtc.Options `json:"http_client" yaml:"http_client" toml:"http_client" mapstructure:"http_client" validate:""` + Auth OptionsAuth `json:"auth" yaml:"auth" toml:"auth" mapstructure:"auth" validate:""` + Health OptionsHealth `json:"health" yaml:"health" toml:"health" mapstructure:"health" validate:""` tls libtls.FctTLSDefault log liblog.FuncLog