omnibus 3.1.1 → 3.2.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/Gemfile +0 -7
  4. data/README.md +108 -36
  5. data/Rakefile +1 -5
  6. data/docs/omnibus-build-cache.md +5 -5
  7. data/features/commands/_deprecated.feature +21 -3
  8. data/features/step_definitions/generator_steps.rb +7 -7
  9. data/lib/omnibus.rb +232 -171
  10. data/lib/omnibus/build_version.rb +2 -2
  11. data/lib/omnibus/builder.rb +38 -19
  12. data/lib/omnibus/cleaner.rb +5 -5
  13. data/lib/omnibus/cleanroom.rb +141 -0
  14. data/lib/omnibus/cli.rb +6 -9
  15. data/lib/omnibus/cli/base.rb +2 -1
  16. data/lib/omnibus/cli/cache.rb +15 -21
  17. data/lib/omnibus/cli/deprecated.rb +40 -4
  18. data/lib/omnibus/cli/publish.rb +61 -0
  19. data/lib/omnibus/config.rb +350 -189
  20. data/lib/omnibus/digestable.rb +131 -0
  21. data/lib/omnibus/exceptions.rb +163 -83
  22. data/lib/omnibus/fetcher.rb +1 -1
  23. data/lib/omnibus/fetchers/net_fetcher.rb +19 -13
  24. data/lib/omnibus/fetchers/path_fetcher.rb +8 -1
  25. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +16 -7
  26. data/lib/omnibus/generator.rb +2 -2
  27. data/lib/omnibus/generator_files/Gemfile.erb +4 -1
  28. data/lib/omnibus/generator_files/README.md.erb +10 -0
  29. data/lib/omnibus/generator_files/{omnibus.rb.example.erb → omnibus.rb.erb} +20 -11
  30. data/lib/omnibus/generator_files/package_scripts/makeselfinst.erb +1 -1
  31. data/lib/omnibus/generator_files/project.rb.erb +2 -2
  32. data/lib/omnibus/generator_files/windows_msi/localization-en-us.wxl.erb +3 -3
  33. data/lib/omnibus/git_cache.rb +192 -0
  34. data/lib/omnibus/health_check.rb +171 -116
  35. data/lib/omnibus/library.rb +4 -2
  36. data/lib/omnibus/logger.rb +60 -1
  37. data/lib/omnibus/null_argumentable.rb +51 -0
  38. data/lib/omnibus/ohai.rb +29 -8
  39. data/lib/omnibus/package.rb +240 -0
  40. data/lib/omnibus/packagers/base.rb +21 -42
  41. data/lib/omnibus/packagers/mac_dmg.rb +5 -5
  42. data/lib/omnibus/packagers/mac_pkg.rb +20 -19
  43. data/lib/omnibus/packagers/windows_msi.rb +7 -7
  44. data/lib/omnibus/project.rb +969 -486
  45. data/lib/omnibus/publisher.rb +76 -0
  46. data/lib/omnibus/publishers/artifactory_publisher.rb +168 -0
  47. data/lib/omnibus/publishers/null_publisher.rb +23 -0
  48. data/lib/omnibus/publishers/s3_publisher.rb +99 -0
  49. data/lib/omnibus/s3_cache.rb +150 -63
  50. data/lib/omnibus/software.rb +749 -321
  51. data/lib/omnibus/{sugar.rb → sugarable.rb} +11 -6
  52. data/lib/omnibus/version.rb +1 -1
  53. data/omnibus.gemspec +8 -8
  54. data/spec/data/complicated/config/projects/angrychef.rb +1 -1
  55. data/spec/data/complicated/config/projects/chef-windows.rb +1 -1
  56. data/spec/data/complicated/config/projects/chef.rb +1 -1
  57. data/spec/data/complicated/config/projects/chefdk-windows.rb +1 -1
  58. data/spec/data/complicated/config/projects/chefdk.rb +1 -1
  59. data/spec/data/complicated/config/software/cacerts.rb +1 -1
  60. data/spec/data/complicated/config/software/chef-client-msi.rb +1 -1
  61. data/spec/data/complicated/config/software/libgcc.rb +1 -1
  62. data/spec/data/complicated/config/software/libiconv.rb +0 -11
  63. data/spec/data/complicated/config/software/libpng.rb +2 -2
  64. data/spec/data/complicated/config/software/openssl.rb +1 -1
  65. data/spec/data/complicated/config/software/ruby.rb +1 -1
  66. data/spec/data/complicated/config/software/runit.rb +4 -4
  67. data/spec/data/projects/chefdk.rb +1 -1
  68. data/spec/data/projects/sample.rb +1 -1
  69. data/spec/data/software/erchef.rb +3 -1
  70. data/spec/functional/packagers/mac_spec.rb +25 -24
  71. data/spec/functional/packagers/windows_spec.rb +21 -20
  72. data/spec/spec_helper.rb +43 -4
  73. data/spec/unit/build_version_spec.rb +14 -16
  74. data/spec/unit/cleanroom_spec.rb +63 -0
  75. data/spec/unit/config_spec.rb +36 -30
  76. data/spec/unit/digestable_spec.rb +38 -0
  77. data/spec/unit/fetchers/net_fetcher_spec.rb +98 -87
  78. data/spec/unit/{install_path_cache_spec.rb → git_cache_spec.rb} +67 -56
  79. data/spec/unit/health_check_spec.rb +73 -0
  80. data/spec/unit/library_spec.rb +166 -159
  81. data/spec/unit/ohai_spec.rb +19 -0
  82. data/spec/unit/omnibus_spec.rb +43 -41
  83. data/spec/unit/package_spec.rb +178 -0
  84. data/spec/unit/packagers/base_spec.rb +17 -47
  85. data/spec/unit/packagers/mac_pkg_spec.rb +104 -126
  86. data/spec/unit/project_spec.rb +176 -25
  87. data/spec/unit/publisher_spec.rb +49 -0
  88. data/spec/unit/publishers/artifactory_publisher_spec.rb +80 -0
  89. data/spec/unit/publishers/s3_publisher_spec.rb +120 -0
  90. data/spec/unit/s3_cacher_spec.rb +84 -19
  91. data/spec/unit/software_spec.rb +397 -170
  92. data/spec/unit/sugarable_spec.rb +43 -0
  93. metadata +62 -50
  94. data/Guardfile +0 -10
  95. data/lib/omnibus/artifact.rb +0 -165
  96. data/lib/omnibus/cli/release.rb +0 -40
  97. data/lib/omnibus/generator_files/Vagrantfile.erb +0 -75
  98. data/lib/omnibus/install_path_cache.rb +0 -105
  99. data/lib/omnibus/overrides.rb +0 -88
  100. data/lib/omnibus/package_release.rb +0 -154
  101. data/lib/omnibus/software_s3_urls.rb +0 -50
  102. data/spec/unit/artifact_spec.rb +0 -91
  103. data/spec/unit/overrides_spec.rb +0 -102
  104. data/spec/unit/package_release_spec.rb +0 -180
  105. data/spec/unit/sugar_spec.rb +0 -17
