puppet-blacksmith 5.0.0 → 5.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
  SHA256:
3
- metadata.gz: a927a889bdf0cfbd7d704e233b43a6eab265a1388c7374c5d2190807cad807b8
4
- data.tar.gz: 58c976364590d195ef251220e90801560b57433cbf7a65274ad2dbd8b4d30908
3
+ metadata.gz: 305f0506d63f4917fafb2bc2c7a136901dcb00afad6344fb8237c8f9fd49243e
4
+ data.tar.gz: b6a858b2f0a624f0b0f263ffa7dd9040c4c979366a79430addb7d21f5f037f7f
5
5
  SHA512:
6
- metadata.gz: d0f90cd167ebd0d01d1f266795d8602548b0869654a48a98c58fc8c3652c125b9cde78e6041754fb4d3ab58ded58d277f059af8a7cb2f9955ccf2d14ffa2f2c7
7
- data.tar.gz: 39df9eb53e3616be2f47ba972206c09d43928c7bbefb550b6cf167c2332c0a8764405f482bba59b99ee560a063b7ac3a8db295213460e4279d8363566e9541ad
6
+ metadata.gz: 9bfbb91e54799c358123411a37e9aefea96036ea71f4da8c452eaea90f938c5473c0315287c94c3f07e735e4a29452c56a718f7472f6e35b835e39ce3d6a5b0d
7
+ data.tar.gz: bd96a1ce3caabc6841b2e9d57ddff9d642bd418895fa099c147832cf947334c0b6bf4769e128f62619f9d8d13dd0f1542e15f424e690e0aa5fd3b9ae11b34420
@@ -15,12 +15,13 @@ module Blacksmith
15
15
  DEFAULT_CREDENTIALS = { 'url' => PUPPETLABS_FORGE, 'forge_type' => FORGE_TYPE_PUPPET }
16
16
  HEADERS = { 'User-Agent' => "Blacksmith/#{Blacksmith::VERSION} Ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE}; #{RUBY_PLATFORM})" }
17
17
 
18
- attr_accessor :username, :password, :url, :client_id, :client_secret, :forge_type, :token
18
+ attr_accessor :username, :password, :url, :client_id, :client_secret, :forge_type, :token, :api_key
19
19
 
20
- def initialize(username = nil, password = nil, url = nil, forge_type = nil, token = nil)
20
+ def initialize(username = nil, password = nil, url = nil, forge_type = nil, token = nil, api_key = nil)
21
21
  self.username = username
22
22
  self.password = password
23
23
  self.token = token
24
+ self.api_key = api_key
24
25
  RestClient.proxy = ENV['http_proxy']
25
26
  load_credentials
26
27
  load_client_credentials_from_file
@@ -51,14 +52,15 @@ module Blacksmith
51
52
  private
52
53
 
53
54
  def upload(author, name, file)
55
+ url = http_url(author, name, file)
54
56
  case forge_type
55
57
  when FORGE_TYPE_ARTIFACTORY
56
- RestClient::Request.execute(:method => :put, :url => http_url(author, name, file), :payload => File.new(file, 'rb'), :headers => http_headers)
58
+ RestClient::Request.execute(:method => :put, :url => url, :payload => File.new(file, 'rb'), :headers => http_headers)
57
59
  else
58
- RestClient::Request.execute(:method => :post, :url => http_url(author, name, file), :payload => {:file => File.new(file, 'rb')}, :headers => http_headers)
60
+ RestClient::Request.execute(:method => :post, :url => url, :payload => {:file => File.new(file, 'rb')}, :headers => http_headers)
59
61
  end
60
62
  rescue RestClient::Exception => e
61
- raise Blacksmith::Error, "Error uploading #{package} to the forge #{url} [#{e.message}]: #{e.response}"
63
+ raise Blacksmith::Error, "Error uploading #{name} to the forge #{url} [#{e.message}]: #{e.response}"
62
64
  end
63
65
 
64
66
  def http_url(author, name, file)
@@ -73,7 +75,9 @@ module Blacksmith
73
75
  def http_headers
74
76
  case forge_type
75
77
  when FORGE_TYPE_ARTIFACTORY
76
- if token
78
+ if api_key
79
+ HEADERS.merge({'X-JFrog-Art-Api' => api_key})
80
+ elsif token
77
81
  HEADERS.merge({'Authorization' => "Bearer #{token}"})
78
82
  else
79
83
  HEADERS.merge({'Authorization' => "Basic " + Base64.strict_encode64("#{username}:#{password}")})
@@ -109,6 +113,7 @@ module Blacksmith
109
113
  self.username = credentials['username'] if credentials['username']
110
114
  self.password = credentials['password'] if credentials['password']
111
115
  self.token = credentials['token'] if credentials['token']
116
+ self.api_key = credentials['api_key'] if credentials['api_key']
112
117
  if credentials['forge']
