Skip to content

Commit

Permalink
Handle breaking change to docker compose ps output format
Browse files Browse the repository at this point in the history
docker/compose#10958

Signed-off-by: Andrew Haines <haines@cerbos.dev>
  • Loading branch information
haines committed Sep 12, 2023
1 parent d3fd7a8 commit 4d91dc8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ services:
plaintext:
image: ghcr.io/cerbos/cerbos:${CERBOS_IMAGE_TAG:-$CERBOS_VERSION}
environment:
- CERBOS_CONFIG=/config/plaintext.cerbos.yaml
- CERBOS_CONFIG=/config/plaintext.yaml
healthcheck:
interval: 2s
ports:
- 3593
user: ${USER}
volumes:
- type: bind
source: config
source: config/cerbos
target: /config
read_only: true
- type: bind
Expand All @@ -21,9 +21,11 @@ services:
read_only: true

socket:
profiles:
- linux
extends: plaintext
environment:
- CERBOS_CONFIG=/config/socket.cerbos.yaml
- CERBOS_CONFIG=/config/socket.yaml
volumes:
- type: bind
source: ../../tmp/socket
Expand All @@ -32,19 +34,19 @@ services:
tls:
extends: plaintext
environment:
- CERBOS_CONFIG=/config/tls.cerbos.yaml
- CERBOS_CONFIG=/config/tls.yaml
volumes:
- type: bind
source: ../../tmp/certificates
target: /certificates
read_only: true

mtls:
image: traefik:2.6
image: traefik:2.10
command:
- --entrypoints.grpc.address=:3593
- --ping
- --providers.file.filename=/config/mtls.traefik.yaml
- --providers.file.filename=/config/mtls.yaml
healthcheck:
interval: 2s
timeout: 1s
Expand All @@ -61,6 +63,6 @@ services:
target: /certificates
read_only: true
- type: bind
source: config
source: config/traefik
target: /config
read_only: true
13 changes: 8 additions & 5 deletions tasks/test/servers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,22 @@ def export_ports
output, status = Open3.capture2(*command)
raise "`#{command.join(" ")}` exited with status #{status.exitstatus}" unless status.success?

ports(JSON.parse(output)).each do |service, port|
ports(output).each do |service, port|
ENV["CERBOS_PORT_#{service.upcase}"] = port.to_s
end
end

def stop
ENV["POLICIES_VERSION"] = ""
sh(*docker_compose_command("down"))
sh(*docker_compose_command("down", "--remove-orphans"))
end

private

def ports(containers)
containers
def ports(output)
output
.each_line
.flat_map { |line| JSON.parse(line) }
.map { |container| [container.fetch("Service"), port(container)] }
.to_h
.compact
Expand All @@ -66,7 +68,8 @@ def docker_compose_command(*args)
[
{"USER" => "#{Process.uid}:#{Process.gid}"},
"docker", "compose",
"--file", File.expand_path("../../spec/servers/docker-compose.yml", __dir__),
"--file", File.expand_path("../../spec/servers/docker-compose.yaml", __dir__),
"--profile", Gem::Platform.local.os,
*args
]
end
Expand Down

0 comments on commit 4d91dc8

Please sign in to comment.