@@ -33,15 +33,20 @@ module Omnibus
33
33
 
34
34
  if truthy?(value)
35
35
  warn("The environment variable 'OMNIBUS_APPEND_TIMESTAMP' is deprecated. Please use '--override append_timestamp:true' instead.")
36
- args += %(--override append_timestamp:true)
36
+ args += %w(--override append_timestamp:true)
37
37
  elsif falsey?(value)
38
38
  warn("The environment variable 'OMNIBUS_APPEND_TIMESTAMP' is deprecated. Please use '--override append_timestamp:false' instead.")
39
- args += %(--override append_timestamp:false)
39
+ args += %w(--override append_timestamp:false)
40
40
  else
41
- raise "Unknown value for OMNIBUS_APPEND_TIMESTAMP: #{value.inspect}!"
41
+ raise Omnibus::Error, "Unknown value for OMNIBUS_APPEND_TIMESTAMP: #{value.inspect}!"
42
42
  end
43
43
  end
44
44
 
45
+ # Handle old Config.release_s3_bucket
46
+ if Config.has_key?(:release_s3_bucket)
47
+ warn("The config variable 'release_s3_bucket' is deprecated. Please remove it from your config.")
48
+ end
49
+
45
50
  # Handle old --timestamp
46
51
  if args.include?('--timestamp') || args.include?('-t')
47
52
  warn("The '--timestamp' option has been deprecated! Please use '--override append_timestamp:true' instead.")
@@ -74,7 +79,7 @@ module Omnibus
74
79
  # $ omnibus build software SOFTWARE
75
80
  #
76
81
  if args[0..1] == %w(build software)
77
- raise 'Building individual software definitions is no longer supported!'
82
+ raise Omnibus::Error, 'Building individual software definitions is no longer supported!'
78
83
  end
79
84
 
80
85
  #
@@ -88,6 +93,37 @@ module Omnibus
88
93
  return old_dispatch(m, args, options, config)
89
94
  end
