Class: Omnibus::Config

Inherits:
Object
  • Object
show all
Includes:
Cleanroom, NullArgumentable, Sugarable, 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 Sugarable

extended, included, #node

Methods included from Util

#compiler_safe_path, #copy_file, #create_directory, #create_file, #create_link, included, #path_key, #remove_directory, #remove_file, #retry_block, #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



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

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)


73
74
75
# File 'lib/omnibus/config.rb', line 73

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:



35
36
37
# File 'lib/omnibus/config.rb', line 35

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)


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

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)


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

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)


388
389
390
# File 'lib/omnibus/config.rb', line 388

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)


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

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)


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

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)


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

default(:artifactory_proxy_address, nil)

#artifactory_proxy_password(value = NULL) ⇒ String

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

Returns:

  • (String)


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

default(:artifactory_proxy_password, nil)

#artifactory_proxy_port(value = NULL) ⇒ String

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

Returns:

  • (String)


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

default(:artifactory_proxy_port, nil)

#artifactory_proxy_username(value = NULL) ⇒ String

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

Returns:

  • (String)


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

default(:artifactory_proxy_username, nil)

#artifactory_publish_pattern(value = NULL) ⇒ String

Directory pattern for the Artifactory publisher. Interpolation of metadata keys is supported.

Examples:

‘%platform/%platform_version/%arch/%basename’

Returns:

  • (String)


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

default(:artifactory_publish_pattern, "%{name}/%{version}/%{platform}/%{platform_version}/%{basename}")

#artifactory_ssl_pem_file(value = NULL) ⇒ String?

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

Returns:

  • (String, nil)


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

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)


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

default(:artifactory_ssl_verify, true)

#artifactory_username(value = NULL) ⇒ String

The username of the artifactory user to authenticate with.

Returns:

  • (String)


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

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)


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

default(:base_dir) do
  if Ohai["platform"] == "windows"
    File.join(*["C:/omnibus-ruby", cache_suffix].compact)
  else
    File.join(*["/var/cache/omnibus", cache_suffix].compact)
  end
end

#build_dir(value = NULL) ⇒ String

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

Returns:

  • (String)


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

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

#build_dmg(value = NULL) ⇒ true, false

Package OSX pkg files inside a DMG

Returns:

  • (true, false)


188
189
190
191
192
193
# File 'lib/omnibus/config.rb', line 188

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)


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

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)


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

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

#cache_suffix(value = NULL) ⇒ String

The suffix added (typically the software name) to create a wholly separate base cache directory for the software.

Returns:

  • (String)


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

default(:cache_suffix, nil)

#dmg_pkg_position(value = NULL) ⇒ String

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

Returns:

  • (String)


209
210
211
212
213
214
# File 'lib/omnibus/config.rb', line 209

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)


198
199
200
201
202
203
# File 'lib/omnibus/config.rb', line 198

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

#fatal_licensing_warnings(value = NULL) ⇒ true, false

Fail the build or warn when build encounters a licensing warning.

Returns:

  • (true, false)


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

default(:fatal_licensing_warnings, false)

#fatal_transitive_dependency_licensing_warnings(value = NULL) ⇒ true, false

Fail the build or warn when build encounters a transitive dependency licensing warning.

Returns:

  • (true, false)


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

default(:fatal_transitive_dependency_licensing_warnings, false)

#fetcher_read_timeout(value = NULL) ⇒ Integer

The number of seconds to wait

Returns:

  • (Integer)


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

default(:fetcher_read_timeout, 60)

#fetcher_retries(value = NULL) ⇒ Integer

The number of retries before marking a download as failed

Returns:

  • (Integer)


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

default(:fetcher_retries, 5)

#fips_mode(value = NULL) ⇒ true, false

Flag specifying whether the project should be built with FIPS compatability or not.

Returns:

  • (true, false)


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

default(:fips_mode, false)

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


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

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

#health_check(value = NULL) ⇒ true, false

Fail the build when health check does not succeed. This may only be set to false for very specific use-cases in the omnibus project. e.g. creating a wrapper installer

Returns:

  • (true, false)


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

default(:health_check, true)

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


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

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)


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

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

#package_tmp(value = NULL) ⇒ String

Deprecated.

Do not use this method.

Returns:

  • (String)


153
154
155
156
157
# File 'lib/omnibus/config.rb', line 153

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)


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

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)


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

default(:project_root) { Dir.pwd }

#publish_retries(value = NULL) ⇒ Integer

The number of times to try to publish an artifact

Returns:

  • (Integer)


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

default(:publish_retries, 2)

