Repository navigation
Add --upsert flag to update list commands - #3248
Conversation
|
I figured this approach was better than trying to make the shell scripts have to parse the text output of the create command determine if they needed to call the update command. |
d4756db to
c3aea0f
Compare
gbrodman
left a comment
There was a problem hiding this comment.
@gbrodman reviewed 13 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on CydeWeys).
core/src/main/java/google/registry/tools/CreatePremiumListCommand.java line 60 at r1 (raw file):
} inputData = Files.readAllLines(inputFile, UTF_8); checkArgument(!inputData.isEmpty(), "New premium list data cannot be empty");
instead of checking here, as long as we're parsing the list anyway, we should parse the list then check to make sure there are at least some lines -- this would falsely succeed on a file with only a comment
core/src/main/java/google/registry/tools/UpdateReservedListCommand.java line 52 at r1 (raw file):
List<String> allLines = Files.readAllLines(input, UTF_8); if (existingReservedList.isEmpty()) { newChange = true;
i think we also need to make sure the name is valid (though we cannot guarantee the TLD exists yet)
c3aea0f to
2067f53
Compare
CydeWeys
left a comment
There was a problem hiding this comment.
@CydeWeys made 2 comments.
Reviewable status: 6 of 14 files reviewed, 2 unresolved discussions (waiting on gbrodman).
core/src/main/java/google/registry/tools/CreatePremiumListCommand.java line 60 at r1 (raw file):
Previously, gbrodman wrote…
instead of checking here, as long as we're parsing the list anyway, we should parse the list then check to make sure there are at least some lines -- this would falsely succeed on a file with only a comment
Done.
core/src/main/java/google/registry/tools/UpdateReservedListCommand.java line 52 at r1 (raw file):
Previously, gbrodman wrote…
i think we also need to make sure the name is valid (though we cannot guarantee the TLD exists yet)
Done.
CydeWeys
left a comment
There was a problem hiding this comment.
PTAL
@CydeWeys made 1 comment.
Reviewable status: 6 of 14 files reviewed, 2 unresolved discussions (waiting on gbrodman).
gbrodman
left a comment
There was a problem hiding this comment.
@gbrodman reviewed 8 files and all commit messages, and resolved 2 discussions.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on CydeWeys).
Add --upsert (-u) flag to UpdatePremiumListCommand and UpdateReservedListCommand so that missing premium and reserved lists are created automatically when --upsert is specified, while still failing when --upsert is omitted and the list does not exist. Allow CurrencyUnit to be nullable in PremiumListUtils.parseToPremiumList() so that PremiumList.createFromLine() infers the currency unit from the input lines when currency is unset, and use this in UpdatePremiumListCommand when creating a new list via --upsert. Also fix the mixed-currency example in config/files/premium/example.txt. Also propagate exceptions from CreateOrUpdatePremiumListCommand.execute() and CreateOrUpdateReservedListCommand.execute() instead of catching and swallowing Throwable, and validate non-empty and parseable input data in CreatePremiumListCommand.prompt(). Add comprehensive unit tests across PremiumListUtilsTest and the create/update list command test suites. BUG=http://b/569977604
2067f53 to
7f96e14
Compare
Add
--upsert(-u) flag toUpdatePremiumListCommandandUpdateReservedListCommandso that missing premium and reserved lists are created automatically when--upsertis specified, while still failing when--upsertis omitted and the list does not exist.Allow
CurrencyUnitto be nullable inPremiumListUtils.parseToPremiumList()so thatPremiumList.createFromLine()infers the currency unit from the input lines when currency is unset, and use this inUpdatePremiumListCommandwhen creating a new list via--upsert. Also fix the mixed-currency example inconfig/files/premium/example.txt.Also propagate exceptions from
CreateOrUpdatePremiumListCommand.execute()andCreateOrUpdateReservedListCommand.execute()instead of catching and swallowingThrowable, and validate non-empty and parseable input data inCreatePremiumListCommand.prompt(). Add comprehensive unit tests acrossPremiumListUtilsTestand the create/update list command test suites.BUG=http://b/569977604
This change is