From c49b75a36dae846bdd546eb7b746db5d9662c61f Mon Sep 17 00:00:00 2001 From: Sean Millichamp Date: Fri, 10 Nov 2023 12:34:33 -0500 Subject: [PATCH] Fix docker remote host support URI.parse in Ruby 3.2 returns an empty host string instead of nil, so we should check for both conditions before using the value. --- tasks/docker.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/docker.rb b/tasks/docker.rb index 446d7d7..3d80768 100755 --- a/tasks/docker.rb +++ b/tasks/docker.rb @@ -165,7 +165,8 @@ def provision(image, inventory_location, vars) begin # Use the current docker context to determine the docker hostname docker_context = JSON.parse(run_local_command('docker context inspect'))[0] - hostname = URI.parse(docker_context['Endpoints']['docker']['Host']).host || hostname + docker_uri = URI.parse(docker_context['Endpoints']['docker']['Host']) + hostname = docker_uri.host unless docker_uri.host.nil? || docker_uri.host.empty? rescue RuntimeError # old clients may not support docker context end