chef-raketasks 0.1.1 → 0.2.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: a8963f48508e84013f158c64ba8fc6a7c3aba2ba46e145d0de116062c568596d
4
- data.tar.gz: 5875511bc8b8af3b166ccd54e1bb2a43dc425a56b3b07db839650519b7f113f5
3
+ metadata.gz: de3a81f91933796f84623d88036f3a891d4f74e4194cf8f14eeac0243f382a8c
4
+ data.tar.gz: 56da97b647d22b54646b1f4f6710f553631fd48e56aa9acce23d7320bd9c7c34
5
5
  SHA512:
6
- metadata.gz: fc22f529eac3dc4bea1c3dff06d6226e1e06459853467d2ce3572fd0b46d2b824917ed60350b5c51e8eb413009bdfa011b77af0a2df121bfe818b3a7594286a9
7
- data.tar.gz: a72625e0d5d6fe94abb604faadc1645496712c1f63026fc7fdf3e550bf2a5b4273e7d2335025f4276a3cf8993660ef2813c052f647c95afaec92659d4e2730ad
6
+ metadata.gz: 727860aa43b68c056ee435f00b1ad31863e00e895e8a056d5c84cc2a45515a4236d3289aacd82f345424b8f8fcccdc00c1832e2839e7d178a4e2c323cb0e5bfd
7
+ data.tar.gz: 6ad1066f6eccdcbf899ae73307386a087e5626f844c15a7265b6a4482b96db4f9e157688ff9c1824efdc096944a4b91f890ea6aa2789c417f038bb82f7decc63
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.2.0
4
+
5
+ - Add `repin` tasks
6
+ - Fix style
7
+
3
8
  ## Version 0.1.1
4
9
 
5
10
  - Fix missing status badges in readme
data/README.md CHANGED
@@ -25,6 +25,9 @@ Include the Gem via ```require 'chef-raketasks'``` at the top of your
25
25
  Rakefile. After that, just run ```rake -T``` or ```rake --tasks``` to see all
26
26
  available tasks.
27
27
 
28
+ If you start a Rake task with parameters, please assure to not use spaces
29
+ between `[ ]`. This will result in `Don't know how to build task` errors.
30
+
28
31
  ## Cleanup Tasks
29
32
 
30
33
  ### rake clean:chefcache
@@ -109,6 +112,32 @@ It uses the current configured supermarket in your knife.rb or config.rb.
109
112
  Upload to Chef Supermarket.
110
113
  It uses the current configured supermarket in your knife.rb or config.rb.
111
114
 
115
+ ## Repin Tasks
116
+
117
+ ### rake repin:chef-client[gem,version]
118
+
119
+ Allows repinning dependencies in executables delivered with Chef Workstation.
120
+ This is often needed if you do private/prerelease builds of Chef components
121
+ like Kitchen drivers or InSpec plugins.
122
+
123
+ As the Chef installers hard-pin the versions in `/opt/chef-workstation/bin`
124
+ files, this needs the privileges to modify those files as well.
125
+
126
+ * `gem`: name of the dependency
127
+ * `version`: new version to pin
128
+
129
+ ### rake repin:inspec[gem,version]
130
+
131
+ See `repin:chef-client`
132
+
133
+ ### rake repin:kitchen[gem,version]
134
+
135
+ See `repin:chef-client`
136
+
137
+ ### rake repin:ohai[gem,version]
138
+
139
+ See `repin:chef-client`
140
+
112
141
  ## Test Tasks
113
142
 
114
143
  ### rake test:integration:ec2[regexp,action]
@@ -168,7 +197,6 @@ specific file for this task is `.kitchen.vcenter.yml`.
168
197
 
169
198
  Details at <https://github.com/chef/kitchen-vcenter>
170
199
 
171
-
172
200
  ### rake test:lint:cookbook
173
201
 
174
202
  Run linting tests for cookbook in current dir.
@@ -24,6 +24,7 @@ require_relative 'chef/raketasks/doc'
24
24
  require_relative 'chef/raketasks/gem'
25
25
  require_relative 'chef/raketasks/package'
