-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from jeffreycoe/windows-support
Refactor driver to include Windows support (includes new transport for all supported platforms)
- Loading branch information
Showing
24 changed files
with
1,457 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,3 +18,4 @@ tmp | |
.kitchen/ | ||
.kitchen.local.yml | ||
Dockerfile* | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<% # Make sure the local copy of the driver is loaded %> | ||
<% lib = File.expand_path('../lib', __FILE__) %> | ||
<% $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) %> | ||
--- | ||
driver: | ||
name: docker | ||
provision_command: | ||
- powershell -ExecutionPolicy Bypass -NoLogo -Command . { iwr -useb https://omnitruck.chef.io/install.ps1 } ^| iex; install | ||
- powershell -Command $path=$env:Path + ';c:\opscode\chef\embedded\bin'; Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\' -Name Path -Value $path | ||
|
||
transport: | ||
name: docker | ||
socket: tcp://localhost:2375 | ||
|
||
provisioner: | ||
name: dummy | ||
|
||
platforms: | ||
- name: windows | ||
driver_config: | ||
image: mcr.microsoft.com/windows/servercore:1803 | ||
platform: windows | ||
|
||
suites: | ||
- name: default | ||
- name: context | ||
driver: | ||
build_context: false | ||
- name: inspec | ||
driver: | ||
provision_command: echo 1 | ||
verifier: | ||
name: inspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,52 @@ | ||
dist: xenial | ||
language: ruby | ||
cache: bundler | ||
|
||
rvm: | ||
- 2.3.8 | ||
- 2.4.5 | ||
- 2.5.4 | ||
- 2.6.2 | ||
matrix: | ||
include: | ||
- os: linux | ||
rvm: 2.4.5 | ||
dist: xenial | ||
language: ruby | ||
cache: bundler | ||
script: | ||
- bundle exec docker version | ||
- bundle exec kitchen --version | ||
- bundle exec rake spec | ||
- bundle exec kitchen test -d always | ||
- os: linux | ||
rvm: 2.5.4 | ||
dist: xenial | ||
language: ruby | ||
cache: bundler | ||
script: | ||
- bundle exec docker version | ||
- bundle exec kitchen --version | ||
- bundle exec rake spec | ||
- bundle exec kitchen test -d always | ||
- os: linux | ||
rvm: 2.6.2 | ||
dist: xenial | ||
language: ruby | ||
cache: bundler | ||
script: | ||
- bundle exec docker version | ||
- bundle exec kitchen --version | ||
- bundle exec rake spec | ||
- bundle exec kitchen test -d always | ||
- os: windows | ||
language: bash | ||
install: | ||
- choco install mingw | ||
- choco install msys2 | ||
- ridk.cmd exec pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain | ||
script: | ||
- taskkill -IM "gpg-agent.exe" -F | ||
- powershell -ExecutionPolicy Bypass -NoLogo -File docker.ps1 | ||
- export KITCHEN_YAML=.kitchen.windows.yml | ||
- ruby -v | ||
- gem install bundler | ||
- bundle install | ||
- bundle exec docker version | ||
- bundle exec kitchen --version | ||
- bundle exec rake spec | ||
- bundle exec kitchen test -d always | ||
|
||
services: | ||
- docker | ||
|
||
script: | ||
- bundle exec docker version | ||
- bundle exec kitchen --version | ||
- bundle exec rake spec | ||
- bundle exec kitchen test -d always |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# This script is used to configure the Docker service for Windows builds in Travis CI | ||
Write-Host "Configuring Docker service to listen on TCP port 2375..." | ||
$dockerSvcArgs = (Get-WmiObject Win32_Service | ?{$_.Name -eq 'docker'} | Select PathName).PathName | ||
$dockerSvcArgs = "$dockerSvcArgs -H tcp://0.0.0.0:2375 -H npipe:////./pipe/docker_engine" | ||
Write-Host "Docker Service Args: $dockerSvcArgs" | ||
|
||
Get-WmiObject Win32_Service -Filter "Name='docker'" | Invoke-WmiMethod -Name Change -ArgumentList @($null,$null,$null,$null,$null, $dockerSvcArgs) | Out-Null | ||
|
||
Restart-Service docker -Force -Verbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
# coding: utf-8 | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require 'kitchen/driver/docker_version' | ||
require 'kitchen/docker/docker_version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = 'kitchen-docker' | ||
spec.version = Kitchen::Driver::DOCKER_VERSION | ||
spec.version = Kitchen::Docker::DOCKER_VERSION | ||
spec.authors = ['Sean Porter'] | ||
spec.email = ['[email protected]'] | ||
spec.description = %q{A Docker Driver for Test Kitchen} | ||
|
@@ -36,5 +35,6 @@ Gem::Specification.new do |spec| | |
spec.add_development_dependency 'codecov', '~> 0.0', '>= 0.0.2' | ||
|
||
# Integration testing gems. | ||
spec.add_development_dependency 'kitchen-inspec', '~> 0.14' | ||
spec.add_development_dependency 'kitchen-inspec', '~> 1.1' | ||
spec.add_development_dependency 'train', '~> 2.1' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
begin | ||
require 'docker' | ||
|
||
# Override API_VERSION constant in docker-api gem to use version 1.24 of the Docker API | ||
# This override is for the docker-api gem to communicate to the Docker engine on Windows | ||
module Docker | ||
VERSION = '0.0.0' | ||
API_VERSION = '1.24' | ||
end | ||
rescue LoadError => e | ||
logger.debug("[Docker] docker-api gem not found for InSpec verifier. #{e}") | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
require 'kitchen/docker/helpers/cli_helper' | ||
require 'kitchen/docker/helpers/container_helper' | ||
require 'kitchen/docker/helpers/file_helper' | ||
require 'kitchen/docker/helpers/image_helper' | ||
|
||
module Kitchen | ||
module Docker | ||
class Container | ||
include Kitchen::Docker::Helpers::CliHelper | ||
include Kitchen::Docker::Helpers::ContainerHelper | ||
include Kitchen::Docker::Helpers::FileHelper | ||
include Kitchen::Docker::Helpers::ImageHelper | ||
|
||
def initialize(config) | ||
@config = config | ||
end | ||
|
||
def create(state) | ||
if container_exists?(state) | ||
info("Container ID #{state[:container_id]} already exists.") | ||
elsif !container_exists?(state) && state[:container_id] | ||
raise ActionFailed, "Container ID #{state[:container_id]} was found in the kitchen state data, "\ | ||
'but the container does not exist.' | ||
end | ||
|
||
state[:username] = @config[:username] | ||
state[:hostname] = 'localhost' | ||
|
||
if remote_socket? | ||
state[:hostname] = socket_uri.host | ||
elsif config[:use_internal_docker_network] | ||
state[:hostname] = container_ip_address(state) | ||
end | ||
end | ||
|
||
def upload(locals, remote) | ||
files = locals | ||
files = Array(locals) unless locals.is_a?(Array) | ||
|
||
files.each do |file| | ||
copy_file_to_container(@config, file, remote) | ||
end | ||
|
||
files | ||
end | ||
|
||
def destroy(state) | ||
info("[Docker] Destroying Docker container #{state[:container_id]}") if state[:container_id] | ||
remove_container(state) if container_exists?(state) | ||
|
||
if @config[:remove_images] && state[:image_id] | ||
remove_image(state) if image_exists?(state) | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.