From f0f9e46dcc490da299e1ec2d4dc9f3c5aa9d133f Mon Sep 17 00:00:00 2001 From: Patrick Mirwald Date: Fri, 9 Aug 2024 13:09:13 +0200 Subject: [PATCH] chore: remove vault(secret) function --- .../kotlin/com/liftric/vault/GetSecretTest.kt | 8 ------- .../com/liftric/vault/VaultClientPlugin.kt | 21 +------------------ 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/integrationMain/kotlin/com/liftric/vault/GetSecretTest.kt b/src/integrationMain/kotlin/com/liftric/vault/GetSecretTest.kt index 54f43af..06e260c 100644 --- a/src/integrationMain/kotlin/com/liftric/vault/GetSecretTest.kt +++ b/src/integrationMain/kotlin/com/liftric/vault/GetSecretTest.kt @@ -35,15 +35,7 @@ vault { maxRetries.set(2) retryIntervalMilliseconds.set(200) } -val configTimeSecrets: Map = 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 { diff --git a/src/main/kotlin/com/liftric/vault/VaultClientPlugin.kt b/src/main/kotlin/com/liftric/vault/VaultClientPlugin.kt index 3298ade..6fd1beb 100644 --- a/src/main/kotlin/com/liftric/vault/VaultClientPlugin.kt +++ b/src/main/kotlin/com/liftric/vault/VaultClientPlugin.kt @@ -21,23 +21,4 @@ class VaultClientPlugin : Plugin { 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 { - 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) -} +} \ No newline at end of file