26
26
  require_relative 'chef/raketasks/release'
27
+ require_relative 'chef/raketasks/repin'
27
28
  require_relative 'chef/raketasks/test'
28
29
  require_relative 'chef/raketasks/version'
29
30
 
@@ -21,14 +21,15 @@ module ChefRake
21
21
  include Rake::DSL if defined? Rake::DSL
22
22
  class Clean < ::Rake::TaskLib
23
23
  def initialize
24
+ super
24
25
 
25
26
  namespace :clean do
26
27
  desc 'Removes cache dirs from any local chef installation'
27
28
  task :chefcache do
28
29
  cachedirs = [
29
- ENV['HOME'] + '/.chef/cache',
30
- ENV['HOME'] + '/.chefdk/cache',
31
- ENV['HOME'] + '/.chef-workstation/cache'
30
+ File.join(ENV['HOME'], '.chef/cache'),
31
+ File.join(ENV['HOME'], '.chefdk/cache'),
32
+ File.join(ENV['HOME'], '.chef-workstation/cache')
32
33
  ]
33
34
  cachedirs.each { |f| FileUtils.rm_rf(Dir.glob(f)) }
34
35
  end
@@ -21,6 +21,7 @@ module ChefRake
21
21
  include Rake::DSL if defined? Rake::DSL
22
22
  class Doc < ::Rake::TaskLib
23
23
  def initialize
24
+ super
24
25
 
25
26
  desc 'Generate Ruby documentation'
26
27
  task :doc do
@@ -21,13 +21,14 @@ module ChefRake
21
21
  include Rake::DSL if defined? Rake::DSL
22
22
  class Gem < ::Rake::TaskLib
23
23
  def initialize
24
+ super
24
25
 
25
26
  namespace :gem do
26
27
  desc 'gem:install'
27
28
  namespace :install do
28
29
  def install_gem(name, version, source)
29
30
  cmd = 'chef gem install '
30
- cmd << name + ' '
31
+ cmd << "#{name} "
31
32
  cmd << "-v #{version} " unless version.nil?
32
33
  cmd << "-s #{source} " unless source.nil?
33
34
  cmd << '--no-document'
@@ -22,6 +22,7 @@ module ChefRake
22
22
  include Rake::DSL if defined? Rake::DSL
23
23
  class Package < ::Rake::TaskLib
24
24
  def initialize
25
+ super
25
26
 
26
27
  namespace :package do
27
28
  desc 'Package cookbook as .tgz file'
@@ -64,13 +65,13 @@ module ChefRake
64
65
  abs_path = File.join(current_dir, pkg_rel_path)
65
66
 
66
67
  Dir.mkdir(pkg_path) unless Dir.exist?(pkg_path)
67
- Dir.mkdir(ENV['HOME'] + '/.inspec/cache') unless Dir.exist?(ENV['HOME'] + '/.inspec/cache')
68
+ Dir.mkdir File.join(ENV['HOME'], '.inspec/cache') unless Dir.exist? File.join(ENV['HOME'], '.inspec/cache')
68
69
 
69
70
  cmd = Train.create('local', command_runner: :generic).connection
70
71
  command = 'inspec'
71
- command << ' archive ' + current_dir
72
+ command << " archive #{current_dir}"
72
73
  command << ' --overwrite'
73
- command << ' --output ' + abs_path
74
+ command << " --output #{abs_path}"
74
75
  # command << ' --vendor-cache=' + ENV['HOME'] + "/.inspec/cache" # looks like this has an error in main code
75
76
 
76
77
  puts command
@@ -21,6 +21,7 @@ module ChefRake
21
21
  include Rake::DSL if defined? Rake::DSL
22
22
  class Release < ::Rake::TaskLib
23
23
  def initialize
24
+ super
24
25
 
25
26
  namespace :release do
26
27
  desc 'Upload to Artifactory'
@@ -38,7 +39,7 @@ module ChefRake
38
39
  require 'artifactory'
39
40
  Artifactory.endpoint = args.endpoint # @TODO: Remove trailing slash, if exist
40
41
  Artifactory.api_key = args.apikey
