Method: Chef::Resource::Execute#validate_identity_platform

Defined in:
lib/chef/resource/execute.rb

#validate_identity_platform(specified_user, password = nil, specified_domain = nil, elevated = false) ⇒ Object



612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
# File 'lib/chef/resource/execute.rb', line 612

def validate_identity_platform(specified_user, password = nil, specified_domain = nil, elevated = false)
  if windows?
    if specified_user && password.nil?
      raise ArgumentError, "A value for `password` must be specified when a value for `user` is specified on the Windows platform"
    end

    if elevated && !specified_user && !password
      raise ArgumentError, "`elevated` option should be passed only with `username` and `password`."
    end
  else
    if password || specified_domain
      raise Exceptions::UnsupportedPlatform, "Values for `domain` and `password` are only supported on the Windows platform"
    end

    if elevated
      raise Exceptions::UnsupportedPlatform, "Value for `elevated` is only supported on the Windows platform"
    end
  end
end