Skip to content

Commit

Permalink
Merge pull request #846 from joshcooper/uri_new
Browse files Browse the repository at this point in the history
Use URI.parse when selecting the docker target
  • Loading branch information
joshcooper authored Apr 17, 2024
2 parents 89889f7 + 5b9af35 commit b5ea0d6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](https://semver.org).
This changelog adheres to [Keep a CHANGELOG](https://keepachangelog.com).

## [Unreleased]
### Fixed
- Use URI.parse when selecting the docker target

## [0.48.0] - 2024-04-16
### Added
Expand Down
2 changes: 1 addition & 1 deletion lib/vanagon/engine/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def select_target
extra_args = @platform.docker_run_args.nil? ? [] : @platform.docker_run_args

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

wait_for_ssh unless @platform.use_docker_exec
rescue StandardError => e
Expand Down
22 changes: 22 additions & 0 deletions spec/lib/vanagon/engine/docker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,26 @@
end
end
end

describe '#select_target' do
context 'when platform has use_docker_exec set' do
subject { described_class.new(platform_with_docker_exec) }

it 'starts a new docker instance' do
expect(Vanagon::Utilities).to receive(:ex).with("/usr/bin/docker run -d --name debian_10-slim-builder debian:10-slim")

subject.select_target
end

it 'sets the target to a localhost URI' do
allow(Vanagon::Utilities).to receive(:ex)

subject.select_target

uri = subject.target
expect(uri).to be_an_instance_of(URI::Generic)
expect(uri.path).to eq('localhost')
end
end
end
end

0 comments on commit b5ea0d6

Please sign in to comment.