Sha256: 2ec634b328aa97d894edf45d8055f0fb421ff5e863de48ce3578d8d4935cce21

Contents?: true

Size: 1.36 KB

Versions: 63

Compression:

Stored size: 1.36 KB

Contents

require "fileutils"
require "pathname"
require "rubygems"
require "set"

require "log4r"

module VagrantPlugins
  module CommandPlugin
    module Action
      # This middleware licenses a plugin by copying the license file to
      # the proper place.
      class LicensePlugin
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant::plugins::plugincommand::license")
        end

        def call(env)
          # Verify the license file exists
          license_file = Pathname.new(env[:plugin_license_path])
          if !license_file.file?
            raise Vagrant::Errors::PluginInstallLicenseNotFound,
              name: env[:plugin_name],
              path: license_file.to_s
          end

          # Copy it in.
          final_path = env[:home_path].join("license-#{env[:plugin_name]}.lic")
          @logger.info("Copying license from: #{license_file}")
          @logger.info("Copying license to: #{final_path}")
          env[:ui].info(I18n.t("vagrant.commands.plugin.installing_license",
                               name: env[:plugin_name]))
          FileUtils.cp(license_file, final_path)

          # Installed!
          env[:ui].success(I18n.t("vagrant.commands.plugin.installed_license",
                                 name: env[:plugin_name]))

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

63 entries across 56 versions & 8 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/commands/plugin/action/license_plugin.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.3.3.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.3.2.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.19.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.18.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.16.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.14.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.10.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.9.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.8.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.7.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.6.2 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.6.1 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.6.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.5.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.4.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.3.0 plugins/commands/plugin/action/license_plugin.rb
vagrant-unbundled-2.2.2.0 plugins/commands/plugin/action/license_plugin.rb