helm-wrapper 1.2.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/helm-wrapper.rb +6 -3
- data/lib/helm-wrapper/shared/chart.rb +9 -5
- data/lib/helm-wrapper/shared/config.rb +29 -14
- data/lib/helm-wrapper/shared/runner.rb +3 -0
- data/lib/helm-wrapper/shared/variables.rb +14 -12
- data/lib/helm-wrapper/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 426d691601f0abf81de0fed973b780d045f280ae57667f1d6568421073949e80
|
4
|
+
data.tar.gz: 29ca573755007d4f3060f468ff81874fb27a59bc62a530a969683c4b1ecec71d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 856ac83c194d9950099ce41db009788068c5bfc3e9a9982b88ec78aeac9ff199f6b435d443fb9f62975affb8703e0d3a803d76aa662c7a123b870865700c5765
|
7
|
+
data.tar.gz: 9f44e3844f86f852042a13ab7da3146d83348083db9ae49f3b772f7c0f8b26accedc939f469beb61e9035837ca874ea4eed30ea8b8601e2c5fa3d95e02f21897
|
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
|
|
@@ -38,11 +38,14 @@ module HelmWrapper
|
|
38
38
|
chart_options["version"] = options.key?("chart-version") ? options["chart-version"] : String.new
|
39
39
|
|
40
40
|
config_options = Hash.new
|
41
|
+
config_options["atomic"] = options.key?("config-atomic") ? options["config-atomic"] : false
|
41
42
|
config_options["auth-azure"] = options.key?("config-auth-azure") ? options["config-auth-azure"] : false
|
42
43
|
config_options["auth-azure-options"] = options.key?("config-auth-azure-options") ? options["config-auth-azure-options"] : Hash.new
|
43
44
|
config_options["base"] = options.key?("config-base") ? options["config-base"] : File.join(Dir.pwd, "config")
|
44
45
|
config_options["namespace"] = namespace
|
45
46
|
config_options["release"] = release
|
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)
|
@@ -57,7 +60,7 @@ module HelmWrapper
|
|
57
60
|
|
58
61
|
###############################################################################
|
59
62
|
|
60
|
-
def self.development_tasks(chart:, path:, options: Hash.new)
|
63
|
+
def self.development_tasks(chart:, path:, oci: false, options: Hash.new)
|
61
64
|
@logger.info("Building development tasks for path: #{path}...")
|
62
65
|
|
63
66
|
@logger.fatal("Options must be specified as a hash!") unless options.kind_of?(Hash)
|
@@ -77,7 +80,7 @@ module HelmWrapper
|
|
77
80
|
|
78
81
|
tasks = Array.new
|
79
82
|
tasks << HelmWrapper::Tasks::Binary.new(binary: binary)
|
80
|
-
tasks << HelmWrapper::Tasks::Push.new(binary: binary, chart: chart)
|
83
|
+
tasks << HelmWrapper::Tasks::Push.new(binary: binary, chart: chart) if oci
|
81
84
|
tasks << HelmWrapper::Tasks::Validate.new(binary: binary, chart: chart)
|
82
85
|
return tasks
|
83
86
|
end
|
@@ -30,10 +30,6 @@ module HelmWrapper
|
|
30
30
|
|
31
31
|
@name = options["name"]
|
32
32
|
|
33
|
-
logger.fatal("Chart version must be a string!") unless options["version"].kind_of?(String)
|
34
|
-
|
35
|
-
@version = options["version"]
|
36
|
-
|
37
33
|
unless options["path"].nil? then
|
38
34
|
logger.fatal("Chart path must be a string!") unless options["path"].kind_of?(String)
|
39
35
|
logger.fatal("Chart path must not be blank!") if options["path"].strip.empty?
|
@@ -42,6 +38,10 @@ module HelmWrapper
|
|
42
38
|
|
43
39
|
@path = options["path"]
|
44
40
|
|
41
|
+
logger.fatal("Chart version must be a string!") unless options["version"].kind_of?(String)
|
42
|
+
|
43
|
+
@version = options["version"]
|
44
|
+
|
45
45
|
logger.fatal("Chart repos must be a list of hashes!") unless options["repos"].kind_of?(Array)
|
46
46
|
|
47
47
|
repos = options["repos"]
|
@@ -49,7 +49,11 @@ module HelmWrapper
|
|
49
49
|
@oci = Array.new
|
50
50
|
@artefact = Array.new
|
51
51
|
|
52
|
-
repos.each do |repo|
|
52
|
+
repos.each do |repo| logger.fatal("Configuration name must be a string!") unless options["name"].kind_of?(String)
|
53
|
+
logger.fatal("Configuration name must not be blank!") if options["name"].strip.empty?
|
54
|
+
|
55
|
+
@name = options["name"]
|
56
|
+
|
53
57
|
logger.fatal("All elements of chart repos must be hashes!") unless repo.kind_of?(Hash)
|
54
58
|
|
55
59
|
logger.fatal("Chart repo: #{hash["name"]} must have a type attribute!") unless repo.key?("type")
|
@@ -24,18 +24,25 @@ 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
|
-
attr_reader :path
|
33
33
|
attr_reader :release
|
34
|
+
attr_reader :path
|
35
|
+
attr_reader :timeout
|
34
36
|
attr_reader :variables
|
37
|
+
attr_reader :wait
|
35
38
|
|
36
39
|
###############################################################################
|
37
40
|
|
38
41
|
def initialize(chart:, options:)
|
42
|
+
logger.fatal("Configuration atomic mode must be a boolean!") unless [ true, false ].include?(options["atomic"])
|
43
|
+
|
44
|
+
@atomic = options["atomic"]
|
45
|
+
|
39
46
|
logger.fatal("Configuration base path must be a string!") unless options["base"].kind_of?(String)
|
40
47
|
logger.fatal("Configuration base path must not be blank!") if options["base"].strip.empty?
|
41
48
|
|
@@ -46,32 +53,43 @@ module HelmWrapper
|
|
46
53
|
|
47
54
|
@name = options["name"]
|
48
55
|
|
49
|
-
logger.fatal("Configuration destination namespace must be a string!") unless options["namespace"].kind_of?(String)
|
50
|
-
logger.fatal("Configuration destination namespace must not be blank!") if options["namespace"].strip.empty?
|
51
|
-
|
52
|
-
namespace = options["namespace"]
|
53
|
-
|
54
56
|
logger.fatal("Configuration release name must be a string!") unless options["release"].kind_of?(String)
|
55
57
|
logger.fatal("Configuration release name must not be blank!") if options["release"].strip.empty?
|
56
58
|
|
57
|
-
release = options["release"]
|
59
|
+
@release = options["release"]
|
60
|
+
|
61
|
+
logger.fatal("Configuration wait timeout must be a string!") unless options["timeout"].kind_of?(String)
|
62
|
+
logger.fatal("Configuration wait timeout must not be blank!") if options["timeout"].strip.empty?
|
63
|
+
|
64
|
+
@timeout = options["timeout"]
|
58
65
|
|
59
|
-
logger.fatal("Configuration authenticator for Azure enabled must be a
|
66
|
+
logger.fatal("Configuration authenticator for Azure enabled must be a boolean!") unless [ true, false ].include?(options["auth-azure"])
|
60
67
|
|
61
68
|
auth_azure = options["auth-azure"]
|
62
69
|
|
63
|
-
logger.fatal("Configuration authenticator for Azure options must be a
|
70
|
+
logger.fatal("Configuration authenticator for Azure options must be a hash!") unless options["auth-azure-options"].kind_of?(Hash)
|
64
71
|
|
65
72
|
auth_azure_options = options["auth-azure-options"]
|
66
73
|
|
74
|
+
logger.fatal("Configuration destination namespace must be a string!") unless options["namespace"].kind_of?(String)
|
75
|
+
logger.fatal("Configuration destination namespace must not be blank!") if options["namespace"].strip.empty?
|
76
|
+
|
77
|
+
namespace = options["namespace"]
|
78
|
+
|
79
|
+
logger.fatal("Configuration wait mode must be a boolean!") unless [ true, false ].include?(options["wait"])
|
80
|
+
|
81
|
+
wait = options["wait"]
|
82
|
+
|
67
83
|
@chart = chart
|
68
84
|
@path = ::HelmWrapper.find(base: @base, name: @name, exts: @@config_exts, description: "Configuration")
|
85
|
+
@wait = (not @atomic) and wait
|
69
86
|
|
70
87
|
yaml = YAML.load(File.read(@path))
|
71
88
|
logger.fatal("Invalid YAML in configuration file: #{@path}") unless yaml.kind_of?(Hash)
|
72
89
|
|
73
90
|
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)
|
91
|
+
@variables = HelmWrapper::Shared::Variables.new(chart: @chart.name, config: @name, namespace: namespace, release: @release, identifiers: identifers)
|
92
|
+
@namespace = @variables.core[:namespace]
|
75
93
|
|
76
94
|
if yaml.key?("globals") then
|
77
95
|
logger.fatal("Key 'globals' is not a hash in configuration file: #{@path}") unless yaml["globals"].kind_of?(Hash)
|
@@ -84,7 +102,7 @@ module HelmWrapper
|
|
84
102
|
logger.fatal("Key 'helm' is not a hash in configuration file: #{@path}") unless yaml["helm"].kind_of?(Hash)
|
85
103
|
helm = yaml["helm"]
|
86
104
|
|
87
|
-
[ "globals", @
|
105
|
+
[ "globals", @release ].each do |extra|
|
88
106
|
if helm.key?(extra) then
|
89
107
|
logger.fatal("Key '#{extra}' under 'helm' is not a hash in configuration file: #{@path}") unless helm[extra].kind_of?(Hash)
|
90
108
|
section = helm[extra]
|
@@ -95,9 +113,6 @@ module HelmWrapper
|
|
95
113
|
end
|
96
114
|
end
|
97
115
|
|
98
|
-
@namespace = @variables.core[:namespace]
|
99
|
-
@release = @variables.core[:release]
|
100
|
-
|
101
116
|
@auths = Array.new
|
102
117
|
@auths.append(HelmWrapper::Shared::Auths::Azure.new(options: auth_azure_options, variables: @variables)) if auth_azure
|
103
118
|
end
|
@@ -154,6 +154,9 @@ module HelmWrapper
|
|
154
154
|
parameters.append("--install") if install
|
155
155
|
parameters.append("\"#{@config.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,22 +35,21 @@ 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
|
-
user = cleanse(variables: identifiers, reserved: core.keys)
|
40
|
+
user = cleanse(variables: identifiers, reserved: core.keys, downcase: true)
|
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)
|
50
49
|
|
51
50
|
@core = core
|
52
51
|
@identifiers = sort ? merged.sort.to_h : merged
|
53
|
-
@values =
|
52
|
+
@values = Hash.new
|
54
53
|
@files = Array.new
|
55
54
|
end
|
56
55
|
|
@@ -99,7 +98,7 @@ module HelmWrapper
|
|
99
98
|
###############################################################################
|
100
99
|
|
101
100
|
def clear_variables()
|
102
|
-
@values =
|
101
|
+
@values = Hash.new
|
103
102
|
end
|
104
103
|
|
105
104
|
###############################################################################
|
@@ -108,17 +107,20 @@ module HelmWrapper
|
|
108
107
|
|
109
108
|
###############################################################################
|
110
109
|
|
111
|
-
def cleanse(variables:, reserved:)
|
110
|
+
def cleanse(variables:, reserved:, downcase: false)
|
112
111
|
result = Hash.new
|
113
112
|
|
114
113
|
variables.keys.each do |key|
|
115
114
|
logger.fatal("Could not clean variables hash. All keys MUST be strings!") unless key.kind_of?(String)
|
116
|
-
logger.fatal("Could not clean variables hash, key: #{key.downcase} is reserved or already in use and cannot be used!") if reserved.include?(key.downcase.to_sym)
|
117
|
-
logger.fatal("Could not clean variables hash, duplicate key found: #{key.downcase}!") if result.key?(key.downcase.to_sym)
|
118
|
-
logger.fatal("Could not clean variables hash, value for: #{key.downcase} is not a string!") unless variables[key].kind_of?(String)
|
119
|
-
logger.fatal("Could not clean variables hash, value for: #{key.downcase} is empty!") if variables[key].strip.empty?
|
120
115
|
|
121
|
-
|
116
|
+
sym = downcase ? key.downcase.to_sym : key.to_sym
|
117
|
+
|
118
|
+
logger.fatal("Could not clean variables hash, key: #{sym.to_s} is reserved or already in use and cannot be used!") if reserved.include?(sym)
|
119
|
+
logger.fatal("Could not clean variables hash, duplicate key found: #{sym.to_s}!") if result.key?(sym)
|
120
|
+
logger.fatal("Could not clean variables hash, value for: #{sym.to_s} is not a string!") unless variables[key].kind_of?(String)
|
121
|
+
logger.fatal("Could not clean variables hash, value for: #{sym.to_s} is empty!") if variables[key].strip.empty?
|
122
|
+
|
123
|
+
result[sym] = variables[key].strip
|
122
124
|
end
|
123
125
|
|
124
126
|
return result
|
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.6.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-
|
11
|
+
date: 2021-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.2.
|
86
|
+
rubygems_version: 3.2.15
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: A ruby wrapper for managing Helm binaries and chart deployment.
|