41
- targetpath = args.path + '/' + file_name
42
+ targetpath = File.join(args.path, file_name)
42
43
 
43
44
  artifact = Artifactory::Resource::Artifact.new(local_path: abs_path)
44
45
  upload = artifact.upload(args.repokey, targetpath)
@@ -0,0 +1,71 @@
1
+ #
2
+ # Author:: Thomas Heinen (<theinen@tecracer.de>)
3
+ # Copyright:: Copyright 2020, tecRacer Group
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ module ChefRake
20
+ module Task
21
+ include Rake::DSL if defined? Rake::DSL
22
+ class Repin < ::Rake::TaskLib
23
+ def initialize
24
+ super
25
+
26
+ namespace :repin do
27
+ desc 'Repin hard dependencies in Chef Workstation binaries'
28
+
29
+ %w[chef-client kitchen inspec ohai].each do |binary|
30
+ next unless File.exist? binary_wrapper(binary)
31
+
32
+ desc "Repin #{binary} dependency to a specific gem"
33
+ task binary.to_sym, [:gem, :version] do |_task, args|
34
+ task_repin binary, args.gem, args.version
35
+ end
36
+ end
37
+ end # namespace repin
38
+ end # def initialize
39
+
40
+ def task_repin(name, gem, version)
41
+ read binary_wrapper(name)
42
+ repin gem, version
43
+ write_back
44
+ end
45
+
46
+ def binary_wrapper(name)
47
+ File.join('/opt/chef-workstation/bin', name)
48
+ end
49
+
50
+ def read(filename)
51
+ @contents = File.read(filename)
52
+ @filename = filename
53
+ end
54
+
55
+ def repin(gem, version)
56
+ printf("Changing version pin of %<gem>s to %<version>s for %<binary>s\n",
57
+ gem: gem,
58
+ version: version,
59
+ binary: @filename)
60
+
61
+ @contents.gsub!(/(?<=#{gem}"), "= [.0-9]+"/, ", \"= #{version}\"")
62
+ end
63
+
64
+ def write_back
65
+ File.write(@filename, @contents)
66
+ end
67
+ end # class Repin
68
+ end # module RakeTasks
69
+ end # module Chef
70
+
71
+ ChefRake::Task::Repin.new
@@ -22,6 +22,7 @@ module ChefRake
22
22
  include Rake::DSL if defined? Rake::DSL
23
23
  class Test < ::Rake::TaskLib
24
24
  def initialize
25
+ super
25
26
 
26
27
  namespace :test do
27
28
  desc 'Run all integration tests'
@@ -18,6 +18,6 @@
18
18
 
19
19
  module ChefRake
20
20
  module Task
21
- VERSION = '0.1.1'.freeze
21
+ VERSION = '0.2.0'.freeze
22
22
  end
23
23
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-raketasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Schaumburg
8
+ - Thomas Heinen
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2020-04-17 00:00:00.000000000 Z
12
+ date: 2020-11-03 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: mdl
@@ -94,6 +95,20 @@ dependencies:
94
95
  - - "~>"
95
96
  - !ruby/object:Gem::Version
96
97
  version: '3.9'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rubocop
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '1.1'
105
+ type: :runtime
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '1.1'
97
112
  - !ruby/object:Gem::Dependency
98
113
  name: yard
99
114
  requirement: !ruby/object:Gem::Requirement
@@ -111,6 +126,7 @@ dependencies:
111
126
  description: Provides a central repository of the most essential tasks
112
127
  email:
113
128
  - pschaumburg@tecracer.de
129
+ - theinen@tecracer.de
114
130
  executables: []
115
131
  extensions: []
116
132
  extra_rdoc_files: []
@@ -123,6 +139,7 @@ files:
123
139
  - lib/chef/raketasks/gem.rb
124
140
  - lib/chef/raketasks/package.rb
125
141
  - lib/chef/raketasks/release.rb
142
+ - lib/chef/raketasks/repin.rb
126
143
  - lib/chef/raketasks/test.rb
127
144
  - lib/chef/raketasks/version.rb
128
145
  homepage: https://www.tecracer.de