Skip to content

Commit b5ea0d6

Browse files
authored
Merge pull request #846 from joshcooper/uri_new
Use URI.parse when selecting the docker target
2 parents 89889f7 + 5b9af35 commit b5ea0d6

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](https://semver.org).
55
This changelog adheres to [Keep a CHANGELOG](https://keepachangelog.com).
66

77
## [Unreleased]
8+
### Fixed
9+
- Use URI.parse when selecting the docker target
810

911
## [0.48.0] - 2024-04-16
1012
### Added

lib/vanagon/engine/docker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def select_target
4040
extra_args = @platform.docker_run_args.nil? ? [] : @platform.docker_run_args
4141

4242
Vanagon::Utilities.ex("#{@docker_cmd} run -d --name #{build_host_name}-builder #{ssh_args} #{extra_args.join(' ')} #{@platform.docker_image}")
43-
@target = URI.new('localhost')
43+
@target = URI.parse('localhost')
4444

4545
wait_for_ssh unless @platform.use_docker_exec
4646
rescue StandardError => e

spec/lib/vanagon/engine/docker_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,26 @@
101101
end
102102
end
103103
end
104+
105+
describe '#select_target' do
106+
context 'when platform has use_docker_exec set' do
107+
subject { described_class.new(platform_with_docker_exec) }
108+
109+
it 'starts a new docker instance' do
110+
expect(Vanagon::Utilities).to receive(:ex).with("/usr/bin/docker run -d --name debian_10-slim-builder debian:10-slim")
111+
112+
subject.select_target
113+
end
114+
115+
it 'sets the target to a localhost URI' do
116+
allow(Vanagon::Utilities).to receive(:ex)
117+
118+
subject.select_target
119+
120+
uri = subject.target
121+
expect(uri).to be_an_instance_of(URI::Generic)
122+
expect(uri.path).to eq('localhost')
123+
end
124+
end
125+
end
104126
end

0 commit comments

Comments
 (0)