1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-11-23 21:44:41 +02:00
Files
go-micro/plugins/config/source/vault
Jerry 93ba8cd0df continue fix pre version go get bug that unknown v3.5.1 (#2188)
* 1.fix plugins go get bug.
2.update all mode.
3.add tidy tools

* continue fix pre version go get bug that unknown v3.5.1
2021-06-30 09:24:00 +01:00
..
2021-06-30 07:21:03 +01:00
2021-01-20 21:01:10 +00:00
2021-01-20 21:01:10 +00:00
2021-01-20 21:01:10 +00:00
2021-01-20 21:01:10 +00:00
2021-01-20 21:01:10 +00: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)