Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
CiTroNaK committed Jul 24, 2023
1 parent ab72936 commit 6e20daf
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions docs/gemstash-multiple-sources.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ gem "rubywarrior"
source "http://localhost:9292/upstream/#{CGI.escape("https://my.gem-source.local")}" do
gem "my-gem"
end
source "http://localhost:9292/upstream/my-other.gem-source.local" do
gem "my-other-gem"
end
```

Notice the `CGI.escape` call in the second source. This is important, as
Expand All @@ -57,6 +61,53 @@ you want. The `/upstream` prefix tells Gemstash to use a gem source
other than the default source. You can now bundle with the additional
source.

Notice that the third source doesn't need to be escaped.
This is because the `https://` is used by default when no schema is set,
and the source URL does not contain any chars that need to be escaped.

## Authentication with Multiple Sources

You can use basic authentication or API keys on sources directly in Gemfile
or using ENV variables on the Gemstash instance.

Example `Gemfile`:
```ruby
# ./Gemfile
require "cgi"
source "http://localhost:9292"
source "http://localhost:9292/upstream/#{CGI.escape("user:[email protected]")}" do
gem "my-gem"
end
source "http://localhost:9292/upstream/#{CGI.escape("[email protected]")}" do
gem "my-other-gem"
end
```

If you set `GEMSTASH_<HOST>` ENV variable with your authentication information,
you can omit it from the `Gemfile`:

```ruby
# ./Gemfile
source "http://localhost:9292"
source "http://localhost:9292/upstream/my.gem-source.local" do
gem "my-gem"
end
```

And run the Gemstash with the credentials set in an ENV variable:

```bash
GEMSTASH_MY__GEM___SOURCE__LOCAL=user:password gemstash start --no-daemonize --config-file config.yml.erb
```

The name of the ENV variable is the uppercase version of the host name,
with all `.` characters replaced with `__`, all `-` with `___` and a `GEMSTASH_` prefix.

Example: `my.gem-source.local` => `GEMSTASH_MY__GEM___SOURCE__LOCAL`

## Redirecting

Gemstash supports an alternate mode of specifying your gem sources. If
Expand Down

0 comments on commit 6e20daf

Please sign in to comment.