diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-11-28 18:33:18 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-11-28 18:33:18 -0800 |
| commit | f60154f330a81354c433da37d612f235d1c0e4e9 (patch) | |
| tree | 5e473f9616e35e525468959496e0448fb505e20a /weed/command/scaffold_test.go | |
| parent | 641b92f53c057a2d0dd957ef2da26aadf0b70419 (diff) | |
| download | seaweedfs-f60154f330a81354c433da37d612f235d1c0e4e9.tar.xz seaweedfs-f60154f330a81354c433da37d612f235d1c0e4e9.zip | |
master load backend storage config from master.toml
Diffstat (limited to 'weed/command/scaffold_test.go')
| -rw-r--r-- | weed/command/scaffold_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/weed/command/scaffold_test.go b/weed/command/scaffold_test.go new file mode 100644 index 000000000..3d69fa317 --- /dev/null +++ b/weed/command/scaffold_test.go @@ -0,0 +1,42 @@ +package command + +import ( + "bytes" + "fmt" + "testing" +) + +func TestReadingTomlConfiguration(t *testing.T) { + + viper.SetConfigType("toml") + + // any approach to require this configuration into your program. + var tomlExample = []byte(` +[database] +server = "192.168.1.1" +ports = [ 8001, 8001, 8002 ] +connection_max = 5000 +enabled = true + +[servers] + + # You can indent as you please. Tabs or spaces. TOML don't care. + [servers.alpha] + ip = "10.0.0.1" + dc = "eqdc10" + + [servers.beta] + ip = "10.0.0.2" + dc = "eqdc10" + +`) + + viper.ReadConfig(bytes.NewBuffer(tomlExample)) + + fmt.Printf("database is %v\n", viper.Get("database")) + fmt.Printf("servers is %v\n", viper.GetStringMap("servers")) + + alpha := viper.Sub("servers.alpha") + + fmt.Printf("alpha ip is %v\n", alpha.GetString("ip")) +} |
