build-labels 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0dcae3ead743d1387c98b31eb227be0c14ba162c092b417ed45815b129bc3b81
4
+ data.tar.gz: f9ead067fd0089650a063737fc51b0d2686f40a0699576d40ae256ce70a579bb
5
+ SHA512:
6
+ metadata.gz: 75acdb27cb268daab9dafe3484de6b53abab2e6abcb8e7e2454cede885af4f9df038d8d3162f692eadfcfb2446a8093fadd2268b32af2d74a65d4da931bad0c8
7
+ data.tar.gz: c6d62b2c80d37039ad07a15a37a9d29b2754851508ebce6d1fabb308375c167197f937ef80eb24ded6f2073f88143268541aeec09f137bc86b5a4955b41d98c2
data/bin/build-labels ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path('../lib', __dir__)
3
+ $LOAD_PATH << lib
4
+ #$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require 'build-labels'
7
+ require 'build-labels/command_line'
8
+ include BuildLabels
9
+
10
+ BuildLabels::CommandLine.run ARGV
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ require 'yaml'
3
+ require 'optparse'
4
+
5
+ module BuildLabels
6
+
7
+ class Builder
8
+
9
+ def initialize()
10
+ end
11
+ end
12
+
13
+ end
14
+
@@ -0,0 +1,65 @@
1
+ require_relative '../version'
2
+
3
+ module BuildLabels
4
+ module CommandLine
5
+ COMMANDS = {}
6
+
7
+ class << self
8
+ def load_env
9
+ File.read('.env').lines.map(&:strip).grep_v(/^\s*#/).reject(&:empty?)
10
+ .map {_1.split('=').map(&:strip).tap { |k,v|
11
+ ENV[k] = v
12
+ }}.to_h
13
+ rescue =>e
14
+ puts "Load env error: #{e.message}"
15
+ raise 'Invalid .env file'
16
+ end
17
+
18
+ def run(args)
19
+ params = {}
20
+
21
+ ARGV << '-h' if ARGV.empty?
22
+ OptionParser.new do |o|
23
+ o.version = "#{BuildLabels::Builder::VERSION}"
24
+
25
+ usage = [
26
+ 'dry-stack -s stackfile [options] COMMAND',
27
+ 'cat stackfile | dry-stack COMMAND',
28
+ 'dry-stack COMMAND < stack.drs'
29
+ ]
30
+ o.banner = "Version: #{o.version}\nUsage:\n\t#{usage.join "\n\t"}"
31
+ o.separator ''
32
+ o.separator 'Commands:'
33
+ COMMANDS.each { |name, cmd| o.separator "#{' ' * 5}#{name} - #{cmd.help}" }
34
+
35
+ o.separator ''
36
+ o.separator 'Options:'
37
+
38
+ # in all caps are required
39
+ o.on('-s', '--stack STACK_NAME', 'Stack file')
40
+ o.on('-e', '--env', 'Load .env file') { load_env }
41
+ o.on('', '--name STACK_NAME', 'Define stack name')
42
+ o.on('', '--ingress', 'Generate ingress labels') { true }
43
+ o.on('', '--traefik', 'Generate traefik labels') { true }
44
+ o.on('', '--traefik_tls', 'Generate traefik tls labels') { true }
45
+ o.on('', '--host_sed /from/to/', 'Sed ingress host /\\*/dev.*/')
46
+ o.on('-n', '--no-env', 'Do not process env variables') { true }
47
+ o.on('-h', '--help') { puts o; exit }
48
+ o.parse! args, into: params
49
+
50
+ raise 'Stack file not defined' if $stdin.tty? && !params[:stack]
51
+
52
+ command = args.shift || ''
53
+ raise "Unknown command: #{command}" unless COMMANDS.key?(command.to_sym)
54
+
55
+ stack_text = File.read(params[:stack]) if params[:stack]
56
+ stack_text ||= STDIN.read unless $stdin.tty?
57
+
58
+ rescue => e
59
+ puts e.message
60
+ exit 1
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "build-labels/builder"
data/lib/version.rb ADDED
@@ -0,0 +1,5 @@
1
+ module BuildLabels
2
+ class Builder
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: build-labels
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Artyom B
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '13.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
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'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.6.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.14.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.14.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.5.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.5.1
97
+ description: ''
98
+ email: author@email.address
99
+ executables:
100
+ - build-labels
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - bin/build-labels
105
+ - lib/build-labels.rb
106
+ - lib/build-labels/builder.rb
107
+ - lib/build-labels/command_line.rb
108
+ - lib/version.rb
109
+ homepage: https://rubygems.org/gems/build-labels
110
+ licenses:
111
+ - Nonstandard
112
+ metadata:
113
+ source_code_uri: https://github.com/artyomb/build-labels
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 3.1.2
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubygems_version: 3.3.7
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Generate docker build image labels from CI variables
133
+ test_files: []