-
Notifications
You must be signed in to change notification settings - Fork 8
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: Simplify the secrets API via an enum for the id's entity #271
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ import org.eclipse.apoapsis.ortserver.core.utils.pagingOptions | |
import org.eclipse.apoapsis.ortserver.core.utils.requireIdParameter | ||
import org.eclipse.apoapsis.ortserver.core.utils.requireParameter | ||
import org.eclipse.apoapsis.ortserver.model.authorization.OrganizationPermission | ||
import org.eclipse.apoapsis.ortserver.model.repositories.SecretRepository.Entity | ||
import org.eclipse.apoapsis.ortserver.services.InfrastructureServiceService | ||
import org.eclipse.apoapsis.ortserver.services.OrganizationService | ||
import org.eclipse.apoapsis.ortserver.services.SecretService | ||
|
@@ -175,7 +176,8 @@ fun Route.organizations() = route("organizations") { | |
val orgId = call.requireIdParameter("organizationId") | ||
val pagingOptions = call.pagingOptions(SortProperty("name", SortDirection.ASCENDING)) | ||
|
||
val secretsForOrganization = secretService.listForOrganization(orgId, pagingOptions.mapToModel()) | ||
val secretsForOrganization = secretService | ||
.listSecrets(Entity.ORGANIZATION, orgId, pagingOptions.mapToModel()) | ||
val pagedResponse = PagedResponse( | ||
secretsForOrganization.map { it.mapToApi() }, | ||
pagingOptions | ||
|
@@ -191,7 +193,7 @@ fun Route.organizations() = route("organizations") { | |
val organizationId = call.requireIdParameter("organizationId") | ||
val secretName = call.requireParameter("secretName") | ||
|
||
secretService.getSecretByOrganizationIdAndName(organizationId, secretName) | ||
secretService.getSecret(Entity.ORGANIZATION, organizationId, secretName) | ||
?.let { call.respond(HttpStatusCode.OK, it.mapToApi()) } | ||
?: call.respond(HttpStatusCode.NotFound) | ||
} | ||
|
@@ -205,7 +207,8 @@ fun Route.organizations() = route("organizations") { | |
|
||
call.respond( | ||
HttpStatusCode.OK, | ||
secretService.updateSecretByOrganizationAndName( | ||
secretService.updateSecret( | ||
Entity.ORGANIZATION, | ||
organizationId, | ||
secretName, | ||
updateSecret.value.mapToModel(), | ||
|
@@ -220,7 +223,7 @@ fun Route.organizations() = route("organizations") { | |
val organizationId = call.requireIdParameter("organizationId") | ||
val secretName = call.requireParameter("secretName") | ||
|
||
secretService.deleteSecretByOrganizationAndName(organizationId, secretName) | ||
secretService.deleteSecret(Entity.ORGANIZATION, organizationId, secretName) | ||
|
||
call.respond(HttpStatusCode.NoContent) | ||
} | ||
|
@@ -238,9 +241,8 @@ fun Route.organizations() = route("organizations") { | |
createSecret.name, | ||
createSecret.value, | ||
createSecret.description, | ||
organizationId, | ||
null, | ||
null | ||
Entity.ORGANIZATION, | ||
organizationId | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For most callers it would be nicer to have convenience functions like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where's the convenient in using these functions that basically just encode the entity parameter as part of the function name? They are hardly shorter, and create a maintenance burden if more entities (like business units, groups of organizations etc.) would be added in the future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it's a matter of taste as well, personally I'd rather call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So, not a must to address? Because I'd prefer not to. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, not a must, but as this is still a draft maybe there is some time to get an opinion from another contributor (@oheger-bosch @MarcelBochtler @bs-ondem)? |
||
).mapToApi() | ||
) | ||
} | ||
|
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.
Similar to the comment on the first commit, it would be nice to have convenience functions like
getRepositorySecret
,deleteRepositorySecret
, orlistRepositorySecrets
.