Skip to content
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

Merged

Conversation

sschuberth
Copy link
Contributor

No description provided.

@sschuberth sschuberth force-pushed the default-create-path branch from 98a4d5d to faa86cc Compare May 23, 2024 21:27
organizationId != null -> "organization"
productId != null -> "product"
repositoryId != null -> "repository"
organizationId != null -> "organization_$organizationId"
Copy link
Contributor

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(...)

Copy link
Contributor Author

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 😉

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

@sschuberth sschuberth requested a review from oheger-bosch May 24, 2024 09:40
@sschuberth sschuberth force-pushed the default-create-path branch from faa86cc to 1482f21 Compare May 27, 2024 07:01
@oheger-bosch oheger-bosch added this pull request to the merge queue May 27, 2024
Merged via the queue into eclipse-apoapsis:main with commit 03d206c May 27, 2024
12 checks passed
@sschuberth sschuberth deleted the default-create-path branch May 27, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants