Skip to content

Commit

Permalink
Merge pull request #257 from devops-works/private_gitlab_repo_support
Browse files Browse the repository at this point in the history
Private gitlab repo support
  • Loading branch information
leucos authored Jul 17, 2024
2 parents 73f1aaf + c3a5206 commit d689fa6
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 344 deletions.
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ To update distributions **and** their versions:
binenv update --all # or -a
```

##### Using custom distributions file
##### Using custom distributions file (and private GitLab repos)

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

You can use this mechanism to install binaries from private GitLab repositories
(GitHub not supported right now). If you need to pass a `PRIVATE-TOKEN` in the
headers, you need to set the `token_env` key in the `list` and `fetch`
sections. This key should contain the name of the environment variable that is
set with the token.

Here is an example file:

```yaml
$ cat ~/.config/binenv/distributions-custom.yaml
---
sources:
foo:
description: This tool let's you foo database tables
url: https://gitlab.exemple.org/infrastructure/tools/foo
list:
type: gitlab-releases
url: https://gitlab.example.org/api/v4/projects/42/releases
token_env: FOO_PRIVATE_TOKEN
fetch:
url: https://gitlab.example.org/api/v4/projects/42/packages/generic/foo/{{ .Version }}/foo-{{.OS }}-{{ .Arch }}-{{ .Version }}.gz
token_env: FOO_PRIVATE_TOKEN
install:
type: gzip
binaries:
- "foo-{{.OS }}-{{ .Arch }}-{{ .Version }}.gz"
```
You will have to `export FOO_PRIVATE_TOKEN=your_token` before running `binenv`
to make the token available.

#### Examples

- `binenv update`: update available versions for all distributions from github
Expand Down Expand Up @@ -810,9 +841,6 @@ sudo env "PATH=$PATH" "HOME=$HOME" binary_installed_with_binenv ...
Welcomed !
We will need other installation mechanisms (see
https://github.com/devops-works/binenv/tree/master/internal/install).
Thanks to all contributors:
- @alenzen
Expand Down
6 changes: 5 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ This is version ` + Version + ` built on ` + BuildDate + `.`,
a.SetCacheDir(cachedir)
}

a.Init()
err = a.Init()
if err != nil {
os.Exit(0)
return err
}

// short circuit ShellCompNoDescRequestCmd handling
// for binaries completion completion handling
Expand Down
2 changes: 1 addition & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func updateCmd(a *app.App) *cobra.Command {
)

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

0 comments on commit d689fa6

Please sign in to comment.