Class: Omnibus::Config

Inherits:
Object
  • Object
show all
Includes:
Cleanroom, NullArgumentable, Util, Singleton
Defined in:
lib/omnibus/config.rb

Constant Summary

Constants included from Util

Util::SHELLOUT_OPTIONS

Constants included from NullArgumentable

NullArgumentable::NULL

Directory Configuration Parameters collapse

DMG / PKG configuration options collapse

RPM configuration options collapse

S3 Caching Configuration Parameters collapse

Publisher collapse

Artifactory Publisher collapse

S3 Publisher collapse

Miscellaneous Configuration Parameters collapse

Build Parameters collapse

Fetcher Parameters collapse

Class Method Summary collapse

Methods included from Util

#copy_file, #create_directory, #create_file, #create_link, included, #remove_directory, #remove_file, #shellout, #shellout!, #windows_safe_path

Methods included from NullArgumentable

included, #null?

Class Method Details

.default(key, default = NullArgumentable::NULL, &block) ⇒ Object

Parameters:

  • key (Symbol)

    the name of the configuration value to create

  • default (Object) (defaults to: NullArgumentable::NULL)

    the default value

  • block (Proc)

    a block to be called for the default value. If the block is provided, the default attribute is ignored


49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/omnibus/config.rb', line 49

def default(key, default = NullArgumentable::NULL, &block)
  # This is a class method, which delegates to the instance method
  define_singleton_method(key) do |value = NullArgumentable::NULL|
    instance.send(key, value)
  end

  # This is an instance method, but this is a singleton object ;)
  define_method(key) do |value = NullArgumentable::NULL|
    set_or_return(key, value, default, &block)
  end

  # All config options should be avaiable as DSL methods
  expose(key)
end

.key?(key) ⇒ true, false Also known as: has_key?

Check if the configuration includes the given key.

Parameters:

  • key (Symbol)

Returns:

  • (true, false)

71
72
73
# File 'lib/omnibus/config.rb', line 71

def key?(key)
  public_method_defined?(key.to_sym)
end

.load(filepath) ⇒ Config

Parameters:

  • filepath (String)

    the path to the config definition to load from disk

Returns:


33
34
35
# File 'lib/omnibus/config.rb', line 33

def load(filepath)
  evaluate_file(instance, filepath)
end

.reset!true

Reset the current configuration values. This method will unset any “stored” or memorized configuration values.

Returns:

  • (true)

82
83
84
85
86
87
88
# File 'lib/omnibus/config.rb', line 82

def reset!
  instance.instance_variables.each do |instance_variable|
    instance.send(:remove_instance_variable, instance_variable)
  end

  true
end

Instance Method Details

#append_timestamp(value = NULL) ⇒ true, false

Append the current timestamp to the version identifier.

Returns:

  • (true, false)

451
# File 'lib/omnibus/config.rb', line 451

default(:append_timestamp, true)

#artifactory_base_path(value = NULL) ⇒ String

The base path artifacts are published to. This is usually maps to the artifacts's organization. AKA `orgPath` in the Artifactory world.

Returns:

  • (String)

339
340
341
# File 'lib/omnibus/config.rb', line 339

default(:artifactory_base_path) do
  raise MissingRequiredAttribute.new(self, :artifactory_base_path, "'com/mycompany'")
end

#artifactory_endpoint(value = NULL) ⇒ String

The full URL where the artifactory instance is accessible.

Returns:

  • (String)

316
317
318
# File 'lib/omnibus/config.rb', line 316

default(:artifactory_endpoint) do
  raise MissingRequiredAttribute.new(self, :artifactory_endpoint, "'https://...'")
end

#artifactory_password(value = NULL) ⇒ String

The password of the artifactory user to authenticate with.

Returns:

  • (String)

330
331
332
# File 'lib/omnibus/config.rb', line 330

default(:artifactory_password) do
  raise MissingRequiredAttribute.new(self, :artifactory_password, "'password'")
end

#artifactory_proxy_address(value = NULL) ⇒ String

The address to use when connecting to artifactory via a proxy.

Returns:

  • (String)

366
# File 'lib/omnibus/config.rb', line 366

