1 |
commit: b3019dfb52716448680a5ba080b61cba6a28dc26 |
2 |
Author: Manuel Rüger <mrueg <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jan 28 10:53:05 2019 +0000 |
4 |
Commit: Manuel Rüger <mrueg <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jan 28 10:53:05 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b3019dfb |
7 |
|
8 |
app-emulation/reg: Add new snapshot |
9 |
|
10 |
Package-Manager: Portage-2.3.58, Repoman-2.3.12 |
11 |
Signed-off-by: Manuel Rüger <mrueg <AT> gentoo.org> |
12 |
|
13 |
app-emulation/reg/Manifest | 2 + |
14 |
app-emulation/reg/files/reg-0.16.0-config.patch | 254 ++++++++++++++++++++++++ |
15 |
app-emulation/reg/reg-0.16.0_p20180102.ebuild | 53 +++++ |
16 |
3 files changed, 309 insertions(+) |
17 |
|
18 |
diff --git a/app-emulation/reg/Manifest b/app-emulation/reg/Manifest |
19 |
index b92b4fb0169..9d2d1bb904a 100644 |
20 |
--- a/app-emulation/reg/Manifest |
21 |
+++ b/app-emulation/reg/Manifest |
22 |
@@ -1,3 +1,5 @@ |
23 |
+DIST github.com-go-yaml-yaml-a3f3340b5840cee44f372bddb5880fcbc419b46a.tar.gz 60814 BLAKE2B a77b7d72e2937af71a0734c21bee7a1d7770157c27f1ddfa164c66fd5461f86a2ef46e002087092ef011caae572838bcc9537a8290cd54dfafb7f54423e47c48 SHA512 184a0e658a4eac3b867533cd0e494bd84db94fbe10e8df0d0b755c7ffc95bc99e2f84c0157183ca74cdc79289a85dcf7f1dea8a4c89a253565baf473b3627eae |
24 |
DIST reg-0.15.7.tar.gz 4300839 BLAKE2B 67c9ca344e0a2984559c210cbdb4f5fc42f588f0c50a171c145bc63953b7540cbc166b51a5c209a2ece0c3b5647a34ffc1ac6b439b4e5a243e505c223a1a6fe5 SHA512 4c26aa0a438ac87208c4e269e16a994587ccdab38399a664638dd8c7407cf06f00c43a9c3c71cf4c88fa47a6e4466c8143ee7ee8130a8133518f5017ca34cc2d |
25 |
DIST reg-0.15.8.tar.gz 4300575 BLAKE2B 554a6afebf0c662fa4e4076019b25aa600f327cc6d3fbd9aff3462b8d1faf0b790724bb9d66725766087f6e4a2ccf55a61f41e7aba936ed386d97cf52c54afab SHA512 23d45d061e2914818787e6837fd02ba7b4fcf5c96a511d5e6ee66689bfd925870780d7a9fcfe6ee98f2b74ce68f05eecfa9d00852ff79965f59c88684113e0d5 |
26 |
DIST reg-0.16.0.tar.gz 2991496 BLAKE2B e94a53c79ff062013e091d4c558870ef5c25af181cba201a44fa38b9dfe8816d6f3fd581f4e9a3dafe5b3753a3755c31f8b2f4a347da134a969fc93ac296897c SHA512 1e4d936e406998ffaa176e7834b28970b594f88a339fd8447bef2f944efa9b51c1d35bf71b384b3ed1b3e84be08db6d7fd487f4a3c65aa2de0308d6128cf0070 |
27 |
+DIST reg-0.16.0_p20180102.tar.gz 2994965 BLAKE2B c7cb8a0eaa1599a5464b7a98c3df0b146dbbfea884260b7c8cbf5393a9384c8875e38ea4e45c5f888c65b9bb8c326cf9934d9b3c32a4809fe8e3b23239e8f2a8 SHA512 90e92c15b7ca4f2a5f943cb80096af0eba50acd7691963609c25f15a6795f886843776180754ab7d28477f1fc3a4b8d916bc9ac99b768368471b31564d14769c |
28 |
|
29 |
diff --git a/app-emulation/reg/files/reg-0.16.0-config.patch b/app-emulation/reg/files/reg-0.16.0-config.patch |
30 |
new file mode 100644 |
31 |
index 00000000000..3ec1bf44d03 |
32 |
--- /dev/null |
33 |
+++ b/app-emulation/reg/files/reg-0.16.0-config.patch |
34 |
@@ -0,0 +1,254 @@ |
35 |
+From 0ab86b565f437b9dede5d3a7cef56690d8d19bbb Mon Sep 17 00:00:00 2001 |
36 |
+From: =?UTF-8?q?Manuel=20R=C3=BCger?= <manuel@××××.eu> |
37 |
+Date: Tue, 18 Sep 2018 15:42:24 +0200 |
38 |
+Subject: [PATCH 2/2] server: Read config from file |
39 |
+ |
40 |
+--- |
41 |
+ README.md | 4 ++ |
42 |
+ config.yml.example | 37 ++++++++++++++++ |
43 |
+ server.go | 107 +++++++++++++++++++++++++++++++-------------- |
44 |
+ 3 files changed, 114 insertions(+), 34 deletions(-) |
45 |
+ create mode 100644 config.yml.example |
46 |
+ |
47 |
+diff --git a/README.md b/README.md |
48 |
+index 3b1b661f..5e0f0175 100644 |
49 |
+--- a/README.md |
50 |
++++ b/README.md |
51 |
+@@ -228,6 +228,7 @@ Flags: |
52 |
+ -u, --username username for the registry (default: <none>) |
53 |
+ --listen-address address to listen on (default: <none>) |
54 |
+ --asset-path Path to assets and templates (default: <none>) |
55 |
++ --config Path to config file (default: <none>) |
56 |
+ -f, --force-non-ssl force allow use of non-ssl (default: false) |
57 |
+ --once generate the templates once and then exit (default: false) |
58 |
+ --skip-ping skip pinging the registry while establishing connection (default: false) |
59 |
+@@ -243,6 +244,9 @@ Flags: |
60 |
+ -p, --password password for the registry (default: <none>) |
61 |
+ ``` |
62 |
+ |
63 |
++Alternatively you can provide configuration to `reg server` via a file passed to |
64 |
++`reg server` via as `--config`. See also config.yml.example in this repository. |
65 |
++ |
66 |
+ **Screenshots:** |
67 |
+ |
68 |
+ ![home.png](server/home.png) |
69 |
+diff --git a/config.yml.example b/config.yml.example |
70 |
+new file mode 100644 |
71 |
+index 00000000..9d4be25f |
72 |
+--- /dev/null |
73 |
++++ b/config.yml.example |
74 |
+@@ -0,0 +1,37 @@ |
75 |
++### Reg Server Settings |
76 |
++ |
77 |
++## Path to server TLS certificate: |
78 |
++# cert: |
79 |
++## Path to server TLS key: |
80 |
++# key: |
81 |
++## Address to listen on: |
82 |
++# listen-address: 0.0.0.0 |
83 |
++## Port to listen on: |
84 |
++# port: 8080 |
85 |
++## Path Assets are stored under: |
86 |
++# asset-path: /var/lib/reg |
87 |
++## Generate static website and exit: |
88 |
++# once: false |
89 |
++## Refresh interval: |
90 |
++# interval: 1h0m0s |
91 |
++## Debug output |
92 |
++# debug: false |
93 |
++## Skip initial ping |
94 |
++# skip-ping: false |
95 |
++## Timeout |
96 |
++# timeout: 1m0s |
97 |
++ |
98 |
++ |
99 |
++### Registry and Clair Server Settings |
100 |
++## Registry Server: |
101 |
++# registry: r.j3ss.co |
102 |
++## Username to authenticate against registry server |
103 |
++# username: |
104 |
++## Password to authenticate against registry server |
105 |
++# password: |
106 |
++## If true, do not verify TLS certificates |
107 |
++# insecure: false |
108 |
++## Force allow use of non-TLS connections |
109 |
++# force-nonssl: false |
110 |
++## Clair Server: |
111 |
++# clair: |
112 |
+diff --git a/server.go b/server.go |
113 |
+index fcd4cd71..0c84d85d 100644 |
114 |
+--- a/server.go |
115 |
++++ b/server.go |
116 |
+@@ -4,7 +4,9 @@ import ( |
117 |
+ "context" |
118 |
+ "flag" |
119 |
+ "fmt" |
120 |
++ "gopkg.in/yaml.v2" |
121 |
+ "html/template" |
122 |
++ "io/ioutil" |
123 |
+ "net/http" |
124 |
+ "os" |
125 |
+ "path/filepath" |
126 |
+@@ -29,39 +31,76 @@ func (cmd *serverCommand) LongHelp() string { return serverHelp } |
127 |
+ func (cmd *serverCommand) Hidden() bool { return false } |
128 |
+ |
129 |
+ func (cmd *serverCommand) Register(fs *flag.FlagSet) { |
130 |
+- fs.DurationVar(&cmd.interval, "interval", time.Hour, "interval to generate new index.html's at") |
131 |
++ fs.DurationVar(&cmd.Interval, "interval", time.Hour, "interval to generate new index.html's at") |
132 |
+ |
133 |
+- fs.StringVar(&cmd.registryServer, "registry", "", "URL to the private registry (ex. r.j3ss.co)") |
134 |
+- fs.StringVar(&cmd.registryServer, "r", "", "URL to the private registry (ex. r.j3ss.co)") |
135 |
++ fs.StringVar(&cmd.RegistryServer, "registry", "", "URL to the private registry (ex. r.j3ss.co)") |
136 |
++ fs.StringVar(&cmd.RegistryServer, "r", "", "URL to the private registry (ex. r.j3ss.co)") |
137 |
+ |
138 |
+- fs.StringVar(&cmd.clairServer, "clair", "", "url to clair instance") |
139 |
++ fs.StringVar(&cmd.ClairServer, "clair", "", "url to clair instance") |
140 |
+ |
141 |
+- fs.StringVar(&cmd.cert, "cert", "", "path to ssl cert") |
142 |
+- fs.StringVar(&cmd.key, "key", "", "path to ssl key") |
143 |
+- fs.StringVar(&cmd.listenAddress, "listen-address", "", "address to listen on") |
144 |
+- fs.StringVar(&cmd.port, "port", "8080", "port for server to run on") |
145 |
+- fs.StringVar(&cmd.assetPath, "asset-path", "", "Path to assets and templates") |
146 |
++ fs.StringVar(&cmd.Cert, "cert", "", "path to ssl cert") |
147 |
++ fs.StringVar(&cmd.Key, "key", "", "path to ssl key") |
148 |
++ fs.StringVar(&cmd.ListenAddress, "listen-address", "", "address to listen on") |
149 |
++ fs.StringVar(&cmd.Port, "port", "8080", "port for server to run on") |
150 |
+ |
151 |
+- fs.BoolVar(&cmd.generateAndExit, "once", false, "generate the templates once and then exit") |
152 |
++ fs.StringVar(&cmd.AssetPath, "asset-path", "", "Path to assets and templates") |
153 |
++ fs.StringVar(&cmd.configPath, "config", "", "Path to config file") |
154 |
++ |
155 |
++ fs.BoolVar(&cmd.GenerateAndExit, "once", false, "generate the templates once and then exit") |
156 |
+ } |
157 |
+ |
158 |
+ type serverCommand struct { |
159 |
+- interval time.Duration |
160 |
+- registryServer string |
161 |
+- clairServer string |
162 |
+- |
163 |
+- generateAndExit bool |
164 |
+- |
165 |
+- cert string |
166 |
+- key string |
167 |
+- listenAddress string |
168 |
+- port string |
169 |
+- assetPath string |
170 |
++ Interval time.Duration `yaml:"interval"` |
171 |
++ RegistryServer string `yaml:"registry"` |
172 |
++ ClairServer string `yaml:"clair"` |
173 |
++ GenerateAndExit bool `yaml:"once"` |
174 |
++ Cert string `yaml:"cert"` |
175 |
++ Key string `yaml:"key"` |
176 |
++ ListenAddress string `yaml:"listen-address"` |
177 |
++ Port string `yaml:"port"` |
178 |
++ AssetPath string `yaml:"asset-path"` |
179 |
++ configPath string |
180 |
++ |
181 |
++ Password string `yaml:"password"` |
182 |
++ Username string `yaml:"username"` |
183 |
++ Insecure bool `yaml:"insecure"` |
184 |
++ Debug bool `yaml:"debug"` |
185 |
++ SkipPing bool `yaml:"skip-ping"` |
186 |
++ ForceNonSSL bool `yaml:"force-nonssl"` |
187 |
++ Timeout time.Duration `yaml:"timeout"` |
188 |
+ } |
189 |
+ |
190 |
+ func (cmd *serverCommand) Run(ctx context.Context, args []string) error { |
191 |
+ // Create the registry client. |
192 |
+- r, err := createRegistryClient(ctx, cmd.registryServer) |
193 |
++ if len(cmd.configPath) > 0 { |
194 |
++ config, err := ioutil.ReadFile(cmd.configPath) |
195 |
++ if err != nil { |
196 |
++ return err |
197 |
++ } |
198 |
++ yaml.Unmarshal(config, cmd) |
199 |
++ if err != nil { |
200 |
++ return err |
201 |
++ } |
202 |
++ if len(cmd.Username) > 0 { |
203 |
++ username = cmd.Username |
204 |
++ } |
205 |
++ if len(cmd.Password) > 0 { |
206 |
++ password = cmd.Password |
207 |
++ } |
208 |
++ if cmd.Debug { |
209 |
++ debug = cmd.Debug |
210 |
++ } |
211 |
++ if cmd.Insecure { |
212 |
++ insecure = cmd.Insecure |
213 |
++ } |
214 |
++ if cmd.SkipPing { |
215 |
++ skipPing = cmd.SkipPing |
216 |
++ } |
217 |
++ if cmd.Timeout != 0 { |
218 |
++ timeout = cmd.Timeout |
219 |
++ } |
220 |
++ } |
221 |
++ r, err := createRegistryClient(ctx, cmd.RegistryServer) |
222 |
+ if err != nil { |
223 |
+ return err |
224 |
+ } |
225 |
+@@ -69,25 +108,25 @@ func (cmd *serverCommand) Run(ctx context.Context, args []string) error { |
226 |
+ // Create the registry controller for the handlers. |
227 |
+ rc := registryController{ |
228 |
+ reg: r, |
229 |
+- generateOnly: cmd.generateAndExit, |
230 |
++ generateOnly: cmd.GenerateAndExit, |
231 |
+ } |
232 |
+ |
233 |
+ // Create a clair client if the user passed in a server address. |
234 |
+- if len(cmd.clairServer) > 0 { |
235 |
+- rc.cl, err = clair.New(cmd.clairServer, clair.Opt{ |
236 |
++ if len(cmd.ClairServer) > 0 { |
237 |
++ rc.cl, err = clair.New(cmd.ClairServer, clair.Opt{ |
238 |
+ Insecure: insecure, |
239 |
+ Debug: debug, |
240 |
+ Timeout: timeout, |
241 |
+ }) |
242 |
+ if err != nil { |
243 |
+- return fmt.Errorf("creation of clair client at %s failed: %v", cmd.clairServer, err) |
244 |
++ return fmt.Errorf("creation of clair client at %s failed: %v", cmd.ClairServer, err) |
245 |
+ } |
246 |
+ } else { |
247 |
+ rc.cl = nil |
248 |
+ } |
249 |
+ // Get the path to the asset directory. |
250 |
+- assetDir := cmd.assetPath |
251 |
+- if len(cmd.assetPath) <= 0 { |
252 |
++ assetDir := cmd.AssetPath |
253 |
++ if len(cmd.AssetPath) <= 0 { |
254 |
+ assetDir, err = os.Getwd() |
255 |
+ if err != nil { |
256 |
+ return err |
257 |
+@@ -131,12 +170,12 @@ func (cmd *serverCommand) Run(ctx context.Context, args []string) error { |
258 |
+ return fmt.Errorf("creating index failed: %v", err) |
259 |
+ } |
260 |
+ |
261 |
+- if cmd.generateAndExit { |
262 |
++ if cmd.GenerateAndExit { |
263 |
+ logrus.Info("output generated, exiting...") |
264 |
+ return nil |
265 |
+ } |
266 |
+ |
267 |
+- rc.interval = cmd.interval |
268 |
++ rc.interval = cmd.Interval |
269 |
+ ticker := time.NewTicker(rc.interval) |
270 |
+ go func() { |
271 |
+ // Create more indexes every X minutes based off interval. |
272 |
+@@ -174,12 +213,12 @@ func (cmd *serverCommand) Run(ctx context.Context, args []string) error { |
273 |
+ |
274 |
+ // Set up the server. |
275 |
+ server := &http.Server{ |
276 |
+- Addr: cmd.listenAddress + ":" + cmd.port, |
277 |
++ Addr: cmd.ListenAddress + ":" + cmd.Port, |
278 |
+ Handler: mux, |
279 |
+ } |
280 |
+- logrus.Infof("Starting server on port %q", cmd.port) |
281 |
+- if len(cmd.cert) > 0 && len(cmd.key) > 0 { |
282 |
+- return server.ListenAndServeTLS(cmd.cert, cmd.key) |
283 |
++ logrus.Infof("Starting server on port %q", cmd.Port) |
284 |
++ if len(cmd.Cert) > 0 && len(cmd.Key) > 0 { |
285 |
++ return server.ListenAndServeTLS(cmd.Cert, cmd.Key) |
286 |
+ } |
287 |
+ return server.ListenAndServe() |
288 |
+ } |
289 |
|
290 |
diff --git a/app-emulation/reg/reg-0.16.0_p20180102.ebuild b/app-emulation/reg/reg-0.16.0_p20180102.ebuild |
291 |
new file mode 100644 |
292 |
index 00000000000..3d7a774209c |
293 |
--- /dev/null |
294 |
+++ b/app-emulation/reg/reg-0.16.0_p20180102.ebuild |
295 |
@@ -0,0 +1,53 @@ |
296 |
+# Copyright 1999-2019 Gentoo Authors |
297 |
+# Distributed under the terms of the GNU General Public License v2 |
298 |
+ |
299 |
+EAPI=6 |
300 |
+ |
301 |
+EGO_VENDOR=( "gopkg.in/yaml.v2 a3f3340b5840cee44f372bddb5880fcbc419b46a github.com/go-yaml/yaml" ) |
302 |
+ |
303 |
+inherit golang-build golang-vcs-snapshot user |
304 |
+ |
305 |
+EGO_PN="github.com/genuinetools/reg" |
306 |
+GIT_COMMIT="d959057b30da67d5f162790f9d5b5160686901fd" |
307 |
+ARCHIVE_URI="https://${EGO_PN}/archive/${GIT_COMMIT}.tar.gz -> ${P}.tar.gz |
308 |
+ ${EGO_VENDOR_URI}" |
309 |
+KEYWORDS="~amd64" |
310 |
+ |
311 |
+DESCRIPTION="Docker registry v2 command line client" |
312 |
+HOMEPAGE="https://github.com/genuinetools/reg" |
313 |
+SRC_URI="${ARCHIVE_URI}" |
314 |
+LICENSE="MIT" |
315 |
+SLOT="0" |
316 |
+IUSE="" |
317 |
+ |
318 |
+RESTRICT="test" |
319 |
+ |
320 |
+pkg_setup() { |
321 |
+ enewgroup reg |
322 |
+ enewuser reg -1 -1 /var/lib/reg reg |
323 |
+} |
324 |
+ |
325 |
+src_prepare() { |
326 |
+ pushd src/${EGO_PN} || die |
327 |
+ eapply "${FILESDIR}"/reg-0.16.0-config.patch |
328 |
+ default |
329 |
+ popd || die |
330 |
+} |
331 |
+ |
332 |
+src_compile() { |
333 |
+ pushd src/${EGO_PN} || die |
334 |
+ GOPATH="${S}" go build -v -ldflags "-X ${EGO_PN}/version.GITCOMMIT=${GIT_COMMIT} -X ${EGO_PN}/version.VERSION=${PV}" -o "${S}"/bin/reg . || die |
335 |
+ popd || die |
336 |
+} |
337 |
+ |
338 |
+src_install() { |
339 |
+ dobin bin/* |
340 |
+ dodoc src/${EGO_PN}/README.md |
341 |
+ insinto /var/lib/${PN} |
342 |
+ doins -r src/${EGO_PN}/server/* |
343 |
+ newinitd "${FILESDIR}"/reg.initd reg |
344 |
+ newconfd "${FILESDIR}"/reg.confd reg |
345 |
+ |
346 |
+ keepdir /var/log/reg |
347 |
+ fowners -R reg:reg /var/log/reg /var/lib/reg/static |
348 |
+} |