#publish_s3_access_key(value = NULL) ⇒ String?

The S3 access key to use for S3 artifact release.

Returns:

  • (String, nil)


441
442
443
444
445
446
447
# File 'lib/omnibus/config.rb', line 441

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

#publish_s3_iam_role_arn(value = NULL) ⇒ String?

The AWS IAM role arn to use with S3 publisher.

Returns:

  • (String, nil)


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

default(:publish_s3_iam_role_arn, nil)

#publish_s3_profile(value = NULL) ⇒ String?

The AWS credentials profile to use with S3 publisher.

Returns:

  • (String, nil)


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

default(:publish_s3_profile, nil)

#publish_s3_secret_key(value = NULL) ⇒ String?

The S3 secret key to use for S3 artifact release

Returns:

  • (String, nil)


452
453
454
455
456
457
458
# File 'lib/omnibus/config.rb', line 452

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

#rpm_signing_passphrase(value = NULL) ⇒ String

The passphrase to sign the RPM with.

Returns:

  • (String)


257
258
259
260
261
262
# File 'lib/omnibus/config.rb', line 257

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_accelerate(value = NULL) ⇒ true, false

Enable or disable S3 Accelerate support

Returns:

  • (true, false)


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

default(:s3_accelerate, false)

#s3_access_key(value = NULL) ⇒ String?

The S3 access key to use with S3 caching.

Returns:

  • (String, nil)


289
290
291
292
293
294
295
# File 'lib/omnibus/config.rb', line 289

default(:s3_access_key) do
  if s3_profile || s3_iam_role_arn
    nil
  else
    raise MissingRequiredAttribute.new(self, :s3_access_key, "'ABCD1234'")
  end
end

#s3_bucket(value = NULL) ⇒ String

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

Returns:

  • (String)


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

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

#s3_endpoint(value = NULL) ⇒ String?

The HTTP or HTTPS endpoint to send requests to, when using non-standard endpoint

Returns:

  • (String, nil)


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

default(:s3_endpoint, nil)

#s3_force_path_style(value = NULL) ⇒ true, false

Use path style URLs instead of subdomains for S3 URLs

Returns:

  • (true, false)


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

default(:s3_force_path_style, false)

#s3_iam_role_arn(value = NULL) ⇒ String?

The AWS IAM role arn to use with S3 caching.

Returns:

  • (String, nil)


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

default(:s3_iam_role_arn, nil)

#s3_profile(value = NULL) ⇒ String?

The AWS credentials profile to use with S3 caching.

Returns:

  • (String, nil)


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

default(:s3_profile, nil)

#s3_publish_pattern(value = NULL) ⇒ String

Directory pattern for the S3 publisher. Interpolation of metadata keys is supported.

Examples:

‘%platform/%platform_version/%arch/%basename’

Returns:

  • (String)


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

default(:s3_publish_pattern, "%{platform}/%{platform_version}/%{arch}/%{basename}")

#s3_region(value = NULL) ⇒ String

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

Returns:

  • (String)


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

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

#s3_secret_key(value = NULL) ⇒ String?

The S3 secret key to use with S3 caching.

Returns:

  • (String, nil)


300
301
302
303
304
305
306
# File 'lib/omnibus/config.rb', line 300

default(:s3_secret_key) do
  if s3_profile || s3_iam_role_arn
    nil
  else
    raise MissingRequiredAttribute.new(self, :s3_secret_key, "'EFGH5678'")
  end
end

#sign_pkg(value = NULL) ⇒ true, false

Sign the pkg package.

Returns:

  • (true, false)


219
220
221
222
223
224
# File 'lib/omnibus/config.rb', line 219

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)


247
248
249
250
251
252
# File 'lib/omnibus/config.rb', line 247

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)


229
230
231
232
233
234
# File 'lib/omnibus/config.rb', line 229

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)


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

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>)


514
515
516
# File 'lib/omnibus/config.rb', line 514

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

Returns:

  • (String, nil)


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

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.

Returns:

  • (String)


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

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)


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

default(:use_git_caching, true)

#use_internal_sources(value = NULL) ⇒ true, false

Use the internal_source URL when fetching software dependencies. e.g. when creating an omnibus package using artifactory as the source url.

Returns:

  • (true, false)


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

default(:use_internal_sources, false)

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


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

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.

Returns:

  • (:x86, :x64)


537
538
539
540
541
542
543
544
545
546
547
# File 'lib/omnibus/config.rb', line 537

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

Returns:

  • (Integer)


585
586
587
588
589
590
591
# File 'lib/omnibus/config.rb', line 585

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