Class: Hippo::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/hippo/package.rb

Class Method Summary collapse

Instance Method Summary collapse

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(options, stage)
  @options = 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.options[: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_valuesHash

Compile a set of final values which should be used when upgrading and installing this package.

Returns:



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

#installvoid

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?

Returns:

  • (Boolean)


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

#nameString

Return the name of the package (i.e. the release name) and how this package will be referred.

Returns:

  • (String)


17
18
19
# File 'lib/hippo/package.rb', line 17

def name
  @options['name']
end

#notesString

Return the notes for this package

Returns:

  • (String)


77
78
79
# File 'lib/hippo/package.rb', line 77

def notes
  run(helm('get', 'notes', name))
end

#packageString

Return the name of the package to be installed. Including the registry.

Returns:

  • (String)


25
26
27
# File 'lib/hippo/package.rb', line 25

def package
  @options['package']
end

#uninstallvoid

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

#upgradevoid

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

#valuesHash

return values defined in the package’s manifest file

Returns:



32
33
34
# File 'lib/hippo/package.rb', line 32

def values
  @options['values']
end