90
95
 
96
+ #
97
+ # Legacy releaser:
98
+ #
99
+ # $ omnibus release
100
+ #
101
+ if args[0..1] == %w(release package)
102
+ warn("The interface for releasing a project has changed. Please use 'omnibus publish BACKEND [COMAMND]' instead.")
103
+ args[0] = 'publish'
104
+ args.delete('package')
105
+ args.insert(1, 's3')
106
+
107
+ if args.include?('--public')
108
+ warn("The '--public' option has been deprecated! Please use '--acl public' instead.")
109
+ args.delete('--public')
110
+ args += %w(--acl public)
111
+ end
112
+
113
+ if args.include?('--no-public')
114
+ warn("The '--no-public' option has been deprecated! Please use '--acl private' instead.")
115
+ args.delete('--no-public')
116
+ args += %w(--acl private)
117
+ end
118
+
119
+ if Config.has_key?(:release_s3_bucket)
120
+ warn("The config variable 'release_s3_bucket' is deprecated. Please use 'omnibus publish s3 #{Config[:release_s3_bucket]}' instead.")
121
+ args.insert(2, Config[:release_s3_bucket])
122
+ end
123
+
124
+ return old_dispatch(m, args, options, config)
125
+ end
126
+
91
127
  # Dispatch everything else down the stack
92
128
  old_dispatch(m, args, options, config)
93
129
  end
@@ -0,0 +1,61 @@
1
+ #
2
+ # Copyright 2013-2014 Chef Software, Inc.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ module Omnibus
18
+ class Command::Publish < Command::Base
19
+ namespace :publish
20
+
21
+ #
22
+ # Publish to S3.
23
+ #
24
+ # $ omnibus publish s3 buckethands pkg/chef*
25
+ #
26
+ method_option :acl,
27
+ type: :string,
28
+ desc: 'The accessibility of the uploaded packages',
29
+ enum: %w(public private),
30
+ default: 'private'
31
+ desc 's3 BUCKET PATTERN', 'Publish to an S3 bucket'
32
+ def s3(bucket, pattern)
33
+ options[:bucket] = bucket
34
+ publish(S3Publisher, pattern, options)
35
+ end
36
+
37
+ #
38
+ # Publish to artifactory.
39
+ #
40
+ # $ omnibus publish artifactory libs-omnibus-local pkg/chef*
41
+ #
42
+ desc 'artifactory REPOSITORY PATTERN', 'Publish to an Artifactory instance'
43
+ def artifactory(repository, pattern)
44
+ options[:repository] = repository
45
+ publish(ArtifactoryPublisher, pattern, options)
46
+ end
47
+
48
+ private
49
+
50
+ #
51
+ # Shortcut method for executing a publisher.
52
+ #
53
+ # @return [void]
54
+ #
55
+ def publish(klass, pattern, options)
56
+ klass.publish(pattern, options) do |package|
57
+ say("Uploaded '#{package.name}'", :green)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -14,303 +14,464 @@
14
14
  # limitations under the License.
15
15
  #
16
16
 
17
- require 'mixlib/config'
17
+ require 'singleton'
18
18
 
19
19
  module Omnibus
20
- # Global configuration object for Omnibus runs.
21
- #
22
- # @todo Write a {http://yardoc.org/guides/extending-yard/writing-handlers.html
23
- # Yard handler} for Mixlib::Config-style DSL methods. I'd like
24
- # the default value to show up in the docs without having to type
25
- # it out twice, which I'm doing now for benefit of viewers of the Yard docs.
26
20
  class Config
