Sha256: 41361fdff0d9424c72c77b6ff4c3b174f81af5bbce16c58a3e9a8766eccc4b18

Contents?: true

Size: 1.27 KB

Versions: 18

Compression:

Stored size: 1.27 KB

Contents

require 'open3'

module Kontena::Cli::Plugins
  class InstallCommand < Kontena::Command
    include Kontena::Util
    include Kontena::Cli::Common

    parameter 'NAME', 'Plugin name'

    option ['-v', '--version'], 'VERSION', 'Specify version of plugin to install'
    option '--pre', :flag, 'Allow pre-release of a plugin to be installed', default: false

    def execute
      installed_version = Kontena::PluginManager.instance.installed(name)

      if installed_version
        installed = spinner "Upgrading plugin #{name.colorize(:cyan)}" do
          Kontena::PluginManager.instance.upgrade_plugin(name, pre: pre?)
        end

        spinner "Running cleanup" do
          Kontena::PluginManager.instance.cleanup_plugin(name)
        end
      else
        installed = spinner "Installing plugin #{name.colorize(:cyan)}" do
          Kontena::PluginManager.instance.install_plugin(name, pre: pre?, version: version)
        end
      end

      Array(installed).each do |gem|
        if gem.name.start_with?('kontena-plugin-')
          puts Kontena.pastel.green("Installed plugin #{gem.name.sub('kontena-plugin-', '')} version #{gem.version}")
        else
          puts Kontena.pastel.cyan("Installed dependency #{gem.name} version #{gem.version}")
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
kontena-cli-1.3.5 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.3.5.rc1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre6 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre5 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre4 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre3 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre2 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.4.0.pre1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.3.4 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.3.4.rc1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.3.3 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.3.3.rc1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.3.2 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.3.2.rc2 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.3.2.rc1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.3.1 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.3.1.rc2 lib/kontena/cli/plugins/install_command.rb
kontena-cli-1.3.1.rc1 lib/kontena/cli/plugins/install_command.rb