1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-11-30 08:06:40 +02:00
go-micro/plugins/config/source/vault
2021-11-11 14:03:34 +00:00
..
testdata add all the plugins 2020-12-26 15:32:45 +00:00
go.mod upgrade to go 1.17 (#2346) 2021-11-11 14:03:34 +00:00
go.sum upgrade to go 1.17 (#2346) 2021-11-11 14:03:34 +00:00
options.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
README.md add all the plugins 2020-12-26 15:32:45 +00:00
util.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
vault_test.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
vault.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00
watcher.go go-micro.dev/v4 (#2305) 2021-10-12 12:55:53 +01:00

Vault Source

The vault source reads config from different secret engines in a Vault server. For example:

kv: secret/data/<my/secret>
database credentials: database/creds/<my-db-role>

New Source

Specify source with data

vaultSource := vault.NewSource(
	// mandatory: it specifies server address. 
	// It could have different formats:
	// 127.0.0.1 -> https://127.0.0.1:8200
	// http://127.0.0.1 -> http://127.0.0.1:8200
	// http://127.0.0.1:2233
	vault.WithAddress("http://127.0.0.1:8200"),
	// mandatory: it specifies a resource to been access
	vault.WithResourcePath("secret/data/my/secret"),
    // mandatory: it specifies a resource to been access
	vault.WithToken("<my-token>"),
	// optional: path to store my secret.
	// By default use resourcePath value 
	vault.WithSecretName("my/secret"),
	// optional: namespace.
    vault.WithNameSpace("myNameSpace"),
)

Load Source

Load the source into config

// Create new config
conf := config.NewConfig()

// Load file source
conf.Load(vaultSource)