27
- extend Mixlib::Config
28
- extend Util
21
+ include Cleanroom
22
+ include NullArgumentable
23
+ include Singleton
24
+ include Util
25
+
26
+ class << self
27
+ #
28
+ # @param [String] filepath
29
+ # the path to the config definition to load from disk
30
+ #
31
+ # @return [Config]
32
+ #
33
+ def load(filepath)
34
+ evaluate_file(instance, filepath)
35
+ end
36
+
37
+ #
38
+ # @macro default
39
+ # @method $1(value = NULL)
40
+ #
41
+ # @param [Symbol] key
42
+ # the name of the configuration value to create
43
+ # @param [Object] default
44
+ # the default value
45
+ # @param [Proc] block
46
+ # a block to be called for the default value. If the block is provided,
47
+ # the +default+ attribute is ignored
48
+ #
49
+ def default(key, default = NullArgumentable::NULL, &block)
50
+ # This is a class method, which delegates to the instance method
51
+ define_singleton_method(key) do |value = NullArgumentable::NULL|
52
+ instance.send(key, value)
53
+ end
54
+
55
+ # This is an instance method, but this is a singleton object ;)
56
+ define_method(key) do |value = NullArgumentable::NULL|
57
+ set_or_return(key, value, default, &block)
58
+ end
59
+
60
+ # All config options should be avaiable as DSL methods
61
+ expose(key)
62
+ end
63
+
64
+ #
65
+ # Check if the configuration includes the given key.
66
+ #
67
+ # @param [Symbol] key
68
+ #
69
+ # @return [true, false]
70
+ #
71
+ def key?(key)
72
+ public_method_defined?(key.to_sym)
73
+ end
74
+ alias_method :has_key?, :key?
75
+
76
+ #
77
+ # Get a value from the config object.
78
+ #
79
+ # @deprecated Use direct method instead
80
+ #
81
+ # @param [Symbol] key
82
+ # the key to fetch
83
+ #
84
+ # @return [Object]
85
+ #
86
+ def fetch(key)
87
+ Omnibus.logger.deprecated('Config') do
88
+ "fetch ([]). Please use `Config.#{key}' instead."
89
+ end
90
+
91
+ public_method_defined?(key.to_sym) && instance.send(key.to_sym)
92
+ end
93
+ alias_method :[], :fetch
94
+
95
+ #
96
+ # Reset the current configuration values. This method will unset any
97
+ # "stored" or memorized configuration values.
98
+ #
99
+ # @return [true]
100
+ #
101
+ def reset!
102
+ instance.instance_variables.each do |instance_variable|
103
+ instance.send(:remove_instance_variable, instance_variable)
104
+ end
105
+
106
+ true
107
+ end
108
+ end
29
109
 
110
+ #
30
111
  # @!group Directory Configuration Parameters
112
+ # --------------------------------------------------
31
113
 
32
- # @!attribute [rw] base_dir
33
- # The "base" directory where Omnibus will store it's data. Other paths are
34
- # dynamically constructed from this value.
114
+ # The "base" directory where Omnibus will store it's data. Other paths are
115
+ # dynamically computed from this value.
35
116
  #
36
- # Defaults to `"C:\omnibus-ruby"` on Windows
37
- # Defaults to `"/var/cache/omnibus"` on other platforms
117
+ # - Defaults to +C:\omnibus-ruby+ on Windows
118
+ # - Defaults to +/var/cache/omnibus+ on other platforms
38
119
  #
39
- # @return [String]
120
+ # @return [String]
40
121
  default(:base_dir) do
41
- if Ohai.platform == 'windows'
122
+ if Ohai['platform'] == 'windows'
42
123
  'C:\\omnibus-ruby'
43
124
  else
44
125
  '/var/cache/omnibus'
45
126
  end
46
127
  end
47
128
 
48
- # @!attribute [rw] cache_dir
49
- # The absolute path to the directory on the virtual machine where
50
- # code will be cached.
129
+ # The absolute path to the directory on the virtual machine where
130
+ # code will be cached.
51
131
  #
52
- # Defaults to `"/var/cache/omnibus/cache"`.
53
- #
54
- # @return [String]
132
+ # @return [String]
55
133
  default(:cache_dir) { windows_safe_path(base_dir, 'cache') }
56
134
 
57
- # @!attribute [rw] install_path_cache_dir
58
- # The absolute path to the directory on the virtual machine where
59
- # install paths will be progressively cached.
135
+ # The absolute path to the directory on the virtual machine where
136
+ # git caching will occur and software's will be progressively cached.
60
137
  #
61
- # Defaults to `"/var/cache/omnibus/cache/install_path"`.
62
- #
63
- # @return [String]
64
- default(:install_path_cache_dir) { windows_safe_path(base_dir, 'cache', 'install_path') }
138
+ # @return [String]
139
+ default(:git_cache_dir) do
140
+ if defined?(@install_path_cache_dir)
141
+ @install_path_cache_dir
142
+ else
143
+ windows_safe_path(base_dir, 'cache', 'git_cache')
144
+ end
145
+ end
65
146
 
66
- # @!attribute [rw] source_dir
67
- # The absolute path to the directory on the virtual machine where
68
- # source code will be downloaded.
147
+ # @deprecated Use {#git_cache_dir} instead.
69
148
  #
