Skip to content

Commit 9c7016b

Browse files
committed
fix: add single initialization to main
1 parent e199688 commit 9c7016b

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

  • tokenstore/provider/awsparamstr

tokenstore/provider/awsparamstr/main.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,38 @@ package main
22

33
import (
44
"context"
5+
"os"
56

67
"github.com/DevLabFoundry/configmanager-plugin/awsparamstr/impl"
78
"github.com/DevLabFoundry/configmanager/v3/tokenstore"
89
"github.com/hashicorp/go-hclog"
910
"github.com/hashicorp/go-plugin"
1011
)
1112

13+
type implIface interface {
14+
Value(token string, metadata []byte) (string, error)
15+
}
1216
type TokenStorePlugin struct {
13-
log hclog.Logger
17+
impl implIface // Value(token string, metadata []byte) (string, error)
1418
}
1519

1620
func (ts TokenStorePlugin) Value(key string, metadata []byte) (string, error) {
17-
srv, err := impl.NewParamStore(context.Background(), ts.log)
18-
if err != nil {
19-
return "", err
20-
}
21-
return srv.Value(key, metadata)
21+
return ts.impl.Value(key, metadata)
2222
}
2323

2424
func main() {
2525
log := hclog.New(hclog.DefaultOptions)
2626
log.SetLevel(hclog.LevelFromString("error"))
2727

28-
// if os.Getenv("CONFIGMANAGER_LOG")
29-
ts := TokenStorePlugin{log: log}
28+
i, err := impl.NewParamStore(context.Background(), log)
29+
if err != nil {
30+
log.Error("error", err)
31+
os.Exit(1)
32+
}
33+
34+
ts := TokenStorePlugin{impl: i}
35+
3036
plugin.Serve(&plugin.ServeConfig{
31-
// Logger: ,
3237
HandshakeConfig: tokenstore.Handshake,
3338
Plugins: map[string]plugin.Plugin{
3439
"configmanager_token_store": &tokenstore.GRPCPlugin{Impl: ts},

0 commit comments

Comments
 (0)