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


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.


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

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

.load(filepath) ⇒ Config


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.


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.


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

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.


347
348
349
# File 'lib/omnibus/config.rb', line 347

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.


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

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.


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

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.


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

default(:artifactory_proxy_address, nil)

#artifactory_proxy_password(value = NULL) ⇒ String

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


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

default(:artifactory_proxy_password, nil)

#artifactory_proxy_port(value = NULL) ⇒ String

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


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

default(:artifactory_proxy_port, nil)

#artifactory_proxy_username(value = NULL) ⇒ String

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


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

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.


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

default(:artifactory_ssl_pem_file, nil)

#artifactory_ssl_verify(value = NULL) ⇒ true, false

Whether to perform SSL verification when connecting to artifactory.


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

default(:artifactory_ssl_verify, true)

#artifactory_username(value = NULL) ⇒ String

The username of the artifactory user to authenticate with.


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

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


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.


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


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.


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

default(:build_retries, 0)

#cache_dir(value = NULL) ⇒ String

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


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.


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.


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


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

default(:fetcher_read_timeout, 60)

#fetcher_retries(value = NULL) ⇒ Integer

The number of retries before marking a download as failed


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

default(:fetcher_retries, 5)

#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.


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/*

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

default(:local_software_dirs) { [] }

#package_dir(value = NULL) ⇒ String

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


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.


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.


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.


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


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

default(:publish_retries, 2)

#publish_s3_access_key(value = NULL) ⇒ String

The S3 access key to use for S3 artifact release.


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

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


399
400
401
# File 'lib/omnibus/config.rb', line 399

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.


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.


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.


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

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

#s3_region(value = NULL) ⇒ String

The region of the S3 bucket you want to cache software artifacts in. Defaults to 'us-east-1'


296
297
298
# File 'lib/omnibus/config.rb', line 296

default(:s3_region) do
  'us-east-1'
end

#s3_secret_key(value = NULL) ⇒ String

The S3 secret key to use with S3 caching.


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.


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.


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.


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.


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/*

439
440
441
# File 'lib/omnibus/config.rb', line 439

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

#solaris_linker_mapfile(value = NULL) ⇒ String?

Solaris linker mapfile to use, if needed see docs.oracle.com/cd/E23824_01/html/819-0690/chapter5-1.html Path is relative to the 'files' directory in your omnibus project

For example:

/PATH/files/my_map_file

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

default(:solaris_linker_mapfile, "files/mapfiles/solaris")

#source_dir(value = NULL) ⇒ String

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


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.


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

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.


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

default(:use_s3_caching, false)

#windows_arch(value = NULL) ⇒ :x86, :x64

Architecture to target when building on windows. This option should affect the bit-ness of Ruby and DevKit used, the platform of any MSIs generated and package dlls being downloaded.

See the windows_arch_i386? software definition dsl methods.


462
463
464
465
466
467
468
469
470
471
472
# File 'lib/omnibus/config.rb', line 462

default(:windows_arch) do
  if Ohai['kernel']['machine'] == 'x86_64'
    Omnibus.logger.deprecated('Config') do
      "windows_arch is defaulting to :x86. In Omnibus 5, it will " \
      "default to :x64 if the machine architecture is x86_64. " \
      "If you would like to continue building 32 bit packages, please "\
      "manually set windows_arch in your omnibus.rb file to :x86."
    end
  end
  :x86
end

#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


504
505
506
507
508
509
510
# File 'lib/omnibus/config.rb', line 504

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