70
- # Defaults to `"/var/cache/omnibus/src"`.
149
+ # @return [String]
150
+ default(:install_path_cache_dir) do
151
+ Omnibus.logger.deprecated('Config') do
152
+ 'Config.install_path_cache_dir. Plase use Config.git_cache_dir instead.'
153
+ end
154
+
155
+ git_cache_dir
156
+ end
157
+
158
+ # The absolute path to the directory on the virtual machine where
159
+ # source code will be downloaded.
71
160
  #
72
- # @return [String]
161
+ # @return [String]
73
162
  default(:source_dir) { windows_safe_path(base_dir, 'src') }
74
163
 
75
- # @!attribute [rw] build_dir
76
- # The absolute path to the directory on the virtual machine where
77
- # software will be built.
164
+ # The absolute path to the directory on the virtual machine where
165
+ # software will be built.
78
166
  #
79
- # Defaults to `"/var/cache/omnibus/build"`.
80
- #
81
- # @return [String]
167
+ # @return [String]
82
168
  default(:build_dir) { windows_safe_path(base_dir, 'build') }
83
169
 
84
- # @!attribute [rw] package_dir
85
- # The absolute path to the directory on the virtual machine where
86
- # packages will be constructed.
170
+ # The absolute path to the directory on the virtual machine where
171
+ # packages will be constructed.
87
172
  #
88
- # Defaults to `"/var/cache/omnibus/pkg"`.
89
- #
90
- # @return [String]
173
+ # @return [String]
91
174
  default(:package_dir) { windows_safe_path(base_dir, 'pkg') }
92
175
 
93
- # @!attribute [rw] package_tmp
94
- # The absolute path to the directory on the virtual machine where
95
- # packagers will store intermediate packaging products. Some packaging
96
- # methods (notably fpm) handle this internally so not all packagers will
97
- # use this setting.
176
+ # The absolute path to the directory on the virtual machine where
177
+ # packagers will store intermediate packaging products. Some packaging
178
+ # methods (notably fpm) handle this internally so not all packagers will
179
+ # use this setting.
98
180
  #
99
- # Defaults to `"/var/cache/omnibus/pkg-tmp"`.
100
- #
101
- # @return [String]
181
+ # @return [String]
102
182
  default(:package_tmp) { windows_safe_path(base_dir, 'pkg-tmp') }
103
183
 
104
- # @!attribute [rw] project_dir
105
- # The relative path of the directory containing {Omnibus::Project}
106
- # DSL files. This is relative to {#project_root}.
184
+ # The relative path of the directory containing {Omnibus::Project}
185
+ # DSL files. This is relative to {#project_root}.
107
186
  #
108
- # Defaults to `"config/projects"`.
187
+ # @return [String]
188
+ default(:project_dir, 'config/projects')
189
+
190
+ # The relative path of the directory containing {Omnibus::Software}
191
+ # DSL files. This is relative {#project_root}.
109
192
  #
110
- # @return [String]
111
- default :project_dir, 'config/projects'
193
+ # @return [String]
194
+ default(:software_dir, 'config/software')
112
195
 
113
- # @!attribute [rw] software_dir
114
- # The relative path of the directory containing {Omnibus::Software}
115
- # DSL files. This is relative {#project_root}.
196
+ # The root directory in which to look for {Omnibus::Project} and
197
+ # {Omnibus::Software} DSL files.
116
198
  #
117
- # Defaults to `"config/software"`.
199
+ # @return [String]
200
+ default(:project_root) { Dir.pwd }
201
+
202
+ # --------------------------------------------------
203
+ # @!endgroup
204
+ #
205
+
118
206
  #
119
- # @return [String]
120
- default :software_dir, 'config/software'
207
+ # @!group DMG / PKG configuration options
208
+ # --------------------------------------------------
121
209
 
122
- # @!attribute [rw] project_root
123
- # The root directory in which to look for {Omnibus::Project} and
124
- # {Omnibus::Software} DSL files.
210
+ # Package OSX pkg files inside a DMG
125
211
  #
126
- # Defaults to the current working directory.
212
+ # @return [true, false]
213
+ default(:build_dmg, true)
214
+
215
+ # The starting x,y and ending x,y positions for the created DMG window.
127
216
  #
128
- # @return [String]
129
- default(:project_root) { Dir.pwd }
217
+ # @return [String]
218
+ default(:dmg_window_bounds, '100, 100, 750, 600')
130
219
 
131
- # @!attribute [rw] install_dir
132
- # Installation directory
220
+ # The starting x,y position where the .pkg file should live in the DMG
221
+ # window.
133
222
  #
134
- # Defaults to `"/opt/chef"`.
223
+ # @return [String]
224
+ default(:dmg_pkg_position, '535, 50')
225
+
226
+ # Sign the pkg package.
135
227
  #
