-
Notifications
You must be signed in to change notification settings - Fork 16
/
manifest.go
37 lines (30 loc) · 985 Bytes
/
manifest.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package flags
import (
"fmt"
manifests "github.com/consensys/quorum-key-manager/src/infra/manifests/yaml"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)
func init() {
viper.SetDefault(manifestPathViperKey, manifestPathDefault)
_ = viper.BindEnv(manifestPathViperKey, manifestPathEnv)
}
const (
ManifestPath = "manifest-path"
manifestPathEnv = "MANIFEST_PATH"
manifestPathViperKey = "manifest.path"
manifestPathDefault = ""
)
func manifestPath(f *pflag.FlagSet) {
desc := fmt.Sprintf(`Path to manifest file/folder to configure key manager stores and nodes
Environment variable: %q`, manifestPathEnv)
f.String(ManifestPath, manifestPathDefault, desc)
_ = viper.BindPFlag(manifestPathViperKey, f.Lookup(ManifestPath))
}
// ManifestFlags register flags for Node
func ManifestFlags(f *pflag.FlagSet) {
manifestPath(f)
}
func NewManifestConfig(vipr *viper.Viper) *manifests.Config {
return manifests.NewConfig(vipr.GetString(manifestPathViperKey))
}