Skip to content

Commit

Permalink
feat(readme): additional information
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingwersaft committed Mar 9, 2020
1 parent 2604640 commit e2298d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ You can specify the token in the vault configuration as well (see below), but th
and is highly discouraged. The vaultAddress and vaultTokenFilePath configs should be fine though.

Usage example in you build script:
```
## build scripts

```kotlin
import com.liftric.vault.vault

Expand All @@ -31,11 +30,24 @@ vault {
}
tasks {
val needsSecrets by creating {
val secrets = project.objects.mapProperty<String, String>()
val secrets: Map<String, String> = project.vault("secret/example")
}
}
```

See the `integration-` sub projects for working examples.

## configuration
After the plugin is applied, the vault extension is registered with the following settings:

Property | Description | default value
---|---|---
vaultAddress | vault address to be used | result of `System.getenv()["VAULT_ADDR"]`
vaultToken | vault token to be used (it's recommend you don't set this in your build file) | result of `System.getenv()["VAULT_TOKEN"]`
vaultTokenFilePath | vault token file path (if set has precedence over vaultToken) | result of `System.getenv()["VAULT_TOKEN_FILE_PATH"]`
maxRetries | vault client max retry count | 5
retryIntervalMilliseconds | time between vault request retries | 1000

## buildSrc
You can also use the plugin directly in you buildSrc code:
```kotlin
Expand Down Expand Up @@ -69,3 +81,5 @@ with(Configs) {
[...] // use it
}
```

See `integration-token` for an example.
7 changes: 3 additions & 4 deletions integration-token/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ vault {
}
tasks {
val needsSecrets by creating {
val secrets = project.objects.mapProperty<String, String>()
doLast {
secrets.set(project.vault("secret/example"))
if (secrets.get()["examplestring"] != "helloworld") throw kotlin.IllegalStateException("examplestring couldn't be read")
if (secrets.get()["exampleint"]?.toInt() != 1337) throw kotlin.IllegalStateException("exampleint couldn't be read")
val secrets: Map<String, String> = project.vault("secret/example")
if (secrets["examplestring"] != "helloworld") throw kotlin.IllegalStateException("examplestring couldn't be read")
if (secrets["exampleint"]?.toInt() != 1337) throw kotlin.IllegalStateException("exampleint couldn't be read")
println("getting secrets succeeded!")
}
}
Expand Down

0 comments on commit e2298d3

Please sign in to comment.