Skip to content

Commit

Permalink
refactor(secrets): Simplify path creation a bit
Browse files Browse the repository at this point in the history
Avoid a `listOfNotNull` that contains both strings and longs.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed May 23, 2024
1 parent 1482f21 commit faa86cc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions secrets/spi/src/main/kotlin/SecretsProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ interface SecretsProvider {
*/
fun createPath(organizationId: Long?, productId: Long?, repositoryId: Long?, secretName: String): Path {
val secretType = when {
organizationId != null -> "organization"
productId != null -> "product"
repositoryId != null -> "repository"
organizationId != null -> "organization_$organizationId"
productId != null -> "product_$productId"
repositoryId != null -> "repository_$repositoryId"
else -> throw IllegalArgumentException(
"Either one of organizationId, productId or repositoryId should be specified to create a path."
)
}

return Path(listOfNotNull(secretType, organizationId, productId, repositoryId, secretName).joinToString("_"))
return Path("${secretType}_$secretName")
}
}

0 comments on commit faa86cc

Please sign in to comment.