Class: Dapp::Kube::Helm::Release

Inherits:
Object
  • Object
show all
Includes:
Helper::YAML
Defined in:
lib/dapp/kube/helm/release.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper::YAML

#yaml_load, #yaml_load_file

Constructor Details

#initialize(dapp, name:, repo:, image_version:, namespace:, chart_path:, set: [], values: [], deploy_timeout: nil) ⇒ Release

Returns a new instance of Release.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/dapp/kube/helm/release.rb', line 17

def initialize(dapp,
  name:, repo:, image_version:, namespace:, chart_path:,
  set: [], values: [], deploy_timeout: nil)
  @dapp = dapp

  @name = name
  @repo = repo
  @image_version = image_version
  @namespace = namespace
  @chart_path = chart_path
  @set = set
  @values = values
  @deploy_timeout = deploy_timeout
end

Instance Attribute Details

#chart_pathObject (readonly)

Returns the value of attribute chart_path.



12
13
14
# File 'lib/dapp/kube/helm/release.rb', line 12

def chart_path
  @chart_path
end

#dappObject (readonly)

Returns the value of attribute dapp.



6
7
8
# File 'lib/dapp/kube/helm/release.rb', line 6

def dapp
  @dapp
end

#deploy_timeoutObject (readonly)

Returns the value of attribute deploy_timeout.



15
16
17
# File 'lib/dapp/kube/helm/release.rb', line 15

def deploy_timeout
  @deploy_timeout
end

#image_versionObject (readonly)

Returns the value of attribute image_version.



10
11
12
# File 'lib/dapp/kube/helm/release.rb', line 10

def image_version
  @image_version
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/dapp/kube/helm/release.rb', line 8

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



11
12
13
# File 'lib/dapp/kube/helm/release.rb', line 11

def namespace
  @namespace
end

#repoObject (readonly)

Returns the value of attribute repo.



9
10
11
# File 'lib/dapp/kube/helm/release.rb', line 9

def repo
  @repo
end

#setObject (readonly)

Returns the value of attribute set.



13
14
15
# File 'lib/dapp/kube/helm/release.rb', line 13

def set
  @set
end

#valuesObject (readonly)

Returns the value of attribute values.



14
15
16
# File 'lib/dapp/kube/helm/release.rb', line 14

def values
  @values
end

Instance Method Details

#deploy!Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/dapp/kube/helm/release.rb', line 50

def deploy!
  args = [
    name, chart_path, additional_values,
    set_options, extra_options
  ].flatten

  dapp.kubernetes.create_namespace!(namespace) unless dapp.kubernetes.namespace?(namespace)

  dapp.shellout! "helm upgrade #{args.join(' ')}", verbose: true
end

#deploymentsObject



44
45
46
47
48
# File 'lib/dapp/kube/helm/release.rb', line 44

def deployments
  (resources_specs['Deployment'] || {}).map do |name, spec|
    [name, Kubernetes::Client::Resource::Deployment.new(spec)]
  end.to_h
end

#hooksObject



38
39
40
41
42
# File 'lib/dapp/kube/helm/release.rb', line 38

def hooks
  jobs.select do |_, spec|
    spec.annotations.key? "helm.sh/hook"
  end
end

#jobsObject



32
33
34
35
36
# File 'lib/dapp/kube/helm/release.rb', line 32

def jobs
  (resources_specs['Job'] || {}).map do |name, spec|
    [name, Kubernetes::Client::Resource::Job.new(spec)]
  end.to_h
end