helm-wrapper 1.6.2 → 1.7.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/shared/chart.rb +49 -14
- data/lib/helm-wrapper/shared/runner.rb +15 -11
- data/lib/helm-wrapper/tasks/push.rb +8 -7
- data/lib/helm-wrapper/version.rb +1 -1
- data/lib/helm-wrapper.rb +8 -6
- 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: 141b2ae006039883e281b95616f3ee6f44da3623e4bccf38c50a616f896ef25b
|
4
|
+
data.tar.gz: ac1155aaa3afce63dd46b3502fb6f412e0da6a4b2809c3dc04d22c4766d38b7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f19b2c92e6685320a8d335729402377c28a2a80ae9d4d6f5a1a61943bfaee94fec8f0d4531e1c712fad1cde8431b4d93427b75463cf41ef30dc336b7232e7f9c
|
7
|
+
data.tar.gz: ef40889f9d01ae740ad1e367c7fd37a38d99eea9a2700937d0534c7597afbcd0b901209b1d80791a429bc39485af50534ea1577c8601d352dc2cba2631f8650f
|
@@ -14,6 +14,10 @@ module HelmWrapper
|
|
14
14
|
|
15
15
|
include HelmWrapper::Shared::Logging
|
16
16
|
|
17
|
+
###############################################################################
|
18
|
+
|
19
|
+
@@chart_metadata_file = "Chart.yaml"
|
20
|
+
|
17
21
|
###############################################################################
|
18
22
|
|
19
23
|
attr_reader :artefact
|
@@ -25,22 +29,24 @@ module HelmWrapper
|
|
25
29
|
###############################################################################
|
26
30
|
|
27
31
|
def initialize(options:)
|
28
|
-
|
29
|
-
|
32
|
+
if options["path"].nil? then
|
33
|
+
@path = options["path"]
|
30
34
|
|
31
|
-
|
35
|
+
logger.fatal("Chart name must be a string!") unless options["name"].kind_of?(String)
|
36
|
+
logger.fatal("Chart name must not be blank!") if options["name"].strip.empty?
|
37
|
+
@name = options["name"]
|
32
38
|
|
33
|
-
|
39
|
+
logger.fatal("Chart version must be a string!") unless options["version"].kind_of?(String)
|
40
|
+
@version = options["version"]
|
41
|
+
else
|
34
42
|
logger.fatal("Chart path must be a string!") unless options["path"].kind_of?(String)
|
35
43
|
logger.fatal("Chart path must not be blank!") if options["path"].strip.empty?
|
36
44
|
logger.fatal("Chart path must exist!") unless File.directory?(options["path"])
|
37
|
-
end
|
38
|
-
|
39
|
-
@path = options["path"]
|
40
45
|
|
41
|
-
|
46
|
+
@path = options["path"]
|
42
47
|
|
43
|
-
|
48
|
+
load_metadata
|
49
|
+
end
|
44
50
|
|
45
51
|
logger.fatal("Chart repos must be a list of hashes!") unless options["repos"].kind_of?(Array)
|
46
52
|
|
@@ -49,11 +55,7 @@ module HelmWrapper
|
|
49
55
|
@oci = Array.new
|
50
56
|
@artefact = Array.new
|
51
57
|
|
52
|
-
repos.each do |repo|
|
53
|
-
logger.fatal("Configuration name must not be blank!") if options["name"].strip.empty?
|
54
|
-
|
55
|
-
@name = options["name"]
|
56
|
-
|
58
|
+
repos.each do |repo|
|
57
59
|
logger.fatal("All elements of chart repos must be hashes!") unless repo.kind_of?(Hash)
|
58
60
|
|
59
61
|
logger.fatal("Chart repo: #{hash["name"]} must have a type attribute!") unless repo.key?("type")
|
@@ -113,6 +115,39 @@ module HelmWrapper
|
|
113
115
|
oci[index]["active"] = active
|
114
116
|
end
|
115
117
|
|
118
|
+
###############################################################################
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
###############################################################################
|
123
|
+
|
124
|
+
def load_metadata
|
125
|
+
file = File.join(@path, @@chart_metadata_file)
|
126
|
+
|
127
|
+
if File.file?(file)
|
128
|
+
logger.info("Loading chart metadata from: #{file}...")
|
129
|
+
else
|
130
|
+
logger.fatal("Chart metadata file: #{file} not found!")
|
131
|
+
end
|
132
|
+
|
133
|
+
yaml = YAML.load(File.read(file))
|
134
|
+
logger.fatal("Invalid YAML in chart metadata file: #{file}") unless yaml.kind_of?(Hash)
|
135
|
+
|
136
|
+
logger.fatal("Chart name is missing from chart metadata file!") unless yaml.key?("name")
|
137
|
+
logger.fatal("Chart name is not a string in chart metadata file!") unless yaml["name"].kind_of?(String)
|
138
|
+
logger.fatal("Chart name is blank in chart metadata file!") if yaml["name"].strip.empty?
|
139
|
+
|
140
|
+
@name = yaml["name"]
|
141
|
+
|
142
|
+
logger.fatal("Chart version is missing from chart metadata file!") unless yaml.key?("version")
|
143
|
+
logger.fatal("Chart version is not a string in chart metadata file!") unless yaml["version"].kind_of?(String)
|
144
|
+
logger.fatal("Chart version is blank in chart metadata file!") if yaml["version"].strip.empty?
|
145
|
+
|
146
|
+
@version = yaml["version"]
|
147
|
+
|
148
|
+
logger.info("Metadata loaded: #{@name} version: #{@version}")
|
149
|
+
end
|
150
|
+
|
116
151
|
###############################################################################
|
117
152
|
|
118
153
|
end
|
@@ -175,25 +175,29 @@ module HelmWrapper
|
|
175
175
|
|
176
176
|
###############################################################################
|
177
177
|
|
178
|
-
def
|
179
|
-
logger.fatal("Cannot Helm push before initialising repositories!") unless repos
|
180
|
-
|
178
|
+
def package(destination: ".")
|
181
179
|
parameters = Array.new
|
182
|
-
parameters.append("
|
183
|
-
parameters.append("\"#{@chart.
|
180
|
+
parameters.append("--destination=\"#{destination}\"")
|
181
|
+
parameters.append("\"#{@chart.path}\"")
|
184
182
|
|
185
|
-
logger.fatal("Helm
|
183
|
+
logger.fatal("Helm package failed!") unless run(action: "package", parameters: parameters)
|
186
184
|
end
|
187
185
|
|
188
186
|
###############################################################################
|
189
187
|
|
190
|
-
def
|
188
|
+
def push(source: ".", destination:)
|
189
|
+
logger.fatal("Cannot Helm push before initialising repositories!") unless repos
|
190
|
+
|
191
|
+
package_name = "#{@chart.name}-#{@chart.version}.tgz"
|
192
|
+
package_path = File.join(source, package_name)
|
193
|
+
|
194
|
+
logger.fatal("Must package before pushing! Package: #{package_path} not found!") unless File.file?(package_path)
|
195
|
+
|
191
196
|
parameters = Array.new
|
192
|
-
parameters.append("
|
193
|
-
parameters.append("\"#{
|
194
|
-
parameters.append("\"#{@chart.name}:#{tag}\"")
|
197
|
+
parameters.append("\"#{package_path}\"")
|
198
|
+
parameters.append("\"#{destination}\"")
|
195
199
|
|
196
|
-
logger.fatal("Helm
|
200
|
+
logger.fatal("Helm push failed!") unless run(action: "push", parameters: parameters)
|
197
201
|
end
|
198
202
|
|
199
203
|
###############################################################################
|
@@ -18,12 +18,14 @@ module HelmWrapper
|
|
18
18
|
|
19
19
|
@binary
|
20
20
|
@chart
|
21
|
+
@destination
|
21
22
|
|
22
23
|
###############################################################################
|
23
24
|
|
24
|
-
def initialize(binary:, chart:)
|
25
|
-
@binary
|
26
|
-
@chart
|
25
|
+
def initialize(binary:, chart:, destination:)
|
26
|
+
@binary = binary
|
27
|
+
@chart = chart
|
28
|
+
@destination = destination
|
27
29
|
|
28
30
|
yield self if block_given?
|
29
31
|
|
@@ -34,8 +36,7 @@ module HelmWrapper
|
|
34
36
|
|
35
37
|
def push_task
|
36
38
|
desc "Pushes a Helm chart to an OCI Helm repository."
|
37
|
-
task :push, [:
|
38
|
-
tag = (args[:tag].kind_of?(String) and (not args[:tag].strip.empty?)) ? args[:tag].strip : "latest"
|
39
|
+
task :push, [:clean] => :binary do |t, args|
|
39
40
|
clean = args[:clean].kind_of?(String) ? args[:clean].downcase == "true" : true
|
40
41
|
|
41
42
|
runner = HelmWrapper::Shared::Runner.new(binary: @binary, chart: @chart)
|
@@ -44,8 +45,8 @@ module HelmWrapper
|
|
44
45
|
|
45
46
|
begin
|
46
47
|
runner.init_repos
|
47
|
-
runner.
|
48
|
-
runner.push(
|
48
|
+
runner.package
|
49
|
+
runner.push(destination: @destination)
|
49
50
|
ensure
|
50
51
|
runner.clean(repos: clean)
|
51
52
|
end
|
data/lib/helm-wrapper/version.rb
CHANGED
data/lib/helm-wrapper.rb
CHANGED
@@ -25,6 +25,7 @@ module HelmWrapper
|
|
25
25
|
def self.deployment_tasks(chart:, namespace:, release:, options: Hash.new)
|
26
26
|
@logger.info("Building deployment tasks for release: #{release}...")
|
27
27
|
|
28
|
+
@logger.fatal("Chart must be specified as a string!") unless chart.kind_of?(String)
|
28
29
|
@logger.fatal("Options must be specified as a hash!") unless options.kind_of?(Hash)
|
29
30
|
|
30
31
|
binary_options = Hash.new
|
@@ -60,9 +61,11 @@ module HelmWrapper
|
|
60
61
|
|
61
62
|
###############################################################################
|
62
63
|
|
63
|
-
def self.development_tasks(
|
64
|
+
def self.development_tasks(path:, destination: String.new, options: Hash.new)
|
64
65
|
@logger.info("Building development tasks for path: #{path}...")
|
65
66
|
|
67
|
+
@logger.fatal("Path must be specified as a string!") unless path.kind_of?(String)
|
68
|
+
@logger.fatal("Destination must be specified as a string!") unless destination.kind_of?(String)
|
66
69
|
@logger.fatal("Options must be specified as a hash!") unless options.kind_of?(Hash)
|
67
70
|
|
68
71
|
binary_options = Hash.new
|
@@ -70,17 +73,16 @@ module HelmWrapper
|
|
70
73
|
binary_options["version"] = options.key?("binary-version") ? options["binary-version"] : Shared::Latest.instance.version
|
71
74
|
|
72
75
|
chart_options = Hash.new
|
73
|
-
chart_options["name"]
|
74
|
-
chart_options["path"]
|
75
|
-
chart_options["repos"]
|
76
|
-
chart_options["version"] = String.new
|
76
|
+
chart_options["name"] = nil
|
77
|
+
chart_options["path"] = path
|
78
|
+
chart_options["repos"] = options.key?("chart-repos") ? options["chart-repos"] : Array.new
|
77
79
|
|
78
80
|
binary = HelmWrapper::Shared::Binary.new(options: binary_options)
|
79
81
|
chart = HelmWrapper::Shared::Chart.new(options: chart_options)
|
80
82
|
|
81
83
|
tasks = Array.new
|
82
84
|
tasks << HelmWrapper::Tasks::Binary.new(binary: binary)
|
83
|
-
tasks << HelmWrapper::Tasks::Push.new(binary: binary, chart: chart)
|
85
|
+
tasks << HelmWrapper::Tasks::Push.new(binary: binary, chart: chart, destination: destination) unless destination.strip.empty?
|
84
86
|
tasks << HelmWrapper::Tasks::Validate.new(binary: binary, chart: chart)
|
85
87
|
return tasks
|
86
88
|
end
|
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.7.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-
|
11
|
+
date: 2021-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|