gemstash 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/gemstash/man/gemstash-multiple-sources.7 +55 -0
- data/lib/gemstash/man/gemstash-multiple-sources.7.txt +52 -4
- data/lib/gemstash/upstream.rb +33 -2
- data/lib/gemstash/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59ae67f1f26a47d970012c77d909c00420030e41c1322b1d84fdfb30b7ef3ab1
|
4
|
+
data.tar.gz: c015b8c6f1f267b9a3d8ae91303c2bfc651d6414c3680b46190d5ec6717613b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6d53322808129a2644884b3984bc82378a5e79a2e8f1594dddf6662402f1a7e7ff7a31ba2cf907c225e8165fe597046ebd03e93fd8a2ba414d7026a37ef3437
|
7
|
+
data.tar.gz: 3e659be61e8154cd32d560e4745da994fd484f46052fa679f1006c1c2b31edbed882f851d5944d08fc9ade4fbc7ba648392504e39a16d2c4ee6d084e3ff8d324
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 2.5.0 (2023-09-28)
|
2
|
+
|
3
|
+
- Add support for upstream auth with ENV variables ([#339](https://github.com/rubygems/gemstash/pull/339), [@CiTroNaK](https://github.com/CiTroNaK))
|
4
|
+
|
1
5
|
## 2.4.0 (2023-09-27)
|
2
6
|
|
3
7
|
### Changes
|
@@ -8,7 +12,7 @@
|
|
8
12
|
|
9
13
|
### Fixes
|
10
14
|
|
11
|
-
- Require a now-needed file for Puma 6. Thanks, [@ktreis]
|
15
|
+
- Require a now-needed file for Puma 6. Thanks, [@ktreis](https://github.com/ktreis)! ([#362](https://github.com/rubygems/gemstash/pull/362), [@olleolleolle](https://github.com/olleolleolle))
|
12
16
|
|
13
17
|
## 2.3.1 (2023-09-05)
|
14
18
|
|
@@ -49,6 +49,10 @@ gem \[dq]rubywarrior\[dq]
|
|
49
49
|
source \[dq]http://localhost:9292/upstream/#{CGI.escape(\[dq]https://my.gem-source.local\[dq])}\[dq] do
|
50
50
|
gem \[dq]my-gem\[dq]
|
51
51
|
end
|
52
|
+
|
53
|
+
source \[dq]http://localhost:9292/upstream/my-other.gem-source.local\[dq] do
|
54
|
+
gem \[dq]my-other-gem\[dq]
|
55
|
+
end
|
52
56
|
.EE
|
53
57
|
.PP
|
54
58
|
Notice the \f[CR]CGI.escape\f[R] call in the second source.
|
@@ -57,6 +61,57 @@ knows what gem source you want.
|
|
57
61
|
The \f[CR]/upstream\f[R] prefix tells Gemstash to use a gem source other
|
58
62
|
than the default source.
|
59
63
|
You can now bundle with the additional source.
|
64
|
+
.PP
|
65
|
+
Notice that the third source doesn\[cq]t need to be escaped.
|
66
|
+
This is because the \f[CR]https://\f[R] is used by default when no
|
67
|
+
scheme is set, and the source URL does not contain any characters that
|
68
|
+
need to be escaped.
|
69
|
+
.SS Authentication with Multiple Sources
|
70
|
+
You can use basic authentication or API keys on sources directly in
|
71
|
+
Gemfile or using ENV variables on the Gemstash instance.
|
72
|
+
.PP
|
73
|
+
Example \f[CR]Gemfile\f[R]:
|
74
|
+
.IP
|
75
|
+
.EX
|
76
|
+
# ./Gemfile
|
77
|
+
require \[dq]cgi\[dq]
|
78
|
+
source \[dq]http://localhost:9292\[dq]
|
79
|
+
|
80
|
+
source \[dq]http://localhost:9292/upstream/#{CGI.escape(\[dq]user:password\[at]my.gem-source.local\[dq])}\[dq] do
|
81
|
+
gem \[dq]my-gem\[dq]
|
82
|
+
end
|
83
|
+
|
84
|
+
source \[dq]http://localhost:9292/upstream/#{CGI.escape(\[dq]api_key\[at]my-other.gem-source.local\[dq])}\[dq] do
|
85
|
+
gem \[dq]my-other-gem\[dq]
|
86
|
+
end
|
87
|
+
.EE
|
88
|
+
.PP
|
89
|
+
If you set \f[CR]GEMSTASH_<HOST>\f[R] ENV variable with your
|
90
|
+
authentication information, you can omit it from the \f[CR]Gemfile\f[R]:
|
91
|
+
.IP
|
92
|
+
.EX
|
93
|
+
# ./Gemfile
|
94
|
+
source \[dq]http://localhost:9292\[dq]
|
95
|
+
|
96
|
+
source \[dq]http://localhost:9292/upstream/my.gem-source.local\[dq] do
|
97
|
+
gem \[dq]my-gem\[dq]
|
98
|
+
end
|
99
|
+
.EE
|
100
|
+
.PP
|
101
|
+
And run the Gemstash with the credentials set in an ENV variable:
|
102
|
+
.IP
|
103
|
+
.EX
|
104
|
+
GEMSTASH_MY__GEM___SOURCE__LOCAL=user:password gemstash start --no-daemonize --config-file config.yml.erb
|
105
|
+
.EE
|
106
|
+
.PP
|
107
|
+
The name of the ENV variable is the uppercase version of the host name,
|
108
|
+
with all \f[CR].\f[R] characters replaced with \f[CR]__\f[R], all
|
109
|
+
\f[CR]-\f[R] with \f[CR]___\f[R] and a \f[CR]GEMSTASH_\f[R] prefix (it
|
110
|
+
uses the same syntax as
|
111
|
+
Bundler (https://bundler.io/v2.4/man/bundle-config.1.html#CREDENTIALS-FOR-GEM-SOURCES)).
|
112
|
+
.PP
|
113
|
+
Example: \f[CR]my.gem-source.local\f[R] =>
|
114
|
+
\f[CR]GEMSTASH_MY__GEM___SOURCE__LOCAL\f[R]
|
60
115
|
.SS Redirecting
|
61
116
|
Gemstash supports an alternate mode of specifying your gem sources.
|
62
117
|
If you want Gemstash to redirect Bundler to your given gem sources, then
|
@@ -44,15 +44,63 @@
|
|
44
44
|
gem "my-gem"
|
45
45
|
end
|
46
46
|
|
47
|
+
source "http://localhost:9292/upstream/my-other.gem-source.local" do
|
48
|
+
gem "my-other-gem"
|
49
|
+
end
|
50
|
+
|
47
51
|
Notice the CGI.escape call in the second source. This is important, as
|
48
52
|
it properly URL escapes the source URL so Gemstash knows what gem
|
49
53
|
source you want. The /upstream prefix tells Gemstash to use a gem
|
50
54
|
source other than the default source. You can now bundle with the ad-
|
51
55
|
ditional source.
|
52
56
|
|
57
|
+
Notice that the third source doesn't need to be escaped. This is be-
|
58
|
+
cause the https:// is used by default when no scheme is set, and the
|
59
|
+
source URL does not contain any characters that need to be escaped.
|
60
|
+
|
61
|
+
1mAuthentication with Multiple Sources0m
|
62
|
+
You can use basic authentication or API keys on sources directly in
|
63
|
+
Gemfile or using ENV variables on the Gemstash instance.
|
64
|
+
|
65
|
+
Example Gemfile:
|
66
|
+
|
67
|
+
# ./Gemfile
|
68
|
+
require "cgi"
|
69
|
+
source "http://localhost:9292"
|
70
|
+
|
71
|
+
source "http://localhost:9292/upstream/#{CGI.escape("user:password@my.gem-source.local")}" do
|
72
|
+
gem "my-gem"
|
73
|
+
end
|
74
|
+
|
75
|
+
source "http://localhost:9292/upstream/#{CGI.escape("api_key@my-other.gem-source.local")}" do
|
76
|
+
gem "my-other-gem"
|
77
|
+
end
|
78
|
+
|
79
|
+
If you set GEMSTASH_<HOST> ENV variable with your authentication infor-
|
80
|
+
mation, you can omit it from the Gemfile:
|
81
|
+
|
82
|
+
# ./Gemfile
|
83
|
+
source "http://localhost:9292"
|
84
|
+
|
85
|
+
source "http://localhost:9292/upstream/my.gem-source.local" do
|
86
|
+
gem "my-gem"
|
87
|
+
end
|
88
|
+
|
89
|
+
And run the Gemstash with the credentials set in an ENV variable:
|
90
|
+
|
91
|
+
GEMSTASH_MY__GEM___SOURCE__LOCAL=user:password gemstash start --no-daemonize --config-file config.yml.erb
|
92
|
+
|
93
|
+
The name of the ENV variable is the uppercase version of the host name,
|
94
|
+
with all . characters replaced with __, all - with ___ and a GEMSTASH_
|
95
|
+
prefix (it uses the same syntax as Bundler
|
96
|
+
(https://bundler.io/v2.4/man/bundle-config.1.html#CREDENTIALS-FOR-GEM-
|
97
|
+
SOURCES)).
|
98
|
+
|
99
|
+
Example: my.gem-source.local => GEMSTASH_MY__GEM___SOURCE__LOCAL
|
100
|
+
|
53
101
|
1mRedirecting0m
|
54
102
|
Gemstash supports an alternate mode of specifying your gem sources. If
|
55
|
-
you
|
103
|
+
you want Gemstash to redirect Bundler to your given gem sources, then
|
56
104
|
you can specify your Gemfile like so:
|
57
105
|
|
58
106
|
# ./Gemfile
|
@@ -60,9 +108,9 @@
|
|
60
108
|
source "http://localhost:9292/redirect/#{CGI.escape("https://rubygems.org")}"
|
61
109
|
gem "rubywarrior"
|
62
110
|
|
63
|
-
Notice
|
64
|
-
API
|
65
|
-
cached
|
111
|
+
Notice the /redirect prefix. This prefix tells Gemstash to redirect
|
112
|
+
API calls to the provided URL. Redirected calls like this will not be
|
113
|
+
cached by Gemstash, and gem files will not be stashed, even if they
|
66
114
|
were previously cached or stashed from the same gem source.
|
67
115
|
|
68
116
|
October 8, 2015 4mgemstash-multiple-sources24m(7)
|
data/lib/gemstash/upstream.rb
CHANGED
@@ -11,10 +11,12 @@ module Gemstash
|
|
11
11
|
|
12
12
|
attr_reader :user_agent, :uri
|
13
13
|
|
14
|
-
def_delegators :@uri, :scheme, :host, :
|
14
|
+
def_delegators :@uri, :scheme, :host, :to_s
|
15
15
|
|
16
16
|
def initialize(upstream, user_agent: nil)
|
17
|
-
|
17
|
+
url = CGI.unescape(upstream.to_s)
|
18
|
+
url = "https://#{url}" unless %r{^https?://}.match?(url)
|
19
|
+
@uri = URI(url)
|
18
20
|
@user_agent = user_agent
|
19
21
|
raise "URL '#{@uri}' is not valid!" unless @uri.to_s&.match?(URI::DEFAULT_PARSER.make_regexp)
|
20
22
|
end
|
@@ -40,12 +42,41 @@ module Gemstash
|
|
40
42
|
@host_id ||= "#{host}_#{hash}"
|
41
43
|
end
|
42
44
|
|
45
|
+
def user
|
46
|
+
env_auth_user || @uri.user
|
47
|
+
end
|
48
|
+
|
49
|
+
def password
|
50
|
+
env_auth_pass || @uri.password
|
51
|
+
end
|
52
|
+
|
43
53
|
private
|
44
54
|
|
45
55
|
def hash
|
46
56
|
Digest::MD5.hexdigest(to_s)
|
47
57
|
end
|
48
58
|
|
59
|
+
def env_auth_user
|
60
|
+
return unless env_auth
|
61
|
+
|
62
|
+
env_auth.split(":", 2).first
|
63
|
+
end
|
64
|
+
|
65
|
+
def env_auth_pass
|
66
|
+
return unless env_auth
|
67
|
+
return unless env_auth.include?(":")
|
68
|
+
|
69
|
+
env_auth.split(":", 2).last
|
70
|
+
end
|
71
|
+
|
72
|
+
def env_auth
|
73
|
+
@env_auth ||= ENV["GEMSTASH_#{host_for_env}"]
|
74
|
+
end
|
75
|
+
|
76
|
+
def host_for_env
|
77
|
+
host.upcase.gsub(".", "__").gsub("-", "___")
|
78
|
+
end
|
79
|
+
|
49
80
|
# :nodoc:
|
50
81
|
class GemName
|
51
82
|
def initialize(upstream, gem_name)
|
data/lib/gemstash/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemstash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andre Arko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|