Class: Dapp::Kube::Helm::Release
- Inherits:
-
Object
- Object
- Dapp::Kube::Helm::Release
- Includes:
- Helper::YAML
- Defined in:
- lib/dapp/kube/helm/release.rb
Instance Attribute Summary collapse
-
#chart_path ⇒ Object
readonly
Returns the value of attribute chart_path.
-
#dapp ⇒ Object
readonly
Returns the value of attribute dapp.
-
#deploy_timeout ⇒ Object
readonly
Returns the value of attribute deploy_timeout.
-
#docker_tag ⇒ Object
readonly
Returns the value of attribute docker_tag.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#set ⇒ Object
readonly
Returns the value of attribute set.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
-
#without_registry ⇒ Object
readonly
Returns the value of attribute without_registry.
Instance Method Summary collapse
- #deployments ⇒ Object
- #hooks ⇒ Object
-
#initialize(dapp, name:, repo:, docker_tag:, namespace:, chart_path:, set: [], values: [], deploy_timeout: nil, without_registry: nil) ⇒ Release
constructor
A new instance of Release.
- #install_helm_release ⇒ Object
- #jobs ⇒ Object
- #templates ⇒ Object
- #upgrade_helm_release ⇒ Object
Methods included from Helper::YAML
Constructor Details
#initialize(dapp, name:, repo:, docker_tag:, namespace:, chart_path:, set: [], values: [], deploy_timeout: nil, without_registry: nil) ⇒ Release
Returns a new instance of Release.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/dapp/kube/helm/release.rb', line 18 def initialize(dapp, name:, repo:, docker_tag:, namespace:, chart_path:, set: [], values: [], deploy_timeout: nil, without_registry: nil) @dapp = dapp @name = name @repo = repo @docker_tag = docker_tag @namespace = namespace @chart_path = chart_path @set = set @values = values @deploy_timeout = deploy_timeout @without_registry = (without_registry.nil? ? false : without_registry) end |
Instance Attribute Details
#chart_path ⇒ Object (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 |
#dapp ⇒ Object (readonly)
Returns the value of attribute dapp.
6 7 8 |
# File 'lib/dapp/kube/helm/release.rb', line 6 def dapp @dapp end |
#deploy_timeout ⇒ Object (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 |
#docker_tag ⇒ Object (readonly)
Returns the value of attribute docker_tag.
10 11 12 |
# File 'lib/dapp/kube/helm/release.rb', line 10 def docker_tag @docker_tag end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/dapp/kube/helm/release.rb', line 8 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
11 12 13 |
# File 'lib/dapp/kube/helm/release.rb', line 11 def namespace @namespace end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
9 10 11 |
# File 'lib/dapp/kube/helm/release.rb', line 9 def repo @repo end |
#set ⇒ Object (readonly)
Returns the value of attribute set.
13 14 15 |
# File 'lib/dapp/kube/helm/release.rb', line 13 def set @set end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
14 15 16 |
# File 'lib/dapp/kube/helm/release.rb', line 14 def values @values end |
#without_registry ⇒ Object (readonly)
Returns the value of attribute without_registry.
16 17 18 |
# File 'lib/dapp/kube/helm/release.rb', line 16 def without_registry @without_registry end |
Instance Method Details
#deployments ⇒ Object
46 47 48 49 50 |
# File 'lib/dapp/kube/helm/release.rb', line 46 def deployments (resources_specs['Deployment'] || {}).map do |name, spec| [name, Kubernetes::Client::Resource::Deployment.new(spec)] end.to_h end |
#hooks ⇒ Object
40 41 42 43 44 |
# File 'lib/dapp/kube/helm/release.rb', line 40 def hooks jobs.select do |_, spec| spec.annotations.key? "helm.sh/hook" end end |
#install_helm_release ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/dapp/kube/helm/release.rb', line 52 def install_helm_release unless dapp.dry_run? dapp.kubernetes.create_namespace!(namespace) unless dapp.kubernetes.namespace?(namespace) end cmd = dapp.shellout([ "helm install #{chart_path}", "--name #{name}", *, *, *, ].join(" ")) return cmd end |
#jobs ⇒ Object
34 35 36 37 38 |
# File 'lib/dapp/kube/helm/release.rb', line 34 def jobs (resources_specs['Job'] || {}).map do |name, spec| [name, Kubernetes::Client::Resource::Job.new(spec)] end.to_h end |
#templates ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/dapp/kube/helm/release.rb', line 79 def templates @templates ||= {}.tap do |t| current_template = nil spec = 0 evaluation_output.lines.each do |l| if (match = l[/# Source: (.*)/, 1]) spec = 0 t[current_template = match] ||= [] end if l[/^---$/] spec += 1 elsif current_template (t[current_template][spec] ||= []) << l end end t.each do |template, specs| t[template] = "---\n#{specs.reject(&:nil?).map(&:join).join("---\n").strip}" end end end |
#upgrade_helm_release ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/dapp/kube/helm/release.rb', line 68 def upgrade_helm_release cmd = dapp.shellout([ "helm upgrade #{name} #{chart_path}", *, *, * ].join(" ")) return cmd end |