default(:artifactory_proxy_address, nil)

#artifactory_proxy_password(value = NULL) ⇒ String

The password to use when connecting to artifactory via a proxy.

Returns:

  • (String)

361
# File 'lib/omnibus/config.rb', line 361

default(:artifactory_proxy_password, nil)

#artifactory_proxy_port(value = NULL) ⇒ String

The port to use when connecting to artifactory via a proxy.

Returns:

  • (String)

371
# File 'lib/omnibus/config.rb', line 371

default(:artifactory_proxy_port, nil)

#artifactory_proxy_username(value = NULL) ⇒ String

The username to use when connecting to artifactory via a proxy.

Returns:

  • (String)

356
# File 'lib/omnibus/config.rb', line 356

default(:artifactory_proxy_username, nil)

#artifactory_ssl_pem_file(value = NULL) ⇒ String?

The path on disk to an SSL pem file to sign requests with.

Returns:

  • (String, nil)

346
# File 'lib/omnibus/config.rb', line 346

default(:artifactory_ssl_pem_file, nil)

#artifactory_ssl_verify(value = NULL) ⇒ true, false

Whether to perform SSL verification when connecting to artifactory.

Returns:

  • (true, false)

351
# File 'lib/omnibus/config.rb', line 351

default(:artifactory_ssl_verify, true)

#artifactory_username(value = NULL) ⇒ String

The username of the artifactory user to authenticate with.

Returns:

  • (String)

323
324
325
# File 'lib/omnibus/config.rb', line 323

default(:artifactory_username) do
  raise MissingRequiredAttribute.new(self, :artifactory_username, "'admin'")
end

#base_dir(value = NULL) ⇒ String

The “base” directory where Omnibus will store it's data. Other paths are dynamically computed from this value.

  • Defaults to C:omnibus-ruby on Windows

  • Defaults to /var/cache/omnibus on other platforms

Returns:

  • (String)

102
103
104
105
106
107
108
# File 'lib/omnibus/config.rb', line 102

default(:base_dir) do
  if Ohai['platform'] == 'windows'
    'C:/omnibus-ruby'
  else
    '/var/cache/omnibus'
  end
end

#build_dir(value = NULL) ⇒ String

The absolute path to the directory on the virtual machine where software will be built.

Returns:

  • (String)

134
# File 'lib/omnibus/config.rb', line 134

default(:build_dir) { File.join(base_dir, 'build') }

#build_dmg(value = NULL) ⇒ true, false

Package OSX pkg files inside a DMG

Returns:

  • (true, false)

180
181
182
183
184
185
# File 'lib/omnibus/config.rb', line 180

default(:build_dmg) do
  Omnibus.logger.deprecated('Config') do
    "Config.build_dmg. This value is no longer part of the " \
    "config and is implied when defining a `compressor' block in the project."
  end
end

#build_retries(value = NULL) ⇒ Integer

The number of times to retry the build before failing.

Returns:

  • (Integer)

456
# File 'lib/omnibus/config.rb', line 456

default(:build_retries, 0)

#cache_dir(value = NULL) ⇒ String

The absolute path to the directory on the virtual machine where code will be cached.

Returns:

  • (String)

114
# File 'lib/omnibus/config.rb', line 114

default(:cache_dir) { File.join(base_dir, 'cache') }

#dmg_pkg_position(value = NULL) ⇒ String

The starting x,y position where the .pkg file should live in the DMG window.

Returns:

  • (String)

201
202
203
204
205
206
# File 'lib/omnibus/config.rb', line 201

default(:dmg_pkg_position) do
  Omnibus.logger.deprecated('Config') do
    "Config.dmg_pkg_position. This value is no longer part of the " \
    "config and should be defined in the `compressor' block in the project."
  end
end

#dmg_window_bounds(value = NULL) ⇒ String

The starting x,y and ending x,y positions for the created DMG window.

Returns:

  • (String)

190
191
192
193
194
195
# File 'lib/omnibus/config.rb', line 190

default(:dmg_window_bounds) do
  Omnibus.logger.deprecated('Config') do
    "Config.dmg_window_bounds. This value is no longer part of the " \
    "config and should be defined in the `compressor' block in the project."
  end
