helm-wrapper 1.0.0 → 1.2.0
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 +34 -4
- data/lib/helm-wrapper/shared/auths/azure.rb +20 -19
- data/lib/helm-wrapper/shared/chart.rb +18 -14
- data/lib/helm-wrapper/shared/config.rb +17 -11
- data/lib/helm-wrapper/shared/runner.rb +81 -10
- data/lib/helm-wrapper/tasks.rb +3 -0
- data/lib/helm-wrapper/tasks/apply.rb +1 -1
- data/lib/helm-wrapper/tasks/destroy.rb +1 -1
- data/lib/helm-wrapper/tasks/push.rb +67 -0
- data/lib/helm-wrapper/tasks/template.rb +71 -0
- data/lib/helm-wrapper/tasks/validate.rb +58 -0
- data/lib/helm-wrapper/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04761d13453be5c76dde3ad75e0318bd4bdd5c3a67f10d2f934bc75c0f7f768c
|
4
|
+
data.tar.gz: c542c8b49e6f6fead7766dfeffec28df80777ec9475066d6ae2683102590f26b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 991ea23d02ad2276e14ae5aeca40270b175f65d4dbd2e1598b4d69102a6729e59c0247a03c7dce419d21d36da224ada8ca5c73e237255b0ab21582a73ad26de7
|
7
|
+
data.tar.gz: 9e88d25edc24fff4999c276b49494727cfe5f095d33517a175457bea3f34b83b6d7fd540d6f7003d4201b0fa5cf6a0942553d5bc7c19d407bcc66c0706f326a5
|
data/lib/helm-wrapper.rb
CHANGED
@@ -22,8 +22,8 @@ module HelmWrapper
|
|
22
22
|
|
23
23
|
###############################################################################
|
24
24
|
|
25
|
-
def self.
|
26
|
-
@logger.info("Building tasks for chart: #{chart}...")
|
25
|
+
def self.deployment_tasks(chart:, namespace:, release:, options: Hash.new)
|
26
|
+
@logger.info("Building deployment tasks for chart: #{chart}...")
|
27
27
|
|
28
28
|
@logger.fatal("Options must be specified as a hash!") unless options.kind_of?(Hash)
|
29
29
|
|
@@ -32,8 +32,10 @@ module HelmWrapper
|
|
32
32
|
binary_options["version"] = options.key?("binary-version") ? options["binary-version"] : Shared::Latest.instance.version
|
33
33
|
|
34
34
|
chart_options = Hash.new
|
35
|
-
chart_options["name"]
|
36
|
-
chart_options["
|
35
|
+
chart_options["name"] = chart
|
36
|
+
chart_options["path"] = nil
|
37
|
+
chart_options["repos"] = options.key?("chart-repos") ? options["chart-repos"] : Array.new
|
38
|
+
chart_options["version"] = options.key?("chart-version") ? options["chart-version"] : String.new
|
37
39
|
|
38
40
|
config_options = Hash.new
|
39
41
|
config_options["auth-azure"] = options.key?("config-auth-azure") ? options["config-auth-azure"] : false
|
@@ -49,6 +51,34 @@ module HelmWrapper
|
|
49
51
|
tasks << HelmWrapper::Tasks::Apply.new(binary: binary, chart: chart, options: config_options)
|
50
52
|
tasks << HelmWrapper::Tasks::Binary.new(binary: binary)
|
51
53
|
tasks << HelmWrapper::Tasks::Destroy.new(binary: binary, chart: chart, options: config_options)
|
54
|
+
tasks << HelmWrapper::Tasks::Template.new(binary: binary, chart: chart, options: config_options)
|
55
|
+
return tasks
|
56
|
+
end
|
57
|
+
|
58
|
+
###############################################################################
|
59
|
+
|
60
|
+
def self.development_tasks(chart:, path:, options: Hash.new)
|
61
|
+
@logger.info("Building development tasks for path: #{path}...")
|
62
|
+
|
63
|
+
@logger.fatal("Options must be specified as a hash!") unless options.kind_of?(Hash)
|
64
|
+
|
65
|
+
binary_options = Hash.new
|
66
|
+
binary_options["base"] = options.key?("binary-base") ? options["binary-base"] : File.join(Dir.pwd, "vendor", "helm")
|
67
|
+
binary_options["version"] = options.key?("binary-version") ? options["binary-version"] : Shared::Latest.instance.version
|
68
|
+
|
69
|
+
chart_options = Hash.new
|
70
|
+
chart_options["name"] = chart
|
71
|
+
chart_options["path"] = path
|
72
|
+
chart_options["repos"] = options.key?("chart-repos") ? options["chart-repos"] : Array.new
|
73
|
+
chart_options["version"] = String.new
|
74
|
+
|
75
|
+
binary = HelmWrapper::Shared::Binary.new(options: binary_options)
|
76
|
+
chart = HelmWrapper::Shared::Chart.new(options: chart_options)
|
77
|
+
|
78
|
+
tasks = Array.new
|
79
|
+
tasks << HelmWrapper::Tasks::Binary.new(binary: binary)
|
80
|
+
tasks << HelmWrapper::Tasks::Push.new(binary: binary, chart: chart)
|
81
|
+
tasks << HelmWrapper::Tasks::Validate.new(binary: binary, chart: chart)
|
52
82
|
return tasks
|
53
83
|
end
|
54
84
|
|
@@ -29,13 +29,14 @@ module HelmWrapper
|
|
29
29
|
|
30
30
|
###############################################################################
|
31
31
|
|
32
|
-
@
|
33
|
-
@
|
32
|
+
@keyvault
|
33
|
+
@secret_ca
|
34
|
+
@secret_endpoint
|
35
|
+
@secret_token
|
34
36
|
|
35
37
|
###############################################################################
|
36
38
|
|
37
|
-
|
38
|
-
attr_reader :endpoint
|
39
|
+
@ca_tempfile = nil
|
39
40
|
|
40
41
|
###############################################################################
|
41
42
|
|
@@ -46,6 +47,10 @@ module HelmWrapper
|
|
46
47
|
###############################################################################
|
47
48
|
|
48
49
|
def auth()
|
50
|
+
ca = secret(vault: @keyvault, name: @secret_ca)
|
51
|
+
endpoint = secret(vault: @keyvault, name: @secret_endpoint)
|
52
|
+
token = secret(vault: @keyvault, name: @secret_token)
|
53
|
+
|
49
54
|
@ca_tempfile = Tempfile.new('helm-wrapper-auths-azure-ca')
|
50
55
|
|
51
56
|
begin
|
@@ -57,8 +62,8 @@ module HelmWrapper
|
|
57
62
|
logger.success("Azure authenticator successfully written Kubernetes CA to file!")
|
58
63
|
|
59
64
|
ENV["HELM_KUBECAFILE"] = @ca_tempfile.path
|
60
|
-
ENV["HELM_KUBEAPISERVER"] =
|
61
|
-
ENV["HELM_KUBETOKEN"] =
|
65
|
+
ENV["HELM_KUBEAPISERVER"] = endpoint
|
66
|
+
ENV["HELM_KUBETOKEN"] = token
|
62
67
|
|
63
68
|
logger.success("Azure authenticator environment variables set!")
|
64
69
|
end
|
@@ -109,18 +114,18 @@ module HelmWrapper
|
|
109
114
|
###############################################################################
|
110
115
|
|
111
116
|
def specific()
|
112
|
-
logger.fatal("Azure CLI must
|
117
|
+
logger.fatal("Azure CLI must be installed and accessible to use the Azure authenticator.") unless cli
|
113
118
|
|
114
119
|
logger.fatal("Azure authenticator mandatory option 'keyvault' has not been set!") unless @options.key?("keyvault")
|
115
120
|
logger.fatal("Azure authenticator keyvault must be a string!") unless @options["keyvault"].kind_of?(String)
|
116
121
|
logger.fatal("Azure authenticator keyvault must not be blank!") if @options["keyvault"].strip.empty?
|
117
122
|
|
118
123
|
keyvault = @options["keyvault"]
|
119
|
-
if @options.key?("ca-
|
120
|
-
logger.fatal("Azure authenticator keyvault
|
121
|
-
logger.fatal("Azure authenticator keyvault
|
124
|
+
if @options.key?("ca-secret") then
|
125
|
+
logger.fatal("Azure authenticator keyvault secret for Kubernetes CA must be a string!") unless @options["ca-secret"].kind_of?(String)
|
126
|
+
logger.fatal("Azure authenticator keyvault secret for Kubernetes CA must not be blank!") if @options["ca-secret"].strip.empty?
|
122
127
|
|
123
|
-
ca = @options["ca-
|
128
|
+
ca = @options["ca-secret"]
|
124
129
|
else
|
125
130
|
ca = "kubernetes-ca"
|
126
131
|
end
|
@@ -144,17 +149,13 @@ module HelmWrapper
|
|
144
149
|
end
|
145
150
|
|
146
151
|
begin
|
147
|
-
keyvault
|
148
|
-
|
149
|
-
|
150
|
-
|
152
|
+
@keyvault = keyvault % @variables.identifiers
|
153
|
+
@secret_ca = ca % @variables.identifiers
|
154
|
+
@secret_endpoint = endpoint % @variables.identifiers
|
155
|
+
@secret_token = token % @variables.identifiers
|
151
156
|
rescue
|
152
157
|
logger.fatal("Azure authenticator options contain identifiers that are not included in the configuration file!")
|
153
158
|
end
|
154
|
-
|
155
|
-
@ca = secret(vault: keyvault, name: ca)
|
156
|
-
@endpoint = secret(vault: keyvault, name: endpoint)
|
157
|
-
@token = secret(vault: keyvault, name: token)
|
158
159
|
end
|
159
160
|
|
160
161
|
###############################################################################
|
@@ -16,9 +16,11 @@ module HelmWrapper
|
|
16
16
|
|
17
17
|
###############################################################################
|
18
18
|
|
19
|
-
attr_reader :oci
|
20
|
-
attr_reader :name
|
21
19
|
attr_reader :artefact
|
20
|
+
attr_reader :name
|
21
|
+
attr_reader :path
|
22
|
+
attr_reader :oci
|
23
|
+
attr_reader :version
|
22
24
|
|
23
25
|
###############################################################################
|
24
26
|
|
@@ -28,6 +30,18 @@ module HelmWrapper
|
|
28
30
|
|
29
31
|
@name = options["name"]
|
30
32
|
|
33
|
+
logger.fatal("Chart version must be a string!") unless options["version"].kind_of?(String)
|
34
|
+
|
35
|
+
@version = options["version"]
|
36
|
+
|
37
|
+
unless options["path"].nil? then
|
38
|
+
logger.fatal("Chart path must be a string!") unless options["path"].kind_of?(String)
|
39
|
+
logger.fatal("Chart path must not be blank!") if options["path"].strip.empty?
|
40
|
+
logger.fatal("Chart path must exist!") unless File.directory?(options["path"])
|
41
|
+
end
|
42
|
+
|
43
|
+
@path = options["path"]
|
44
|
+
|
31
45
|
logger.fatal("Chart repos must be a list of hashes!") unless options["repos"].kind_of?(Array)
|
32
46
|
|
33
47
|
repos = options["repos"]
|
@@ -63,23 +77,13 @@ module HelmWrapper
|
|
63
77
|
logger.fatal("Chart repo: #{hash["name"]} username must be a string!") unless repo["username"].kind_of?(String)
|
64
78
|
logger.fatal("Chart repo: #{hash["name"]} username must not be blank!") if repo["username"].strip.empty?
|
65
79
|
|
66
|
-
|
67
|
-
|
68
|
-
logger.fatal("Chart repo: #{hash["name"]} username attribute must refer to a valid environment variable that holds the actual repository username!") unless ENV.key?(repo_username)
|
69
|
-
logger.fatal("Environment variable holding the username for chart repo: #{hash["name"]} is blank!") if ENV[repo_username].strip.empty?
|
70
|
-
|
71
|
-
hash["username"] = ENV[repo_username].strip
|
80
|
+
hash["username"] = repo["username"].strip
|
72
81
|
|
73
82
|
logger.fatal("Chart repo: #{hash["name"]} must have a password attribute if 'username' is set!") unless repo.key?("password")
|
74
83
|
logger.fatal("Chart repo: #{hash["name"]} password must be a string!") unless repo["password"].kind_of?(String)
|
75
84
|
logger.fatal("Chart repo: #{hash["name"]} password must not be blank!") if repo["password"].strip.empty?
|
76
85
|
|
77
|
-
|
78
|
-
|
79
|
-
logger.fatal("Chart repo: #{hash["name"]} password attribute must refer to a valid environment variable that holds the actual repository password!") unless ENV.key?(repo_password)
|
80
|
-
logger.fatal("Environment variable holding the password for chart repo: #{hash["name"]} is blank!") if ENV[repo_password].strip.empty?
|
81
|
-
|
82
|
-
hash["password"] = ENV[repo_password].strip
|
86
|
+
hash["password"] = repo["password"].strip
|
83
87
|
else
|
84
88
|
fatal("Chart repo: #{hash["name"]} is an OCI repository therefore must have a username attribute! Public OCI repositories do not need to be declared.") if is_oci
|
85
89
|
hash["username"] = nil
|
@@ -72,25 +72,31 @@ module HelmWrapper
|
|
72
72
|
|
73
73
|
identifers = yaml.key?("identifiers") ? yaml["identifiers"] : Hash.new
|
74
74
|
@variables = HelmWrapper::Shared::Variables.new(chart: @chart.name, config: @name, namespace: namespace, release: release, identifiers: identifers)
|
75
|
-
|
75
|
+
|
76
|
+
if yaml.key?("globals") then
|
77
|
+
logger.fatal("Key 'globals' is not a hash in configuration file: #{@path}") unless yaml["globals"].kind_of?(Hash)
|
78
|
+
globals = yaml["globals"]
|
79
|
+
|
80
|
+
@variables.add_variables(variables: globals["variables"]) if globals.key?("variables")
|
81
|
+
end
|
76
82
|
|
77
83
|
if yaml.key?("helm") then
|
78
84
|
logger.fatal("Key 'helm' is not a hash in configuration file: #{@path}") unless yaml["helm"].kind_of?(Hash)
|
79
85
|
helm = yaml["helm"]
|
80
86
|
|
81
|
-
@
|
82
|
-
|
83
|
-
|
87
|
+
[ "globals", @chart.name ].each do |extra|
|
88
|
+
if helm.key?(extra) then
|
89
|
+
logger.fatal("Key '#{extra}' under 'helm' is not a hash in configuration file: #{@path}") unless helm[extra].kind_of?(Hash)
|
90
|
+
section = helm[extra]
|
84
91
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
logger.fatal("Provided configuration options contain variables that are not included in the configuration file!")
|
92
|
+
@variables.add_variables(variables: section["variables"]) if section.key?("variables")
|
93
|
+
@variables.add_files(base: @base, files: section["files"]) if section.key?("files")
|
94
|
+
end
|
95
|
+
end
|
90
96
|
end
|
91
97
|
|
92
|
-
@namespace = namespace
|
93
|
-
@release = release
|
98
|
+
@namespace = @variables.core[:namespace]
|
99
|
+
@release = @variables.core[:release]
|
94
100
|
|
95
101
|
@auths = Array.new
|
96
102
|
@auths.append(HelmWrapper::Shared::Auths::Azure.new(options: auth_azure_options, variables: @variables)) if auth_azure
|
@@ -36,7 +36,7 @@ module HelmWrapper
|
|
36
36
|
|
37
37
|
###############################################################################
|
38
38
|
|
39
|
-
def initialize(binary:, chart:, config:)
|
39
|
+
def initialize(binary:, chart:, config: nil)
|
40
40
|
@binary = binary
|
41
41
|
@chart = chart
|
42
42
|
@config = config
|
@@ -48,6 +48,8 @@ module HelmWrapper
|
|
48
48
|
###############################################################################
|
49
49
|
|
50
50
|
def init_auths()
|
51
|
+
logger.fatal("Cannot initialise authenticators without a valid configuration!") if @config.nil?
|
52
|
+
|
51
53
|
@auths_attempted = true
|
52
54
|
|
53
55
|
config.auths.map(&:auth)
|
@@ -62,28 +64,36 @@ module HelmWrapper
|
|
62
64
|
|
63
65
|
@chart.oci.each_with_index do |oci_repo, oci_index|
|
64
66
|
logger.info("Logging into OCI repository: #{oci_repo["name"]}")
|
67
|
+
|
68
|
+
username = from_environment(variable: oci_repo["username"])
|
69
|
+
password = from_environment(variable: oci_repo["password"])
|
70
|
+
|
65
71
|
@chart.oci_active(active: true, index: oci_index)
|
66
72
|
|
67
73
|
parameters = Array.new
|
68
74
|
parameters.append("login")
|
69
75
|
parameters.append("\"#{oci_repo["url"]}\"")
|
70
|
-
parameters.append("--username=\"#{
|
76
|
+
parameters.append("--username=\"#{username}\"")
|
71
77
|
parameters.append("--password-stdin")
|
72
|
-
logger.fatal("Failed to login to Helm OCI repository: #{oci_repo["name"]}, url: #{oci_repo["url"]}") unless run(action: "registry", parameters: parameters, stdin:
|
78
|
+
logger.fatal("Failed to login to Helm OCI repository: #{oci_repo["name"]}, url: #{oci_repo["url"]}") unless run(action: "registry", parameters: parameters, stdin: password)
|
73
79
|
end
|
74
80
|
|
75
81
|
if @chart.artefact.length > 0 then
|
76
82
|
|
77
83
|
@chart.artefact.each_with_index do |artefact_repo, artefact_index|
|
78
84
|
logger.info("Adding artefact repository: #{artefact_repo["name"]}")
|
85
|
+
|
86
|
+
username = artefact_repo["username"].nil? ? nil : from_environment(variable: artefact_repo["username"])
|
87
|
+
password = artefact_repo["password"].nil? ? nil : from_environment(variable: artefact_repo["password"])
|
88
|
+
|
79
89
|
@chart.artefact_active(active: true, index: artefact_index)
|
80
90
|
|
81
91
|
parameters = Array.new
|
82
92
|
parameters.append("add")
|
83
93
|
parameters.append("\"#{artefact_repo["name"]}\"")
|
84
94
|
parameters.append("\"#{artefact_repo["url"]}\"")
|
85
|
-
parameters.append("--username=\"#{
|
86
|
-
parameters.append("--password=\"#{
|
95
|
+
parameters.append("--username=\"#{username}\"") unless username.nil?
|
96
|
+
parameters.append("--password=\"#{password}\"") unless password.nil?
|
87
97
|
parameters.append("--force-update") if force
|
88
98
|
logger.fatal("Failed to add Helm repository: #{artefact_repo["name"]}, url: #{artefact_repo["url"]}") unless run(action: "repo", parameters: parameters)
|
89
99
|
end
|
@@ -105,32 +115,84 @@ module HelmWrapper
|
|
105
115
|
###############################################################################
|
106
116
|
|
107
117
|
def delete()
|
118
|
+
logger.fatal("Cannot Helm delete without a valid configuration!") if @config.nil?
|
108
119
|
logger.fatal("Cannot Helm delete before initialising authenticators!") unless auths
|
109
120
|
|
110
121
|
parameters = Array.new
|
111
|
-
parameters.append("--namespace
|
112
|
-
parameters.append(@config.release)
|
122
|
+
parameters.append("--namespace=\"#{@config.namespace}\"")
|
123
|
+
parameters.append("\"#{@config.release}\"")
|
113
124
|
|
114
125
|
logger.fatal("Helm delete failed!") unless run(action: "delete", parameters: parameters)
|
115
126
|
end
|
116
127
|
|
128
|
+
###############################################################################
|
129
|
+
|
130
|
+
def template()
|
131
|
+
logger.fatal("Cannot Helm template without a valid configuration!") if @config.nil?
|
132
|
+
logger.fatal("Cannot Helm template before initialising repositories!") unless repos
|
133
|
+
|
134
|
+
parameters = Array.new
|
135
|
+
parameters.append("--namespace=\"#{@config.namespace}\"")
|
136
|
+
parameters.append("\"#{@config.release}\"")
|
137
|
+
parameters.append("\"#{@chart.name}\"")
|
138
|
+
parameters.append("--version=\"#{@chart.version}\"") unless @chart.version.strip.empty?
|
139
|
+
parameters.concat(variable_files)
|
140
|
+
parameters.concat(variable_strings)
|
141
|
+
|
142
|
+
logger.fatal("Helm template failed!") unless run(action: "template", parameters: parameters)
|
143
|
+
end
|
144
|
+
|
117
145
|
###############################################################################
|
118
146
|
|
119
147
|
def upgrade(install: true)
|
148
|
+
logger.fatal("Cannot Helm upgrade without a valid configuration!") if @config.nil?
|
120
149
|
logger.fatal("Cannot Helm upgrade before initialising authenticators!") unless auths
|
121
150
|
logger.fatal("Cannot Helm upgrade before initialising repositories!") unless repos
|
122
151
|
|
123
152
|
parameters = Array.new
|
124
|
-
parameters.append("--namespace
|
153
|
+
parameters.append("--namespace=\"#{@config.namespace}\"")
|
125
154
|
parameters.append("--install") if install
|
126
|
-
parameters.append(@config.release)
|
127
|
-
parameters.append(@chart.name)
|
155
|
+
parameters.append("\"#{@config.release}\"")
|
156
|
+
parameters.append("\"#{@chart.name}\"")
|
157
|
+
parameters.append("--version=\"#{@chart.version}\"") unless @chart.version.strip.empty?
|
128
158
|
parameters.concat(variable_files)
|
129
159
|
parameters.concat(variable_strings)
|
130
160
|
|
131
161
|
logger.fatal("Helm upgrade failed!") unless run(action: "upgrade", parameters: parameters)
|
132
162
|
end
|
133
163
|
|
164
|
+
###############################################################################
|
165
|
+
|
166
|
+
def lint()
|
167
|
+
parameters = Array.new
|
168
|
+
parameters.append("\"#{@chart.path}\"")
|
169
|
+
|
170
|
+
logger.fatal("Helm validate failed!") unless run(action: "lint", parameters: parameters)
|
171
|
+
end
|
172
|
+
|
173
|
+
###############################################################################
|
174
|
+
|
175
|
+
def push(tag:)
|
176
|
+
logger.fatal("Cannot Helm push before initialising repositories!") unless repos
|
177
|
+
|
178
|
+
parameters = Array.new
|
179
|
+
parameters.append("push")
|
180
|
+
parameters.append("\"#{@chart.name}:#{tag}\"")
|
181
|
+
|
182
|
+
logger.fatal("Helm push failed!") unless run(action: "chart", parameters: parameters)
|
183
|
+
end
|
184
|
+
|
185
|
+
###############################################################################
|
186
|
+
|
187
|
+
def save(tag:)
|
188
|
+
parameters = Array.new
|
189
|
+
parameters.append("save")
|
190
|
+
parameters.append("\"#{@chart.path}\"")
|
191
|
+
parameters.append("\"#{@chart.name}:#{tag}\"")
|
192
|
+
|
193
|
+
logger.fatal("Helm save failed!") unless run(action: "chart", parameters: parameters)
|
194
|
+
end
|
195
|
+
|
134
196
|
###############################################################################
|
135
197
|
|
136
198
|
private
|
@@ -233,6 +295,15 @@ module HelmWrapper
|
|
233
295
|
return result
|
234
296
|
end
|
235
297
|
|
298
|
+
###############################################################################
|
299
|
+
|
300
|
+
def from_environment(variable:)
|
301
|
+
logger.fatal("Environment variable: #{variable} does not exist") unless ENV.key?(variable)
|
302
|
+
logger.fatal("Environment variable: #{variable} is blank!") if ENV[variable].strip.empty?
|
303
|
+
|
304
|
+
return ENV[variable].strip
|
305
|
+
end
|
306
|
+
|
236
307
|
###############################################################################
|
237
308
|
|
238
309
|
end
|
data/lib/helm-wrapper/tasks.rb
CHANGED
@@ -7,5 +7,8 @@ require 'rake/tasklib'
|
|
7
7
|
require_relative 'tasks/apply'
|
8
8
|
require_relative 'tasks/binary'
|
9
9
|
require_relative 'tasks/destroy'
|
10
|
+
require_relative 'tasks/push'
|
11
|
+
require_relative 'tasks/template'
|
12
|
+
require_relative 'tasks/validate'
|
10
13
|
|
11
14
|
###############################################################################
|
@@ -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
|
48
|
+
logger.info("Running Helm upgrade for release: #{config.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
|
47
|
+
logger.info("Running Helm delete for release: #{config.release}, namespace: #{config.namespace}...")
|
48
48
|
|
49
49
|
begin
|
50
50
|
runner.init_auths
|
@@ -0,0 +1,67 @@
|
|
1
|
+
###############################################################################
|
2
|
+
|
3
|
+
module HelmWrapper
|
4
|
+
|
5
|
+
###############################################################################
|
6
|
+
|
7
|
+
module Tasks
|
8
|
+
|
9
|
+
###############################################################################
|
10
|
+
|
11
|
+
class Push < ::Rake::TaskLib
|
12
|
+
|
13
|
+
###############################################################################
|
14
|
+
|
15
|
+
include HelmWrapper::Shared::Logging
|
16
|
+
|
17
|
+
###############################################################################
|
18
|
+
|
19
|
+
@binary
|
20
|
+
@chart
|
21
|
+
|
22
|
+
###############################################################################
|
23
|
+
|
24
|
+
def initialize(binary:, chart:)
|
25
|
+
@binary = binary
|
26
|
+
@chart = chart
|
27
|
+
|
28
|
+
yield self if block_given?
|
29
|
+
|
30
|
+
push_task
|
31
|
+
end
|
32
|
+
|
33
|
+
###############################################################################
|
34
|
+
|
35
|
+
def push_task
|
36
|
+
desc "Pushes a Helm chart to an OCI Helm repository."
|
37
|
+
task :push, [:tag, :clean] => :binary do |t, args|
|
38
|
+
tag = (args[:tag].kind_of?(String) and (not args[:tag].strip.empty?)) ? args[:tag].strip : "latest"
|
39
|
+
clean = args[:clean].kind_of?(String) ? args[:clean].downcase == "true" : true
|
40
|
+
|
41
|
+
runner = HelmWrapper::Shared::Runner.new(binary: @binary, chart: @chart)
|
42
|
+
|
43
|
+
logger.info("Running Helm push for path: #{@chart.path}...")
|
44
|
+
|
45
|
+
begin
|
46
|
+
runner.init_repos
|
47
|
+
runner.save(tag: tag)
|
48
|
+
runner.push(tag: tag)
|
49
|
+
ensure
|
50
|
+
runner.clean(repos: clean)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
###############################################################################
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
###############################################################################
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
###############################################################################
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
###############################################################################
|
@@ -0,0 +1,71 @@
|
|
1
|
+
###############################################################################
|
2
|
+
|
3
|
+
module HelmWrapper
|
4
|
+
|
5
|
+
###############################################################################
|
6
|
+
|
7
|
+
module Tasks
|
8
|
+
|
9
|
+
###############################################################################
|
10
|
+
|
11
|
+
class Template < ::Rake::TaskLib
|
12
|
+
|
13
|
+
###############################################################################
|
14
|
+
|
15
|
+
include HelmWrapper::Shared::Logging
|
16
|
+
|
17
|
+
###############################################################################
|
18
|
+
|
19
|
+
@binary
|
20
|
+
@chart
|
21
|
+
@options
|
22
|
+
|
23
|
+
###############################################################################
|
24
|
+
|
25
|
+
def initialize(binary:, chart:, options:)
|
26
|
+
@binary = binary
|
27
|
+
@chart = chart
|
28
|
+
@options = options
|
29
|
+
|
30
|
+
yield self if block_given?
|
31
|
+
|
32
|
+
template_task
|
33
|
+
end
|
34
|
+
|
35
|
+
###############################################################################
|
36
|
+
|
37
|
+
def template_task
|
38
|
+
desc "Templates a chart with Helm for a given configuration."
|
39
|
+
task :template, [:config, :clean] => :binary do |t, args|
|
40
|
+
options = @options.merge({"name" => args[:config]})
|
41
|
+
clean = args[:clean].kind_of?(String) ? args[:clean].downcase == "true" : true
|
42
|
+
|
43
|
+
logger.info("Processing configuration for Helm template...")
|
44
|
+
|
45
|
+
config = HelmWrapper::Shared::Config.new(chart: @chart, options: options)
|
46
|
+
runner = HelmWrapper::Shared::Runner.new(binary: @binary, chart: @chart, config: config)
|
47
|
+
|
48
|
+
logger.info("Running Helm template for release: #{config.release}, namespace: #{config.namespace}...")
|
49
|
+
|
50
|
+
begin
|
51
|
+
runner.init_repos
|
52
|
+
runner.template
|
53
|
+
ensure
|
54
|
+
runner.clean(repos: clean)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
###############################################################################
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
###############################################################################
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
###############################################################################
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
###############################################################################
|
@@ -0,0 +1,58 @@
|
|
1
|
+
###############################################################################
|
2
|
+
|
3
|
+
module HelmWrapper
|
4
|
+
|
5
|
+
###############################################################################
|
6
|
+
|
7
|
+
module Tasks
|
8
|
+
|
9
|
+
###############################################################################
|
10
|
+
|
11
|
+
class Validate < ::Rake::TaskLib
|
12
|
+
|
13
|
+
###############################################################################
|
14
|
+
|
15
|
+
include HelmWrapper::Shared::Logging
|
16
|
+
|
17
|
+
###############################################################################
|
18
|
+
|
19
|
+
@binary
|
20
|
+
@chart
|
21
|
+
|
22
|
+
###############################################################################
|
23
|
+
|
24
|
+
def initialize(binary:, chart:)
|
25
|
+
@binary = binary
|
26
|
+
@chart = chart
|
27
|
+
|
28
|
+
yield self if block_given?
|
29
|
+
|
30
|
+
validate_task
|
31
|
+
end
|
32
|
+
|
33
|
+
###############################################################################
|
34
|
+
|
35
|
+
def validate_task
|
36
|
+
desc "Validates a Helm chart stored locally."
|
37
|
+
task :validate => :binary do |t, args|
|
38
|
+
runner = HelmWrapper::Shared::Runner.new(binary: @binary, chart: @chart)
|
39
|
+
|
40
|
+
logger.info("Running Helm validate for path: #{@chart.path}...")
|
41
|
+
|
42
|
+
runner.lint
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
###############################################################################
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
###############################################################################
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
###############################################################################
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
###############################################################################
|
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.2.0
|
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-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -58,6 +58,9 @@ files:
|
|
58
58
|
- lib/helm-wrapper/tasks/apply.rb
|
59
59
|
- lib/helm-wrapper/tasks/binary.rb
|
60
60
|
- lib/helm-wrapper/tasks/destroy.rb
|
61
|
+
- lib/helm-wrapper/tasks/push.rb
|
62
|
+
- lib/helm-wrapper/tasks/template.rb
|
63
|
+
- lib/helm-wrapper/tasks/validate.rb
|
61
64
|
- lib/helm-wrapper/version.rb
|
62
65
|
homepage: https://gitlab.com/rlees85-ruby/helm-wrapper/
|
63
66
|
licenses:
|