chef-stove 7.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +202 -0
  3. data/bin/stove +5 -0
  4. data/lib/stove.rb +87 -0
  5. data/lib/stove/artifactory.rb +83 -0
  6. data/lib/stove/cli.rb +199 -0
  7. data/lib/stove/config.rb +76 -0
  8. data/lib/stove/cookbook.rb +120 -0
  9. data/lib/stove/cookbook/metadata.rb +245 -0
  10. data/lib/stove/error.rb +56 -0
  11. data/lib/stove/filter.rb +60 -0
  12. data/lib/stove/mash.rb +25 -0
  13. data/lib/stove/mixins/insideable.rb +13 -0
  14. data/lib/stove/mixins/instanceable.rb +24 -0
  15. data/lib/stove/mixins/optionable.rb +41 -0
  16. data/lib/stove/mixins/validatable.rb +11 -0
  17. data/lib/stove/packager.rb +156 -0
  18. data/lib/stove/plugins/artifactory.rb +14 -0
  19. data/lib/stove/plugins/base.rb +48 -0
  20. data/lib/stove/plugins/git.rb +70 -0
  21. data/lib/stove/plugins/supermarket.rb +18 -0
  22. data/lib/stove/rake_task.rb +22 -0
  23. data/lib/stove/runner.rb +39 -0
  24. data/lib/stove/supermarket.rb +79 -0
  25. data/lib/stove/util.rb +56 -0
  26. data/lib/stove/validator.rb +68 -0
  27. data/lib/stove/version.rb +3 -0
  28. data/templates/errors/abstract_method.erb +5 -0
  29. data/templates/errors/artifactory_key_validation_failed.erb +11 -0
  30. data/templates/errors/git_clean_validation_failed.erb +1 -0
  31. data/templates/errors/git_failed.erb +5 -0
  32. data/templates/errors/git_repository_validation_failed.erb +3 -0
  33. data/templates/errors/git_tagging_failed.erb +5 -0
  34. data/templates/errors/git_up_to_date_validation_failed.erb +7 -0
  35. data/templates/errors/metadata_not_found.erb +1 -0
  36. data/templates/errors/server_unavailable.erb +1 -0
  37. data/templates/errors/stove_error.erb +1 -0
  38. data/templates/errors/supermarket_already_exists.erb +5 -0
  39. data/templates/errors/supermarket_key_validation_failed.erb +3 -0
  40. data/templates/errors/supermarket_username_validation_failed.erb +3 -0
  41. metadata +212 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e491dd053cbf0a5a1bf6bdb8502280c4292184aaf56612326313870c18331329
