chef 11.14.0.alpha.3 → 11.14.0.alpha.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +140 -99
  3. data/lib/chef/application.rb +80 -2
  4. data/lib/chef/application/apply.rb +1 -0
  5. data/lib/chef/application/client.rb +5 -0
  6. data/lib/chef/application/knife.rb +4 -0
  7. data/lib/chef/application/windows_service.rb +1 -0
  8. data/lib/chef/chef_fs/parallelizer/parallel_enumerable.rb +6 -4
  9. data/lib/chef/config.rb +5 -3
  10. data/lib/chef/exceptions.rb +2 -0
  11. data/lib/chef/http/basic_client.rb +1 -0
  12. data/lib/chef/knife.rb +1 -0
  13. data/lib/chef/platform/provider_mapping.rb +7 -0
  14. data/lib/chef/provider/env/windows.rb +2 -0
  15. data/lib/chef/provider/group/usermod.rb +1 -1
  16. data/lib/chef/provider/mount/solaris.rb +233 -0
  17. data/lib/chef/provider/package/apt.rb +9 -0
  18. data/lib/chef/provider/package/windows.rb +3 -0
  19. data/lib/chef/providers.rb +1 -0
  20. data/lib/chef/resource/mount.rb +6 -1
  21. data/lib/chef/util/path_helper.rb +94 -0
  22. data/lib/chef/version.rb +1 -1
  23. data/spec/functional/application_spec.rb +58 -0
  24. data/spec/functional/resource/mount_spec.rb +14 -11
  25. data/spec/integration/client/client_spec.rb +11 -0
  26. data/spec/integration/knife/common_options_spec.rb +9 -0
  27. data/spec/unit/application_spec.rb +157 -0
  28. data/spec/unit/http/basic_client_spec.rb +42 -0
  29. data/spec/unit/provider/env/windows_spec.rb +67 -0
  30. data/spec/unit/provider/group/usermod_spec.rb +2 -1
  31. data/spec/unit/provider/mount/mount_spec.rb +3 -3
  32. data/spec/unit/provider/mount/solaris_spec.rb +646 -0
  33. data/spec/unit/provider/package/apt_spec.rb +5 -0
  34. data/spec/unit/provider/package/windows_spec.rb +6 -0
  35. data/spec/unit/resource_reporter_spec.rb +2 -2
  36. data/spec/unit/util/path_helper_spec.rb +136 -0
  37. metadata +23 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5039b580e8167d59b30f2bf1131d9799a4537fab
4
- data.tar.gz: 78bca207c5f153026d8fc083f54b3e2f50b68309
3
+ metadata.gz: 1bf813c509c0d62d475b81619a34ca638f13a182
4
+ data.tar.gz: 7ffe956fdce43510fb1242d851a48024bddffc8f
5
5
  SHA512:
6
- metadata.gz: 51b75786a8b3a452a604a43ce2b186b7ecf044927cc4b1fde685ec39ff51c436e7232dcef28e04f044eb2e62a9b5cb9d40b93e40682f1a4260448cbbdf60aff9
7
- data.tar.gz: 49e1daecfa04b62b10c2b4ea24de1d482efe5e6fa2f6d799e3125293c5626e095c083675cd73f316aa7f3b21ea5630afa023536a6f1e600192a3fd3221be5389
6
+ metadata.gz: 3a22dfe7fe71639f17d0373b64acafdab0deabba55dee3a84123cdcbb8c3b27bef5b4cd934b6c285fc51172da9afcf7471c54dd7a72e465da04e2fbb2a288768
7
+ data.tar.gz: ebdeb1fda3554bfb5f31eb41064ffd7a1a46cb1d5b76d5c580fe921a31109cca309d626e33cb693c4b4471deea7027eb4b71bdadc659df786a188e5c0efec8ad
@@ -1,155 +1,196 @@
1
1
  # Contributing to Chef
2
2
 
3
- We are glad you want to contribute to Chef! The first step is the desire to improve the project.
3
+ We are glad you want to contribute to Chef!
4
4
 
