-
Notifications
You must be signed in to change notification settings - Fork 147
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
ReservedPackage + admin action. #8105
Conversation
isoos
commented
Oct 4, 2024
- Fixes Admin action for reserving package names #8082
''', | ||
options: { | ||
'package': 'The package name to be reserved.', | ||
'emails': 'The list of email addresses, separated by comma.' |
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.
Should we add an option to delete the entity? Maybe it is not worth it...
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.
We could just add:
package-reserve-list
package-reserve-delete
Life is easier, if we split them into multiple actions. We can still put them all in the same file if want that.
We could even consider naming them:
package-reservation-create
package-reservation-list
package-reservation-delete
naming is a nit, but it's probably more intuitive to have separate options. And it's probably easier to read the code too.
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.
Like a --delete
flag?
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.
Yeah - probably --delete=true
as we didn't implement real flags for actions,
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.
a separate command is MUCH easier to do.
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.
it's really just something like:
final package = options['package'];
InvalidInputException.check(
package != null && package.isNotEmpty,
'`package` must be given',
);
await withRetryTransaction(dbService, (tx) async {
final existing = await tx.lookupOrNull<ReservedPackage>(
dbService.emptyKey.append(ReservedPackage, id: package));
if (exiting == null) {
return {'message': 'ReservedPackage for "$package" does not exist!'};
}
tx.delete(existing.key);
});
return {'message': 'ReservedPackage for "$package" deleted.'};
A --delete=true
flag requires a lot more explanation in the documentation, it's not very intuitive.
''', | ||
options: { | ||
'package': 'The package name to be reserved.', | ||
'emails': 'The list of email addresses, separated by comma.' |
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.
We could just add:
package-reserve-list
package-reserve-delete
Life is easier, if we split them into multiple actions. We can still put them all in the same file if want that.
We could even consider naming them:
package-reservation-create
package-reservation-list
package-reservation-delete
naming is a nit, but it's probably more intuitive to have separate options. And it's probably easier to read the code too.
Yeah - multiple commands is probably better. |
Updated, PTAL. |
I will add list/delete in a follow-up PR. |