mirror of
https://github.com/apple/container.git
synced 2026-09-22 23:55:34 +00:00
APIServer: Add support for filtering to list rpc (#1175)
This is not intended to be used to support `--filter` or similar on the CLIs list yet, it's solely to clean up our rather awkward use of `ContainerClient.list()` today in the CLI. The list RPC simply returns all of the containers we have created. Because of this, for a LOT of our commands we filter to what we need client side, which feels like a waste.. This change introduces a filter struct that we can provide an array of container IDs, labels, and the status of the containers to filter the `list()` output from. This additionally, because it was killing (pun not intended) me and I was already having to change this area for the `list()` additions, changes container kill slightly to return an error if you try and kill a container that doesn't exist.
This commit is contained in:
@@ -79,9 +79,8 @@ extension Application {
|
||||
log.info("waiting for containers to exit")
|
||||
do {
|
||||
for _ in 0..<Self.shutdownTimeoutSeconds {
|
||||
let anyRunning = try await client.list()
|
||||
.contains { $0.status == .running }
|
||||
guard anyRunning else {
|
||||
let runningContainers = try await client.list(filters: ContainerListFilters(status: .running))
|
||||
guard !runningContainers.isEmpty else {
|
||||
break
|
||||
}
|
||||
try await Task.sleep(for: .seconds(1))
|
||||
|
||||
Reference in New Issue
Block a user