Sha256: dc6e2adf2ba8e2421df0d0a11bb64a759897bd461eb548b4f0e3d543820607eb

Contents?: true

Size: 1.91 KB

Versions: 29

Compression:

Stored size: 1.91 KB

Contents

#
# 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_relative "base"
require_relative "../shell_out"
require_relative "../transport/exec"
require_relative "../version"

module Kitchen
  module Driver
    # Simple driver that runs commands locally. As with the proxy driver, this
    # has no isolation in general.
    class Exec < Kitchen::Driver::Base
      include ShellOut

      plugin_version Kitchen::VERSION

      default_config :reset_command, nil

      no_parallel_for :create, :converge, :destroy

      # Hack to force using the exec transport when using this driver.
      # If someone comes up with a use case for using the driver with a different
      # transport, please let us know.
      #
      # @api private
      def finalize_config!(instance)
        super.tap do
          instance.transport = Kitchen::Transport::Exec.new
        end
      end

      # (see Base#create)
      def create(state)
        super
        reset_instance(state)
      end

      # (see Base#destroy)
      def destroy(state)
        reset_instance(state)
      end

      private

      # Resets the non-Kitchen managed instance using by issuing a command
      # over SSH.
      #
      # @param state [Hash] the state hash
      # @api private
      def reset_instance(state)
        if (cmd = config[:reset_command])
          info("Resetting instance state with command: #{cmd}")
          run_command(cmd)
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
test-kitchen-3.7.0 lib/kitchen/driver/exec.rb
test-kitchen-3.6.0 lib/kitchen/driver/exec.rb
test-kitchen-3.5.1 lib/kitchen/driver/exec.rb
test-kitchen-3.5.0 lib/kitchen/driver/exec.rb
test-kitchen-3.4.0 lib/kitchen/driver/exec.rb
test-kitchen-3.3.2 lib/kitchen/driver/exec.rb
test-kitchen-3.3.1 lib/kitchen/driver/exec.rb
test-kitchen-3.3.0 lib/kitchen/driver/exec.rb
test-kitchen-3.2.2 lib/kitchen/driver/exec.rb
test-kitchen-3.2.1 lib/kitchen/driver/exec.rb
test-kitchen-3.2.0 lib/kitchen/driver/exec.rb
test-kitchen-3.1.1 lib/kitchen/driver/exec.rb
test-kitchen-3.1.0 lib/kitchen/driver/exec.rb
test-kitchen-rsync-3.0.0.pre.3 lib/kitchen/driver/exec.rb
test-kitchen-rsync-3.0.0.pre.2 lib/kitchen/driver/exec.rb
test-kitchen-rsync-3.0.0.pre.1 lib/kitchen/driver/exec.rb
test-kitchen-3.0.0 lib/kitchen/driver/exec.rb
test-kitchen-2.12.0 lib/kitchen/driver/exec.rb
test-kitchen-2.11.2 lib/kitchen/driver/exec.rb
test-kitchen-2.11.1 lib/kitchen/driver/exec.rb