add before Init func support #113

Merged
vtolstov merged 1 commits from config-fix into v3 2023-03-16 07:25:22 +03:00
4 changed files with 27 additions and 4 deletions
Showing only changes of commit 1603add6e6 - Show all commits

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.18
require ( require (
github.com/hashicorp/vault/api v1.9.0 github.com/hashicorp/vault/api v1.9.0
github.com/imdario/mergo v0.3.13 github.com/imdario/mergo v0.3.13
go.unistack.org/micro/v3 v3.10.16 go.unistack.org/micro/v3 v3.10.18
) )
require github.com/stretchr/testify v1.7.2 // indirect require github.com/stretchr/testify v1.7.2 // indirect

4
go.sum
View File

@ -71,8 +71,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s= github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
go.unistack.org/micro/v3 v3.10.16 h1:2er/SKKYbV60M+UuJM4eYCF0MZYAIq/yNUrAbTfgq8Q= go.unistack.org/micro/v3 v3.10.18 h1:iz193N8eZKGrKPXuX6XMsGIRHMqdvUaZSfb9mzwlUYM=
go.unistack.org/micro/v3 v3.10.16/go.mod h1:uMAc0U/x7dmtICCrblGf0ZLgYegu3VwQAquu+OFCw1Q= go.unistack.org/micro/v3 v3.10.18/go.mod h1:uMAc0U/x7dmtICCrblGf0ZLgYegu3VwQAquu+OFCw1Q=
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=

View File

@ -87,7 +87,7 @@ func (c *vaultConfig) Init(opts ...config.Option) error {
return err return err
} }
if err := config.DefaultAfterInit(c.opts.Context, c); err != nil && !c.opts.AllowFail { if err = config.DefaultAfterInit(c.opts.Context, c); err != nil && !c.opts.AllowFail {
return err return err
} }

23
vault_test.go Normal file
View File

@ -0,0 +1,23 @@
package vault
import (
"context"
"testing"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/config"
)
func TestInit(t *testing.T) {
c := NewConfig(
config.Context(context.TODO()),
config.Codec(codec.NewCodec()),
config.BeforeInit(func(ctx context.Context, c config.Config) error {
return c.Init(Token("tkn"), config.BeforeInit(nil))
}),
)
if err := c.Init(); err != nil {
t.Fatal(err)
}
}