helm-wrapper 1.6.1 → 1.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 426d691601f0abf81de0fed973b780d045f280ae57667f1d6568421073949e80
4
- data.tar.gz: 29ca573755007d4f3060f468ff81874fb27a59bc62a530a969683c4b1ecec71d
3
+ metadata.gz: 0aecbab2f1f72005e79c51eac2db8df46aa64213d6ca0202571de8437ee7d293
4
+ data.tar.gz: a2c91b66ffdccb7210f9086f911b5ea49ed039046c40c77e173bc20cea9bfbfc
5
5
  SHA512:
6
- metadata.gz: 856ac83c194d9950099ce41db009788068c5bfc3e9a9982b88ec78aeac9ff199f6b435d443fb9f62975affb8703e0d3a803d76aa662c7a123b870865700c5765
7
- data.tar.gz: 9f44e3844f86f852042a13ab7da3146d83348083db9ae49f3b772f7c0f8b26accedc939f469beb61e9035837ca874ea4eed30ea8b8601e2c5fa3d95e02f21897
6
+ metadata.gz: b09d50fd662c1b4904f1425ae43fb91ad1c2fb884d96e2b819ad4c3c88bc4d31fbb84ac7a039a21cb9a7f3bb6d05da4ef565edfe671948885031b2ec03729daf
7
+ data.tar.gz: 793f72b674d108c36313e60d3ba8359c1f9788dd09f91043377a72e5b01f13b61e5dd983bb256acfdf0e29769e95f69b7cd89f61e10a03c2c5b5022c1c8aac19
data/.gitignore CHANGED
@@ -21,8 +21,3 @@
21
21
  /tmp/
22
22
 
23
23
  ###############################################################################
24
-
25
- /archlinux/
26
- !/archlinux/PKGBUILD
27
-
28
- ###############################################################################
data/.gitlab-ci.yml CHANGED
@@ -1,37 +1,8 @@
1
1
  ###############################################################################
2
2
 
