-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(secrets): Make common createPath()
code the default
#288
refactor(secrets): Make common createPath()
code the default
#288
Conversation
Signed-off-by: Sebastian Schuberth <[email protected]>
98a4d5d
to
faa86cc
Compare
organizationId != null -> "organization" | ||
productId != null -> "product" | ||
repositoryId != null -> "repository" | ||
organizationId != null -> "organization_$organizationId" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I dislike on the new approach is that the separator ('_') between level and ID is now repeated multiple times, making it harder to change the way paths are generated.
An alternative could be having a nested function like
fun levelId(level: String, id: Long?): String? =
id?.let { "${level}_$id" }
and then do something like
return listOfNotNull(
levelId("organization", organizationId),
levelId("product", productId),
levelId("repository", repositoryId)
)..singleOrNull() ?: throw IllegalArgumentException(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the separator ('_') between level and ID is now repeated multiple times, making it harder to change the way paths are generated.
Actually, I think that could be even an advantage, as no one says that the separator between path components and the final name should be the same. While implementing a new secrets provider, I was actually struggling with the fact that from a given Path
, you cannot easily tell anymore which was the "name" part only (as the name could also contain an underscore itself).
I've found a good way to solve that now, but I'm still not sure whether we should enforce the separator to be the same between all path components.
An alternative could be having a nested function like
My goal was to make the code simpler, not more complex / longer 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, I expect the code to change again with a new iteration of #271.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, I expect the code to change again with a new iteration of #271.
So, I see no point in changing this now. Could this commit be dropped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I see no point in changing this now. Could this commit be dropped?
I see no point in spending work to drop it as it's already there. Can it stay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, whatever, I've dropped the last commit to move things forward.
faa86cc
to
1482f21
Compare
No description provided.