4
+ data.tar.gz: e5443526abc84e54e75785ab27fc38f518bc2cc7ee3545b3cf15b701df93cee8
5
+ SHA512:
6
+ metadata.gz: b91dbb0d8a466fde342b3492b0306a5e4c2aa44343f637a63a975a70ea751b5d684c8732befe1f3bd4d4a665591cf5329968704b9d6d21f8e9a60cc775ed5246
7
+ data.tar.gz: f601624874444ede6be3b0e647ed6b37540aaccd67e0e84aeb0164e73c1fdc144d64025b806710efc4b80dfcbda679784e97fb929331bb0f7679bf243b6bb78b
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2013 Seth Vargo <sethvargo@gmail.com>
190
+ Copyright 2013 Opscode, Inc
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
4
+ require 'stove'
5
+ Stove::Cli.new(ARGV.dup).execute!
@@ -0,0 +1,87 @@
1
+ require 'logify'
2
+ require 'pathname'
3
+
4
+ module Stove
5
+ autoload :Artifactory, 'stove/artifactory'
6
+ autoload :Supermarket, 'stove/supermarket'
7
+ autoload :Config, 'stove/config'
8
+ autoload :Cookbook, 'stove/cookbook'
9
+ autoload :Cli, 'stove/cli'
10
+ autoload :Error, 'stove/error'
11
+ autoload :Filter, 'stove/filter'
12
+ autoload :Mash, 'stove/mash'
13
+ autoload :Packager, 'stove/packager'
14
+ autoload :Runner, 'stove/runner'
15
+ autoload :Util, 'stove/util'
16
+ autoload :Validator, 'stove/validator'
17
+ autoload :VERSION, 'stove/version'
18
+
19
+ module Middleware
20
+ autoload :ChefAuthentication, 'stove/middlewares/chef_authentication'
21
+ autoload :Exceptions, 'stove/middlewares/exceptions'
22
+ end
23
+
24
+ module Mixin
25
+ autoload :Insideable, 'stove/mixins/insideable'
26
+ autoload :Instanceable, 'stove/mixins/instanceable'
27
+ autoload :Optionable, 'stove/mixins/optionable'
28
+ autoload :Validatable, 'stove/mixins/validatable'
29
+ end
30
+
31
+ module Plugin
32
+ autoload :Artifactory, 'stove/plugins/artifactory'
33
+ autoload :Base, 'stove/plugins/base'
34
+ autoload :Supermarket, 'stove/plugins/supermarket'
35
+ autoload :Git, 'stove/plugins/git'
36
+ end
37
+
38
+ #
39
+ # A constant to represent an unset value. +nil+ is too generic and doesn't
40
+ # allow users to specify a value as +nil+. Using this constant, we can
41
+ # safely create +set_or_return+-style methods.
42
+ #
43
+ # @return [Object]
44
+ #
45
+ UNSET_VALUE = Object.new
46
+
47
+ #
48
+ # The User-Agent to use for HTTP requests
49
+ #
50
+ # @return [String]
51
+ #
52
+ USER_AGENT = "Stove #{VERSION}"
53
+
54
+ class << self
55
+ #
56
+ # The source root of the ChefAPI gem. This is useful when requiring files
57
+ # that are relative to the root of the project.
58
+ #
59
+ # @return [Pathname]
60
+ #
61
+ def root
62
+ @root ||= Pathname.new(File.expand_path('../../', __FILE__))
63
+ end
64
+
65
+ #
66
+ # Set the log level.
67
+ #
68
+ # @example Set the log level to :info
69
+ # ChefAPI.log_level = :info
70
+ #
71
+ # @param [#to_sym] level
72
+ # the log level to set
73
+ #
74
+ def log_level=(level)
75
+ Logify.level = level.to_sym
76
+ end
77
+
78
+ #
79
+ # Get the current log level.
80
+ #
81
+ # @return [Symbol]
82
+ #
83
+ def log_level
84
+ Logify.level
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,83 @@
1
+ require 'net/http'
2
+
3
+ module Stove
4
+ class Artifactory
5
+ include Mixin::Instanceable
6
+
7
+ #
8
+ # Upload a cookbook to an Artifactory server.
9
+ #
10
+ # @param [Cookbook] cookbook
11
+ # the cookbook to upload
12
+ #
13
+ def upload(cookbook, extended_metadata = false)
14
+ # Artifactory doesn't prevent uploading over an existing release in
15
+ # some cases so let's check for that. Seriously never do this, go delete
16
+ # and then re-upload if you have to.
17
+ response = request(:get, "api/v1/cookbooks/#{cookbook.name}/versions/#{cookbook.version}")
18
+ # Artifactory's version of the cookbook_version endpoint returns an
19
+ # empty 200 on an unknown version.
20
+ unless response.code == '404' || (response.code == '200' && response.body.to_s == '')
21
+ raise Error::CookbookAlreadyExists.new(cookbook: cookbook)
22
+ end
23
+
24
+ # Run the upload.
25
+ response = request(:post, "api/v1/cookbooks/#{cookbook.name}.tgz") do |req|
26
+ req.body_stream = cookbook.tarball(extended_metadata)
27
+ req.content_length = req.body_stream.size
28
+ req['Content-Type'] = 'application/x-binary'
29
+ end
30
+ response.error! unless response.code == '201'
31
+ end
32
+
33
+ private
34
+
35
+ #
36
+ # Create an HTTP connect to the Artifactory server.
37
+ #
38
+ # @return [Net::HTTP]
39
+ #
40
+ def connection
41
+ @connection ||= begin
42
+ uri = URI(Config.artifactory.strip)
43
+ # Open the HTTP connection to artifactory.
44
+ http = Net::HTTP.new(uri.host, uri.port)
45
+ if uri.scheme == 'https'
46
+ http.use_ssl = true
47
+ # Mimic the behavior of the Cookbook uploader for SSL verification.
48
+ if ENV['STOVE_NO_SSL_VERIFY'] || !Config.ssl_verify
49
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
50
+ end
51
+ end
52
+ http.start
53
+ end
54
+ end
55
+
56
+ #
57
+ # Send an HTTP request to the Artifactory server.
58
+ #
59
+ # @param [Symbol] method
60
+ # HTTP method to use
61
+ #
62
+ # @param [String] path
63
+ # URI path to request
64
+ #
65
+ # @param [Proc] block
66
+ # Optional block to set request values
67
+ #
68
+ # @return [Net::HTTPResponse]
69
+ #
70
+ def request(method, path, &block)
71
+ uri_string = Config.artifactory.strip
72
+ # Make sure we end up with the right number of separators.
73
+ uri_string << '/' unless uri_string.end_with?('/')
74
+ uri_string << path
75
+ uri = URI(uri_string)
76
+ request = Net::HTTP.const_get(method.to_s.capitalize).new(uri)
77
+ request['X-Jfrog-Art-Api'] = Config.artifactory_key.strip
78
+ block.call(request) if block
79
+ connection.request(request)
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,199 @@
1
+ require 'optparse'
2
+ require 'stove'
3
+
4
+ module Stove
5
+ class Cli
6
+ include Logify
7
+
8
+ def initialize(argv, stdin=STDIN, stdout=STDOUT, stderr=STDERR, kernel=Kernel)
9
+ @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
10
+ end
11
+
12
+ def execute!
13
+ $stdout, $stderr = @stdout, @stderr
14
+
15
+ # Parse the options hash
16
+ option_parser.parse!(@argv)
17
+
18
+ # Login command
19
+ if @argv.first == 'login'
20
+ if options[:username].nil? || options[:username].to_s.strip.empty?
21
+ raise "Missing argument `--username'!"
22
+ end
23
+
24
+ if options[:key].nil? || options[:key].to_s.strip.empty?
25
+ raise "Missing argument `--key'!"
26
+ end
27
+
28
+ Config.username = options[:username]
29
+ Config.key = options[:key]
30
+ Config.endpoint = options[:endpoint] unless options[:endpoint].nil?
31
+ Config.save
32
+
33
+ @stdout.puts "Successfully saved config to `#{Config.__path__}'!"
34
+ @kernel.exit(0)
35
+ return
36
+ end
37
+
38
+ # Override configs
39
+ Config.endpoint = options[:endpoint] if options[:endpoint]
40
+ Config.username = options[:username] if options[:username]
41
+ Config.key = options[:key] if options[:key]
42
+ Config.artifactory = options[:artifactory] if options[:artifactory]
43
+ Config.artifactory_key = options[:artifactory_key] if options[:artifactory_key]
44
+ Config.ssl_verify = options[:ssl_verify]
45
+
46
+ # Set the log level
47
+ Stove.log_level = options[:log_level]
48
+
49
+ # Useful debugging output for when people type the wrong fucking command
50
+ # and then open an issue like it's somehow my fault
51
+ log.info("Options: #{options.inspect}")
52
+ log.info("ARGV: #{@argv.inspect}")
53
+
54
+ # Make a new cookbook object - this will raise an exception if there is
55
+ # no cookbook at the given path
56
+ cookbook = Cookbook.new(options[:path])
57
+
58
+ # Now execute the actual runners (validations and errors might occur)
59
+ runner = Runner.new(cookbook, options)
60
+ runner.run
61
+
62
+ # If we got this far, everything was successful :)
63
+ @kernel.exit(0)
64
+ rescue => e
65
+ log.error('Stove experienced an error!')
66
+ log.error(e.class.name)
67
+ log.error(e.message)
68
+ log.error(e.backtrace.join("\n"))
69
+
70
+ @kernel.exit(e.respond_to?(:exit_code) ? e.exit_code : 500)
71
+ ensure
72
+ $stdout, $stderr = STDOUT, STDERR
73
+ end
74
+
75
+ private
76
+
77
+ #
78
+ # The option parser for handling command line flags.
79
+ #
80
+ # @return [OptionParser]
81
+ #
82
+ def option_parser
83
+ @option_parser ||= OptionParser.new do |opts|
84
+ opts.banner = 'Usage: stove [OPTIONS]'
85
+
86
+ opts.separator ''
87
+ opts.separator 'Plugins:'
88
+
89
+ opts.on('--no-git', 'Do not use the git plugin. Skips tagging if specified.') do
90
+ options[:no_git] = true
91
+ end
92
+
93
+ opts.separator ''
94
+ opts.separator 'Upload Options:'
95
+
96
+ opts.on('--endpoint [URL]', 'Supermarket endpoint') do |v|
97
+ options[:endpoint] = v
98
+ end
99
+
100
+ opts.on('--username [USERNAME]', 'Username to authenticate with') do |v|
101
+ options[:username] = v
102
+ end
103
+
104
+ opts.on('--key [PATH]', 'Path to the private key on disk') do |v|
105
+ options[:key] = v
106
+ end
107
+
108
+ opts.on('--[no-]extended-metadata', 'Include non-backwards compatible metadata keys such as `issues_url`') do |v|
109
+ options[:extended_metadata] = v
110
+ end
111
+
112
+ opts.on('--no-ssl-verify', 'Turn off ssl verify') do
113
+ options[:ssl_verify] = false
114
+ end
115
+
116
+ opts.separator ''
117
+ opts.separator 'Git Options:'
118
+
119
+ opts.on('--remote [REMOTE]', 'Name of the git remote') do |v|
120
+ options[:remote] = v
121
+ end
122
+
123
+ opts.on('--branch [BRANCH]', 'Name of the git branch') do |v|
124
+ options[:branch] = v
125
+ end
126
+
127
+ opts.on('--sign', 'Sign git tags') do
128
+ options[:sign] = true
129
+ end
130
+
131
+ opts.separator ''
132
+ opts.separator 'Artifactory Options:'
133
+
134
+ opts.on('--artifactory [URL]', 'URL for the Artifactory repository') do |v|
135
+ options[:artifactory] = v
136
+ end
137
+
138
+ opts.on('--artifactory-key [KEY]', 'Artifactory API key to use') do |v|
139
+ options[:artifactory_key] = if v[0] == '@'
140
+ # If passed a key looking like @foo, read it as a file. This allows
141
+ # passing in the key securely.
142
+ IO.read(File.expand_path(v[1..-1]))
143
+ else
144
+ v
145
+ end
146
+ end
147
+
148
+ opts.separator ''
149
+ opts.separator 'Global Options:'
150
+
151
+ opts.on('--log-level [LEVEL]', 'Set the log verbosity') do |v|
152
+ options[:log_level] = v
153
+ end
154
+
155
+ opts.on('--path [PATH]', 'Change the path to a cookbook') do |v|
156
+ options[:path] = v
157
+ end
158
+
159
+ opts.on_tail('-h', '--help', 'Show this message') do
160
+ puts opts
161
+ exit
162
+ end
163
+
164
+ opts.on_tail('-v', '--version', 'Show version') do
165
+ puts Stove::VERSION
166
+ exit(0)
167
+ end
168
+ end
169
+ end
170
+
171
+ # The options to pass to the cookbook. Includes default values
172
+ # that are manipulated by the option parser.
173
+ #
174
+ # @return [Hash]
175
+ def options
176
+ @options ||= {
177
+ # Upload options
178
+ :endpoint => nil,
179
+ :username => Config.username,
180
+ :key => Config.key,
181
+ :extended_metadata => true,
182
+ :ssl_verify => true,
183
+
184
+ # Git options
185
+ :remote => 'origin',
186
+ :branch => 'master',
187
+ :sign => false,
188
+
189
+ # Artifactory options
190
+ :artifactory => false,
191
+ :artifactory_key => ENV['ARTIFACTORY_API_KEY'],
192
+
193
+ # Global options
194
+ :log_level => :warn,
195
+ :path => Dir.pwd,
196
+ }
197
+ end
198
+ end
199
+ end