From bce6873851e6013bf8aa3ac948bccb0282012b5b Mon Sep 17 00:00:00 2001 From: az Date: Fri, 26 May 2023 12:08:13 +0200 Subject: [PATCH] [skip ci] suppress progress for getting secrets from file or gopass --- .../domaindrivenarchitecture/provs/framework/core/Prov.kt | 2 +- .../ubuntu/secret/secretSources/FileSecretSource.kt | 5 +++-- .../ubuntu/secret/secretSources/GopassSecretSource.kt | 3 ++- .../ubuntu/secret/secretSources/PassSecretSource.kt | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) 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 c995d27..f8c24fd 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/Prov.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/Prov.kt @@ -465,7 +465,7 @@ open class Prov protected constructor( } fun printDeprecationWarningIfLevel0(methodName: String) { - if (level == 0) { + if (level == 0 && progressType != ProgressType.NONE) { println("WARNING: method $methodName should not be used at top-level, use method instead.") } } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/FileSecretSource.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/FileSecretSource.kt index a764199..7595b50 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/FileSecretSource.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/FileSecretSource.kt @@ -1,5 +1,6 @@ package org.domaindrivenarchitecture.provs.framework.ubuntu.secret.secretSources +import org.domaindrivenarchitecture.provs.framework.core.ProgressType import org.domaindrivenarchitecture.provs.framework.core.Prov import org.domaindrivenarchitecture.provs.framework.core.Secret import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.SecretSource @@ -11,12 +12,12 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.SecretSource class FileSecretSource(fqFileName: String) : SecretSource(fqFileName) { override fun secret(): Secret { - val p = Prov.newInstance(name = "FileSecretSource") + val p = Prov.newInstance(name = "FileSecretSource", progressType = ProgressType.NONE) return p.getSecret("cat " + input) ?: throw Exception("Failed to get secret.") } override fun secretNullable(): Secret? { - val p = Prov.newInstance(name = "FileSecretSource") + val p = Prov.newInstance(name = "FileSecretSource", progressType = ProgressType.NONE) return p.getSecret("cat " + input) } } \ No newline at end of file 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 65ae378..03d2998 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 @@ -1,5 +1,6 @@ package org.domaindrivenarchitecture.provs.framework.ubuntu.secret.secretSources +import org.domaindrivenarchitecture.provs.framework.core.ProgressType import org.domaindrivenarchitecture.provs.framework.core.Prov import org.domaindrivenarchitecture.provs.framework.core.Secret import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.SecretSource @@ -13,7 +14,7 @@ class GopassSecretSource(path: String) : SecretSource(path) { return secretNullable() ?: throw Exception("Failed to get \"$input\" secret from gopass.") } override fun secretNullable(): Secret? { - val p = Prov.newInstance(name = "GopassSecretSource for $input") + val p = Prov.newInstance(name = "GopassSecretSource for $input", progressType = ProgressType.NONE) return p.getSecret("gopass show -f $input", true) } } \ No newline at end of file diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/PassSecretSource.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/PassSecretSource.kt index fade282..5ec30bb 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/PassSecretSource.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/secretSources/PassSecretSource.kt @@ -1,5 +1,6 @@ package org.domaindrivenarchitecture.provs.framework.ubuntu.secret.secretSources +import org.domaindrivenarchitecture.provs.framework.core.ProgressType import org.domaindrivenarchitecture.provs.framework.core.Prov import org.domaindrivenarchitecture.provs.framework.core.Secret import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.SecretSource @@ -10,11 +11,11 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.SecretSource */ class PassSecretSource(path: String) : SecretSource(path) { override fun secret(): Secret { - val p = Prov.newInstance(name = "PassSecretSource") + val p = Prov.newInstance(name = "PassSecretSource", progressType = ProgressType.NONE) return p.getSecret("pass " + input) ?: throw Exception("Failed to get secret.") } override fun secretNullable(): Secret? { - val p = Prov.newInstance(name = "PassSecretSource") + val p = Prov.newInstance(name = "PassSecretSource", progressType = ProgressType.NONE) return p.getSecret("pass " + input) } } \ No newline at end of file