136
- # @todo This appears to be unused, and actually conflated with
137
- # {Omnibus::Project#install_path}
228
+ # @return [true, false]
229
+ default(:sign_pkg, false)
230
+
231
+ # The identity to sign the pkg with.
138
232
  #
139
- # @return [String]
140
- default :install_dir, '/opt/chef'
233
+ # @return [String]
234
+ default(:signing_identity, nil)
141
235
 
236
+ # --------------------------------------------------
142
237
  # @!endgroup
238
+ #
143
239
 
144
- # @!group DMG / PKG configuration options
240
+ #
241
+ # @!group S3 Caching Configuration Parameters
242
+ # --------------------------------------------------
145
243
 
146
- # @!attribute [rw] build_dmg
147
- # Package OSX pkg files inside a DMG
244
+ # Indicate if you wish to cache software artifacts in S3 for
245
+ # quicker build times. Requires {#s3_bucket}, {#s3_access_key},
246
+ # and {#s3_secret_key} to be set if this is set to +true+.
148
247
  #
149
- # @return [Boolean]
150
- default :build_dmg, true
248
+ # @return [true, false]
249
+ default(:use_s3_caching, false)
151
250
 
152
- # @!attribute [rw] dmg_window_bounds
153
- # Indicate the starting x,y and ending x,y positions for the created DMG
154
- # window.
251
+ # The name of the S3 bucket you want to cache software artifacts in.
155
252
  #
156
253
  # @return [String]
157
- default :dmg_window_bounds, '100, 100, 750, 600'
254
+ default(:s3_bucket) do
255
+ raise MissingConfigOption.new(:s3_bucket, "'my_bucket'")
256
+ end
158
257
 
159
- # @!attribute [rw] dmg_pkg_position
160
- # Indicate the starting x,y position where the .pkg file should live in
161
- # the DMG window.
258
+ # The S3 access key to use with S3 caching.
162
259
  #
163
260
  # @return [String]
164
- default :dmg_pkg_position, '535, 50'
261
+ default(:s3_access_key) do
262
+ raise MissingConfigOption.new(:s3_access_key, "'ABCD1234'")
263
+ end
165
264
 
166
- # @!attribute [rw] sign_pkg
167
- # Sign the pkg package.
168
- #
169
- # Default is false.
265
+ # The S3 secret key to use with S3 caching.
170
266
  #
171
- # @return [Boolean]
172
- default :sign_pkg, false
267
+ # @return [String]
268
+ default(:s3_secret_key) do
269
+ raise MissingConfigOption.new(:s3_secret_key, "'EFGH5678'")
270
+ end
173
271
 
174
- # @!attribute [rw] signing_identity
175
- # The identity to sign the pkg with.
176
- #
177
- # Default is nil. Required if sign_pkg is set.
272
+ # --------------------------------------------------
273
+ # @!endgroup
178
274
  #
179
- # @return [String]
180
- default :signing_identity, nil
181
275
 
182
- # @!endgroup
276
+ #
277
+ # @!group Artifactory Publisher
278
+ # --------------------------------------------------
183
279
 
184
- # @!group S3 Caching Configuration Parameters
280
+ # The full URL where the artifactory instance is accessible.
281
+ #
282
+ # @return [String]
283
+ default(:artifactory_endpoint) do
284
+ raise MissingConfigOption.new(:artifactory_endpoint, "'https://...'")
285
+ end
185
286
 
186
- # @!attribute [rw] use_s3_caching
187
- # Indicate if you wish to cache software artifacts in S3 for
188
- # quicker build times. Requires {#s3_bucket}, {#s3_access_key},
189
- # and {#s3_secret_key} to be set if this is set to `true`.
287
+ # The username of the artifactory user to authenticate with.
190
288
  #
191
- # Defaults to `false`.
289
+ # @return [String]
290
+ default(:artifactory_username) do
291
+ raise MissingConfigOption.new(:artifactory_username, "'admin'")
292
+ end
293
+
294
+ # The password of the artifactory user to authenticate with.
192
295
  #
193
- # @return [Boolean]
194
- default :use_s3_caching, false
296
+ # @return [String]
297
+ default(:artifactory_password) do
298
+ raise MissingConfigOption.new(:artifactory_password, "'password'")
299
+ end
195
300
 
196
- # @!attribute [rw] s3_bucket
197
- # The name of the S3 bucket you want to cache software artifacts in.
301
+ # The path on disk to an SSL pem file to sign requests with.
198
302
  #
