Class: Hippo::Package
- Inherits:
-
Object
- Object
- Hippo::Package
- Defined in:
- lib/hippo/package.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#final_values ⇒ Hash
Compile a set of final values which should be used when upgrading and installing this package.
- #helm(*commands) ⇒ Object
-
#initialize(options, stage) ⇒ Package
constructor
A new instance of Package.
-
#install ⇒ void
Install this package.
-
#installed? ⇒ Boolean
Is this release currently installed for the stage?.
-
#name ⇒ String
Return the name of the package (i.e. the release name) and how this package will be referred.
-
#notes ⇒ String
Return the notes for this package.
-
#package ⇒ String
Return the name of the package to be installed.
-
#uninstall ⇒ void
Uninstall this packgae.
-
#upgrade ⇒ void
Upgrade this package.
-
#values ⇒ Hash
return values defined in the package’s manifest file.
Constructor Details
#initialize(options, stage) ⇒ Package
Returns a new instance of Package.
8 9 10 11 |
# File 'lib/hippo/package.rb', line 8 def initialize(, stage) @options = @stage = stage end |
Class Method Details
.setup_from_cli_context(context) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/hippo/package.rb', line 108 def setup_from_cli_context(context) cli = Hippo::CLI.setup(context) package_name = context.[:package] if package_name.nil? || package_name.empty? raise Error, 'A package name must be provided in -p or --package' end package = cli.stage.packages[package_name] if package.nil? raise Error, "No package named '#{package_name}' has been defined" end [package, cli] end |
Instance Method Details
#final_values ⇒ Hash
Compile a set of final values which should be used when upgrading and installing this package.
40 41 42 43 |
# File 'lib/hippo/package.rb', line 40 def final_values overrides = @stage.overridden_package_values[name] values.deep_merge(overrides) end |
#helm(*commands) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/hippo/package.rb', line 81 def helm(*commands) command = ['helm'] command += ['--kube-context', @stage.context] if @stage.context command += ['-n', @stage.namespace] command += commands command end |
#install ⇒ void
This method returns an undefined value.
Install this package
48 49 50 |
# File 'lib/hippo/package.rb', line 48 def install run_install_command('install') end |
#installed? ⇒ Boolean
Is this release currently installed for the stage?
69 70 71 72 |
# File 'lib/hippo/package.rb', line 69 def installed? secrets = @stage.get('secrets').map(&:name) secrets.any? { |s| s.match(/\Ash\.helm\.release\.v\d+\.#{Regexp.escape(name)}\./) } end |
#name ⇒ String
Return the name of the package (i.e. the release name) and how this package will be referred.
17 18 19 |
# File 'lib/hippo/package.rb', line 17 def name @options['name'] end |
#notes ⇒ String
Return the notes for this package
77 78 79 |
# File 'lib/hippo/package.rb', line 77 def notes run(helm('get', 'notes', name)) end |
#package ⇒ String
Return the name of the package to be installed. Including the registry.
25 26 27 |
# File 'lib/hippo/package.rb', line 25 def package @options['package'] end |
#uninstall ⇒ void
This method returns an undefined value.
Uninstall this packgae
62 63 64 |
# File 'lib/hippo/package.rb', line 62 def uninstall run(helm('uninstall', name)) end |
#upgrade ⇒ void
This method returns an undefined value.
Upgrade this package
55 56 57 |
# File 'lib/hippo/package.rb', line 55 def upgrade run_install_command('upgrade', '--history-max', @options['max-revisions'] ? @options['max-revisions'].to_i.to_s : '5') end |
#values ⇒ Hash
return values defined in the package’s manifest file
32 33 34 |
# File 'lib/hippo/package.rb', line 32 def values @options['values'] end |