feat: Add support for "project_destroy" and "project_rename" hooks
1 unresolved thread
Resolves #80 (closed)
Merge request reports
Activity
Filter activity
requested review from @malowe
requested review from @cguindon
30 30 public class WebhooksResource { 31 31 32 32 private static final Logger LOGGER = LoggerFactory.getLogger(WebhooksResource.class); 33 33 34 public static final String CREATE_EVENT = "project_create"; Instead of static strings, we should use an enum with a method to cast a name to the enum. A lot of our logic gets way cleaner that way. An example of this is from the membership portal, in the image formats:
public enum ImageStoreFormats { SMALL, LARGE, PRINT, WEB, WEB_SRC; public String getName() { return this.name().toLowerCase(); } public static ImageStoreFormat getFormat(String name) { if (name == null) { return null; } return Stream.of(values()).filter(v -> name.equalsIgnoreCase(v.getName())).findFirst().orElse(null); } }
With this sort of thing, if you replace the null return with an
UNSUPPORTED
enum, you could then do something like this:SupportedEventType t = getSupportedEventType(theString); switch(t) { case PROJECT_CREATE: doTheThing(); break; ... case UNSUPPORTED: LOGGER.trace("Dropped event {}", theString); break; }
changed this line in version 4 of the diff
added 2 commits
added 1 commit
- 6aaa939e - feat: Add testing for delete and renam hooks
@malowe ready for review :)
mentioned in commit e421d3ac
Please register or sign in to reply