Sha256: ce66e56a2f7b6b54da1ec3f7256d541e31d47a58eb12f086f46c69e3cc01ca40

Contents?: true

Size: 1.89 KB

Versions: 5

Compression:

Stored size: 1.89 KB

Contents

require "vagrant"

require_relative "ssh_connect"

module VagrantPlugins
  module Kernel_V2
    class SSHConfig < SSHConnectConfig
      attr_accessor :forward_agent
      attr_accessor :forward_x11
      attr_accessor :guest_port
      attr_accessor :keep_alive
      attr_accessor :shell
      attr_accessor :proxy_command
      attr_accessor :pty

      attr_reader :default

      def initialize
        super

        @forward_agent = UNSET_VALUE
        @forward_x11   = UNSET_VALUE
        @guest_port    = UNSET_VALUE
        @keep_alive    = UNSET_VALUE
        @proxy_command = UNSET_VALUE
        @pty           = UNSET_VALUE
        @shell         = UNSET_VALUE

        @default    = SSHConnectConfig.new
      end

      def merge(other)
        super.tap do |result|
          merged_defaults = @default.merge(other.default)
          result.instance_variable_set(:@default, merged_defaults)
        end
      end

      def finalize!
        super

        @forward_agent = false if @forward_agent == UNSET_VALUE
        @forward_x11   = false if @forward_x11 == UNSET_VALUE
        @guest_port = 22 if @guest_port == UNSET_VALUE
        @keep_alive = true if @keep_alive == UNSET_VALUE
        @proxy_command = nil if @proxy_command == UNSET_VALUE
        @pty        = false if @pty == UNSET_VALUE
        @shell      = "bash -l" if @shell == UNSET_VALUE

        @default.username = "vagrant" if @default.username == UNSET_VALUE
        @default.port     = @guest_port if @default.port == UNSET_VALUE
        @default.finalize!
      end

      def to_s
        "SSH"
      end

      def validate(machine)
        errors = super

        # Return the errors
        result = { to_s => errors }

        # Figure out the errors for the defaults
        default_errors = @default.validate(machine)
        result["SSH Defaults"] = default_errors if !default_errors.empty?

        result
      end
    end
  end
end

Version data entries

5 entries across 2 versions & 2 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/plugins/kernel_v2/config/ssh.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-272fb27e0536/plugins/kernel_v2/config/ssh.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-309e896975d1/plugins/kernel_v2/config/ssh.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/plugins/kernel_v2/config/ssh.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/bundler/gems/vagrant-1e28f1ac31e7/plugins/kernel_v2/config/ssh.rb