Class: Kitchen::Docker::Container::Windows
- Inherits:
-
Kitchen::Docker::Container
- Object
- Kitchen::Docker::Container
- Kitchen::Docker::Container::Windows
- Defined in:
- lib/kitchen/docker/container/windows.rb
Instance Method Summary collapse
- #create(state) ⇒ Object
- #execute(command) ⇒ Object
-
#initialize(config) ⇒ Windows
constructor
A new instance of Windows.
Methods inherited from Kitchen::Docker::Container
Methods included from Helpers::ImageHelper
#build_image, #image_exists?, #parse_image_id, #remove_image
Methods included from Helpers::ContainerHelper
#container_env_variables, #container_exec, #container_exists?, #container_ip_address, #copy_file_to_container, #create_dir_on_container, #dockerfile_path, #dockerfile_proxy_config, #dockerfile_template, #parse_container_id, #remote_socket?, #remove_container, #replace_env_variables, #run_container, #socket_uri
Methods included from Helpers::CliHelper
#build_copy_command, #build_env_variable_args, #build_exec_command, #build_powershell_command, #build_run_command, #config_to_options, #dev_null, #docker_command, #docker_shell_opts
Methods included from Helpers::FileHelper
Constructor Details
#initialize(config) ⇒ Windows
Returns a new instance of Windows.
22 23 24 |
# File 'lib/kitchen/docker/container/windows.rb', line 22 def initialize(config) super end |
Instance Method Details
#create(state) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/kitchen/docker/container/windows.rb', line 26 def create(state) super debug('Creating Windows container') state[:username] = @config[:username] state[:image_id] = build_image(state, dockerfile) unless state[:image_id] state[:container_id] = run_container(state) unless state[:container_id] end |
#execute(command) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/kitchen/docker/container/windows.rb', line 35 def execute(command) # Create temp script file and upload files to container debug('Executing command on Windows container') filename = "docker-#{::SecureRandom.uuid}.ps1" temp_file = ".\\.kitchen\\temp\\#{filename}" create_temp_file(temp_file, command) remote_path = @config[:temp_dir].tr('/', '\\') debug("Creating directory #{remote_path} on container") create_dir_on_container(@config, remote_path) debug("Uploading temp file #{temp_file} to #{remote_path} on container") upload(temp_file, remote_path) debug('Deleting temp file from local filesystem') ::File.delete(temp_file) # Replace any environment variables used in the path and execute script file debug("Executing temp script #{remote_path}\\#{filename} on container") remote_path = replace_env_variables(@config, remote_path) cmd = build_powershell_command("-File #{remote_path}\\#{filename}") container_exec(@config, cmd) rescue => e raise "Failed to execute command on Windows container. #{e}" end |