Class: Chef::Provider::Package::Windows

Inherits:
Chef::Provider::Package show all
Defined in:
lib/chef/provider/package/windows.rb,
lib/chef/provider/package/windows/msi.rb

Defined Under Namespace

Classes: MSI

Instance Attribute Summary

Attributes inherited from Chef::Provider::Package

#candidate_version

Attributes inherited from Chef::Provider

#action, #cookbook_name, #current_resource, #new_resource, #recipe_name, #run_context

Instance Method Summary collapse

Methods inherited from Chef::Provider::Package

#action_install, #action_purge, #action_reconfig, #action_remove, #action_upgrade, #define_resource_requirements, #expand_options, #get_preseed_file, #initialize, #preseed_package, #preseed_resource, #purge_package, #reconfig_package, #removing_package?, #target_version_already_installed?, #upgrade_package, #whyrun_supported?

Methods included from Mixin::Command

#chdir_or_tmpdir, #handle_command_failures, #output_of_command, #run_command, #run_command_and_return_stdout_stderr, #run_command_with_systems_locale

Methods included from Mixin::Command::Windows

#popen4

Methods included from Mixin::Command::Unix

#popen4

Methods inherited from Chef::Provider

#action_nothing, #cleanup_after_converge, #converge_by, #define_resource_requirements, #events, #initialize, #node, #process_resource_requirements, #requirements, #resource_collection, #resource_updated?, #run_action, #set_updated_status, #whyrun_mode?, #whyrun_supported?

Methods included from DSL::Recipe

#build_resource, #declare_resource, #describe_self_for_error, #evaluate_resource_definition, #has_resource_definition?, #have_resource_class_for?, #method_missing, #resource_class_for

Methods included from Mixin::ConvertToClassName

#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #snake_case_basename

Constructor Details

This class inherits a constructor from Chef::Provider::Package

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Chef::DSL::Recipe

Instance Method Details

#install_package(name, version) ⇒ Object

Chef::Provider::Package action_install + action_remove call install_package + remove_package Pass those calls to the correct sub-provider



73
74
75
# File 'lib/chef/provider/package/windows.rb', line 73

def install_package(name, version)
  package_provider.install_package(name, version)
end

#installer_typeObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/chef/provider/package/windows.rb', line 55

def installer_type
  @installer_type ||= begin
    if @new_resource.installer_type
      @new_resource.installer_type
    else
      file_extension = ::File.basename(@new_resource.source).split(".").last.downcase

      if file_extension == "msi"
        :msi
      else
        raise ArgumentError, "Installer type for Windows Package '#{@new_resource.name}' not specified and cannot be determined from file extension '#{file_extension}'"
      end
    end
  end
end

#load_current_resourceObject

load_current_resource is run in Chef::Provider#run_action when not in whyrun_mode?



35
36
37
38
39
40
41
42
# File 'lib/chef/provider/package/windows.rb', line 35

def load_current_resource
  @new_resource.source(Chef::Util::PathHelper.validate_path(@new_resource.source))

  @current_resource = Chef::Resource::WindowsPackage.new(@new_resource.name)
  @current_resource.version(package_provider.installed_version)
  @new_resource.version(package_provider.package_version)
  @current_resource
end

#package_providerObject



44
45
46
47
48
49
50
51
52
53
# File 'lib/chef/provider/package/windows.rb', line 44

def package_provider
  @package_provider ||= begin
    case installer_type
    when :msi
      Chef::Provider::Package::Windows::MSI.new(@new_resource)
    else
      raise "Unable to find a Chef::Provider::Package::Windows provider for installer_type '#{installer_type}'"
    end
  end
end

#remove_package(name, version) ⇒ Object



77
78
79
# File 'lib/chef/provider/package/windows.rb', line 77

def remove_package(name, version)
  package_provider.remove_package(name, version)
end