Class: Homebrew::Bundle::Krew Private

Inherits:
Extension show all
Defined in:
bundle/extensions/krew.rb

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Constant Summary collapse

PACKAGE_TYPE =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

:krew
PACKAGE_TYPE_NAME =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

"Krew Plugin"
"Krew plugins"

Class Method Summary collapse

Methods inherited from Extension

add_supported?, banner_name, check, check_label, cleanup!, cleanup_disable_description, cleanup_disable_env, cleanup_item_name, cleanup_items, cleanup_supported?, disable_predicate_method, dump, dump_disable_description, dump_disable_env, dump_disable_predicate_method, dump_disable_supported?, dump_entry, dump_name, dump_output, dump_supported?, dump_with, entry, #failure_reason, fetchable_name, flag, inherited, install!, install_supported?, install_verb, #installed_and_up_to_date?, legacy_check_step, package_description, package_installed?, package_manager_env, package_manager_executable!, package_manager_installed?, package_manager_name, package_record, predicate_method, preinstall!, quote, remove_supported?, switch_description, type, with_package_manager_env

Methods inherited from PackageType

check, #checkable_entries, dump, dump_output, dump_supported?, #exit_early_check, #failure_reason, fetchable_name, #find_actionable, #format_checkable, #full_check, inherited, install!, install_supported?, install_verb, #installed_and_up_to_date?, preinstall!, type

Class Method Details

.cleanup_headingString?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



22
23
24
# File 'bundle/extensions/krew.rb', line 22

def cleanup_heading
  banner_name
end

.install_package!(name, with: nil, verbose: false) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

  • name (String)
  • with (Array<String>, nil) (defaults to: nil)
  • verbose (Boolean) (defaults to: false)

Returns:

  • (Boolean)


52
53
54
55
56
57
58
# File 'bundle/extensions/krew.rb', line 52

def install_package!(name, with: nil, verbose: false)
  _ = with

  with_package_manager_env do |krew|
    Bundle.system(krew.to_s, "install", name, verbose:)
  end
end

.installed_packagesArray<String>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



61
62
63
64
65
66
# File 'bundle/extensions/krew.rb', line 61

def installed_packages
  installed_packages = @installed_packages
  return installed_packages if installed_packages

  @installed_packages = packages.dup
end

.package_manager_executablePathname?

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



27
28
29
# File 'bundle/extensions/krew.rb', line 27

def package_manager_executable
  @package_manager_executable ||= T.let(which("kubectl-krew", ORIGINAL_PATHS), T.nilable(Pathname))
end

.packagesArray<String>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
# File 'bundle/extensions/krew.rb', line 32

def packages
  packages = @packages
  return packages if packages

  @packages = if package_manager_installed?
    with_package_manager_env do |krew|
      parse_plugin_list(`#{krew} list 2>/dev/null`)
    end
  else
    []
  end
end

.parse_plugin_list(output) ⇒ Array<String>

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:



69
70
71
72
73
74
75
76
77
# File 'bundle/extensions/krew.rb', line 69

def parse_plugin_list(output)
  output.lines.filter_map do |line|
    line = line.strip
    next if line.empty?

    name = line.split(/\s+/).first
    name.presence
  end.uniq
end

.reset!void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



15
16
17
18
19
# File 'bundle/extensions/krew.rb', line 15

def reset!
  @packages = T.let(nil, T.nilable(T::Array[String]))
  @installed_packages = T.let(nil, T.nilable(T::Array[String]))
  @package_manager_executable = T.let(nil, T.nilable(Pathname))
end

.uninstall_package!(name, executable: Pathname.new("")) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:



81
82
83
# File 'bundle/extensions/krew.rb', line 81

def uninstall_package!(name, executable: Pathname.new(""))
  Bundle.system(executable.to_s, "uninstall", name, verbose: false)
end