199
- # Defaults to `nil`. Must be set if {#use_s3_caching} is `true`.
303
+ # @return [String, nil]
304
+ default(:artifactory_ssl_pem_file, nil)
305
+
306
+ # Whether to perform SSL verification when connecting to artifactory.
200
307
  #
201
- # @return [String, nil]
202
- default :s3_bucket, nil
308
+ # @return [true, false]
309
+ default(:artifactory_ssl_verify, true)
203
310
 
204
- # @!attribute [rw] s3_access_key
205
- # The S3 access key to use with S3 caching.
311
+ # The username to use when connecting to artifactory via a proxy.
206
312
  #
207
- # Defaults to `nil`. Must be set if {#use_s3_caching} is `true`.
313
+ # @return [String]
314
+ default(:artifactory_proxy_username, nil)
315
+
316
+ # The password to use when connecting to artifactory via a proxy.
208
317
  #
209
- # @return [String, nil]
210
- default :s3_access_key, nil
318
+ # @return [String]
319
+ default(:artifactory_proxy_password, nil)
211
320
 
212
- # @!attribute [rw] s3_secret_key
213
- # The S3 secret key to use with S3 caching.
321
+ # The address to use when connecting to artifactory via a proxy.
214
322
  #
215
- # Defaults to `nil`. Must be set if {#use_s3_caching} is `true.`
323
+ # @return [String]
324
+ default(:artifactory_proxy_address, nil)
325
+
326
+ # The port to use when connecting to artifactory via a proxy.
216
327
  #
217
- # @return [String, nil]
218
- default :s3_secret_key, nil
328
+ # @return [String]
329
+ default(:artifactory_proxy_port, nil)
219
330
 
331
+ # --------------------------------------------------
220
332
  # @!endgroup
333
+ #
221
334
 
222
- # @!group S3 Release Parameters
223
-
224
- # @!attribute [rw] release_s3_bucket
225
- # The name of the S3 bucket you want to release artifacts to.
226
335
  #
227
- # Defaults to `nil`. Must be set to use `release package` command.
336
+ # @!group S3 Publisher
337
+ # --------------------------------------------------
338
+
339
+ # The S3 access key to use for S3 artifact release.
228
340
  #
229
- # @return [String, nil]
230
- default :release_s3_bucket, nil
341
+ # @return [String]
342
+ default(:publish_s3_access_key) do
343
+ raise MissingConfigOption.new(:publish_s3_access_key, "'ABCD1234'")
344
+ end
231
345
 
232
- # @!attribute [rw] release_s3_access_key
233
- # The S3 access key to use for S3 artifact release.
346
+ # The S3 secret key to use for S3 artifact release
234
347
  #
235
- # Defaults to `nil`. Must be set to use `release package` command.
348
+ # @return [String]
349
+ default(:publish_s3_secret_key) do
350
+ raise MissingConfigOption.new(:publish_s3_secret_key, "'EFGH5678'")
351
+ end
352
+
353
+ # --------------------------------------------------
354
+ # @!endgroup
236
355
  #
237
- # @return [String, nil]
238
- default :release_s3_access_key, nil
239
356
 
240
- # @!attribute [rw] release_s3_secret_key
241
- # The S3 secret key to use for S3 artifact release
242
357
  #
243
- # Defaults to `nil`. Must be set to use `release package` command.
358
+ # @!group Miscellaneous Configuration Parameters
359
+ # --------------------------------------------------
360
+
361
+ # @deprecated The is no replacement for this configuration item
244
362
  #
245
- # @return [String, nil]
246
- default :release_s3_secret_key, nil
363
+ # @return [true, false]
364
+ default(:override_file) do
365
+ Omnibus.logger.deprecated('Config') do
366
+ 'Config.override_file. Using an override file is deprecated.'
367
+ end
247
368
 
248
- # @!endgroup
369
+ nil
370
+ end
249
371
 
250
- # @!group Miscellaneous Configuration Parameters
372
+ # An array of local disk paths that include software definitions to load
373
+ # from disk. The software definitions in these paths are pulled
374
+ # **in order**, so if multiple paths have the same software definition, the
375
+ # one that appears **first** in the list here is chosen.
376
+ #
377
+ # - These paths take precedence over those defined in {#software_gems}.
378
+ # - These paths are preceeded by local project vendored softwares.
379
+ #
380
+ # For these paths, it is assumed that the folder structure is:
381
+ #
382
+ # /PATH/config/software/*
383
+ #
384
+ # @return [Array<String>]
385
+ default(:local_software_dirs) { [] }
251
386
 