end

#fetcher_read_timeout(value = NULL) ⇒ Integer

The number of seconds to wait

Returns:

  • (Integer)

489
# File 'lib/omnibus/config.rb', line 489

default(:fetcher_read_timeout, 60)

#git_cache_dir(value = NULL) ⇒ String

The absolute path to the directory on the virtual machine where git caching will occur and software's will be progressively cached.

Returns:

  • (String)

120
121
122
# File 'lib/omnibus/config.rb', line 120

default(:git_cache_dir) do
  File.join(base_dir, 'cache', 'git_cache')
end

#local_software_dirs(value = NULL) ⇒ Array<String>

An array of local disk paths that include software definitions to load from disk. The software definitions in these paths are pulled **in order**, so if multiple paths have the same software definition, the one that appears *first* in the list here is chosen.

  • These paths take precedence over those defined in #software_gems.

  • These paths are preceeded by local project vendored softwares.

For these paths, it is assumed that the folder structure is:

/PATH/config/software/*

Returns:

  • (Array<String>)

416
# File 'lib/omnibus/config.rb', line 416

default(:local_software_dirs) { [] }

#package_dir(value = NULL) ⇒ String

The absolute path to the directory on the virtual machine where packages will be constructed.

Returns:

  • (String)

140
# File 'lib/omnibus/config.rb', line 140

default(:package_dir) { File.join(base_dir, 'pkg') }

#package_tmp(value = NULL) ⇒ String

Deprecated.

Do not use this method.

Returns:

  • (String)

145
146
147
148
149
# File 'lib/omnibus/config.rb', line 145

default(:package_tmp) do
  Omnibus.logger.deprecated('Config') do
    "Config.package_tmp. This value is no longer used."
  end
end

#project_dir(value = NULL) ⇒ String

The relative path of the directory containing Project DSL files. This is relative to #project_root.

Returns:

  • (String)

155
# File 'lib/omnibus/config.rb', line 155

default(:project_dir, 'config/projects')

#project_root(value = NULL) ⇒ String

The root directory in which to look for Project and Software DSL files.

Returns:

  • (String)

167
# File 'lib/omnibus/config.rb', line 167

default(:project_root) { Dir.pwd }

#publish_retries(value = NULL) ⇒ Integer

The number of times to try to publish an artifact

Returns:

  • (Integer)

303
# File 'lib/omnibus/config.rb', line 303

default(:publish_retries, 2)

#publish_s3_access_key(value = NULL) ⇒ String

The S3 access key to use for S3 artifact release.

Returns:

  • (String)

384
385
386
# File 'lib/omnibus/config.rb', line 384

default(:publish_s3_access_key) do
  raise MissingRequiredAttribute.new(self, :publish_s3_access_key, "'ABCD1234'")
end

#publish_s3_secret_key(value = NULL) ⇒ String

The S3 secret key to use for S3 artifact release

Returns:

  • (String)

391
392
393
# File 'lib/omnibus/config.rb', line 391

default(:publish_s3_secret_key) do
  raise MissingRequiredAttribute.new(self, :publish_s3_secret_key, "'EFGH5678'")
end

#rpm_signing_passphrase(value = NULL) ⇒ String

The passphrase to sign the RPM with.

Returns:

  • (String)

249
250
251
252
253
254
# File 'lib/omnibus/config.rb', line 249

default(:rpm_signing_passphrase) do
  Omnibus.logger.deprecated('Config') do
    "Config.rpm_signing_passphrase. This value is no longer part of the " \
    "config and should be defined in the `package' block in the project."
  end
end

#s3_access_key(value = NULL) ⇒ String

The S3 access key to use with S3 caching.

Returns:

  • (String)

281
282
283
# File 'lib/omnibus/config.rb', line 281

default(:s3_access_key) do
  raise MissingRequiredAttribute.new(self, :s3_access_key, "'ABCD1234'")
end

#s3_bucket(value = NULL) ⇒ String

The name of the S3 bucket you want to cache software artifacts in.

Returns:

  • (String)

274
275
276
# File 'lib/omnibus/config.rb', line 274

default(:s3_bucket) do
  raise MissingRequiredAttribute.new(self, :s3_bucket, "'my_bucket'")
end

#s3_secret_key(value = NULL) ⇒ String

The S3 secret key to use with S3 caching.

Returns:

  • (String)

288
289
290
# File 'lib/omnibus/config.rb', line 288

default(:s3_secret_key) do
  raise MissingRequiredAttribute.new(self, :s3_secret_key, "'EFGH5678'")
end

#sign_pkg(value = NULL) ⇒ true, false

Sign the pkg package.

Returns:

  • (true, false)

211
212
213
214
215
216
# File 'lib/omnibus/config.rb', line 211

default(:sign_pkg) do
  Omnibus.logger.deprecated('Config') do
    "Config.sign_pkg. This value is no longer part of the config and " \
    "should be defined in the `package' block in the project."
  end
end

#sign_rpm(value = NULL) ⇒ true, false

Sign the rpm package.

Returns:

  • (true, false)

239
240
241
242
243
244
# File 'lib/omnibus/config.rb', line 239

default(:sign_rpm) do
  Omnibus.logger.deprecated('Config') do
    "Config.sign_rpm. This value is no longer part of the config and " \
    "should be defined in the `package' block in the project."
  end
end

#signing_identity(value = NULL) ⇒ String

The identity to sign the pkg with.

Returns:

  • (String)

221
222
223
224
225
226
# File 'lib/omnibus/config.rb', line 221

default(:signing_identity) do
  Omnibus.logger.deprecated('Config') do
    "Config.signing_identity. This value is no longer part of the " \
    "config and should be defined in the `package' block in the project."
  end
end

#software_dir(value = NULL) ⇒ String

The relative path of the directory containing Software DSL files. This is relative #project_root.

Returns:

  • (String)

161
# File 'lib/omnibus/config.rb', line 161

default(:software_dir, 'config/software')

#software_gems(value = NULL) ⇒ Array<String>

The list of gems to pull software definitions from. The software definitions from these gems are pulled **in order**, so if multiple gems have the same software definition, the one that appears *first* in the list here is chosen.

  • These paths are preceeded by those defined in #local_software_dirs.

  • These paths are preceeded by local project vendored softwares.

For these gems, it is assumed that the folder structure is:

/GEM_ROOT/config/software/*

Returns:

  • (Array<String>)

431
432
433
# File 'lib/omnibus/config.rb', line 431

default(:software_gems) do
  ['omnibus-software']
end

#solaris_compiler(value = NULL) ⇒ String?

The solaris compiler to use

Returns:

  • (String, nil)

438
# File 'lib/omnibus/config.rb', line 438

default(:solaris_compiler, nil)

#source_dir(value = NULL) ⇒ String

The absolute path to the directory on the virtual machine where source code will be downloaded.

Returns:

  • (String)

128
# File 'lib/omnibus/config.rb', line 128

default(:source_dir) { File.join(base_dir, 'src') }

#use_git_caching(value = NULL) ⇒ true, false

Use the incremental build caching implemented via git. This will drastically improve build times, but may result in hidden and unexpected bugs.

Returns:

  • (true, false)

463
# File 'lib/omnibus/config.rb', line 463

default(:use_git_caching, true)

#use_s3_caching(value = NULL) ⇒ true, false

Indicate if you wish to cache software artifacts in S3 for quicker build times. Requires #s3_bucket, #s3_access_key, and #s3_secret_key to be set if this is set to true.

Returns:

  • (true, false)

269
# File 'lib/omnibus/config.rb', line 269

default(:use_s3_caching, false)

#workers(value = NULL) ⇒ Integer

The number of worker threads for make. If this is not set explicitly in config, it will attempt to determine via Ohai in the builder, and failing that will default to 3

Returns:

  • (Integer)

470
471
472
473
474
475
476
# File 'lib/omnibus/config.rb', line 470

default(:workers) do
  if Ohai['cpu'] && Ohai['cpu']['total']
    Ohai['cpu']['total'].to_i + 1
  else
    3
  end
end