3
- image: ruby
4
-
5
- ###############################################################################
6
-
7
- stages:
8
- - test
9
- - publish
10
-
11
- ###############################################################################
12
-
13
- test:
14
- stage : test
15
- script:
16
- - echo "-- Beginning Test --"
17
- - echo "-- Tests not implemented yet --"
18
-
19
- ###############################################################################
20
-
21
- deploy:
22
- rules:
23
- - if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
24
- stage: publish
25
- script:
26
- - echo "-- Beginning Publish --"
27
- - test -n "${GEM_HOST_API_KEY}"
28
- - echo "RubyGems API key found!"
29
- - hash rake
30
- - hash ruby
31
- - hash gem
32
- - echo "-- Publishing Gem --"
33
- - rake release
34
- - echo "-- Listing Sums --"
35
- - sha256sum "pkg"/*.gem
3
+ include:
4
+ - project: 'bitservices/gitlab/ruby'
5
+ ref: latest
6
+ file: '/templates/gems.yml'
36
7
 
37
8
  ###############################################################################
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ###############################################################################
6
6
 
7
- source "https://rubygems.org"
7
+ source 'https://rubygems.org'
8
8
 
9
9
  ###############################################################################
10
10
 
data/avatar-0.png ADDED
Binary file
data/avatar-1.png ADDED
Binary file
data/helm-wrapper.gemspec CHANGED
@@ -4,35 +4,37 @@
4
4
 
5
5
  ###############################################################################
6
6
 
7
- require_relative "lib/helm-wrapper/version"
7
+ require_relative 'lib/helm-wrapper/version'
8
8
 
9
9
  ###############################################################################
10
10
 
11
11
  Gem::Specification.new do |spec|
12
- spec.name = "helm-wrapper"
12
+ spec.name = 'helm-wrapper'
13
13
  spec.version = HelmWrapper::VERSION
14
- spec.authors = ["Richard Lees"]
15
- spec.email = ["git0@bitservices.io"]
14
+ spec.authors = ['Richard Lees']
15
+ spec.email = ['git0@bitservices.io']
16
16
 
17
- spec.summary = "A ruby wrapper for managing Helm binaries and chart deployment."
18
- spec.description = "A ruby wrapper for managing Helm binaries and chart deployment. Helm Wrapper also supports authenticating with specific Kubernetes clusters."
19
- spec.homepage = "https://gitlab.com/rlees85-ruby/helm-wrapper/"
20
- spec.license = "MIT"
17
+ spec.summary = 'A ruby wrapper for managing Helm binaries and chart deployment.'
18
+ spec.description = 'A ruby wrapper for managing Helm binaries and chart deployment. Helm Wrapper also supports authenticating with specific Kubernetes clusters.'
19
+ spec.homepage = 'https://gitlab.com/rlees85-ruby/helm-wrapper/'
20
+ spec.license = 'MIT'
21
21
 
22
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
22
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
23
23
 
24
- spec.metadata["homepage_uri"] = spec.homepage
25
- spec.metadata["source_code_uri"] = spec.homepage
24
+ spec.metadata['homepage_uri'] = spec.homepage
25
+ spec.metadata['source_code_uri'] = spec.homepage
26
26
 
27
27
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
28
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:archlinux|test|spec|features)/}) or f.match(%r{\Aavatar(?:_group)?\.png\z}) }
29
29
  end
30
30
 
31
- spec.bindir = "exe"
31
+ spec.bindir = 'exe'
32
32
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
- spec.require_paths = ["lib"]
33
+ spec.require_paths = ['lib']
34
34
 
35
35
  spec.add_dependency 'rake', '~> 13.0'
36
+
37
+ spec.add_development_dependency 'rspec', '~> 3.10'
36
38
  end
37
39
 
38
40
  ###############################################################################
@@ -92,7 +92,7 @@ module HelmWrapper
92
92
  ###############################################################################
93
93
 
94
94
  def cli()
95
- output = logger.colour ? "jsonc" : "json"
95
+ output = logger.colour ? "yamlc" : "yaml"
96
96
  cmdline = "\"#{@@az}\" version --output \"#{output}\""
97
97
  return(system(cmdline) || false)
98
98
  end
@@ -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
- logger.fatal("Chart name must be a string!") unless options["name"].kind_of?(String)
29
- logger.fatal("Chart name must not be blank!") if options["name"].strip.empty?
32
+ if options["path"].nil? then
33
+ @path = options["path"]
30
34
 
31
- @name = options["name"]
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
- unless options["path"].nil? then
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
- logger.fatal("Chart version must be a string!") unless options["version"].kind_of?(String)
46
+ @path = options["path"]
42
47
 
43
- @version = options["version"]
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| 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
-
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
@@ -52,7 +52,12 @@ module HelmWrapper
52
52
  logger.fatal("Response body from GitHub API is not permitted!") if not response.class.body_permitted?
53
53
  logger.fatal("Response body from GitHub API is empty!") if response.body.nil?
54
54
 
55
- body = JSON.parse(response.body)
55
+ begin
56
+ body = JSON.parse(response.body)
57
+ rescue JSON::ParserError
58
+ logger.fatal("Response body from GitHub API is not valid JSON!")
59
+ end
60
+
56
61
 
57
62
  logger.fatal("GitHub API JSON response did not include latest available Helm tag name!") if not body.key?("tag_name")
58
63
  logger.fatal("GitHub API indicated the latest available tag name for Helm is blank!") if body["tag_name"].empty?
@@ -175,25 +175,29 @@ module HelmWrapper
175
175
 
176
176
  ###############################################################################
177
177
 
178
- def push(tag:)
179
- logger.fatal("Cannot Helm push before initialising repositories!") unless repos
180
-
178
+ def package(destination: ".")
181
179
  parameters = Array.new
182
- parameters.append("push")
183
- parameters.append("\"#{@chart.name}:#{tag}\"")
180
+ parameters.append("--destination=\"#{destination}\"")
181
+ parameters.append("\"#{@chart.path}\"")
184
182
 
185
- logger.fatal("Helm push failed!") unless run(action: "chart", parameters: parameters)
183
+ logger.fatal("Helm package failed!") unless run(action: "package", parameters: parameters)
186
184
  end
187
185
 
188
186
  ###############################################################################
189
187
 
190
- def save(tag:)
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("save")
193
- parameters.append("\"#{@chart.path}\"")
194
- parameters.append("\"#{@chart.name}:#{tag}\"")
197
+ parameters.append("\"#{package_path}\"")
198
+ parameters.append("\"#{destination}\"")
195
199
 
196
- logger.fatal("Helm save failed!") unless run(action: "chart", parameters: parameters)
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 = binary
26
- @chart = 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, [:tag, :clean] => :binary do |t, args|
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.save(tag: tag)
48
- runner.push(tag: tag)
48
+ runner.package
49
+ runner.push(destination: @destination)
49
50
  ensure
50
51
  runner.clean(repos: clean)
51
52
  end
@@ -4,7 +4,7 @@ module HelmWrapper
4
4
 
5
5
  ###############################################################################
6
6
 
7
- VERSION = "1.6.1"
7
+ VERSION = "1.7.1"
8
8
 
9
9
  ###############################################################################
10
10
 
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(chart:, path:, oci: false, options: Hash.new)
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"] = chart
74
- chart_options["path"] = path
75
- chart_options["repos"] = options.key?("chart-repos") ? options["chart-repos"] : Array.new
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) if oci
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.6.1
4
+ version: 1.7.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-06-14 00:00:00.000000000 Z
11
+ date: 2022-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '13.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.10'
27
41
  description: A ruby wrapper for managing Helm binaries and chart deployment. Helm
28
42
  Wrapper also supports authenticating with specific Kubernetes clusters.
29
43
  email:
@@ -34,9 +48,12 @@ extra_rdoc_files: []
34
48
  files:
35
49
  - ".gitignore"
36
50
  - ".gitlab-ci.yml"
51
+ - ".rspec"
37
52
  - Gemfile
38
53
  - LICENSE.txt
39
54
  - Rakefile
55
+ - avatar-0.png
56
+ - avatar-1.png
40
57
  - bin/console
41
58
  - bin/setup
42
59
  - helm-wrapper.gemspec
@@ -83,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
100
  - !ruby/object:Gem::Version
84
101
  version: '0'
85
102
  requirements: []
86
- rubygems_version: 3.2.15
103
+ rubygems_version: 3.3.7
87
104
  signing_key:
88
105
  specification_version: 4
89
106
  summary: A ruby wrapper for managing Helm binaries and chart deployment.