chef 12.17.44 → 12.18.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +3 -2
- data/Rakefile +9 -0
- data/VERSION +1 -1
- data/acceptance/Gemfile.lock +17 -17
- data/distro/common/html/knife_environment.html +4 -8
- data/distro/common/man/man1/knife-environment.1 +4 -16
- data/distro/powershell/chef/chef.psm1 +139 -24
- data/lib/chef/application.rb +5 -4
- data/lib/chef/application/windows_service_manager.rb +6 -4
- data/lib/chef/chef_fs/chef_fs_data_store.rb +1 -1
- data/lib/chef/chef_fs/command_line.rb +1 -1
- data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +8 -1
- data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +1 -1
- data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +1 -1
- data/lib/chef/cookbook/chefignore.rb +1 -1
- data/lib/chef/cookbook/cookbook_version_loader.rb +4 -4
- data/lib/chef/cookbook/metadata.rb +2 -2
- data/lib/chef/cookbook_loader.rb +1 -1
- data/lib/chef/data_collector.rb +24 -13
- data/lib/chef/data_collector/messages.rb +8 -6
- data/lib/chef/data_collector/messages/helpers.rb +1 -1
- data/lib/chef/deprecated.rb +30 -0
- data/lib/chef/dsl/platform_introspection.rb +2 -2
- data/lib/chef/encrypted_data_bag_item.rb +1 -1
- data/lib/chef/encrypted_data_bag_item/decryptor.rb +2 -2
- data/lib/chef/environment.rb +1 -1
- data/lib/chef/exceptions.rb +5 -5
- data/lib/chef/file_access_control/unix.rb +5 -5
- data/lib/chef/formatters/error_description.rb +1 -1
- data/lib/chef/http/basic_client.rb +1 -1
- data/lib/chef/http/json_input.rb +2 -2
- data/lib/chef/knife.rb +1 -1
- data/lib/chef/knife/cookbook_site_install.rb +1 -1
- data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
- data/lib/chef/knife/core/ui.rb +1 -1
- data/lib/chef/mixin/command.rb +1 -0
- data/lib/chef/mixin/deep_merge.rb +1 -1
- data/lib/chef/mixin/shell_out.rb +58 -3
- data/lib/chef/mixin/which.rb +5 -9
- data/lib/chef/mixin/wide_string.rb +1 -1
- data/lib/chef/node.rb +1 -1
- data/lib/chef/node/attribute.rb +4 -5
- data/lib/chef/node_map.rb +18 -2
- data/lib/chef/platform/provider_handler_map.rb +2 -2
- data/lib/chef/platform/provider_mapping.rb +5 -0
- data/lib/chef/platform/resource_handler_map.rb +2 -2
- data/lib/chef/provider/env/windows.rb +1 -1
- data/lib/chef/provider/git.rb +1 -1
- data/lib/chef/provider/group.rb +41 -46
- data/lib/chef/provider/group/aix.rb +12 -19
- data/lib/chef/provider/group/dscl.rb +46 -43
- data/lib/chef/provider/group/gpasswd.rb +7 -7
- data/lib/chef/provider/group/groupadd.rb +29 -34
- data/lib/chef/provider/group/groupmod.rb +26 -31
- data/lib/chef/provider/group/pw.rb +28 -31
- data/lib/chef/provider/group/suse.rb +9 -9
- data/lib/chef/provider/group/usermod.rb +10 -11
- data/lib/chef/provider/group/windows.rb +18 -20
- data/lib/chef/provider/ifconfig.rb +52 -63
- data/lib/chef/provider/ifconfig/aix.rb +23 -28
- data/lib/chef/provider/ifconfig/debian.rb +23 -22
- data/lib/chef/provider/ifconfig/redhat.rb +12 -12
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/osx_profile.rb +4 -2
- data/lib/chef/provider/package.rb +16 -7
- data/lib/chef/provider/package/chocolatey.rb +3 -1
- data/lib/chef/provider/package/dnf.rb +183 -0
- data/lib/chef/provider/package/dnf/dnf_helper.py +91 -0
- data/lib/chef/provider/package/dnf/python_helper.rb +120 -0
- data/lib/chef/provider/package/dnf/version.rb +56 -0
- data/lib/chef/provider/package/easy_install.rb +1 -1
- data/lib/chef/provider/package/freebsd/base.rb +1 -1
- data/lib/chef/provider/package/freebsd/pkgng.rb +1 -1
- data/lib/chef/provider/package/powershell.rb +3 -3
- data/lib/chef/provider/package/windows.rb +1 -1
- data/lib/chef/provider/package/zypper.rb +1 -1
- data/lib/chef/provider/route.rb +186 -184
- data/lib/chef/provider/service/arch.rb +2 -2
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/gentoo.rb +2 -2
- data/lib/chef/provider/service/insserv.rb +2 -2
- data/lib/chef/provider/service/macosx.rb +2 -2
- data/lib/chef/provider/service/openbsd.rb +1 -1
- data/lib/chef/provider/service/redhat.rb +2 -2
- data/lib/chef/provider/support/yum_repo.erb +10 -3
- data/lib/chef/provider/user.rb +17 -20
- data/lib/chef/provider/user/aix.rb +23 -24
- data/lib/chef/provider/user/dscl.rb +56 -53
- data/lib/chef/provider/user/linux.rb +13 -16
- data/lib/chef/provider/user/pw.rb +26 -30
- data/lib/chef/provider/user/solaris.rb +11 -12
- data/lib/chef/provider/user/useradd.rb +20 -22
- data/lib/chef/provider/user/windows.rb +19 -22
- data/lib/chef/provider_resolver.rb +4 -2
- data/lib/chef/providers.rb +1 -0
- data/lib/chef/resource.rb +7 -0
- data/lib/chef/resource/chocolatey_package.rb +1 -0
- data/lib/chef/resource/dnf_package.rb +64 -0
- data/lib/chef/resource/file/verification.rb +6 -4
- data/lib/chef/resource/yum_package.rb +18 -14
- data/lib/chef/resource/yum_repository.rb +1 -1
- data/lib/chef/resource_reporter.rb +11 -0
- data/lib/chef/resources.rb +1 -0
- data/lib/chef/scan_access_control.rb +4 -4
- data/lib/chef/util/dsc/resource_store.rb +1 -1
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/memory.rb +1 -1
- data/lib/chef/win32/security.rb +2 -2
- data/lib/chef/win32/security/sid.rb +2 -2
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.i686.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.src.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.10-1.fc24.x86_64.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.i686.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.src.rpm +0 -0
- data/spec/functional/assets/yumrepo/chef_rpm-1.2-1.fc24.x86_64.rpm +0 -0
- data/spec/functional/assets/yumrepo/repodata/313329137b55fd333b2dc66394a6661a2befa6cc535d8460d92a4a78a9c581f0-primary.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/31ac4db5d5ac593728fcc26aef82b7b93c4cc4dbec843786b1845b939b658553-other.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/4ac40fa3c6728c1401318e2e20a997436624e83dcf7a5f952b851ef422637773-filelists.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/66391e53f0510b98b3f0b79f40ba1048026d9a1ef20905d9c40ba6f5411f3243-primary.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/8b34697595fcc87928e12d24644dda9462c3857bd932861e28bc77ae1f31be16-filelists.xml.gz +0 -0
- data/spec/functional/assets/yumrepo/repodata/b97cca3fe14bcf06c52be4449b6108f7731239ff221111dcce8aada5467f60dc-other.sqlite.bz2 +0 -0
- data/spec/functional/assets/yumrepo/repodata/repomd.xml +55 -0
- data/spec/functional/resource/dnf_package_spec.rb +686 -0
- data/spec/functional/resource/dsc_script_spec.rb +1 -0
- data/spec/functional/resource/user/useradd_spec.rb +10 -1
- data/spec/integration/knife/chef_repo_path_spec.rb +2 -2
- data/spec/integration/recipes/recipe_dsl_spec.rb +3 -0
- data/spec/integration/recipes/resource_load_spec.rb +3 -3
- data/spec/spec_helper.rb +5 -3
- data/spec/support/lib/chef/provider/snakeoil.rb +1 -0
- data/spec/support/lib/chef/resource/cat.rb +1 -0
- data/spec/support/lib/chef/resource/one_two_three_four.rb +1 -0
- data/spec/support/lib/chef/resource/openldap_includer.rb +2 -0
- data/spec/support/lib/chef/resource/with_state.rb +2 -0
- data/spec/support/lib/chef/resource/zen_master.rb +1 -0
- data/spec/unit/cookbook/metadata_spec.rb +3 -3
- data/spec/unit/data_collector/messages/helpers_spec.rb +7 -0
- data/spec/unit/data_collector_spec.rb +56 -0
- data/spec/unit/decorator/lazy_spec.rb +1 -1
- data/spec/unit/environment_spec.rb +1 -1
- data/spec/unit/lwrp_spec.rb +3 -4
- data/spec/unit/node_spec.rb +23 -2
- data/spec/unit/platform_spec.rb +1 -0
- data/spec/unit/provider/group/dscl_spec.rb +29 -29
- data/spec/unit/provider/group/gpasswd_spec.rb +10 -10
- data/spec/unit/provider/group/groupadd_spec.rb +31 -30
- data/spec/unit/provider/group/groupmod_spec.rb +16 -16
- data/spec/unit/provider/group/pw_spec.rb +11 -11
- data/spec/unit/provider/group/suse_spec.rb +5 -5
- data/spec/unit/provider/group/usermod_spec.rb +15 -15
- data/spec/unit/provider/ifconfig/aix_spec.rb +14 -14
- data/spec/unit/provider/ifconfig/debian_spec.rb +10 -22
- data/spec/unit/provider/ifconfig/redhat_spec.rb +4 -4
- data/spec/unit/provider/ifconfig_spec.rb +18 -19
- data/spec/unit/provider/package/chocolatey_spec.rb +21 -21
- data/spec/unit/provider/package/msu_spec.rb +1 -1
- data/spec/unit/provider/route_spec.rb +21 -21
- data/spec/unit/provider/user/dscl_spec.rb +54 -57
- data/spec/unit/provider/user/linux_spec.rb +5 -5
- data/spec/unit/provider/user/pw_spec.rb +26 -22
- data/spec/unit/provider/user/windows_spec.rb +4 -4
- data/spec/unit/provider/user_spec.rb +19 -21
- data/spec/unit/provider_resolver_spec.rb +1 -0
- data/spec/unit/resource/chocolatey_package_spec.rb +12 -0
- data/spec/unit/resource/dnf_package_spec.rb +99 -0
- data/spec/unit/resource/remote_file_spec.rb +2 -2
- data/spec/unit/resource/yum_package_spec.rb +20 -0
- data/spec/unit/resource_reporter_spec.rb +24 -0
- data/spec/unit/resource_spec.rb +2 -0
- data/spec/unit/runner_spec.rb +1 -0
- data/tasks/bin/bundle-platform +1 -1
- data/tasks/gemfile_util.rb +2 -2
- data/tasks/templates/prerelease.md.erb +1 -10
- data/tasks/templates/release.md.erb +1 -9
- metadata +24 -5
- data/lib/chef/platform/handler_map.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cec435e89dd405c5c2a14ae8e84a51167916cb0
|
4
|
+
data.tar.gz: 53971689e1e64f8805d3e09ea17bbbd40fed1b22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 877bb49bf2010f03d374bb24d9bec13e5cce3bad2cb8b5f98185c58485feb55c45073faad9dd8dde94c8c7f3c02165e87242eb98bf405659d3cfceb2a272b3bb
|
7
|
+
data.tar.gz: 5ff1e83cfd0c48cb9ad82de2d3a50aff2f2099e3d03189a27c01bc7346c6f3534b34fbce80ab7946a60b2cc01d49d8f8b408dc9cd923b654c7eeacd5e81eadbf
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -20,13 +20,14 @@ If you just want to use Chef, check out these resources:
|
|
20
20
|
|
21
21
|
* [learnchef](https://learn.chef.io): Getting started guide
|
22
22
|
* [docs.chef.io](https://docs.chef.io): Comprehensive User Docs
|
23
|
-
* [Installer Downloads](https://downloads.chef.io/chef
|
23
|
+
* [Installer Downloads](https://downloads.chef.io/chef/): Install Chef as a complete package
|
24
|
+
* [chef/chef](https://hub.docker.com/r/chef/chef): Docker image for use with [kitchen-dokken](https://github.com/someara/kitchen-dokken)
|
24
25
|
|
25
26
|
## Installing From Git
|
26
27
|
|
27
28
|
**NOTE:** Unless you have a specific reason to install from source (to
|
28
29
|
try a new feature, contribute a patch, or run chef on an OS for which no
|
29
|
-
package is available), you should head to the [downloads page](https://downloads.chef.io/chef
|
30
|
+
package is available), you should head to the [downloads page](https://downloads.chef.io/chef/)
|
30
31
|
to get a prebuilt package.
|
31
32
|
|
32
33
|
### Prerequisites
|
data/Rakefile
CHANGED
@@ -68,6 +68,15 @@ task :register_eventlog do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
desc "Keep the Dockerfile up-to-date"
|
72
|
+
task :update_dockerfile do
|
73
|
+
require "mixlib/install"
|
74
|
+
latest_stable_version = Mixlib::Install.available_versions("chef", "stable").last
|
75
|
+
text = File.read("Dockerfile")
|
76
|
+
new_text = text.gsub(/^ARG VERSION=[\d\.]+$/, "ARG VERSION=#{latest_stable_version}")
|
77
|
+
File.open("Dockerfile", "w+") { |f| f.write(new_text) }
|
78
|
+
end
|
79
|
+
|
71
80
|
begin
|
72
81
|
require "chefstyle"
|
73
82
|
require "rubocop/rake_task"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
12.
|
1
|
+
12.18.31
|
data/acceptance/Gemfile.lock
CHANGED
@@ -12,13 +12,13 @@ GEM
|
|
12
12
|
addressable (2.5.0)
|
13
13
|
public_suffix (~> 2.0, >= 2.0.2)
|
14
14
|
artifactory (2.5.1)
|
15
|
-
aws-sdk (2.6.
|
16
|
-
aws-sdk-resources (= 2.6.
|
17
|
-
aws-sdk-core (2.6.
|
15
|
+
aws-sdk (2.6.44)
|
16
|
+
aws-sdk-resources (= 2.6.44)
|
17
|
+
aws-sdk-core (2.6.44)
|
18
18
|
aws-sigv4 (~> 1.0)
|
19
19
|
jmespath (~> 1.0)
|
20
|
-
aws-sdk-resources (2.6.
|
21
|
-
aws-sdk-core (= 2.6.
|
20
|
+
aws-sdk-resources (2.6.44)
|
21
|
+
aws-sdk-core (= 2.6.44)
|
22
22
|
aws-sigv4 (1.0.0)
|
23
23
|
berkshelf (4.3.5)
|
24
24
|
addressable (~> 2.3, >= 2.3.4)
|
@@ -56,7 +56,7 @@ GEM
|
|
56
56
|
celluloid-io (0.16.2)
|
57
57
|
celluloid (>= 0.16.0)
|
58
58
|
nio4r (>= 1.1.0)
|
59
|
-
chef-config (12.
|
59
|
+
chef-config (12.17.44)
|
60
60
|
addressable
|
61
61
|
fuzzyurl
|
62
62
|
mixlib-config (~> 2.0)
|
@@ -64,7 +64,7 @@ GEM
|
|
64
64
|
cleanroom (1.0.0)
|
65
65
|
coderay (1.1.1)
|
66
66
|
diff-lcs (1.2.5)
|
67
|
-
docker-api (1.33.
|
67
|
+
docker-api (1.33.1)
|
68
68
|
excon (>= 0.38.0)
|
69
69
|
json
|
70
70
|
erubis (2.7.0)
|
@@ -80,7 +80,7 @@ GEM
|
|
80
80
|
hashie (3.4.6)
|
81
81
|
hitimes (1.2.4)
|
82
82
|
httpclient (2.7.2)
|
83
|
-
inspec (1.
|
83
|
+
inspec (1.8.0)
|
84
84
|
hashie (~> 3.4)
|
85
85
|
json (>= 1.8, < 3.0)
|
86
86
|
method_source (~> 0.8)
|
@@ -94,7 +94,7 @@ GEM
|
|
94
94
|
rubyzip (~> 1.1)
|
95
95
|
sslshake (~> 1)
|
96
96
|
thor (~> 0.19)
|
97
|
-
train (>= 0.
|
97
|
+
train (>= 0.22.0, < 1.0)
|
98
98
|
jmespath (1.3.1)
|
99
99
|
json (2.0.2)
|
100
100
|
kitchen-ec2 (1.2.0)
|
@@ -103,11 +103,11 @@ GEM
|
|
103
103
|
multi_json
|
104
104
|
retryable (~> 2.0)
|
105
105
|
test-kitchen (~> 1.4, >= 1.4.1)
|
106
|
-
kitchen-inspec (0.
|
106
|
+
kitchen-inspec (0.17.0)
|
107
107
|
hashie (~> 3.4)
|
108
108
|
inspec (>= 0.34.0, < 2.0.0)
|
109
109
|
test-kitchen (~> 1.6)
|
110
|
-
kitchen-vagrant (0.21.
|
110
|
+
kitchen-vagrant (0.21.1)
|
111
111
|
test-kitchen (~> 1.4)
|
112
112
|
little-plugger (1.1.4)
|
113
113
|
logging (2.1.0)
|
@@ -144,8 +144,8 @@ GEM
|
|
144
144
|
coderay (~> 1.1.0)
|
145
145
|
method_source (~> 0.8.1)
|
146
146
|
slop (~> 3.4)
|
147
|
-
public_suffix (2.0.
|
148
|
-
rainbow (2.1
|
147
|
+
public_suffix (2.0.5)
|
148
|
+
rainbow (2.2.1)
|
149
149
|
retryable (2.0.4)
|
150
150
|
ridley (4.6.1)
|
151
151
|
addressable
|
@@ -196,7 +196,7 @@ GEM
|
|
196
196
|
molinillo (~> 0.4.2)
|
197
197
|
semverse (~> 1.1)
|
198
198
|
sslshake (1.0.13)
|
199
|
-
test-kitchen (1.14.
|
199
|
+
test-kitchen (1.14.2)
|
200
200
|
mixlib-install (>= 1.2, < 3.0)
|
201
201
|
mixlib-shellout (>= 1.2, < 3.0)
|
202
202
|
net-scp (~> 1.1)
|
@@ -220,7 +220,7 @@ GEM
|
|
220
220
|
hashie (>= 2.0.2, < 4.0.0)
|
221
221
|
windows_chef_zero (2.0.0)
|
222
222
|
test-kitchen (>= 1.2.1)
|
223
|
-
winrm (2.1.
|
223
|
+
winrm (2.1.1)
|
224
224
|
builder (>= 2.1.2)
|
225
225
|
erubis (~> 2.7)
|
226
226
|
gssapi (~> 1.2)
|
@@ -229,10 +229,10 @@ GEM
|
|
229
229
|
logging (>= 1.6.1, < 3.0)
|
230
230
|
nori (~> 2.0)
|
231
231
|
rubyntlm (~> 0.6.0, >= 0.6.1)
|
232
|
-
winrm-elevated (1.0
|
232
|
+
winrm-elevated (1.1.0)
|
233
233
|
winrm (~> 2.0)
|
234
234
|
winrm-fs (~> 1.0)
|
235
|
-
winrm-fs (1.0.
|
235
|
+
winrm-fs (1.0.1)
|
236
236
|
erubis (~> 2.7)
|
237
237
|
logging (>= 1.6.1, < 3.0)
|
238
238
|
rubyzip (~> 1.1)
|
@@ -200,11 +200,11 @@ windows 1.0.0 4.1.2
|
|
200
200
|
</div>
|
201
201
|
<div class="section" id="from-file">
|
202
202
|
<h2>from file<a class="headerlink" href="#from-file" title="Permalink to this headline">¶</a></h2>
|
203
|
-
<p>The <tt class="docutils literal"><span class="pre">from</span> <span class="pre">file</span></tt> argument is used to add or update an environment using a JSON or Ruby DSL description
|
203
|
+
<p>The <tt class="docutils literal"><span class="pre">from</span> <span class="pre">file</span></tt> argument is used to add or update an environment using a JSON or Ruby DSL description.</p>
|
204
204
|
<div class="section" id="id7">
|
205
205
|
<h3>Syntax<a class="headerlink" href="#id7" title="Permalink to this headline">¶</a></h3>
|
206
206
|
<p>This argument has the following syntax:</p>
|
207
|
-
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife environment
|
207
|
+
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife environment from file FILE <span class="o">(</span>options<span class="o">)</span>
|
208
208
|
</pre></div>
|
209
209
|
</div>
|
210
210
|
</div>
|
@@ -221,11 +221,7 @@ windows 1.0.0 4.1.2
|
|
221
221
|
<p>The following examples show how to use this knife subcommand:</p>
|
222
222
|
<p><strong>Create an environment from a JSON file</strong></p>
|
223
223
|
<p>To add an environment using data contained in a JSON file:</p>
|
224
|
-
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife environment
|
225
|
-
</pre></div>
|
226
|
-
</div>
|
227
|
-
<p>or:</p>
|
228
|
-
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife environment edit devops from file <span class="s2">"path to JSON file"</span>
|
224
|
+
<div class="highlight-bash"><div class="highlight"><pre><span class="nv">$ </span>knife environment from file <span class="s2">"path to JSON file"</span>
|
229
225
|
</pre></div>
|
230
226
|
</div>
|
231
227
|
</div>
|
@@ -323,4 +319,4 @@ override_attributes:
|
|
323
319
|
|
324
320
|
|
325
321
|
</body>
|
326
|
-
</html>
|
322
|
+
</html>
|
@@ -339,7 +339,7 @@ $ knife environment edit devops
|
|
339
339
|
.UNINDENT
|
340
340
|
.SH FROM FILE
|
341
341
|
.sp
|
342
|
-
The \fBfrom file\fP argument is used to add or update an environment using a JSON or Ruby DSL description.
|
342
|
+
The \fBfrom file\fP argument is used to add or update an environment using a JSON or Ruby DSL description.
|
343
343
|
.sp
|
344
344
|
\fBSyntax\fP
|
345
345
|
.sp
|
@@ -349,7 +349,7 @@ This argument has the following syntax:
|
|
349
349
|
.sp
|
350
350
|
.nf
|
351
351
|
.ft C
|
352
|
-
$ knife environment
|
352
|
+
$ knife environment from file FILE (options)
|
353
353
|
.ft P
|
354
354
|
.fi
|
355
355
|
.UNINDENT
|
@@ -366,25 +366,13 @@ Use to upload all environments found at the specified path.
|
|
366
366
|
.sp
|
367
367
|
\fBExamples\fP
|
368
368
|
.sp
|
369
|
-
To add an environment using data contained in a JSON file:
|
369
|
+
To add or update an environment using data contained in a JSON file:
|
370
370
|
.INDENT 0.0
|
371
371
|
.INDENT 3.5
|
372
372
|
.sp
|
373
373
|
.nf
|
374
374
|
.ft C
|
375
|
-
$ knife environment
|
376
|
-
.ft P
|
377
|
-
.fi
|
378
|
-
.UNINDENT
|
379
|
-
.UNINDENT
|
380
|
-
.sp
|
381
|
-
or:
|
382
|
-
.INDENT 0.0
|
383
|
-
.INDENT 3.5
|
384
|
-
.sp
|
385
|
-
.nf
|
386
|
-
.ft C
|
387
|
-
$ knife environment edit devops from file "path to JSON file"
|
375
|
+
$ knife environment from file "path to JSON file"
|
388
376
|
.ft P
|
389
377
|
.fi
|
390
378
|
.UNINDENT
|
@@ -109,6 +109,12 @@ public enum StandardHandle : int
|
|
109
109
|
Error = -12
|
110
110
|
}
|
111
111
|
|
112
|
+
public enum HandleFlags : int
|
113
|
+
{
|
114
|
+
HANDLE_FLAG_INHERIT = 0x00000001,
|
115
|
+
HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002
|
116
|
+
}
|
117
|
+
|
112
118
|
public static class Kernel32
|
113
119
|
{
|
114
120
|
[DllImport("kernel32.dll", SetLastError=true)]
|
@@ -128,11 +134,12 @@ public static class Kernel32
|
|
128
134
|
[DllImport("kernel32.dll", SetLastError=true)]
|
129
135
|
public static extern IntPtr GetStdHandle(
|
130
136
|
StandardHandle nStdHandle);
|
131
|
-
|
132
|
-
[DllImport("kernel32"
|
133
|
-
public static extern
|
134
|
-
IntPtr
|
135
|
-
int
|
137
|
+
|
138
|
+
[DllImport("kernel32.dll")]
|
139
|
+
public static extern bool SetHandleInformation(
|
140
|
+
IntPtr hObject,
|
141
|
+
int dwMask,
|
142
|
+
uint dwFlags);
|
136
143
|
|
137
144
|
[DllImport("kernel32", SetLastError=true)]
|
138
145
|
[return: MarshalAs(UnmanagedType.Bool)]
|
@@ -144,6 +151,32 @@ public static class Kernel32
|
|
144
151
|
public static extern bool GetExitCodeProcess(
|
145
152
|
IntPtr hProcess,
|
146
153
|
out int lpExitCode);
|
154
|
+
|
155
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
156
|
+
public static extern bool CreatePipe(
|
157
|
+
out IntPtr phReadPipe,
|
158
|
+
out IntPtr phWritePipe,
|
159
|
+
IntPtr lpPipeAttributes,
|
160
|
+
uint nSize);
|
161
|
+
|
162
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
163
|
+
public static extern bool ReadFile(
|
164
|
+
IntPtr hFile,
|
165
|
+
[Out] byte[] lpBuffer,
|
166
|
+
uint nNumberOfBytesToRead,
|
167
|
+
ref int lpNumberOfBytesRead,
|
168
|
+
IntPtr lpOverlapped);
|
169
|
+
|
170
|
+
[DllImport("kernel32.dll", SetLastError = true)]
|
171
|
+
public static extern bool PeekNamedPipe(
|
172
|
+
IntPtr handle,
|
173
|
+
byte[] buffer,
|
174
|
+
uint nBufferSize,
|
175
|
+
ref uint bytesRead,
|
176
|
+
ref uint bytesAvail,
|
177
|
+
ref uint BytesLeftThisMessage);
|
178
|
+
|
179
|
+
public const int STILL_ACTIVE = 259;
|
147
180
|
}
|
148
181
|
}
|
149
182
|
"@
|
@@ -156,13 +189,6 @@ function Run-ExecutableAndWait($AppPath, $ArgumentString) {
|
|
156
189
|
$si = New-Object Chef.STARTUPINFO
|
157
190
|
$pi = New-Object Chef.PROCESS_INFORMATION
|
158
191
|
|
159
|
-
$si.cb = [System.Runtime.InteropServices.Marshal]::SizeOf($si)
|
160
|
-
$si.wShowWindow = [Chef.ShowWindow]::SW_SHOW
|
161
|
-
$si.dwFlags = [Chef.STARTF]::STARTF_USESTDHANDLES
|
162
|
-
$si.hStdError = [Chef.Kernel32]::GetStdHandle([Chef.StandardHandle]::Error)
|
163
|
-
$si.hStdOutput = [Chef.Kernel32]::GetStdHandle([Chef.StandardHandle]::Output)
|
164
|
-
$si.hStdInput = [Chef.Kernel32]::GetStdHandle([Chef.StandardHandle]::Input)
|
165
|
-
|
166
192
|
$pSec = New-Object Chef.SECURITY_ATTRIBUTES
|
167
193
|
$pSec.Length = [System.Runtime.InteropServices.Marshal]::SizeOf($pSec)
|
168
194
|
$pSec.bInheritHandle = $true
|
@@ -170,25 +196,103 @@ function Run-ExecutableAndWait($AppPath, $ArgumentString) {
|
|
170
196
|
$tSec.Length = [System.Runtime.InteropServices.Marshal]::SizeOf($tSec)
|
171
197
|
$tSec.bInheritHandle = $true
|
172
198
|
|
173
|
-
|
199
|
+
# Create pipe for process stdout
|
200
|
+
$ptr = [System.Runtime.InteropServices.Marshal]::AllocHGlobal([System.Runtime.InteropServices.Marshal]::SizeOf($si))
|
201
|
+
[System.Runtime.InteropServices.Marshal]::StructureToPtr($pSec, $ptr, $true)
|
202
|
+
$hReadOut = [IntPtr]::Zero
|
203
|
+
$hWriteOut = [IntPtr]::Zero
|
204
|
+
$success = [Chef.Kernel32]::CreatePipe([ref] $hReadOut, [ref] $hWriteOut, $ptr, 0)
|
174
205
|
if (-Not $success) {
|
175
206
|
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
176
|
-
throw "Unable to create
|
207
|
+
throw "Unable to create output pipe. Error code $reason."
|
177
208
|
}
|
178
|
-
$
|
179
|
-
if (
|
180
|
-
|
181
|
-
|
182
|
-
throw "Could not wait for process to terminate. Error code $reason."
|
183
|
-
} else {
|
184
|
-
throw "WaitForSingleObject failed with return code $waitReason - it's impossible!"
|
185
|
-
}
|
209
|
+
$success = [Chef.Kernel32]::SetHandleInformation($hReadOut, [Chef.HandleFlags]::HANDLE_FLAG_INHERIT, 0)
|
210
|
+
if (-Not $success) {
|
211
|
+
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
212
|
+
throw "Unable to set output pipe handle information. Error code $reason."
|
186
213
|
}
|
187
|
-
|
214
|
+
|
215
|
+
$si.cb = [System.Runtime.InteropServices.Marshal]::SizeOf($si)
|
216
|
+
$si.wShowWindow = [Chef.ShowWindow]::SW_SHOW
|
217
|
+
$si.dwFlags = [Chef.STARTF]::STARTF_USESTDHANDLES
|
218
|
+
$si.hStdOutput = $hWriteOut
|
219
|
+
$si.hStdError = $hWriteOut
|
220
|
+
$si.hStdInput = [Chef.Kernel32]::GetStdHandle([Chef.StandardHandle]::Input)
|
221
|
+
|
222
|
+
$success = [Chef.Kernel32]::CreateProcess(
|
223
|
+
$AppPath,
|
224
|
+
$ArgumentString,
|
225
|
+
[ref] $pSec,
|
226
|
+
[ref] $tSec,
|
227
|
+
$true,
|
228
|
+
[Chef.CreationFlags]::NONE,
|
229
|
+
[IntPtr]::Zero,
|
230
|
+
$pwd,
|
231
|
+
[ref] $si,
|
232
|
+
[ref] $pi
|
233
|
+
)
|
188
234
|
if (-Not $success) {
|
189
235
|
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
190
|
-
throw "
|
236
|
+
throw "Unable to create process [$ArgumentString]. Error code $reason."
|
191
237
|
}
|
238
|
+
|
239
|
+
$sb = New-Object System.Text.StringBuilder
|
240
|
+
$buffer = New-Object byte[] 1024
|
241
|
+
|
242
|
+
# Initialize reference variables
|
243
|
+
$bytesRead = 0
|
244
|
+
$bytesAvailable = 0
|
245
|
+
$bytesLeftThisMsg = 0
|
246
|
+
$global:LASTEXITCODE = [Chef.Kernel32]::STILL_ACTIVE
|
247
|
+
|
248
|
+
$isActive = $true
|
249
|
+
while ($isActive) {
|
250
|
+
$success = [Chef.Kernel32]::GetExitCodeProcess($pi.hProcess, [ref] $global:LASTEXITCODE)
|
251
|
+
if (-Not $success) {
|
252
|
+
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
253
|
+
throw "Process exit code unavailable. Error code $reason."
|
254
|
+
}
|
255
|
+
|
256
|
+
$success = [Chef.Kernel32]::PeekNamedPipe(
|
257
|
+
$hReadOut,
|
258
|
+
$null,
|
259
|
+
$buffer.Length,
|
260
|
+
[ref] $bytesRead,
|
261
|
+
[ref] $bytesAvailable,
|
262
|
+
[ref] $bytesLeftThisMsg
|
263
|
+
)
|
264
|
+
if (-Not $success) {
|
265
|
+
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
266
|
+
throw "Output pipe unavailable for peeking. Error code $reason."
|
267
|
+
}
|
268
|
+
|
269
|
+
if ($bytesRead -gt 0) {
|
270
|
+
while ([Chef.Kernel32]::ReadFile($hReadOut, $buffer, $buffer.Length, [ref] $bytesRead, 0)) {
|
271
|
+
$output = [Text.Encoding]::UTF8.GetString($buffer, 0, $bytesRead)
|
272
|
+
if ($output) {
|
273
|
+
[void]$sb.Append($output)
|
274
|
+
}
|
275
|
+
if ($bytesRead -lt $buffer.Length) {
|
276
|
+
# Partial buffer indicating the end of stream, break out of ReadFile loop
|
277
|
+
# ReadFile will block until:
|
278
|
+
# The number of bytes requested is read.
|
279
|
+
# A write operation completes on the write end of the pipe.
|
280
|
+
# An asynchronous handle is being used and the read is occurring asynchronously.
|
281
|
+
# An error occurs.
|
282
|
+
break
|
283
|
+
}
|
284
|
+
}
|
285
|
+
}
|
286
|
+
|
287
|
+
if ($global:LASTEXITCODE -ne [Chef.Kernel32]::STILL_ACTIVE) {
|
288
|
+
$isActive = $false
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
# Return output obtained from child process stdout/stderr
|
293
|
+
$sb.ToString()
|
294
|
+
|
295
|
+
# Cleanup handles
|
192
296
|
$success = [Chef.Kernel32]::CloseHandle($pi.hProcess)
|
193
297
|
if (-Not $success) {
|
194
298
|
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
@@ -199,6 +303,17 @@ function Run-ExecutableAndWait($AppPath, $ArgumentString) {
|
|
199
303
|
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
200
304
|
throw "Unable to release thread handle. Error code $reason."
|
201
305
|
}
|
306
|
+
$success = [Chef.Kernel32]::CloseHandle($hWriteOut)
|
307
|
+
if (-Not $success) {
|
308
|
+
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
309
|
+
throw "Unable to release output write handle. Error code $reason."
|
310
|
+
}
|
311
|
+
$success = [Chef.Kernel32]::CloseHandle($hReadOut)
|
312
|
+
if (-Not $success) {
|
313
|
+
$reason = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
|
314
|
+
throw "Unable to release output read handle. Error code $reason."
|
315
|
+
}
|
316
|
+
[System.Runtime.InteropServices.Marshal]::FreeHGlobal($ptr)
|
202
317
|
}
|
203
318
|
|
204
319
|
function Get-ScriptDirectory {
|