Skip to content

Commit d689fa6

Browse files
authored
Merge pull request #257 from devops-works/private_gitlab_repo_support
Private gitlab repo support
2 parents 73f1aaf + c3a5206 commit d689fa6

File tree

11 files changed

+113
-344
lines changed

11 files changed

+113
-344
lines changed

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ To update distributions **and** their versions:
298298
binenv update --all # or -a
299299
```
300300

301-
##### Using custom distributions file
301+
##### Using custom distributions file (and private GitLab repos)
302302

303303
If you want to use a custom distributions file, you can add a `.yaml` file in
304304
the `$XDG_CONFIG` directory (often `~/.config/binenv/`).
@@ -308,6 +308,37 @@ This file will be merged with the default distributions file.
308308
Note that files are evaluated in lexicographical order, so if you want to
309309
override a default, you should name your file accordingly.
310310

311+
You can use this mechanism to install binaries from private GitLab repositories
312+
(GitHub not supported right now). If you need to pass a `PRIVATE-TOKEN` in the
313+
headers, you need to set the `token_env` key in the `list` and `fetch`
314+
sections. This key should contain the name of the environment variable that is
315+
set with the token.
316+
317+
Here is an example file:
318+
319+
```yaml
320+
$ cat ~/.config/binenv/distributions-custom.yaml
321+
---
322+
sources:
323+
foo:
324+
description: This tool let's you foo database tables
325+
url: https://gitlab.exemple.org/infrastructure/tools/foo
326+
list:
327+
type: gitlab-releases
328+
url: https://gitlab.example.org/api/v4/projects/42/releases
329+
token_env: FOO_PRIVATE_TOKEN
330+
fetch:
331+
url: https://gitlab.example.org/api/v4/projects/42/packages/generic/foo/{{ .Version }}/foo-{{.OS }}-{{ .Arch }}-{{ .Version }}.gz
332+
token_env: FOO_PRIVATE_TOKEN
333+
install:
334+
type: gzip
335+
binaries:
336+
- "foo-{{.OS }}-{{ .Arch }}-{{ .Version }}.gz"
337+
```
338+
339+
You will have to `export FOO_PRIVATE_TOKEN=your_token` before running `binenv`
340+
to make the token available.
341+
311342
#### Examples
312343

313344
- `binenv update`: update available versions for all distributions from github
@@ -810,9 +841,6 @@ sudo env "PATH=$PATH" "HOME=$HOME" binary_installed_with_binenv ...
810841
811842
Welcomed !
812843
813-
We will need other installation mechanisms (see
814-
https://github.com/devops-works/binenv/tree/master/internal/install).
815-
816844
Thanks to all contributors:
817845
818846
- @alenzen

cmd/root.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ This is version ` + Version + ` built on ` + BuildDate + `.`,
7878
a.SetCacheDir(cachedir)
7979
}
8080

81-
a.Init()
81+
err = a.Init()
82+
if err != nil {
83+
os.Exit(0)
84+
return err
85+
}
8286

8387
// short circuit ShellCompNoDescRequestCmd handling
8488
// for binaries completion completion handling

cmd/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func updateCmd(a *app.App) *cobra.Command {
1313
)
1414

1515
cmd := &cobra.Command{
16-
Use: "update [--all|--distributions] [--cache]",
16+
Use: "update",
1717
Short: "Update available software distributions",
1818
Long: `Available versions listed distribution will be updated.
1919
If not distribution is specified, versions for all distributions will be updated.`,

0 commit comments

Comments
 (0)