252
- # @!attribute [rw] override_file
387
+ # @deprecated Use {#software_gems} instead
253
388
  #
254
- # @return [Boolean]
255
- default :override_file, nil
389
+ # @return [String]
390
+ default(:software_gem) do
391
+ Omnibus.logger.deprecated('Config') do
392
+ 'Config.software_gem. Plase use Config.software_gems (plural) and ' \
393
+ 'specify an array of software gems instead.'
394
+ end
395
+
396
+ software_gems
397
+ end
256
398
 
257
- # @!attribute [rw] software_gem
399
+ # The list of gems to pull software definitions from. The software
400
+ # definitions from these gems are pulled **in order**, so if multiple gems
401
+ # have the same software definition, the one that appears **first** in the
402
+ # list here is chosen.
258
403
  #
259
- # The gem to pull software definitions from. This is just the name of the gem, which is used
260
- # to find the path to your software definitions, and you must also specify this gem in the
261
- # Gemfile of your project repo in order to include the gem in your bundle.
404
+ # - These paths are preceeded by those defined in {#local_software_dirs}.
405
+ # - These paths are preceeded by local project vendored softwares.
262
406
  #
263
- # Defaults to "omnibus-software".
407
+ # For these gems, it is assumed that the folder structure is:
264
408
  #
265
- # @return [String, nil]
266
- default :software_gem, 'omnibus-software'
409
+ # /GEM_ROOT/config/software/*
410
+ #
411
+ # @return [Array<String>]
412
+ default(:software_gems) do
413
+ if defined?(@software_gem)
414
+ Array(@software_gem)
415
+ else
416
+ ['omnibus-software']
417
+ end
418
+ end
267
419
 
268
- # @!attribute [rw] solaris_compiler
420
+ # The solaris compiler to use
269
421
  #
270
- # @return [String, nil]
271
- default :solaris_compiler, nil
422
+ # @return [String, nil]
423
+ default(:solaris_compiler, nil)
272
424
 
425
+ # --------------------------------------------------
273
426
  # @!endgroup
427
+ #
274
428
 
275
- # @!group Build Version Parameters
429
+ #
430
+ # @!group Build Parameters
431
+ # --------------------------------------------------
276
432
 
277
- # @!attribute [rw] append_timestamp
278
- # Append the current timestamp to the version identifier.
433
+ # Append the current timestamp to the version identifier.
279
434
  #
280
- # @return [Boolean]
281
- default :append_timestamp, true
435
+ # @return [true, false]
436
+ default(:append_timestamp, true)
282
437
 
283
- # # @!endgroup
438
+ # The number of times to retry the build before failing.
439
+ #
440
+ # @return [Integer]
441
+ default(:build_retries, 3)
284
442
 
285
- # @!group Build Control Parameters
443
+ # Use the incremental build caching implemented via git. This will
444
+ # drastically improve build times, but may result in hidden and
445
+ # unexpected bugs.
446
+ #
447
+ # @return [true, false]
448
+ default(:use_git_caching, true)
286
449
 
287
- # @! attribute [rw] build_retries
288
- # The number of times to retry the build before failing.
450
+ # --------------------------------------------------
451
+ # @!endgroup
289
452
  #
290
- # @return [Integer, nil]
291
- default :build_retries, 3
292
453
 
293
- # @!group Validation Methods
454
+ private
294
455
 
295
- # Asserts that the Config object is in a valid state. If invalid
296
- # for any reason, an exception will be thrown.
297
456
  #
298
- # @raise [RuntimeError]
299
- # @return [void]
300
- def self.validate
301
- valid_s3_config?
302
- # add other validation methods as needed
303
- end
457
+ #
458
+ #
459
+ def set_or_return(key, value = NULL, default = NULL, &block)
460
+ instance_variable = :"@#{key}"
304
461
 
305
- # @raise [InvalidS3Configuration]
306
- def self.valid_s3_config?
307
- if use_s3_caching
308
- unless s3_bucket
309
- raise InvalidS3Configuration.new(s3_bucket, s3_access_key, s3_secret_key)
462
+ if null?(value)
463
+ if instance_variable_defined?(instance_variable)
464
+ instance_variable_get(instance_variable)
465
+ else
466
+ if block
467
+ instance_eval(&block)
468
+ else
469
+ null?(default) ? nil : default
470
+ end
310
471
  end
472
+ else
473
+ instance_variable_set(instance_variable, value)
311
474
  end
312
475
  end
313
-
314
- # @!endgroup
315
- end # Config
316
- end # Omnibus
476
+ end
477
+ end