5
- You can find the answers to additional frequently asked questions [on the wiki](http://wiki.opscode.com/display/chef/How+to+Contribute).
5
+ We utilize **Github Issues** for issue tracking and contributions. You can contribute in two ways:
6
6
 
7
- ## Quick-contribute
7
+ 1. Reporting an issue or making a feature request [here](#issues).
8
+ 2. Adding features or fixing bugs yourself and contributing your code to Chef.
8
9
 
9
- * Create an account on our [bug tracker](http://tickets.opscode.com)
10
- * Sign our contributor agreement (CLA) [
11
- online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L)
12
- (keep reading if you're contributing on behalf of your employer)
13
- * Create a ticket for your change on the [bug tracker](http://tickets.opscode.com)
14
- * Link to your patch as a rebased git branch or pull request from the ticket
15
- * Resolve the ticket as fixed
10
+ ## Contribution Process
16
11
 
17
- We regularly review contributions and will get back to you if we have any suggestions or concerns.
12
+ We have a 3 step process that utilizes **Github Issues**:
18
13
 
19
- ## The Apache License and the CLA/CCLA
14
+ 1. Sign our
15
+ [Individual Contributor License Agreement (CLA)](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L)
16
+ or [Corporate CLA](https://secure.echosign.com/public/hostedForm?formid=PIE6C7AX856) online once.
17
+ 2. Create a Github Pull Request.
18
+ 3. Do [Code Review](#cr) with the **Chef Engineering Team** or **Chef Core Committers** on the pull request.
20
19
 
21
- Licensing is very important to open source projects, it helps ensure the software continues to be available under the terms that the author desired.
22
- Chef uses the Apache 2.0 license to strike a balance between open contribution and allowing you to use the software however you would like to.
20
+ ### <a name="pulls"></a> Chef Pull Requests
23
21
 
24
- The license tells you what rights you have that are provided by the copyright holder. It is important that the contributor fully understands what rights
25
- they are licensing and agrees to them. Sometimes the copyright holder isn't the contributor, most often when the contributor is doing work for a company.
22
+ Chef is built to last. We strive to ensure high quality throughout the Chef experience. In order to ensure
23
+ this, we require a couple of things for all pull requests to Chef:
26
24
 
27
- To make a good faith effort to ensure these criteria are met, Chef requires a Contributor License Agreement (CLA) or a Corporate Contributor License
28
- Agreement (CCLA) for all contributions. This is without exception due to some matters not being related to copyright and to avoid having to continually
29
- check with our lawyers about small patches.
25
+ 1. **Tests:** To ensure high quality code and protect against future regressions, we require all the
26
+ code in Chef to have at least unit test coverage. See the [spec/unit](https://github.com/opscode/chef/tree/master/spec/unit)
27
+ directory for the existing tests and use ```bundle exec rake spec``` to run them.
28
+ 2. **Green Travis Run:** We use [Travis CI](https://travis-ci.org/) in order to run our tests
29
+ continuously on all the pull requests. We require the Travis runs to succeed on every pull
30
+ request before being merged.
30
31
 
31
- It only takes a few minutes to complete a CLA, and you retain the copyright to your contribution.
32
+ In addition to this it would be nice to include the description of the problem you are solving
33
+ with your change. You can use [Chef Issue Template](#issuetemplate) in the description section
34
+ of the pull request.
35
+
36
+ ### <a name="cr"></a> Chef Code Review Process
37
+
38
+ The Chef Code Review process happens on Github pull requests. See
39
+ [this article](https://help.github.com/articles/using-pull-requests) if you're not
40
+ familiar with Github Pull Requests.
32
41
 
33
- You can complete our contributor agreement (CLA) [
34
- online](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L). If you're contributing on behalf of your employer, have
35
- your employer fill out our [Corporate CLA](https://secure.echosign.com/public/hostedForm?formid=PIE6C7AX856) instead.
42
+ Once you a pull request, the **Chef Engineering Team** or **Chef Core Committers** will review your code
43
+ and respond to you with any feedback they might have. The process at this point is as follows:
36
44
 
37
- ## Ticket Tracker (JIRA)
45
+ 1. 2 thumbs-ups are required from the **Chef Engineering Team** or **Chef Core Committers** for all merges.
46
+ 2. When ready, your pull request will be tagged with label `Ready For Merge`.
47
+ 3. Your patch will be merged into `master` including necessary documentation updates
48
+ and you will be included in `CHANGELOG.md`. Our goal is to have patches merged in 2 weeks
49
+ after they are marked to be merged.
38
50
 
39
- The [ticket tracker](http://tickets.opscode.com) is the most important documentation for the code base. It provides significant historical information,
40
- such as:
51
+ If you would like to learn about when your code will be available in a release of Chef, read more about
52
+ [Chef Release Process](#release).
41
53
 
42
- * Which release a bug fix is included in
43
- * Discussion regarding the design and merits of features
44
- * Error output to aid in finding similar bugs
54
+ ### Contributor License Agreement (CLA)
55
+ Licensing is very important to open source projects. It helps ensure the
56
+ software continues to be available under the terms that the author desired.
45
57
 
46
- Each ticket should aim to fix one bug or add one feature.
58
+ Chef uses [the Apache 2.0 license](https://github.com/opscode/chef/blob/master/LICENSE)
59
+ to strike a balance between open contribution and allowing you to use the
60
+ software however you would like to.
47
61
 
48
- ## Using git
62
+ The license tells you what rights you have that are provided by the copyright holder.
63
+ It is important that the contributor fully understands what rights they are
64
+ licensing and agrees to them. Sometimes the copyright holder isn't the contributor,
65
+ most often when the contributor is doing work for a company.
66
+
67
+ To make a good faith effort to ensure these criteria are met, Chef requires an Individual CLA
68
+ or a Corporate CLA for contributions. This agreement helps ensure you are aware of the
69
+ terms of the license you are contributing your copyrighted works under, which helps to
70
+ prevent the inclusion of works in the projects that the contributor does not hold the rights
71
+ to share.
72
+
73
+ It only takes a few minutes to complete a CLA, and you retain the copyright to your contribution.
49
74
 
50
- You can get a quick copy of the chef repository by running `git clone git://github.com/opscode/chef.git`.
75
+ You can complete our
76
+ [Individual CLA](https://secure.echosign.com/public/hostedForm?formid=PJIF5694K6L) online.
77
+ If you're contributing on behalf of your employer and they retain the copyright for your works,
78
+ have your employer fill out our
79
+ [Corporate CLA](https://secure.echosign.com/public/hostedForm?formid=PIE6C7AX856) instead.
51
80
 
52
- For collaboration purposes, it is best if you create a Github account and fork the repository to your own account.
53
- Once you do this you will be able to push your changes to your Github repository for others to see and use.
81
+ ### Chef Obvious Fix Policy
54
82
 
55
- ### Branches and Commits
83
+ Small contributions such as fixing spelling errors, where the content is small enough
84
+ to not be considered intellectual property, can be submitted by a contributor as a patch,
85
+ without a CLA.
56
86
 
57
- You should submit your patch as a git branch named after the ticket, such as CHEF-1337.
58
- This is called a _topic branch_ and allows users to associate a branch of code with the ticket.
87
+ As a rule of thumb, changes are obvious fixes if they do not introduce any new functionality
88
+ or creative thinking. As long as the change does not affect functionality, some likely
89
+ examples include the following:
59
90
 
60
- It is a best practice to have your commit message have a _summary line_ that includes the ticket number,
61
- followed by an empty line and then a brief description of the commit. This also helps other contributors
62
- understand the purpose of changes to the code.
91
+ * Spelling / grammar fixes
92
+ * Typo correction, white space and formatting changes
93
+ * Comment clean up
94
+ * Bug fixes that change default return values or error codes stored in constants
95
+ * Adding logging messages or debugging output
96
+ * Changes to ‘metadata’ files like Gemfile, .gitignore, build scripts, etc.
97
+ * Moving source files from one directory or package to another
63
98
 
64
- CHEF-3435: Create deploy dirs before calling scm_provider
99
+ **Whenever you invoke the “obvious fix” rule, please say so in your commit message:**
65
100
 
66
- The SCM providers have an assertation that requires the deploy directory to
67
- exist. The deploy provider will create missing directories, we don't converge
68
- the actions before we call run_action against the SCM provider, so it is not
69
- yet created. This ensures we run any converge actions waiting before we call
70
- the SCM provider.
101
+ ```
102
+ ------------------------------------------------------------------------
103
+ commit 370adb3f82d55d912b0cf9c1d1e99b132a8ed3b5
104
+ Author: danielsdeleo <dan@opscode.com>
105
+ Date: Wed Sep 18 11:44:40 2013 -0700
71
106
 
72
- Remember that not all users use Chef in the same way or on the same operating systems as you, so it is
73
- helpful to be clear about your use case and change so they can understand it even when it doesn't apply to them.
107
+ Fix typo in config file docs.
74
108
 
75
- ### Github and Pull Requests
109
+ Obvious fix.
76
110
 
77
- All of Chef's open source projects are available on [Github](http://www.github.com/opscode).
111
+ ------------------------------------------------------------------------
112
+ ```
78
113
 
79
- We don't require you to use Github, and we will even take patch diffs attached to tickets on the tracker.
80
- However Github has a lot of convenient features, such as being able to see a diff of changes between a
81
- pull request and the main repository quickly without downloading the branch.
114
+ ## <a name="issues"></a> Chef Issue Tracking
82
115
 
83
- If you do choose to use a pull request, please provide a link to the pull request from the ticket __and__
84
- a link to the ticket from the pull request. Because pull requests only have two states, open and closed,
85
- we can't easily filter pull requests that are waiting for a reply from the author for various reasons.
116
+ Chef Issue Tracking is handled using Github Issues.
86
117
 
87
- ### More information
118
+ If you are familiar with Chef and know the component that is causing you a problem or if you
119
+ have a feature request on a specific component you can file an issue in the corresponding
120
+ Github project. All of our Open Source Software can be found in our
121
+ [Github organization](https://github.com/opscode/).
88
122
 
89
- Additional help with git is available on the [Working with Git](http://wiki.opscode.com/display/chef/Working+with+Git) wiki page.
123
+ Otherwise you can file your issue in the [Chef project](https://github.com/opscode/chef/issues)
124
+ and we will make sure it gets filed against the appropriate project.
90
125
 
91
- ## Functional and Unit Tests
126
+ In order to decrease the back and forth an issues and help us get to the bottom of them quickly
127
+ we use below issue template. You can copy paste this code into the issue you are opening and
128
+ edit it accordingly.
92
129
 
93
- There are rspec unit tests in the 'spec' directory. If you don't have rspec already installed, you can use the 'bundler'
94
- gem to help you get the necessary prerequisites by running `sudo gem install bundler` and then `bundle install` from
95
- the chef respository. You can run the chef client spec tests by running `rspec spec/*` or `rake spec` from the chef
96
- directory of the chef repository.
130
+ <a name="issuetemplate"></a>
131
+ ```
132
+ ### Version:
133
+ [Version of the project installed]
97
134
 
98
- These tests should pass successfully on Ruby 1.8 and 1.9 on all of the platforms that Chef runs on. It is good to run the tests
99
- once on your system before you get started to ensure they all pass so you have a valid baseline. After you write your patch,
100
- run the tests again to see if they all pass.
135
+ ### Environment: [Details about the environment such as the Operating System, cookbook details, etc...]
101
136
 
102
- If any don't pass, investigate them before submitting your patch.
137
+ ### Scenario:
138
+ [What you are trying to achieve and you can't?]
103
139
 
104
- These tests don't modify your system, and sometimes tests fail because a command that would be run has changed because of your
105
- patch. This should be a simple fix. Other times the failure can show you that an important feature no longer works because of
106
- your change.
107
140
 
108
- Any new feature should have unit tests included with the patch with good code coverage to help protect it from future changes.
109
- Similarly, patches that fix a bug or regression should have a _regression test_. Simply put, this is a test that would fail
110
- without your patch but passes with it. The goal is to ensure this bug doesn't regress in the future. Consider a regular
111
- expression that doesn't match a certain pattern that it should, so you provide a patch and a test to ensure that the part
112
- of the code that uses this regular expression works as expected. Later another contributor may modify this regular expression
113
- in a way that breaks your use cases. The test you wrote will fail, signalling to them to research your ticket and use case
114
- and accounting for it.
115
141
 
116
- ## Code Review
142
+ ### Steps to Reproduce:
143
+ [If you are filing an issue what are the things we need to do in order to repro your problem?]
117
144
 
118
- Chef regularly reviews code contributions and provides suggestions for improvement in the code itself or the implementation.
119
145
 
120
- We find contributions by searching the ticket tracker for _resolved_ tickets with a status of _fixed_. If we have feedback we will
121
- reopen the ticket and you should resolve it again when you've made the changes or have a response to our feedback. When we believe
122
- the patch is ready to be merged, we update the status to _Fix Reviewed_.
146
+ ### Expected Result:
147
+ [What are you expecting to happen as the consequence of above reproduction steps?]
123
148
 
124
- Depending on the project, these tickets are then merged within a week or two, depending on the current release cycle. At this
125
- point the ticket status will be updated to _Fix Committed_ or _Closed_.
126
149
 
127
- Please see the [Code Review](http://wiki.opscode.com/display/chef/Code+Review) page on the wiki for additional information.
150
+ ### Actual Result:
151
+ [What actually happens after the reproduction steps?]
152
+ ```
128
153
 
129
- ## Release Cycle
154
+ ## <a name="release"></a> Chef Release Cycles
130
155
 
131
- The versioning for the Chef project is X.Y.Z.
156
+ Our primary shipping vehicle is operating system specific packages that includes
157
+ all the requirements of Chef. We call these [Omnibus packages](https://github.com/opscode/omnibus-ruby)
158
+
159
+ We also release our software as gems to [Rubygems](http://rubygems.org/) but we strongly
160
+ recommend using Chef packages since they are the only combination of native libraries &
161
+ gems required by Chef that we test throughly.
162
+
163
+ Our version numbering closely follows [Semantic Versioning](http://semver.org/) standard. Our
164
+ standard version numbers look like X.Y.Z which mean:
132
165
 
133
166
  * X is a major release, which may not be fully compatible with prior major releases
134
167
  * Y is a minor release, which adds both new features and bug fixes
135
168
  * Z is a patch release, which adds just bug fixes
136
169
 
137
- Major releases have historically been once a year. Minor releases for Chef average every three months and patch releases come as needed.
170
+ We frequently make `alpha` and `beta` releases with version numbers that look like
171
+ `X.Y.Z.alpha.0` or `X.Y.Z.beta.1`. These releases are still well tested but not as
172
+ throughly as **Minor** or **Patch** releases.
173
+
174
+ We do a `Minor` release approximately every 3 months and `Patch` releases on a when-needed
175
+ basis for regressions, significant bugs, and security issues.
138
176
 
139
- There are usually beta releases and release candidates (RC) of major and minor releases announced on
140
- the [chef-dev mailing list](http://lists.opscode.com/sympa/info/chef-dev). Once an RC is released, we wait at least three
141
- days to allow for testing for regressions before the final release. If a blocking regression is found then another RC is made containing
142
- the fix and the timer is reset.
177
+ Announcements of releases are available on [Chef Blog](http://www.getchef.com/blog) when they are
178
+ available.
143
179
 
144
- Once the official release is made, the release notes are available on the [Chef blog](http://www.getchef.com/blog).
180
+ **TODO**: Can I sign up for a mailing list to get notification of releases?
145
181
 
146
- ## Working with the community
182
+ ## Chef Community
147
183
 
148
- These resources will help you learn more about Chef and connect to other members of the Chef community:
184
+ Chef is made possible by a strong community of developers and system administrators. If you have
185
+ any questions or if you would like to get involved in the Chef community you can check out:
149
186
 
150
187
  * [chef](http://lists.opscode.com/sympa/info/chef) and [chef-dev](http://lists.opscode.com/sympa/info/chef-dev) mailing lists
151
- * #chef and #chef-hacking IRC channels on irc.freenode.net
152
- * [Community Cookbook site](http://community.opscode.com)
153
- * [Chef wiki](http://wiki.opscode.com/display/chef)
154
- * Chef [product page](http://www.getchef.com/chef)
188
+ * [\#chef](https://botbot.me/freenode/chef) and [\#chef-hacking](https://botbot.me/freenode/chef-hacking) IRC channels on irc.freenode.net
189
+
190
+ Also here are some additional pointers to some awesome Chef content:
191
+
192
+ **TODO**: Any blogs of community folks that we would like to put in here?
155
193
 
194
+ * [Chef Docs](http://docs.opscode.com/)
195
+ * [Learn Chef](https://learnchef.opscode.com/)
196
+ * [Chef Inc](http://www.getchef.com/)
@@ -44,6 +44,7 @@ class Chef::Application
44
44
  def reconfigure
45
45
  configure_chef
46
46
  configure_logging
47
+ configure_proxy_environment_variables
47
48
  end
48
49
 
49
50
  # Get this party started
@@ -165,6 +166,14 @@ class Chef::Application
165
166
  end
166
167
  end
167
168
 
169
+ # Configure and set any proxy environment variables according to the config.
170
+ def configure_proxy_environment_variables
171
+ configure_http_proxy
172
+ configure_https_proxy
173
+ configure_ftp_proxy
174
+ configure_no_proxy
175
+ end
176
+
168
177
  # Called prior to starting the application, by the run method
169
178
  def setup_application
170
179
  raise Chef::Exceptions::Application, "#{self.to_s}: you must override setup_application"
@@ -189,9 +198,9 @@ class Chef::Application
189
198
  server_options = {}
190
199
  server_options[:data_store] = data_store
191
200
  server_options[:log_level] = Chef::Log.level
192
- server_options[:port] = Chef::Config.chef_zero.port
193
201
  server_options[:host] = Chef::Config.chef_zero.host
194
- Chef::Log.info("Starting chef-zero on port #{Chef::Config.chef_zero.port} with repository at #{chef_fs.fs_description}")
202
+ server_options[:port] = Chef::Config.chef_zero.port
203
+ Chef::Log.info("Starting chef-zero on host #{Chef::Config.chef_zero.host}, port #{Chef::Config.chef_zero.port} with repository at #{chef_fs.fs_description}")
195
204
  @chef_zero_server = ChefZero::Server.new(server_options)
196
205
  @chef_zero_server.start_background
197
206
  Chef::Config.chef_server_url = @chef_zero_server.url
@@ -242,6 +251,75 @@ class Chef::Application
242
251
  Chef::Application.fatal!("Aborting due to error in '#{config_file_path}'", 2)
243
252
  end
244
253
 
254
+ # Set ENV['http_proxy']
255
+ def configure_http_proxy
256
+ if http_proxy = Chef::Config[:http_proxy]
257
+ env['http_proxy'] = configure_proxy("http", http_proxy,
258
+ Chef::Config[:http_proxy_user], Chef::Config[:http_proxy_pass])
259
+ end
260
+ end
261
+
262
+ # Set ENV['https_proxy']
263
+ def configure_https_proxy
264
+ if https_proxy = Chef::Config[:https_proxy]
265
+ env['https_proxy'] = configure_proxy("https", https_proxy,
266
+ Chef::Config[:https_proxy_user], Chef::Config[:https_proxy_pass])
267
+ end
268
+ end
269
+
270
+ # Set ENV['ftp_proxy']
271
+ def configure_ftp_proxy
272
+ if ftp_proxy = Chef::Config[:ftp_proxy]
273
+ env['ftp_proxy'] = configure_proxy("ftp", ftp_proxy,
274
+ Chef::Config[:ftp_proxy_user], Chef::Config[:ftp_proxy_pass])
275
+ end
276
+ end
277
+
278
+ # Set ENV['no_proxy']
279
+ def configure_no_proxy
280
+ env['no_proxy'] = Chef::Config[:no_proxy] if Chef::Config[:no_proxy]
281
+ end
282
+
283
+ # Builds a proxy uri. Examples:
284
+ # http://username:password@hostname:port
285
+ # https://username@hostname:port
286
+ # ftp://hostname:port
287
+ # when
288
+ # scheme = "http", "https", or "ftp"
289
+ # hostport = hostname:port
290
+ # user = username
291
+ # pass = password
292
+ def configure_proxy(scheme, path, user, pass)
293
+ begin
294
+ path = "#{scheme}://#{path}" unless path.start_with?(scheme)
295
+ # URI.split returns the following parts:
296
+ # [scheme, userinfo, host, port, registry, path, opaque, query, fragment]
297
+ parts = URI.split(URI.encode(path))
298
+ # URI::Generic.build requires an integer for the port, but URI::split gives
299
+ # returns a string for the port.
300
+ parts[3] = parts[3].to_i if parts[3]
301
+ if user
302
+ userinfo = URI.encode(URI.encode(user), '@:')
303
+ if pass
304
+ userinfo << ":#{URI.encode(URI.encode(pass), '@:')}"
305
+ end
306
+ parts[1] = userinfo
307
+ end
308
+
309
+ return URI::Generic.build(parts).to_s
310
+ rescue URI::Error => e
311
+ # URI::Error messages generally include the offending string. Including a message
312
+ # for which proxy config item has the issue should help deduce the issue when
313
+ # the URI::Error message is vague.
314
+ raise Chef::Exceptions::BadProxyURI, "Cannot configure #{scheme} proxy. Does not comply with URI scheme. #{e.message}"
315
+ end
316
+ end
317
+
318
+ # This is a hook for testing
319
+ def env
320
+ ENV
321
+ end
322
+
245
323
  class << self
246
324
  def debug_stacktrace(e)
247
325
  message = "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
@@ -88,6 +88,7 @@ class Chef::Application::Apply < Chef::Application
88
88
  parse_options
89
89
  Chef::Config.merge!(config)
90
90
  configure_logging
91
+ configure_proxy_environment_variables
91
92
  end
92
93
 
93
94
  def read_recipe_file(file_name)
@@ -211,6 +211,10 @@ class Chef::Application::Client < Chef::Application
211
211
  :description => "Point chef-client at local repository",
212
212
  :boolean => true
213
213
 
214
+ option :chef_zero_host,
215
+ :long => "--chef-zero-host HOST",
216
+ :description => "Host to start chef-zero on"
217
+
214
218
  option :chef_zero_port,
215
219
  :long => "--chef-zero-port PORT",
216
220
  :description => "Port to start chef-zero on"
@@ -250,6 +254,7 @@ class Chef::Application::Client < Chef::Application
250
254
  if Chef::Config.local_mode && !Chef::Config.has_key?(:cookbook_path) && !Chef::Config.has_key?(:chef_repo_path)
251
255
  Chef::Config.chef_repo_path = Chef::Config.find_chef_repo_path(Dir.pwd)
252
256
  end
257
+ Chef::Config.chef_zero.host = config[:chef_zero_host] if config[:chef_zero_host]
253
258
  Chef::Config.chef_zero.port = config[:chef_zero_port] if config[:chef_zero_port]
254
259
 
255
260
  if Chef::Config[:daemonize]
@@ -114,6 +114,10 @@ class Chef::Application::Knife < Chef::Application
114
114
  :description => "Point knife commands at local repository instead of server",
115
115
  :boolean => true
116
116
 
117
+ option :chef_zero_host,
118
+ :long => "--chef-zero-host HOST",
119
+ :description => "Host to start chef-zero on"
120
+
117
121
  option :chef_zero_port,
118
122
  :long => "--chef-zero-port PORT",
119
123
  :description => "Port to start chef-zero on"