puppet-forge-server 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/puppet_forge_server.rb +2 -0
- data/lib/puppet_forge_server/app/generic.rb +44 -0
- data/lib/puppet_forge_server/app/version2.rb +44 -0
- data/lib/puppet_forge_server/backends/directory.rb +7 -0
- data/lib/puppet_forge_server/backends/proxy.rb +5 -0
- data/lib/puppet_forge_server/server.rb +2 -0
- data/lib/puppet_forge_server/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09cee1cf77d66c2acd95ccc0aade3298b17ae53b
|
4
|
+
data.tar.gz: d969e171c8534cfa3abea2a67117592dabd31395
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdc51ac20f18d854801f3bd5da30a8b2edeb1e8aee7e98a0be82386c5713a179941d288d7662609046fcdfacb301577ee7973cb20b89a6a82bfc6dc61a01d6c1
|
7
|
+
data.tar.gz: 5c3de75a5a9f187a01bdce013fe6c649379eaf98cdd1f4094c55302dced5c55255ceaa738efff87e9f08e4af95d94399a1526b96263dfd1fceb52404a534edca
|
data/lib/puppet_forge_server.rb
CHANGED
@@ -34,7 +34,9 @@ module PuppetForgeServer
|
|
34
34
|
end
|
35
35
|
|
36
36
|
module App
|
37
|
+
autoload :Generic, 'puppet_forge_server/app/generic'
|
37
38
|
autoload :Version1, 'puppet_forge_server/app/version1'
|
39
|
+
autoload :Version2, 'puppet_forge_server/app/version2'
|
38
40
|
autoload :Version3, 'puppet_forge_server/app/version3'
|
39
41
|
end
|
40
42
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 North Development AB
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'sinatra/base'
|
18
|
+
|
19
|
+
module PuppetForgeServer::App
|
20
|
+
class Generic < Sinatra::Base
|
21
|
+
|
22
|
+
configure do
|
23
|
+
enable :logging
|
24
|
+
use ::Rack::CommonLogger, PuppetForgeServer::Logger.get(:access)
|
25
|
+
end
|
26
|
+
|
27
|
+
before {
|
28
|
+
env['rack.errors'] = PuppetForgeServer::Logger.get(:server)
|
29
|
+
}
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
super(nil)
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Debug log the received call parameters and return the bogus access token
|
37
|
+
#
|
38
|
+
post '/oauth/token' do
|
39
|
+
PuppetForgeServer::Logger.get(:server).debug "Params: #{params}"
|
40
|
+
{'access_token' => 'BOGUS_ACCESS_TOKEN'}.to_json
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Copyright 2014 North Development AB
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
require 'sinatra/base'
|
18
|
+
|
19
|
+
module PuppetForgeServer::App
|
20
|
+
class Version2 < Sinatra::Base
|
21
|
+
|
22
|
+
configure do
|
23
|
+
enable :logging
|
24
|
+
use ::Rack::CommonLogger, PuppetForgeServer::Logger.get(:access)
|
25
|
+
end
|
26
|
+
|
27
|
+
before {
|
28
|
+
env['rack.errors'] = PuppetForgeServer::Logger.get(:server)
|
29
|
+
}
|
30
|
+
|
31
|
+
def initialize(backends)
|
32
|
+
super(nil)
|
33
|
+
@backends = backends
|
34
|
+
end
|
35
|
+
|
36
|
+
post '/v2/releases' do
|
37
|
+
halt 410, {'errors' => ['File not provided']}.to_json unless params['file']
|
38
|
+
states = @backends.map do |backend|
|
39
|
+
backend.upload(params['file'])
|
40
|
+
end.compact
|
41
|
+
status (states.include?(true) ? 200 : 412)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -43,6 +43,13 @@ module PuppetForgeServer::Backends
|
|
43
43
|
File.open(path, 'r') if File.exist?(path)
|
44
44
|
end
|
45
45
|
|
46
|
+
def upload(file_data)
|
47
|
+
File.open(File.join(@module_dir, file_data[:filename]), 'w') do |f|
|
48
|
+
f.write(file_data[:tempfile].read)
|
49
|
+
end
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
46
53
|
private
|
47
54
|
def read_metadata(archive_path)
|
48
55
|
metadata_file = read_entry(archive_path, %r[[^/]+/metadata\.json$])
|
@@ -47,6 +47,11 @@ module PuppetForgeServer::Backends
|
|
47
47
|
# ignore
|
48
48
|
end
|
49
49
|
|
50
|
+
def upload(file_data)
|
51
|
+
PuppetForgeServer::Logger.get(:server).debug 'File upload is not supported by the proxy backends'
|
52
|
+
false
|
53
|
+
end
|
54
|
+
|
50
55
|
protected
|
51
56
|
def get(relative_url)
|
52
57
|
@http_client.get(url(relative_url))
|
@@ -48,7 +48,9 @@ module PuppetForgeServer
|
|
48
48
|
|
49
49
|
def build(backends)
|
50
50
|
Rack::Mount::RouteSet.new do |set|
|
51
|
+
set.add_route PuppetForgeServer::App::Generic.new
|
51
52
|
set.add_route PuppetForgeServer::App::Version1.new(backends)
|
53
|
+
set.add_route PuppetForgeServer::App::Version2.new(backends)
|
52
54
|
set.add_route PuppetForgeServer::App::Version3.new(backends)
|
53
55
|
end
|
54
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-forge-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilja Bobkevic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -126,7 +126,9 @@ files:
|
|
126
126
|
- lib/puppet_forge_server/api/v1/releases.rb
|
127
127
|
- lib/puppet_forge_server/api/v3/modules.rb
|
128
128
|
- lib/puppet_forge_server/api/v3/releases.rb
|
129
|
+
- lib/puppet_forge_server/app/generic.rb
|
129
130
|
- lib/puppet_forge_server/app/version1.rb
|
131
|
+
- lib/puppet_forge_server/app/version2.rb
|
130
132
|
- lib/puppet_forge_server/app/version3.rb
|
131
133
|
- lib/puppet_forge_server/backends/directory.rb
|
132
134
|
- lib/puppet_forge_server/backends/proxy.rb
|