aggkit 0.2.9.8363 → 0.2.9.8641
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/Gemfile.lock +1 -1
- data/bin/agggen +169 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33ca8ab7697d6ef1146d189a8ca49f55cb826137
|
4
|
+
data.tar.gz: 2586108c4d8f9ae5923327a95a21f9c3fbe89cb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4e3380429348bcf099fce89bc8961f7d97072f7e617bb0522360d4371e3c722fb75e37e555e7112bd33530556a26bf556c8e630b9a7c7d71d3f3d97581949c0
|
7
|
+
data.tar.gz: cb6690be833fd0f57d90b8cc9da630b1cd2dadb3fe4a89d7a2d2f67be1ea49e377ad6970a96bed4b412ba62370e37e3f62dae21a99c747497176f2bbf6a6b162
|
data/Gemfile.lock
CHANGED
data/bin/agggen
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
require 'gitlab'
|
5
|
+
require 'awesome_print'
|
6
|
+
require 'optparse'
|
7
|
+
UTIL = File.basename(__FILE__)
|
8
|
+
|
9
|
+
@opts = {
|
10
|
+
token: ENV['GITLAB_API_PRIVATE_TOKEN'] || ENV['BOT_TOKEN'] || ENV['TOKEN'],
|
11
|
+
endpoint: 'https://br.rnds.pro/api/v4',
|
12
|
+
exclude: 'core/mq,core/auth,core/ca,core/router,core/admin,core/filator',
|
13
|
+
gtmpl: '%name%:%id%',
|
14
|
+
ptmpl: '%badge% %name%:%id%',
|
15
|
+
}
|
16
|
+
|
17
|
+
|
18
|
+
@dynamic = {
|
19
|
+
badge: Proc.new do |object|
|
20
|
+
"#{object.web_url}/badges/master/pipeline.svg"
|
21
|
+
end,
|
22
|
+
pipeline: Proc.new do |object|
|
23
|
+
"#{object.web_url}/pipelines"
|
24
|
+
end,
|
25
|
+
redmine_badge:Proc.new do |object|
|
26
|
+
"!#{object.web_url}/badges/master/pipeline.svg!:#{object.web_url}/pipelines"
|
27
|
+
end,
|
28
|
+
redmine_link:Proc.new do |object|
|
29
|
+
"\"#{object.name}\":#{object.web_url}"
|
30
|
+
end,
|
31
|
+
|
32
|
+
gitlab_link:Proc.new do |object|
|
33
|
+
"[#{object.name}](#{object.web_url})"
|
34
|
+
end,
|
35
|
+
gitlab_badge:Proc.new do |object|
|
36
|
+
"[](#{object.web_url})"
|
37
|
+
end,
|
38
|
+
}
|
39
|
+
|
40
|
+
@tempaltes = {
|
41
|
+
redmine: "|%redmine_badge%|%redmine_link%|%description%|",
|
42
|
+
gredmine: "\n|*%name%*||%description%|",
|
43
|
+
gitlab: "* [ ] %gitlab_link% %description%",
|
44
|
+
ggitlab: "\n**%name%**",
|
45
|
+
}
|
46
|
+
|
47
|
+
parser = OptionParser.new do |o|
|
48
|
+
o.banner = "Usage: #{UTIL} [options]"
|
49
|
+
|
50
|
+
o.on("--list", 'list projects') do
|
51
|
+
@opts[:list] = true
|
52
|
+
end
|
53
|
+
|
54
|
+
o.on("--groups groups", 'process only these groups') do |groups|
|
55
|
+
@opts[:groups] = groups.to_s.split(/[ ,;|]/).map(&:to_s).reject(&:empty?).uniq
|
56
|
+
end
|
57
|
+
|
58
|
+
o.on("--gtmpl template", 'template to print group') do |tmpl|
|
59
|
+
tmpl = @tempaltes[tmpl.to_s.to_sym] || tmpl
|
60
|
+
@opts[:gtmpl] = tmpl.to_s
|
61
|
+
end
|
62
|
+
|
63
|
+
o.on("--ptmpl template", 'template to print projects') do |tmpl|
|
64
|
+
tmpl = @tempaltes[tmpl.to_s.to_sym] || tmpl
|
65
|
+
@opts[:ptmpl] = tmpl.to_s
|
66
|
+
end
|
67
|
+
|
68
|
+
o.on("--exclude projects", 'exclude projects from selection') do |exclude|
|
69
|
+
@opts[:exclude] = exclude.to_s
|
70
|
+
end
|
71
|
+
|
72
|
+
o.on("--endpoint endpoint=#{@opts[:endpoint]}", 'set api endpoint') do |endpoint|
|
73
|
+
@opts[:endpoint] = endpoint.to_s.strip
|
74
|
+
end
|
75
|
+
|
76
|
+
o.on("--token token", 'set api token') do |token|
|
77
|
+
@opts[:token] = token.to_s.strip
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
parser.parse!
|
82
|
+
|
83
|
+
@api = Gitlab.client(endpoint: @opts[:endpoint], private_token: @opts[:token])
|
84
|
+
|
85
|
+
MAIN_GROUP='aggredator'
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
def each_group group
|
90
|
+
Enumerator.new do |y|
|
91
|
+
y << group
|
92
|
+
|
93
|
+
@api.group_subgroups(group.id, per_page: 1000).each do |sub|
|
94
|
+
each_group(sub).each do |g|
|
95
|
+
y << g
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def each_project group
|
102
|
+
Enumerator.new do |y|
|
103
|
+
@api.group_projects(group.id, per_page: 1000).each do |p|
|
104
|
+
y << p
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def inspect_group group
|
110
|
+
result = {}
|
111
|
+
result[:groups] = @api.group_subgroups(group.id).each_with_object({}) do |sub, ret|
|
112
|
+
ret[sub.name] = inspect_group(sub)
|
113
|
+
end
|
114
|
+
result[:projects] = @api.group_projects(group.id).map(&:name)
|
115
|
+
result
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
def render tmpl, substs, object
|
120
|
+
substs.reduce(tmpl) do |ret, s|
|
121
|
+
if callable = @dynamic[s.to_sym]
|
122
|
+
ret.gsub("%#{s}%", callable.call(object).to_s)
|
123
|
+
else
|
124
|
+
ret.gsub("%#{s}%", object.send(s).to_s)
|
125
|
+
end
|
126
|
+
end.gsub('\n', "\n")
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
if @opts[:list]
|
132
|
+
gsubsts = @opts[:gtmpl].scan(/%\w+%/).map{|pattern| pattern[/\w+/]}
|
133
|
+
psubsts = @opts[:ptmpl].scan(/%\w+%/).map{|pattern| pattern[/\w+/]}
|
134
|
+
|
135
|
+
|
136
|
+
main = @api.groups(search: MAIN_GROUP).first
|
137
|
+
|
138
|
+
groups = each_group(main).select do |group|
|
139
|
+
@opts[:groups].any? do |match|
|
140
|
+
group.full_path[match]
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
excludes = @opts[:exclude].to_s.split(/[ ,;|]/).map(&:to_s).reject(&:empty?).uniq
|
145
|
+
|
146
|
+
groups.each do |group|
|
147
|
+
puts render(@opts[:gtmpl], gsubsts, group)
|
148
|
+
|
149
|
+
projects = each_project(group).reject do |p|
|
150
|
+
excludes.any? do |exclude|
|
151
|
+
p.path_with_namespace[exclude]
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
projects.map do |p|
|
156
|
+
render(@opts[:ptmpl], psubsts, p)
|
157
|
+
end.sort.each do |line|
|
158
|
+
puts line
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
exit 0
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
STDERR.puts parser.help
|
167
|
+
exit 1
|
168
|
+
|
169
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aggkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.9.
|
4
|
+
version: 0.2.9.8641
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Godko Ivan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-02-
|
12
|
+
date: 2019-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: diplomat
|
@@ -103,6 +103,7 @@ executables:
|
|
103
103
|
- agg
|
104
104
|
- aggci
|
105
105
|
- aggconsul
|
106
|
+
- agggen
|
106
107
|
- agglock
|
107
108
|
- aggmerge
|
108
109
|
- aggterm
|
@@ -123,6 +124,7 @@ files:
|
|
123
124
|
- bin/agg
|
124
125
|
- bin/aggci
|
125
126
|
- bin/aggconsul
|
127
|
+
- bin/agggen
|
126
128
|
- bin/agglock
|
127
129
|
- bin/aggmerge
|
128
130
|
- bin/aggterm
|