Skip to content

Commit

Permalink
chore: remove vault(secret) function
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Mirwald committed Aug 9, 2024
1 parent 94d77a2 commit f0f9e46
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
8 changes: 0 additions & 8 deletions src/integrationMain/kotlin/com/liftric/vault/GetSecretTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,7 @@ vault {
maxRetries.set(2)
retryIntervalMilliseconds.set(200)
}
val configTimeSecrets: Map<String, String> = vault("secret/example")
tasks {
val needsSecretsConfigTime by creating {
doLast {
if (configTimeSecrets["examplestring"] != "helloworld") throw kotlin.IllegalStateException("examplestring couldn't be read")
if (configTimeSecrets["exampleint"]?.toInt() != 1337) throw kotlin.IllegalStateException("exampleint couldn't be read")
println("getting secrets succeeded!")
}
}
val needsSecrets by creating(GetVaultSecretTask::class) {
secretPath.set("secret/example")
doLast {
Expand Down
21 changes: 1 addition & 20 deletions src/main/kotlin/com/liftric/vault/VaultClientPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,4 @@ class VaultClientPlugin : Plugin<Project> {
fun Project.vault(): VaultClientExtension {
return extensions.getByName(extensionName) as? VaultClientExtension
?: throw IllegalStateException("$extensionName is not of the correct type")
}

fun Project.vault(secretPath: String): Map<String, String> {
val extension: VaultClientExtension = vault()
val token = GetVaultSecretTask.determineToken(
vaultToken = extension.vaultToken.orNull,
vaultTokenFilePath = extension.vaultTokenFilePath.orNull
)
val address = GetVaultSecretTask.determinAddress(vaultAddress = extension.vaultAddress.orNull)
val maxRetries = extension.maxRetries.getOrElse(Defaults.MAX_RETRIES)
val retryIntervalMilliseconds = extension.retryIntervalMilliseconds.getOrElse(Defaults.RETRY_INTERVAL_MILLI)
println("[vault] getting `$secretPath` from $address")

return VaultClient(
token = token,
vaultAddress = address,
maxRetries = maxRetries,
retryIntervalMilliseconds = retryIntervalMilliseconds
).get(secretPath)
}
}

0 comments on commit f0f9e46

Please sign in to comment.