gemstash 2.4.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/lib/gemstash/configuration.rb +5 -0
- 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: 69af5c3ee89fc53cee466750fcf2f0028e48da55c97ec1e088ce57115982e0fd
|
4
|
+
data.tar.gz: 548acfcde803f83ef757218d414a8d88677af45b9e60164bcaffd178adeb86b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8eb6be20540527c746f5d9a02d2f170549e8764ad182a834384a4f63edd62ea373b5113256a89c250524c4551a02d792c8eb0e88d3a860f1337add8548bec0e
|
7
|
+
data.tar.gz: d35028447a52b25de004572ce975f6dff4d2cd358e54f72c537edb29e85dba43682f9c313f8b94461a3fcd7b3e9be089593fdba29fde039f664d7cebb1d11580
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 2.6.0 (2023-09-30)
|
2
|
+
|
3
|
+
### Changes
|
4
|
+
|
5
|
+
- Support `GEMSTASH_CONFIG` environment variable ([#369](https://github.com/rubygems/gemstash/pull/369), [@kyrofa](https://github.com/kyrofa))
|
6
|
+
|
7
|
+
## 2.5.0 (2023-09-28)
|
8
|
+
|
9
|
+
### Changes
|
10
|
+
|
11
|
+
- Add support for upstream auth with ENV variables ([#339](https://github.com/rubygems/gemstash/pull/339), [@CiTroNaK](https://github.com/CiTroNaK))
|
12
|
+
|
1
13
|
## 2.4.0 (2023-09-27)
|
2
14
|
|
3
15
|
### Changes
|
@@ -8,7 +20,7 @@
|
|
8
20
|
|
9
21
|
### Fixes
|
10
22
|
|
11
|
-
- Require a now-needed file for Puma 6. Thanks, [@ktreis]
|
23
|
+
- 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
24
|
|
13
25
|
## 2.3.1 (2023-09-05)
|
14
26
|
|
@@ -75,6 +75,11 @@ module Gemstash
|
|
75
75
|
private
|
76
76
|
|
77
77
|
def default_file
|
78
|
+
# Support the config file being specified via environment variable
|
79
|
+
gemstash_config = ENV["GEMSTASH_CONFIG"]
|
80
|
+
return gemstash_config if gemstash_config
|
81
|
+
|
82
|
+
# If no environment variable is used, fall back to the normal defaults
|
78
83
|
File.exist?("#{DEFAULT_FILE}.erb") ? "#{DEFAULT_FILE}.erb" : DEFAULT_FILE
|
79
84
|
end
|
80
85
|
|
@@ -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.6.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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|