helm-wrapper 1.2.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/helm-wrapper.rb +5 -2
- data/lib/helm-wrapper/shared/chart.rb +15 -5
- data/lib/helm-wrapper/shared/config.rb +25 -16
- data/lib/helm-wrapper/shared/runner.rb +6 -3
- data/lib/helm-wrapper/shared/variables.rb +2 -3
- data/lib/helm-wrapper/tasks/apply.rb +1 -1
- data/lib/helm-wrapper/tasks/destroy.rb +1 -1
- data/lib/helm-wrapper/tasks/template.rb +1 -1
- data/lib/helm-wrapper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64fe7756c771f5de17023c164a926696c6514315542e35b444ef31d4396ac130
|
4
|
+
data.tar.gz: 79334dd60dfc68de644ca511ebefde9b2382ca13bbb7f65e7347868337a13aa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e69d4b002536594076ac8476f791a4e5b0fe3c2062de5cf5f4225e6df1919e21eb19b4ba362ed430d36cc2f01e8bda9edd14ab1f0cc2fa1701955c2d46944b61
|
7
|
+
data.tar.gz: 681c5bc705a01aa22730f6994ac975785701c16d1f39ef0265851cccfdf81404ea97d75b9a8edc868871ff51cdd1dc2a70bd89528411b9bf44698822ef60d76c
|
data/lib/helm-wrapper.rb
CHANGED
@@ -23,7 +23,7 @@ module HelmWrapper
|
|
23
23
|
###############################################################################
|
24
24
|
|
25
25
|
def self.deployment_tasks(chart:, namespace:, release:, options: Hash.new)
|
26
|
-
@logger.info("Building deployment tasks for
|
26
|
+
@logger.info("Building deployment tasks for release: #{release}...")
|
27
27
|
|
28
28
|
@logger.fatal("Options must be specified as a hash!") unless options.kind_of?(Hash)
|
29
29
|
|
@@ -35,14 +35,17 @@ module HelmWrapper
|
|
35
35
|
chart_options["name"] = chart
|
36
36
|
chart_options["path"] = nil
|
37
37
|
chart_options["repos"] = options.key?("chart-repos") ? options["chart-repos"] : Array.new
|
38
|
+
chart_options["release"] = release
|
38
39
|
chart_options["version"] = options.key?("chart-version") ? options["chart-version"] : String.new
|
39
40
|
|
40
41
|
config_options = Hash.new
|
42
|
+
config_options["atomic"] = options.key?("config-atomic") ? options["config-atomic"] : false
|
41
43
|
config_options["auth-azure"] = options.key?("config-auth-azure") ? options["config-auth-azure"] : false
|
42
44
|
config_options["auth-azure-options"] = options.key?("config-auth-azure-options") ? options["config-auth-azure-options"] : Hash.new
|
43
45
|
config_options["base"] = options.key?("config-base") ? options["config-base"] : File.join(Dir.pwd, "config")
|
44
46
|
config_options["namespace"] = namespace
|
45
|
-
config_options["
|
47
|
+
config_options["timeout"] = options.key?("config-timeout") ? options["config-timeout"] : "5m0s"
|
48
|
+
config_options["wait"] = options.key?("config-wait") ? options["config-wait"] : true
|
46
49
|
|
47
50
|
binary = HelmWrapper::Shared::Binary.new(options: binary_options)
|
48
51
|
chart = HelmWrapper::Shared::Chart.new(options: chart_options)
|
@@ -20,6 +20,7 @@ module HelmWrapper
|
|
20
20
|
attr_reader :name
|
21
21
|
attr_reader :path
|
22
22
|
attr_reader :oci
|
23
|
+
attr_reader :release
|
23
24
|
attr_reader :version
|
24
25
|
|
25
26
|
###############################################################################
|
@@ -30,10 +31,6 @@ module HelmWrapper
|
|
30
31
|
|
31
32
|
@name = options["name"]
|
32
33
|
|
33
|
-
logger.fatal("Chart version must be a string!") unless options["version"].kind_of?(String)
|
34
|
-
|
35
|
-
@version = options["version"]
|
36
|
-
|
37
34
|
unless options["path"].nil? then
|
38
35
|
logger.fatal("Chart path must be a string!") unless options["path"].kind_of?(String)
|
39
36
|
logger.fatal("Chart path must not be blank!") if options["path"].strip.empty?
|
@@ -42,6 +39,15 @@ module HelmWrapper
|
|
42
39
|
|
43
40
|
@path = options["path"]
|
44
41
|
|
42
|
+
logger.fatal("Chart release instance must be a string!") unless options["release"].kind_of?(String)
|
43
|
+
logger.fatal("Chart release instance must not be blank!") if options["release"].strip.empty?
|
44
|
+
|
45
|
+
@release = options["release"]
|
46
|
+
|
47
|
+
logger.fatal("Chart version must be a string!") unless options["version"].kind_of?(String)
|
48
|
+
|
49
|
+
@version = options["version"]
|
50
|
+
|
45
51
|
logger.fatal("Chart repos must be a list of hashes!") unless options["repos"].kind_of?(Array)
|
46
52
|
|
47
53
|
repos = options["repos"]
|
@@ -49,7 +55,11 @@ module HelmWrapper
|
|
49
55
|
@oci = Array.new
|
50
56
|
@artefact = Array.new
|
51
57
|
|
52
|
-
repos.each do |repo|
|
58
|
+
repos.each do |repo| logger.fatal("Configuration name must be a string!") unless options["name"].kind_of?(String)
|
59
|
+
logger.fatal("Configuration name must not be blank!") if options["name"].strip.empty?
|
60
|
+
|
61
|
+
@name = options["name"]
|
62
|
+
|
53
63
|
logger.fatal("All elements of chart repos must be hashes!") unless repo.kind_of?(Hash)
|
54
64
|
|
55
65
|
logger.fatal("Chart repo: #{hash["name"]} must have a type attribute!") unless repo.key?("type")
|
@@ -24,18 +24,24 @@ module HelmWrapper
|
|
24
24
|
|
25
25
|
###############################################################################
|
26
26
|
|
27
|
+
attr_reader :atomic
|
27
28
|
attr_reader :auths
|
28
29
|
attr_reader :base
|
29
30
|
attr_reader :chart
|
30
31
|
attr_reader :name
|
31
32
|
attr_reader :namespace
|
32
33
|
attr_reader :path
|
33
|
-
attr_reader :
|
34
|
+
attr_reader :timeout
|
34
35
|
attr_reader :variables
|
36
|
+
attr_reader :wait
|
35
37
|
|
36
38
|
###############################################################################
|
37
39
|
|
38
40
|
def initialize(chart:, options:)
|
41
|
+
logger.fatal("Configuration atomic mode must be a boolean!") unless [ true, false ].include?(options["atomic"])
|
42
|
+
|
43
|
+
@atomic = options["atomic"]
|
44
|
+
|
39
45
|
logger.fatal("Configuration base path must be a string!") unless options["base"].kind_of?(String)
|
40
46
|
logger.fatal("Configuration base path must not be blank!") if options["base"].strip.empty?
|
41
47
|
|
@@ -46,32 +52,38 @@ module HelmWrapper
|
|
46
52
|
|
47
53
|
@name = options["name"]
|
48
54
|
|
49
|
-
logger.fatal("Configuration
|
50
|
-
logger.fatal("Configuration
|
55
|
+
logger.fatal("Configuration wait timeout must be a string!") unless options["timeout"].kind_of?(String)
|
56
|
+
logger.fatal("Configuration wait timeout must not be blank!") if options["timeout"].strip.empty?
|
51
57
|
|
52
|
-
|
58
|
+
@timeout = options["timeout"]
|
53
59
|
|
54
|
-
logger.fatal("Configuration
|
55
|
-
logger.fatal("Configuration release name must not be blank!") if options["release"].strip.empty?
|
56
|
-
|
57
|
-
release = options["release"]
|
58
|
-
|
59
|
-
logger.fatal("Configuration authenticator for Azure enabled must be a Boolean!") unless [ true, false ].include?(options["auth-azure"])
|
60
|
+
logger.fatal("Configuration authenticator for Azure enabled must be a boolean!") unless [ true, false ].include?(options["auth-azure"])
|
60
61
|
|
61
62
|
auth_azure = options["auth-azure"]
|
62
63
|
|
63
|
-
logger.fatal("Configuration authenticator for Azure options must be a
|
64
|
+
logger.fatal("Configuration authenticator for Azure options must be a hash!") unless options["auth-azure-options"].kind_of?(Hash)
|
64
65
|
|
65
66
|
auth_azure_options = options["auth-azure-options"]
|
66
67
|
|
68
|
+
logger.fatal("Configuration destination namespace must be a string!") unless options["namespace"].kind_of?(String)
|
69
|
+
logger.fatal("Configuration destination namespace must not be blank!") if options["namespace"].strip.empty?
|
70
|
+
|
71
|
+
namespace = options["namespace"]
|
72
|
+
|
73
|
+
logger.fatal("Configuration wait mode must be a boolean!") unless [ true, false ].include?(options["wait"])
|
74
|
+
|
75
|
+
wait = options["wait"]
|
76
|
+
|
67
77
|
@chart = chart
|
68
78
|
@path = ::HelmWrapper.find(base: @base, name: @name, exts: @@config_exts, description: "Configuration")
|
79
|
+
@wait = (not @atomic) and wait
|
69
80
|
|
70
81
|
yaml = YAML.load(File.read(@path))
|
71
82
|
logger.fatal("Invalid YAML in configuration file: #{@path}") unless yaml.kind_of?(Hash)
|
72
83
|
|
73
84
|
identifers = yaml.key?("identifiers") ? yaml["identifiers"] : Hash.new
|
74
|
-
@variables = HelmWrapper::Shared::Variables.new(chart: @chart.name, config: @name, namespace: namespace, release: release, identifiers: identifers)
|
85
|
+
@variables = HelmWrapper::Shared::Variables.new(chart: @chart.name, config: @name, namespace: namespace, release: @chart.release, identifiers: identifers)
|
86
|
+
@namespace = @variables.core[:namespace]
|
75
87
|
|
76
88
|
if yaml.key?("globals") then
|
77
89
|
logger.fatal("Key 'globals' is not a hash in configuration file: #{@path}") unless yaml["globals"].kind_of?(Hash)
|
@@ -84,7 +96,7 @@ module HelmWrapper
|
|
84
96
|
logger.fatal("Key 'helm' is not a hash in configuration file: #{@path}") unless yaml["helm"].kind_of?(Hash)
|
85
97
|
helm = yaml["helm"]
|
86
98
|
|
87
|
-
[ "globals", @chart.
|
99
|
+
[ "globals", @chart.release ].each do |extra|
|
88
100
|
if helm.key?(extra) then
|
89
101
|
logger.fatal("Key '#{extra}' under 'helm' is not a hash in configuration file: #{@path}") unless helm[extra].kind_of?(Hash)
|
90
102
|
section = helm[extra]
|
@@ -95,9 +107,6 @@ module HelmWrapper
|
|
95
107
|
end
|
96
108
|
end
|
97
109
|
|
98
|
-
@namespace = @variables.core[:namespace]
|
99
|
-
@release = @variables.core[:release]
|
100
|
-
|
101
110
|
@auths = Array.new
|
102
111
|
@auths.append(HelmWrapper::Shared::Auths::Azure.new(options: auth_azure_options, variables: @variables)) if auth_azure
|
103
112
|
end
|
@@ -120,7 +120,7 @@ module HelmWrapper
|
|
120
120
|
|
121
121
|
parameters = Array.new
|
122
122
|
parameters.append("--namespace=\"#{@config.namespace}\"")
|
123
|
-
parameters.append("\"#{@
|
123
|
+
parameters.append("\"#{@chart.release}\"")
|
124
124
|
|
125
125
|
logger.fatal("Helm delete failed!") unless run(action: "delete", parameters: parameters)
|
126
126
|
end
|
@@ -133,7 +133,7 @@ module HelmWrapper
|
|
133
133
|
|
134
134
|
parameters = Array.new
|
135
135
|
parameters.append("--namespace=\"#{@config.namespace}\"")
|
136
|
-
parameters.append("\"#{@
|
136
|
+
parameters.append("\"#{@chart.release}\"")
|
137
137
|
parameters.append("\"#{@chart.name}\"")
|
138
138
|
parameters.append("--version=\"#{@chart.version}\"") unless @chart.version.strip.empty?
|
139
139
|
parameters.concat(variable_files)
|
@@ -152,8 +152,11 @@ module HelmWrapper
|
|
152
152
|
parameters = Array.new
|
153
153
|
parameters.append("--namespace=\"#{@config.namespace}\"")
|
154
154
|
parameters.append("--install") if install
|
155
|
-
parameters.append("\"#{@
|
155
|
+
parameters.append("\"#{@chart.release}\"")
|
156
156
|
parameters.append("\"#{@chart.name}\"")
|
157
|
+
parameters.append("--atomic") if @config.atomic
|
158
|
+
parameters.append("--wait") if @config.wait
|
159
|
+
parameters.append("--timeout=\"#{@config.timeout}\"") if (@config.atomic or @config.wait)
|
157
160
|
parameters.append("--version=\"#{@chart.version}\"") unless @chart.version.strip.empty?
|
158
161
|
parameters.concat(variable_files)
|
159
162
|
parameters.concat(variable_strings)
|
@@ -35,15 +35,14 @@ module HelmWrapper
|
|
35
35
|
core[:chart] = chart
|
36
36
|
core[:config] = config
|
37
37
|
core[:namespace] = nil
|
38
|
-
core[:release] =
|
38
|
+
core[:release] = release
|
39
39
|
|
40
40
|
user = cleanse(variables: identifiers, reserved: core.keys)
|
41
41
|
|
42
42
|
begin
|
43
43
|
core[:namespace] = namespace % user
|
44
|
-
core[:release] = release % user
|
45
44
|
rescue
|
46
|
-
logger.fatal("Provided
|
45
|
+
logger.fatal("Provided namespace includes identifiers that are not included in the configuration file!")
|
47
46
|
end
|
48
47
|
|
49
48
|
merged = core.merge(user)
|
@@ -45,7 +45,7 @@ module HelmWrapper
|
|
45
45
|
config = HelmWrapper::Shared::Config.new(chart: @chart, options: options)
|
46
46
|
runner = HelmWrapper::Shared::Runner.new(binary: @binary, chart: @chart, config: config)
|
47
47
|
|
48
|
-
logger.info("Running Helm upgrade for release: #{
|
48
|
+
logger.info("Running Helm upgrade for release: #{@chart.release}, namespace: #{config.namespace}...")
|
49
49
|
|
50
50
|
begin
|
51
51
|
runner.init_repos
|
@@ -44,7 +44,7 @@ module HelmWrapper
|
|
44
44
|
config = HelmWrapper::Shared::Config.new(chart: @chart, options: options)
|
45
45
|
runner = HelmWrapper::Shared::Runner.new(binary: @binary, chart: @chart, config: config)
|
46
46
|
|
47
|
-
logger.info("Running Helm delete for release: #{
|
47
|
+
logger.info("Running Helm delete for release: #{@chart.release}, namespace: #{config.namespace}...")
|
48
48
|
|
49
49
|
begin
|
50
50
|
runner.init_auths
|
@@ -45,7 +45,7 @@ module HelmWrapper
|
|
45
45
|
config = HelmWrapper::Shared::Config.new(chart: @chart, options: options)
|
46
46
|
runner = HelmWrapper::Shared::Runner.new(binary: @binary, chart: @chart, config: config)
|
47
47
|
|
48
|
-
logger.info("Running Helm template for release: #{
|
48
|
+
logger.info("Running Helm template for release: #{@chart.release}, namespace: #{config.namespace}...")
|
49
49
|
|
50
50
|
begin
|
51
51
|
runner.init_repos
|
data/lib/helm-wrapper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helm-wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Lees
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|