-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
over-generous "or". oops. - add a debug endpoint - catch exception when fetching non-existent config files - cache collaborators
- Loading branch information
Showing
12 changed files
with
121 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
cf-admin-bot/src/main/java/org/commonhaus/automation/admin/dev/DebugRoutes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.commonhaus.automation.admin.dev; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.PathParam; | ||
import jakarta.ws.rs.core.Response; | ||
|
||
import org.commonhaus.automation.admin.github.AppContextService; | ||
import org.commonhaus.automation.admin.github.ScopedQueryContext; | ||
import org.kohsuke.github.GHUser; | ||
|
||
import io.quarkus.arc.profile.IfBuildProfile; | ||
import io.quarkus.logging.Log; | ||
|
||
@IfBuildProfile("dev") | ||
@Path("/debug") | ||
public class DebugRoutes { | ||
@Inject | ||
AppContextService appCtx; | ||
|
||
@GET | ||
@Path("/{login}/roles") | ||
public Response getRoles(@PathParam("login") String login) { | ||
Log.infof("DEBUG: getRoles(%s)", login); | ||
|
||
ScopedQueryContext qc = appCtx.getScopedQueryContext("commonhaus/sponsors"); | ||
|
||
GHUser user = qc.getUser(login); | ||
isTeamMember(qc, user, "commonhaus/cf-council"); | ||
isTeamMember(qc, user, "commonhaus/cf-egc"); | ||
isTeamMember(qc, user, "commonhaus/members"); | ||
isCollaborator(qc, user, "commonhaus/sponsors"); | ||
|
||
Set<String> roles = new HashSet<>(); | ||
appCtx.userIsKnown(qc, login, roles); | ||
|
||
// appCtx.userIsKnown(qc, login, roles); | ||
return Response.ok().build(); | ||
} | ||
|
||
private boolean isTeamMember(ScopedQueryContext qc, GHUser user, String fullTeamName) { | ||
boolean result = qc.isTeamMember(user, fullTeamName); | ||
Log.debugf("%s isTeamMember of %s -> %s", | ||
user.getLogin(), fullTeamName, result); | ||
return result; | ||
} | ||
|
||
private boolean isCollaborator(ScopedQueryContext qc, GHUser user, String repoName) { | ||
boolean result = qc.isCollaborator(user, repoName); | ||
Log.debugf("%s isCollaborator of %s -> %s", | ||
user.getLogin(), repoName, result); | ||
return result; | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...mmonhaus/automation/admin/TestRoutes.java → ...haus/automation/admin/dev/TestRoutes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters