Skip to content
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

add groups endpoint #396

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Lists all changes with user impact.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [0.19.36]

### Changed
- Added debug endpoint, which returns current groups

## [0.19.35]

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RestController
import pl.allegro.tech.servicemesh.envoycontrol.groups.Group
import io.envoyproxy.envoy.config.core.v3.Node as NodeV3
import io.envoyproxy.envoy.extensions.filters.http.rbac.v3.RBAC as RBACFilter

Expand All @@ -57,6 +58,15 @@ class SnapshotDebugController(val debugService: SnapshotDebugService) {
)
}

@GetMapping("/groups")
fun globalSnapshot(@RequestParam(required = false) discoveryServiceName: String?)
: ResponseEntity<Collection<Group>> {
return ResponseEntity(
debugService.groups(discoveryServiceName),
HttpStatus.OK
)
}

@GetMapping("/snapshot-global")
fun globalSnapshot(@RequestParam(defaultValue = "false") xds: Boolean): ResponseEntity<SnapshotDebugInfo> {
return ResponseEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ class SnapshotDebugService(
}
}

fun groups(discoveryServiceName: String?): Collection<Group> {
return if (discoveryServiceName != null) {
cache.groups().filter { it.discoveryServiceName == discoveryServiceName }
} else {
cache.groups()
}
}

fun globalSnapshot(xds: Boolean): SnapshotDebugInfo {
val globalSnapshot = snapshotUpdater.getGlobalSnapshot()
if (xds) {
Expand Down
Loading