113
118
  # deprecated
114
119
  puts "'forge' entry is deprecated in .puppetforge.yml, use 'url'"
@@ -117,7 +122,7 @@ module Blacksmith
117
122
  self.url = credentials['url'] if credentials['url']
118
123
  self.forge_type = credentials['forge_type'] if credentials['forge_type']
119
124
 
120
- unless (self.username && self.password) || self.token
125
+ unless (self.username && self.password) || self.token || self.api_key
121
126
  raise Blacksmith::Error, <<-eos
122
127
  Could not find Puppet Forge credentials!
123
128
 
@@ -127,6 +132,7 @@ BLACKSMITH_FORGE_TYPE
127
132
  BLACKSMITH_FORGE_USERNAME
128
133
  BLACKSMITH_FORGE_PASSWORD
129
134
  BLACKSMITH_FORGE_TOKEN
135
+ BLACKSMITH_FORGE_API_KEY
130
136
 
131
137
  or create the file '#{CREDENTIALS_FILE_PROJECT}' or '#{CREDENTIALS_FILE_HOME}'
132
138
  with content similiar to:
@@ -180,6 +186,10 @@ password: mypassword
180
186
  credentials['token'] = ENV['BLACKSMITH_FORGE_TOKEN']
181
187
  end
182
188
 
189
+ if ENV['BLACKSMITH_FORGE_API_KEY']
190
+ credentials['api_key'] = ENV['BLACKSMITH_FORGE_API_KEY']
191
+ end
192
+
183
193
  return credentials
184
194
  end
185
195
 
@@ -1,3 +1,3 @@
1
1
  module Blacksmith
2
- VERSION = '5.0.0'
2
+ VERSION = '5.1.0'
3
3
  end
@@ -32,6 +32,6 @@ RSpec.shared_context "forge" do
32
32
  File.open(File.join(target, "metadata.json"),"w") do |file|
33
33
  file.write(JSON.pretty_generate(metadata))
34
34
  end
35
- `cd #{target}/..; tar -czf #{module_name}.tar.gz #{module_name}`
35
+ `cd '#{target}/..'; tar -czf #{module_name}.tar.gz #{module_name}`
36
36
  end
37
37
  end
@@ -10,9 +10,9 @@ describe 'Blacksmith::Git' do
10
10
  before do
11
11
  FileUtils.rm_rf path
12
12
  FileUtils.mkdir_p(path)
13
- `git init #{path}`
13
+ `git init '#{path}'`
14
14
  FileUtils.touch(File.join(path, metadata_file))
15
- `cd #{path} && git add #{metadata_file} && git commit -am "Init"`
15
+ `cd '#{path}' && git add #{metadata_file} && git commit -am "Init"`
16
16
  end
17
17
 
18
18
  shared_examples_for :git do
@@ -47,7 +47,7 @@ describe 'Blacksmith::Git' do
47
47
  context 'basic tag' do
48
48
  before { subject.tag!(version) }
49
49
  it "should have the tag" do
50
- out = `cd #{path} && git tag`
50
+ out = `cd '#{path}' && git tag`
51
51
  expect(out.chomp).to match(/^v1.0.0$/)
52
52
  end
53
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-blacksmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MaestroDev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-09-13 00:00:00.000000000 Z
12
+ date: 2020-03-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
@@ -26,7 +26,7 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '2.0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: rake
29
+ name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - ">="
@@ -40,7 +40,7 @@ dependencies:
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
- name: pdk
43
+ name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
@@ -53,6 +53,20 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: pdk
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 1.17.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.17.0
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: puppet
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -154,7 +168,6 @@ files:
154
168
  - lib/puppet_blacksmith/rake_tasks.rb
155
169
  - lib/puppet_blacksmith/version.rb
156
170
  - lib/puppet_blacksmith/version_helper.rb
157
- - spec/data/Modulefile
158
171
  - spec/data/maestrodev-test/metadata.json
159
172
  - spec/data/metadata.json
160
173
  - spec/data/response.json
@@ -195,6 +208,5 @@ test_files:
195
208
  - spec/puppet_blacksmith/forge_spec.rb
196
209
  - spec/spec_helper.rb
197
210
  - spec/data/maestrodev-test/metadata.json
198
- - spec/data/Modulefile
199
211
  - spec/data/response.json
200
212
  - spec/data/metadata.json
@@ -1,9 +0,0 @@
1
- name 'maestrodev-test'
2
- version '1.0.0'
3
-
4
- license 'Apache License, Version 2.0'
5
- project_page 'http://github.com/maestrodev/puppet-blacksmith'
6
- source 'http://github.com/maestrodev/puppet-blacksmith'
7
- summary 'Testing Puppet module operations'
8
- description 'Testing Puppet module operations'
9
- dependency 'puppetlabs/stdlib', '>= 3.0.0'