build-labels 0.0.33 → 0.0.35
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/bin/helm-push +9 -0
- data/lib/helm-push/command_line.rb +78 -0
- data/lib/helm-push/command_push.rb +29 -0
- data/lib/helm-push.rb +3 -0
- data/lib/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a62dff9e164a3749d73437662ef1a249abd71a02050ca03e25351ca1d1a41010
|
4
|
+
data.tar.gz: 91cc2502095199151d2b172b6c93c32734789c62297827e61d062e89da0b47a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de0cf08be70b97b79bad86dc198a0e0908cc8c4e69444b4d223c1f4172f5de5e2cfde7ea625ba0e5298597810529956b93d8ee13be7f6f54f60b44038fe6ddea
|
7
|
+
data.tar.gz: f0c7ea0621cd5b80fa0001aef381e10b737fe9e1e4658c7571d48997e0c1968f71698d98532f3191dfcd85a87b1b902d036414a378775432c456c355c9444718
|
data/bin/helm-push
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require_relative '../version'
|
2
|
+
require 'optparse'
|
3
|
+
# frozen_string_literal: true
|
4
|
+
require_relative '../build-labels/yaml_merge'
|
5
|
+
|
6
|
+
module HelmPush
|
7
|
+
module CommandLine
|
8
|
+
COMMANDS = {}
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def load_env(filename)
|
12
|
+
File.read(filename).lines.map(&:strip).grep_v(/^\s*#/).reject(&:empty?)
|
13
|
+
.map {
|
14
|
+
if _1 =~ /([^=]+)=(.*)/
|
15
|
+
a, k,v = Regexp.last_match.to_a
|
16
|
+
ENV[k] = v
|
17
|
+
[k,v]
|
18
|
+
else
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
}.compact.to_h
|
22
|
+
rescue =>e
|
23
|
+
puts "Load env error: #{e.message}"
|
24
|
+
raise "Invalid #{filename} file"
|
25
|
+
end
|
26
|
+
|
27
|
+
def run(args)
|
28
|
+
params = {}
|
29
|
+
|
30
|
+
ARGV << '-h' if ARGV.empty?
|
31
|
+
OptionParser.new do |o|
|
32
|
+
o.version = "#{BuildLabels::Builder::VERSION}"
|
33
|
+
|
34
|
+
usage = [
|
35
|
+
'helm-push -c docker-compose.yml -version-mask=\d+\.\d+\.\d+',
|
36
|
+
'cat docker-compose.yml | helm-push',
|
37
|
+
'helm-push < docker-compose.yml'
|
38
|
+
]
|
39
|
+
o.banner = "Version: #{o.version}\nUsage:\n\t#{usage.join "\n\t"}"
|
40
|
+
o.separator ''
|
41
|
+
o.separator 'Commands:'
|
42
|
+
COMMANDS.each { |name, cmd| o.separator "#{' ' * 5}#{name} - #{cmd.help}" }
|
43
|
+
|
44
|
+
o.separator ''
|
45
|
+
o.separator 'Options:'
|
46
|
+
|
47
|
+
# in all caps are required
|
48
|
+
o.on('-c', '--compose COMPOSE_FILE', 'Compose file')
|
49
|
+
o.on('-m', '--version-mask VERSION_MASK', 'Version mask')
|
50
|
+
o.on('-e', '--env FILE', 'Load .build_info FILE') { load_env _1 }
|
51
|
+
o.on('-n', '--no-env', 'Do not process env variables') { true }
|
52
|
+
COMMANDS.values.select{_1.options(o) if _1.respond_to? :options }
|
53
|
+
|
54
|
+
o.on('-h', '--help') { puts o; exit }
|
55
|
+
rest = o.parse! args, into: params
|
56
|
+
|
57
|
+
|
58
|
+
compose_text = File.read(params[:compose]) if params[:compose]
|
59
|
+
compose_text ||= STDIN.read unless $stdin.tty?
|
60
|
+
|
61
|
+
result = YamlMerge.parse_and_process_yaml compose_text
|
62
|
+
compose_text = YamlMerge.deep_copy_without_aliases result
|
63
|
+
|
64
|
+
# eval $(grep -v -e '^#' .build_info | xargs -I {} echo export \'{}\') && echo $CI_COMMIT_AUTHOR
|
65
|
+
rest = ['push'] if rest.empty?
|
66
|
+
|
67
|
+
rest.each do |command|
|
68
|
+
raise "Unknown command: #{command}" unless COMMANDS.key?(command.to_sym)
|
69
|
+
COMMANDS[command.to_sym].run params, compose_text
|
70
|
+
end
|
71
|
+
rescue => e
|
72
|
+
puts e.message
|
73
|
+
exit 1
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'command_line'
|
2
|
+
|
3
|
+
HelmPush::CommandLine::COMMANDS[:push] = Class.new do
|
4
|
+
def run(params, compose)
|
5
|
+
raise 'Compose file not defined' unless compose
|
6
|
+
raise 'Version mask not defined' unless params[:'version-mask']
|
7
|
+
|
8
|
+
compose['services'].each do |service_name, svc|
|
9
|
+
next unless svc['build']
|
10
|
+
unless svc['build']['tags']
|
11
|
+
svc['build']['tags'] = [svc['image']]
|
12
|
+
end
|
13
|
+
|
14
|
+
svc['build']['tags'].each do |full_tag|
|
15
|
+
_image, tag = full_tag.split(':')
|
16
|
+
if tag =~ Regexp.new(params[:'version-mask'])
|
17
|
+
puts "Package and Push Helm for the image #{full_tag}"
|
18
|
+
|
19
|
+
system "helm package helm/#{service_name} --app-version #{tag} --version #{tag} --destination helm/" or raise("helm package failed")
|
20
|
+
system "curl -u ${HELM_USER}:${HELM_PASSWORD} --upload-file helm/#{service_name}-#{tag}.tgz ${HELM_HOST}" or raise("helm push failed")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def help = 'Package and Push Helm for each service'
|
27
|
+
end.new
|
28
|
+
|
29
|
+
|
data/lib/helm-push.rb
ADDED
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build-labels
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artyom B
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -98,10 +98,12 @@ description: ''
|
|
98
98
|
email: author@email.address
|
99
99
|
executables:
|
100
100
|
- build-labels
|
101
|
+
- helm-push
|
101
102
|
extensions: []
|
102
103
|
extra_rdoc_files: []
|
103
104
|
files:
|
104
105
|
- bin/build-labels
|
106
|
+
- bin/helm-push
|
105
107
|
- examples/Dockerfile
|
106
108
|
- examples/common-compose.yml
|
107
109
|
- examples/simple-compose.yml
|
@@ -115,6 +117,9 @@ files:
|
|
115
117
|
- lib/build-labels/command_to_compose.rb
|
116
118
|
- lib/build-labels/command_to_dockerfiles.rb
|
117
119
|
- lib/build-labels/yaml_merge.rb
|
120
|
+
- lib/helm-push.rb
|
121
|
+
- lib/helm-push/command_line.rb
|
122
|
+
- lib/helm-push/command_push.rb
|
118
123
|
- lib/version.rb
|
119
124
|
homepage: https://rubygems.org/gems/build-labels
|
120
125
|
licenses:
|