diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/Prov.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/Prov.kt index 6420ccb..87a88c8 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/Prov.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/Prov.kt @@ -195,11 +195,12 @@ open class Prov protected constructor( * Retrieve a secret by executing the given command. * Returns the result of the command as secret. */ - fun getSecret(command: String): Secret? { + fun getSecret(command: String, removeNewlineSuffix: Boolean = false): Secret? { val result = cmdNoLog(command) return if (result.success && result.out != null) { addResultToEval(ProvResult(true, getCallingMethodName())) - Secret(result.out) + val plainSecret = if (removeNewlineSuffix && result.out.takeLast(1) == "\n") result.out.dropLast(1) else result.out + Secret(plainSecret) } else { addResultToEval(ProvResult(false, getCallingMethodName(), err = result.err, exception = result.exception)) null diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/GopassSecretSource.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/GopassSecretSource.kt index 5a6cb76..65ae378 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/GopassSecretSource.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/GopassSecretSource.kt @@ -14,6 +14,6 @@ class GopassSecretSource(path: String) : SecretSource(path) { } override fun secretNullable(): Secret? { val p = Prov.newInstance(name = "GopassSecretSource for $input") - return p.getSecret("gopass show -f " + input) + return p.getSecret("gopass show -f $input", true) } } \ No newline at end of file