chef-zero-scheduled-task 0.0.12 → 0.1.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/.cane +7 -7
- data/.gitignore +15 -15
- data/.rubocop.yml +3 -3
- data/.yardopts +3 -3
- data/Gemfile +15 -15
- data/README.md +39 -39
- data/Rakefile +67 -67
- data/chef-zero-scheduled-task.gemspec +46 -46
- data/lib/chef/zero/scheduled/task/version.rb +9 -9
- data/lib/kitchen/provisioner/chef_zero_scheduled_task.rb +175 -170
- data/spec/kitchen/provisioner/chef_zero_scheduled_task_spec.rb +88 -88
- data/spec/spec_helper.rb +85 -85
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f3acb420f410d9de9998ce1f84dd1d5d5bcf5f8
|
4
|
+
data.tar.gz: 50e9cd3b55afc6e3f9b8173cb2311e60c72f58ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee8f18aa97189e76f91cbe126c3d52969e941c7ee3279c8285a8137b5654008cf5136b320769ad5439ec6388adce7b957aaf231242bd7360fec5de37d558ddb5
|
7
|
+
data.tar.gz: a51c76a51764c6fe3c6f8934613d55676a8314170565d1c270e891a72c47a8a4f01af2705f6f0be4f05ecea96d54a4284f6488537f206fa68bb853a12ac36a57
|
data/.cane
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
--abc-max 20
|
2
|
-
--style-measure 100
|
3
|
-
--abc-exclude Kitchen::ThorTasks#define
|
4
|
-
--abc-exclude Kitchen::Driver::SSHBase#converge
|
5
|
-
--abc-exclude Kitchen::Driver::SSHBase#verify
|
6
|
-
--style-exclude lib/vendor/**/*.rb
|
7
|
-
--doc-exclude lib/vendor/**/.rb
|
1
|
+
--abc-max 20
|
2
|
+
--style-measure 100
|
3
|
+
--abc-exclude Kitchen::ThorTasks#define
|
4
|
+
--abc-exclude Kitchen::Driver::SSHBase#converge
|
5
|
+
--abc-exclude Kitchen::Driver::SSHBase#verify
|
6
|
+
--style-exclude lib/vendor/**/*.rb
|
7
|
+
--doc-exclude lib/vendor/**/.rb
|
data/.gitignore
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/Gemfile.lock
|
4
|
-
/_yardoc/
|
5
|
-
/coverage/
|
6
|
-
/doc/
|
7
|
-
/pkg/
|
8
|
-
/spec/reports/
|
9
|
-
/tmp/
|
10
|
-
*.bundle
|
11
|
-
*.so
|
12
|
-
*.o
|
13
|
-
*.a
|
14
|
-
mkmf.log
|
15
|
-
*.swp
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/Gemfile.lock
|
4
|
+
/_yardoc/
|
5
|
+
/coverage/
|
6
|
+
/doc/
|
7
|
+
/pkg/
|
8
|
+
/spec/reports/
|
9
|
+
/tmp/
|
10
|
+
*.bundle
|
11
|
+
*.so
|
12
|
+
*.o
|
13
|
+
*.a
|
14
|
+
mkmf.log
|
15
|
+
*.swp
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
Style/FileName:
|
2
|
-
Exclude:
|
3
|
-
- 'support/**/*'
|
1
|
+
Style/FileName:
|
2
|
+
Exclude:
|
3
|
+
- 'support/**/*'
|
data/.yardopts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
--readme README.md
|
2
|
-
--markup markdown
|
3
|
-
--markup-provider maruku
|
1
|
+
--readme README.md
|
2
|
+
--markup markdown
|
3
|
+
--markup-provider maruku
|
data/Gemfile
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
# Specify your gem's dependencies in chef-zero-scheduled-task.gemspec
|
4
|
-
gemspec
|
5
|
-
|
6
|
-
group :guard do
|
7
|
-
gem "guard-minitest"
|
8
|
-
gem "guard-cucumber", "~> 1.4"
|
9
|
-
gem "guard-rubocop"
|
10
|
-
gem "guard-yard"
|
11
|
-
end
|
12
|
-
|
13
|
-
group :test do
|
14
|
-
gem "codeclimate-test-reporter", :require => nil
|
15
|
-
end
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in chef-zero-scheduled-task.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :guard do
|
7
|
+
gem "guard-minitest"
|
8
|
+
gem "guard-cucumber", "~> 1.4"
|
9
|
+
gem "guard-rubocop"
|
10
|
+
gem "guard-yard"
|
11
|
+
end
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem "codeclimate-test-reporter", :require => nil
|
15
|
+
end
|
data/README.md
CHANGED
@@ -1,39 +1,39 @@
|
|
1
|
-
[](http://badge.fury.io/rb/chef-zero-scheduled-task)
|
2
|
-
# Chef::Zero::Scheduled::Task
|
3
|
-
|
4
|
-
## Installation
|
5
|
-
|
6
|
-
Add this line to your application's Gemfile:
|
7
|
-
|
8
|
-
```ruby
|
9
|
-
gem 'chef-zero-scheduled-task'
|
10
|
-
```
|
11
|
-
|
12
|
-
And then execute:
|
13
|
-
|
14
|
-
$ bundle
|
15
|
-
|
16
|
-
Or install it yourself as:
|
17
|
-
|
18
|
-
$ gem install chef-zero-scheduled-task
|
19
|
-
|
20
|
-
## Usage
|
21
|
-
|
22
|
-
In the .kitchen.yml
|
23
|
-
```
|
24
|
-
provisioner:
|
25
|
-
name: chef_zero_scheduled_task
|
26
|
-
```
|
27
|
-
|
28
|
-
This provisioner uses all the same configuration options as the native chef-zero provisioner, as well as:
|
29
|
-
|
30
|
-
* task_username - user account the scheduled task should run under. (defaults to the username used for the transport)
|
31
|
-
* task_password - password to use to create the scheduled task. (defaults to the password used for the transport)
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
1. Fork it ( https://github.com/[my-github-username]/chef-zero-scheduled-task/fork )
|
36
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
-
5. Create a new Pull Request
|
1
|
+
[](http://badge.fury.io/rb/chef-zero-scheduled-task)
|
2
|
+
# Chef::Zero::Scheduled::Task
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Add this line to your application's Gemfile:
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
gem 'chef-zero-scheduled-task'
|
10
|
+
```
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install chef-zero-scheduled-task
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
In the .kitchen.yml
|
23
|
+
```
|
24
|
+
provisioner:
|
25
|
+
name: chef_zero_scheduled_task
|
26
|
+
```
|
27
|
+
|
28
|
+
This provisioner uses all the same configuration options as the native chef-zero provisioner, as well as:
|
29
|
+
|
30
|
+
* task_username - user account the scheduled task should run under. (defaults to the username used for the transport)
|
31
|
+
* task_password - password to use to create the scheduled task. (defaults to the password used for the transport)
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/chef-zero-scheduled-task/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
CHANGED
@@ -1,67 +1,67 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
require "bundler/gem_tasks"
|
4
|
-
|
5
|
-
require "rake/testtask"
|
6
|
-
Rake::TestTask.new(:unit) do |t|
|
7
|
-
t.libs.push "lib"
|
8
|
-
t.test_files = FileList["spec/**/*_spec.rb"]
|
9
|
-
t.verbose = true
|
10
|
-
end
|
11
|
-
|
12
|
-
require "cucumber"
|
13
|
-
require "cucumber/rake/task"
|
14
|
-
Cucumber::Rake::Task.new(:features) do |t|
|
15
|
-
t.cucumber_opts = ["features", "-x", "--format progress", "--no-color"]
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "Run all test suites"
|
19
|
-
task :test => [:unit] # [:unit, :features]
|
20
|
-
|
21
|
-
desc "Display LOC stats"
|
22
|
-
task :stats do
|
23
|
-
puts "\n## Production Code Stats"
|
24
|
-
sh "countloc -r lib/kitchen lib/kitchen.rb"
|
25
|
-
puts "\n## Test Code Stats"
|
26
|
-
sh "countloc -r spec features"
|
27
|
-
end
|
28
|
-
|
29
|
-
require "finstyle"
|
30
|
-
require "rubocop/rake_task"
|
31
|
-
RuboCop::RakeTask.new(:style) do |task|
|
32
|
-
task.options += ["--display-cop-names", "--no-color"]
|
33
|
-
end
|
34
|
-
|
35
|
-
if RUBY_ENGINE != "jruby"
|
36
|
-
require "cane/rake_task"
|
37
|
-
desc "Run cane to check quality metrics"
|
38
|
-
Cane::RakeTask.new do |cane|
|
39
|
-
cane.canefile = "./.cane"
|
40
|
-
end
|
41
|
-
|
42
|
-
desc "Run all quality tasks"
|
43
|
-
task :quality => [:cane, :style, :stats]
|
44
|
-
else
|
45
|
-
desc "Run all quality tasks"
|
46
|
-
task :quality => [:style, :stats]
|
47
|
-
end
|
48
|
-
|
49
|
-
require "yard"
|
50
|
-
YARD::Rake::YardocTask.new
|
51
|
-
|
52
|
-
task :default => [:test, :quality]
|
53
|
-
|
54
|
-
task :deploy_over_dk do
|
55
|
-
if RUBY_PLATFORM =~ /mswin|mingw|windows/
|
56
|
-
dk_path = File.join(ENV["SYSTEMDRIVE"], "opscode", "chefdk")
|
57
|
-
else
|
58
|
-
dk_path = "/opt/chefdk"
|
59
|
-
end
|
60
|
-
|
61
|
-
dk_app_path = File.join(dk_path, %w[embedded apps test-kitchen])
|
62
|
-
FileUtils.copy_entry(File.dirname(__FILE__), dk_app_path)
|
63
|
-
git_dir = File.join(dk_app_path, ".git")
|
64
|
-
FileUtils.rm_rf(git_dir) if Dir.exist?(git_dir)
|
65
|
-
end
|
66
|
-
|
67
|
-
task :dk_install => [:deploy_over_dk, :install]
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
|
5
|
+
require "rake/testtask"
|
6
|
+
Rake::TestTask.new(:unit) do |t|
|
7
|
+
t.libs.push "lib"
|
8
|
+
t.test_files = FileList["spec/**/*_spec.rb"]
|
9
|
+
t.verbose = true
|
10
|
+
end
|
11
|
+
|
12
|
+
require "cucumber"
|
13
|
+
require "cucumber/rake/task"
|
14
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
15
|
+
t.cucumber_opts = ["features", "-x", "--format progress", "--no-color"]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run all test suites"
|
19
|
+
task :test => [:unit] # [:unit, :features]
|
20
|
+
|
21
|
+
desc "Display LOC stats"
|
22
|
+
task :stats do
|
23
|
+
puts "\n## Production Code Stats"
|
24
|
+
sh "countloc -r lib/kitchen lib/kitchen.rb"
|
25
|
+
puts "\n## Test Code Stats"
|
26
|
+
sh "countloc -r spec features"
|
27
|
+
end
|
28
|
+
|
29
|
+
require "finstyle"
|
30
|
+
require "rubocop/rake_task"
|
31
|
+
RuboCop::RakeTask.new(:style) do |task|
|
32
|
+
task.options += ["--display-cop-names", "--no-color"]
|
33
|
+
end
|
34
|
+
|
35
|
+
if RUBY_ENGINE != "jruby"
|
36
|
+
require "cane/rake_task"
|
37
|
+
desc "Run cane to check quality metrics"
|
38
|
+
Cane::RakeTask.new do |cane|
|
39
|
+
cane.canefile = "./.cane"
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Run all quality tasks"
|
43
|
+
task :quality => [:cane, :style, :stats]
|
44
|
+
else
|
45
|
+
desc "Run all quality tasks"
|
46
|
+
task :quality => [:style, :stats]
|
47
|
+
end
|
48
|
+
|
49
|
+
require "yard"
|
50
|
+
YARD::Rake::YardocTask.new
|
51
|
+
|
52
|
+
task :default => [:test, :quality]
|
53
|
+
|
54
|
+
task :deploy_over_dk do
|
55
|
+
if RUBY_PLATFORM =~ /mswin|mingw|windows/
|
56
|
+
dk_path = File.join(ENV["SYSTEMDRIVE"], "opscode", "chefdk")
|
57
|
+
else
|
58
|
+
dk_path = "/opt/chefdk"
|
59
|
+
end
|
60
|
+
|
61
|
+
dk_app_path = File.join(dk_path, %w[embedded apps test-kitchen])
|
62
|
+
FileUtils.copy_entry(File.dirname(__FILE__), dk_app_path)
|
63
|
+
git_dir = File.join(dk_app_path, ".git")
|
64
|
+
FileUtils.rm_rf(git_dir) if Dir.exist?(git_dir)
|
65
|
+
end
|
66
|
+
|
67
|
+
task :dk_install => [:deploy_over_dk, :install]
|
@@ -1,46 +1,46 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
lib = File.expand_path("../lib", __FILE__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require "chef/zero/scheduled/task/version"
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = "chef-zero-scheduled-task"
|
9
|
-
spec.version = Chef::Zero::Scheduled::Task::VERSION
|
10
|
-
spec.authors = ["Steven Murawski"]
|
11
|
-
spec.email = ["steven.murawski@gmail.com"]
|
12
|
-
spec.summary = "Test-Kitchen Provisioner that runs Chef Zero in a Scheduled Task"
|
13
|
-
spec.description = "Test-Kitchen Provisioner that runs Chef Zero in a Scheduled Task"
|
14
|
-
spec.homepage = "https://github.com/smurawski/chef-zero-scheduled-task"
|
15
|
-
spec.license = "Apache 2"
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0")
|
18
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
-
spec.require_paths = ["lib"]
|
21
|
-
|
22
|
-
spec.add_dependency "test-kitchen", "~> 1.4"
|
23
|
-
|
24
|
-
spec.add_development_dependency "pry"
|
25
|
-
spec.add_development_dependency "winrm-transport", "~> 1.0"
|
26
|
-
|
27
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
28
|
-
spec.add_development_dependency "rake"
|
29
|
-
|
30
|
-
spec.add_development_dependency "aruba", "~> 0.7.0"
|
31
|
-
spec.add_development_dependency "fakefs", "~> 0.4"
|
32
|
-
spec.add_development_dependency "minitest", "~> 5.3"
|
33
|
-
spec.add_development_dependency "mocha", "~> 1.1"
|
34
|
-
|
35
|
-
spec.add_development_dependency "countloc", "~> 0.4"
|
36
|
-
spec.add_development_dependency "maruku", "~> 0.6"
|
37
|
-
spec.add_development_dependency "simplecov", "~> 0.7"
|
38
|
-
spec.add_development_dependency "yard", "~> 0.8"
|
39
|
-
|
40
|
-
# style and complexity libraries are tightly version pinned as newer releases
|
41
|
-
# may introduce new and undesireable style choices which would be immediately
|
42
|
-
# enforced in CI
|
43
|
-
spec.add_development_dependency "finstyle", "1.5.0"
|
44
|
-
spec.add_development_dependency "cane", "2.6.2"
|
45
|
-
|
46
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "chef/zero/scheduled/task/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "chef-zero-scheduled-task"
|
9
|
+
spec.version = Chef::Zero::Scheduled::Task::VERSION
|
10
|
+
spec.authors = ["Steven Murawski"]
|
11
|
+
spec.email = ["steven.murawski@gmail.com"]
|
12
|
+
spec.summary = "Test-Kitchen Provisioner that runs Chef Zero in a Scheduled Task"
|
13
|
+
spec.description = "Test-Kitchen Provisioner that runs Chef Zero in a Scheduled Task"
|
14
|
+
spec.homepage = "https://github.com/smurawski/chef-zero-scheduled-task"
|
15
|
+
spec.license = "Apache 2"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "test-kitchen", "~> 1.4"
|
23
|
+
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
spec.add_development_dependency "winrm-transport", "~> 1.0"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
|
30
|
+
spec.add_development_dependency "aruba", "~> 0.7.0"
|
31
|
+
spec.add_development_dependency "fakefs", "~> 0.4"
|
32
|
+
spec.add_development_dependency "minitest", "~> 5.3"
|
33
|
+
spec.add_development_dependency "mocha", "~> 1.1"
|
34
|
+
|
35
|
+
spec.add_development_dependency "countloc", "~> 0.4"
|
36
|
+
spec.add_development_dependency "maruku", "~> 0.6"
|
37
|
+
spec.add_development_dependency "simplecov", "~> 0.7"
|
38
|
+
spec.add_development_dependency "yard", "~> 0.8"
|
39
|
+
|
40
|
+
# style and complexity libraries are tightly version pinned as newer releases
|
41
|
+
# may introduce new and undesireable style choices which would be immediately
|
42
|
+
# enforced in CI
|
43
|
+
spec.add_development_dependency "finstyle", "1.5.0"
|
44
|
+
spec.add_development_dependency "cane", "2.6.2"
|
45
|
+
|
46
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module Chef
|
2
|
-
module Zero
|
3
|
-
module Scheduled
|
4
|
-
module Task
|
5
|
-
VERSION = "0.0
|
6
|
-
end
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module Chef
|
2
|
+
module Zero
|
3
|
+
module Scheduled
|
4
|
+
module Task
|
5
|
+
VERSION = "0.1.0"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -1,170 +1,175 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Author:: Steven Murawski (<smurawski@chef.io>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2015, Chef Software
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
|
19
|
-
require "kitchen/provisioner/chef_zero"
|
20
|
-
|
21
|
-
module Kitchen
|
22
|
-
module Provisioner
|
23
|
-
# Chef Zero provisioner to run in scheduled task on Windows
|
24
|
-
class ChefZeroScheduledTask < ChefZero
|
25
|
-
kitchen_provisioner_api_version 2
|
26
|
-
|
27
|
-
plugin_version Kitchen::VERSION
|
28
|
-
|
29
|
-
default_config :task_username
|
30
|
-
|
31
|
-
default_config :task_password
|
32
|
-
|
33
|
-
def init_command
|
34
|
-
if windows_os?
|
35
|
-
info("Creating the scheduled task.")
|
36
|
-
wrap_shell_code("#{super}\n#{setup_scheduled_task_command}")
|
37
|
-
else
|
38
|
-
super
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def run_command
|
43
|
-
if windows_os?
|
44
|
-
script =
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
$
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
"/
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
def
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
def
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Steven Murawski (<smurawski@chef.io>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2015, Chef Software
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require "kitchen/provisioner/chef_zero"
|
20
|
+
|
21
|
+
module Kitchen
|
22
|
+
module Provisioner
|
23
|
+
# Chef Zero provisioner to run in scheduled task on Windows
|
24
|
+
class ChefZeroScheduledTask < ChefZero
|
25
|
+
kitchen_provisioner_api_version 2
|
26
|
+
|
27
|
+
plugin_version Kitchen::VERSION
|
28
|
+
|
29
|
+
default_config :task_username
|
30
|
+
|
31
|
+
default_config :task_password
|
32
|
+
|
33
|
+
def init_command
|
34
|
+
if windows_os?
|
35
|
+
info("Creating the scheduled task.")
|
36
|
+
wrap_shell_code("#{super}\n#{setup_scheduled_task_command}")
|
37
|
+
else
|
38
|
+
super
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def run_command
|
43
|
+
if windows_os?
|
44
|
+
script = <<-EOH
|
45
|
+
$script = @'\n#{scheduled_task_command_script}\n'@
|
46
|
+
$ExecutionContext.InvokeCommand.ExpandString($Script) |
|
47
|
+
out-file "$env:temp/kitchen/chef-client-script.ps1"
|
48
|
+
#{run_scheduled_task_command}
|
49
|
+
EOH
|
50
|
+
wrap_shell_code(script)
|
51
|
+
else
|
52
|
+
super
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# private
|
57
|
+
|
58
|
+
def local_state_file
|
59
|
+
@local_state_file ||= @instance.diagnose[:state_file]
|
60
|
+
end
|
61
|
+
|
62
|
+
def task_username
|
63
|
+
if config[:task_username]
|
64
|
+
config[:task_username]
|
65
|
+
else
|
66
|
+
if local_state_file.key?(:username)
|
67
|
+
local_state_file[:username]
|
68
|
+
else
|
69
|
+
@instance.transport[:username]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def task_password
|
75
|
+
unless config[:task_password]
|
76
|
+
if local_state_file.key?(:password)
|
77
|
+
local_state_file[:password]
|
78
|
+
else
|
79
|
+
@instance.transport[:password]
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# rubocop:disable MethodLength
|
85
|
+
def run_scheduled_task_command
|
86
|
+
<<-EOH
|
87
|
+
try {
|
88
|
+
Add-Type -AssemblyName System.Core
|
89
|
+
$npipeServer = new-object System.IO.Pipes.NamedPipeServerStream('task',
|
90
|
+
[System.IO.Pipes.PipeDirection]::In)
|
91
|
+
$pipeReader = new-object System.IO.StreamReader($npipeServer)
|
92
|
+
schtasks /run /tn "chef-tk" /i
|
93
|
+
$npipeserver.waitforconnection()
|
94
|
+
$host.ui.writeline('Connected to the scheduled task.')
|
95
|
+
while ($npipeserver.IsConnected) {
|
96
|
+
$output = $pipereader.ReadLine()
|
97
|
+
if ($output -like 'SCHEDULED_TASK_DONE:*') {
|
98
|
+
$exit_code = ($output -replace 'SCHEDULED_TASK_DONE:').trim()
|
99
|
+
}
|
100
|
+
else { $host.ui.WriteLine($output) } } }
|
101
|
+
finally {
|
102
|
+
$pipereader.dispose()
|
103
|
+
$npipeserver.dispose()
|
104
|
+
$host.setshouldexit($exit_code)
|
105
|
+
}
|
106
|
+
EOH
|
107
|
+
end
|
108
|
+
# rubocop:enable MethodLength
|
109
|
+
|
110
|
+
def new_scheduled_task_command
|
111
|
+
"schtasks /create /tn 'chef-tk' " \
|
112
|
+
"/ru '#{task_username}' /rp '#{task_password}' " \
|
113
|
+
"/sc daily /st 00:00 /rl HIGHEST /f "
|
114
|
+
end
|
115
|
+
|
116
|
+
def new_scheduled_task_command_line_ps
|
117
|
+
"/tr $executioncontext.invokecommand.expandstring(" \
|
118
|
+
'"powershell -executionpolicy unrestricted -File '
|
119
|
+
end
|
120
|
+
|
121
|
+
def setup_scheduled_task_command
|
122
|
+
new_scheduled_task_command +
|
123
|
+
new_scheduled_task_command_line_ps +
|
124
|
+
remote_chef_client_script +
|
125
|
+
'")'
|
126
|
+
end
|
127
|
+
|
128
|
+
def remote_chef_client_script
|
129
|
+
@remote_script_path ||= remote_path_join(
|
130
|
+
config[:root_path], "chef-client-script.ps1")
|
131
|
+
end
|
132
|
+
|
133
|
+
def scheduled_task_command_script
|
134
|
+
<<-EOH
|
135
|
+
Add-Type -AssemblyName System.Core
|
136
|
+
start-sleep -seconds 5;
|
137
|
+
`$npipeClient = new-object System.IO.Pipes.NamedPipeClientStream(`$env:ComputerName,
|
138
|
+
`'task`', [System.IO.Pipes.PipeDirection]::Out);
|
139
|
+
`$npipeclient.connect();
|
140
|
+
`$pipeWriter = new-object System.IO.StreamWriter(`$npipeClient);
|
141
|
+
`$pipeWriter.AutoFlush = `$true;
|
142
|
+
#{client_zero_command} |
|
143
|
+
foreach-object {} {`$pipewriter.writeline(`$_)} {
|
144
|
+
`$pipewriter.writeline("SCHEDULED_TASK_DONE: `$LastExitCode");
|
145
|
+
`$pipewriter.dispose();
|
146
|
+
`$npipeclient.dispose()
|
147
|
+
}
|
148
|
+
EOH
|
149
|
+
end
|
150
|
+
|
151
|
+
def prepare_client_zero_script
|
152
|
+
File.open(File.join(sandbox_path, "chef-client-script.ps1"), "w") do |file|
|
153
|
+
file.write(Util.outdent!(scheduled_task_command_script))
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def client_zero_command
|
158
|
+
[local_mode_command, *chef_client_args].join(" ")
|
159
|
+
end
|
160
|
+
|
161
|
+
def chef_client_args
|
162
|
+
level = config[:log_level] == :info ? :info : config[:log_level]
|
163
|
+
args = [
|
164
|
+
"--config #{remote_path_join(config[:root_path], "client.rb")}",
|
165
|
+
"--log_level #{level}",
|
166
|
+
"--force-formatter",
|
167
|
+
"--no-color"
|
168
|
+
]
|
169
|
+
add_optional_chef_client_args!(args)
|
170
|
+
|
171
|
+
args
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -1,88 +1,88 @@
|
|
1
|
-
require_relative "../../spec_helper"
|
2
|
-
|
3
|
-
require "pry"
|
4
|
-
require "kitchen"
|
5
|
-
require "kitchen/provisioner/chef_zero_scheduled_task"
|
6
|
-
|
7
|
-
describe Kitchen::Provisioner::ChefZeroScheduledTask do
|
8
|
-
|
9
|
-
let(:logged_output) { StringIO.new }
|
10
|
-
let(:logger) { Logger.new(logged_output) }
|
11
|
-
let(:platform) do
|
12
|
-
stub(:os_type => "windows", :shell_type => "powershell")
|
13
|
-
end
|
14
|
-
let(:suite) { stub(:name => "fries") }
|
15
|
-
let(:transport) do
|
16
|
-
{ :username => "Administrator", :password => "P@ssw0rd" }
|
17
|
-
end
|
18
|
-
let(:diagnose) { { :state_file => { :hostname => "Blah" } } }
|
19
|
-
|
20
|
-
let(:config) do
|
21
|
-
{ :test_base_path => "/b",
|
22
|
-
:kitchen_root => "/r",
|
23
|
-
:log_level => :info,
|
24
|
-
:root_path => "c:\\" }
|
25
|
-
end
|
26
|
-
|
27
|
-
let(:instance) do
|
28
|
-
stub(
|
29
|
-
:name => "coolbeans",
|
30
|
-
:logger => logger,
|
31
|
-
:suite => suite,
|
32
|
-
:platform => platform,
|
33
|
-
:transport => transport,
|
34
|
-
:diagnose => diagnose
|
35
|
-
)
|
36
|
-
end
|
37
|
-
|
38
|
-
let(:provisioner) do
|
39
|
-
Kitchen::Provisioner::ChefZeroScheduledTask.new(config).finalize_config!(instance)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "provisioner api_version is 2" do
|
43
|
-
provisioner.diagnose_plugin[:api_version].must_equal 2
|
44
|
-
end
|
45
|
-
|
46
|
-
it "plugin_version is set to Kitchen::VERSION" do
|
47
|
-
provisioner.diagnose_plugin[:version].must_equal Kitchen::VERSION
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "when username is not provided by the driver or task_username" do
|
51
|
-
it "is resolved from the transport" do
|
52
|
-
provisioner.task_username.must_match "Administrator"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "when password is not provided by the driver or task_password" do
|
57
|
-
it "is resolved from the transport" do
|
58
|
-
provisioner.task_password.must_match "P@ssw0rd"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "new_scheduled_task_command" do
|
63
|
-
it "returns a valid command line" do
|
64
|
-
provisioner.
|
65
|
-
new_scheduled_task_command.
|
66
|
-
must_match("schtasks /create /tn 'chef-tk' /ru " \
|
67
|
-
"'Administrator' /rp 'P@ssw0rd' /sc daily /st 00:00 /f ")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe "new_scheduled_task_command_line_ps" do
|
72
|
-
it "returns a valid task to execute" do
|
73
|
-
provisioner.
|
74
|
-
new_scheduled_task_command_line_ps.
|
75
|
-
must_match("/tr $executioncontext.invokecommand.expandstring(" \
|
76
|
-
'"powershell -executionpolicy unrestricted -File ')
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "remote_chef_client_script" do
|
81
|
-
it "returns a valid path to the script to execute" do
|
82
|
-
provisioner.
|
83
|
-
remote_chef_client_script.
|
84
|
-
must_match("c:\\chef-client-script.ps1")
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
1
|
+
require_relative "../../spec_helper"
|
2
|
+
|
3
|
+
require "pry"
|
4
|
+
require "kitchen"
|
5
|
+
require "kitchen/provisioner/chef_zero_scheduled_task"
|
6
|
+
|
7
|
+
describe Kitchen::Provisioner::ChefZeroScheduledTask do
|
8
|
+
|
9
|
+
let(:logged_output) { StringIO.new }
|
10
|
+
let(:logger) { Logger.new(logged_output) }
|
11
|
+
let(:platform) do
|
12
|
+
stub(:os_type => "windows", :shell_type => "powershell")
|
13
|
+
end
|
14
|
+
let(:suite) { stub(:name => "fries") }
|
15
|
+
let(:transport) do
|
16
|
+
{ :username => "Administrator", :password => "P@ssw0rd" }
|
17
|
+
end
|
18
|
+
let(:diagnose) { { :state_file => { :hostname => "Blah" } } }
|
19
|
+
|
20
|
+
let(:config) do
|
21
|
+
{ :test_base_path => "/b",
|
22
|
+
:kitchen_root => "/r",
|
23
|
+
:log_level => :info,
|
24
|
+
:root_path => "c:\\" }
|
25
|
+
end
|
26
|
+
|
27
|
+
let(:instance) do
|
28
|
+
stub(
|
29
|
+
:name => "coolbeans",
|
30
|
+
:logger => logger,
|
31
|
+
:suite => suite,
|
32
|
+
:platform => platform,
|
33
|
+
:transport => transport,
|
34
|
+
:diagnose => diagnose
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
let(:provisioner) do
|
39
|
+
Kitchen::Provisioner::ChefZeroScheduledTask.new(config).finalize_config!(instance)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "provisioner api_version is 2" do
|
43
|
+
provisioner.diagnose_plugin[:api_version].must_equal 2
|
44
|
+
end
|
45
|
+
|
46
|
+
it "plugin_version is set to Kitchen::VERSION" do
|
47
|
+
provisioner.diagnose_plugin[:version].must_equal Kitchen::VERSION
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "when username is not provided by the driver or task_username" do
|
51
|
+
it "is resolved from the transport" do
|
52
|
+
provisioner.task_username.must_match "Administrator"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "when password is not provided by the driver or task_password" do
|
57
|
+
it "is resolved from the transport" do
|
58
|
+
provisioner.task_password.must_match "P@ssw0rd"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "new_scheduled_task_command" do
|
63
|
+
it "returns a valid command line" do
|
64
|
+
provisioner.
|
65
|
+
new_scheduled_task_command.
|
66
|
+
must_match("schtasks /create /tn 'chef-tk' /ru " \
|
67
|
+
"'Administrator' /rp 'P@ssw0rd' /sc daily /st 00:00 /rl HIGHEST /f ")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe "new_scheduled_task_command_line_ps" do
|
72
|
+
it "returns a valid task to execute" do
|
73
|
+
provisioner.
|
74
|
+
new_scheduled_task_command_line_ps.
|
75
|
+
must_match("/tr $executioncontext.invokecommand.expandstring(" \
|
76
|
+
'"powershell -executionpolicy unrestricted -File ')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "remote_chef_client_script" do
|
81
|
+
it "returns a valid path to the script to execute" do
|
82
|
+
provisioner.
|
83
|
+
remote_chef_client_script.
|
84
|
+
must_match("c:\\chef-client-script.ps1")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,85 +1,85 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
#
|
3
|
-
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
-
#
|
5
|
-
# Copyright (C) 2012, Fletcher Nichol
|
6
|
-
#
|
7
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
-
# you may not use this file except in compliance with the License.
|
9
|
-
# You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
-
# See the License for the specific language governing permissions and
|
17
|
-
# limitations under the License.
|
18
|
-
|
19
|
-
gem "minitest"
|
20
|
-
|
21
|
-
if ENV["CODECLIMATE_REPO_TOKEN"]
|
22
|
-
require "codeclimate-test-reporter"
|
23
|
-
CodeClimate::TestReporter.start
|
24
|
-
elsif ENV["COVERAGE"]
|
25
|
-
require "simplecov"
|
26
|
-
SimpleCov.profiles.define "gem" do
|
27
|
-
command_name "Specs"
|
28
|
-
|
29
|
-
add_filter ".gem/"
|
30
|
-
add_filter "/spec/"
|
31
|
-
add_filter "/lib/vendor/"
|
32
|
-
|
33
|
-
add_group "Libraries", "/lib/"
|
34
|
-
end
|
35
|
-
SimpleCov.start "gem"
|
36
|
-
end
|
37
|
-
|
38
|
-
require "fakefs/safe"
|
39
|
-
require "minitest/autorun"
|
40
|
-
require "mocha/setup"
|
41
|
-
require "tempfile"
|
42
|
-
|
43
|
-
# Nasty hack to redefine IO.read in terms of File#read for fakefs
|
44
|
-
class IO
|
45
|
-
def self.read(*args)
|
46
|
-
length = args[1]
|
47
|
-
offset = args[2]
|
48
|
-
opt = args[3]
|
49
|
-
if length.is_a? Hash
|
50
|
-
opt = length
|
51
|
-
length = nil
|
52
|
-
elsif offset.is_a? Hash
|
53
|
-
opt = offset
|
54
|
-
end
|
55
|
-
if opt && opt.key?(:mode)
|
56
|
-
File.open(args[0], opt) { |f| f.read(length) }
|
57
|
-
else
|
58
|
-
File.open(args[0], "rb", opt) { |f| f.read(length) }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def with_fake_fs
|
64
|
-
FakeFS.activate!
|
65
|
-
FileUtils.mkdir_p("/tmp")
|
66
|
-
yield
|
67
|
-
FakeFS.deactivate!
|
68
|
-
FakeFS::FileSystem.clear
|
69
|
-
end
|
70
|
-
|
71
|
-
def running_tests_on_windows?
|
72
|
-
ENV["OS"] == "Windows_NT"
|
73
|
-
end
|
74
|
-
|
75
|
-
def os_safe_root_path(root_path)
|
76
|
-
if running_tests_on_windows?
|
77
|
-
"#{File.join(ENV["SystemDrive"], root_path)}"
|
78
|
-
else
|
79
|
-
root_path
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def padded_octal_string(integer)
|
84
|
-
integer.to_s(8).rjust(4, "0")
|
85
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2012, Fletcher Nichol
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
gem "minitest"
|
20
|
+
|
21
|
+
if ENV["CODECLIMATE_REPO_TOKEN"]
|
22
|
+
require "codeclimate-test-reporter"
|
23
|
+
CodeClimate::TestReporter.start
|
24
|
+
elsif ENV["COVERAGE"]
|
25
|
+
require "simplecov"
|
26
|
+
SimpleCov.profiles.define "gem" do
|
27
|
+
command_name "Specs"
|
28
|
+
|
29
|
+
add_filter ".gem/"
|
30
|
+
add_filter "/spec/"
|
31
|
+
add_filter "/lib/vendor/"
|
32
|
+
|
33
|
+
add_group "Libraries", "/lib/"
|
34
|
+
end
|
35
|
+
SimpleCov.start "gem"
|
36
|
+
end
|
37
|
+
|
38
|
+
require "fakefs/safe"
|
39
|
+
require "minitest/autorun"
|
40
|
+
require "mocha/setup"
|
41
|
+
require "tempfile"
|
42
|
+
|
43
|
+
# Nasty hack to redefine IO.read in terms of File#read for fakefs
|
44
|
+
class IO
|
45
|
+
def self.read(*args)
|
46
|
+
length = args[1]
|
47
|
+
offset = args[2]
|
48
|
+
opt = args[3]
|
49
|
+
if length.is_a? Hash
|
50
|
+
opt = length
|
51
|
+
length = nil
|
52
|
+
elsif offset.is_a? Hash
|
53
|
+
opt = offset
|
54
|
+
end
|
55
|
+
if opt && opt.key?(:mode)
|
56
|
+
File.open(args[0], opt) { |f| f.read(length) }
|
57
|
+
else
|
58
|
+
File.open(args[0], "rb", opt) { |f| f.read(length) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def with_fake_fs
|
64
|
+
FakeFS.activate!
|
65
|
+
FileUtils.mkdir_p("/tmp")
|
66
|
+
yield
|
67
|
+
FakeFS.deactivate!
|
68
|
+
FakeFS::FileSystem.clear
|
69
|
+
end
|
70
|
+
|
71
|
+
def running_tests_on_windows?
|
72
|
+
ENV["OS"] == "Windows_NT"
|
73
|
+
end
|
74
|
+
|
75
|
+
def os_safe_root_path(root_path)
|
76
|
+
if running_tests_on_windows?
|
77
|
+
"#{File.join(ENV["SystemDrive"], root_path)}"
|
78
|
+
else
|
79
|
+
root_path
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def padded_octal_string(integer)
|
84
|
+
integer.to_s(8).rjust(4, "0")
|
85
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-zero-scheduled-task
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Murawski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: test-kitchen
|