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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d43c453a3985b2f4f66fd7198884c4399ab3a2d7
4
- data.tar.gz: 8799890fdd90141a7c0451376ebe7e41fe41511b
3
+ metadata.gz: 09cee1cf77d66c2acd95ccc0aade3298b17ae53b
4
+ data.tar.gz: d969e171c8534cfa3abea2a67117592dabd31395
5
5
  SHA512:
6
- metadata.gz: 601977f75107f924d31a14f74b820236a6ef3e29c05a4b00f8b6125838515d223dac4566ada0f43b5ab42247fe0f1929134f18e68b96cc85b3d23917482533c9
7
- data.tar.gz: 0260ec708cad578c3c5a4b80d9d345e3d24e91fe51b26dd04762cd7da39279f7b71b29e6579ac5ec58fba64d44fe5d3f269ffc1badbe82a28b46712fe901e001
6
+ metadata.gz: fdc51ac20f18d854801f3bd5da30a8b2edeb1e8aee7e98a0be82386c5713a179941d288d7662609046fcdfacb301577ee7973cb20b89a6a82bfc6dc61a01d6c1
7
+ data.tar.gz: 5c3de75a5a9f187a01bdce013fe6c649379eaf98cdd1f4094c55302dced5c55255ceaa738efff87e9f08e4af95d94399a1526b96263dfd1fceb52404a534edca
@@ -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
@@ -15,5 +15,5 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module PuppetForgeServer
18
- VERSION = '1.0.4'
18
+ VERSION = '1.1.0'
19
19
  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
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-19 00:00:00.000000000 Z
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