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

#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


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)

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

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)

386
387
388
# File 'lib/omnibus/config.rb', line 386

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)

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

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)

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

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)

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

default(:artifactory_proxy_address, nil)

#artifactory_proxy_password(value = NULL) ⇒ String

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

Returns:

  • (String)

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

default(:artifactory_proxy_password, nil)

#artifactory_proxy_port(value = NULL) ⇒ String

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

Returns:

  • (String)

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

default(:artifactory_proxy_port, nil)

#artifactory_proxy_username(value = NULL) ⇒ String

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

Returns:

  • (String)

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

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)

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

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)

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

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)

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

default(:artifactory_ssl_verify, true)

#artifactory_username(value = NULL) ⇒ String

The username of the artifactory user to authenticate with.

Returns:

  • (String)

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

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

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

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

#build_dmg(value = NULL) ⇒ true, false

Package OSX pkg files inside a DMG

Returns:

  • (true, false)

186
187
188
189
190
191
# File 'lib/omnibus/config.rb', line 186

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)

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

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

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

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

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)

207
208
209
210
211
212
# File 'lib/omnibus/config.rb', line 207

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)

196
197
198
199
200
201
# File 'lib/omnibus/config.rb', line 196

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)

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

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)

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

default(:fatal_transitive_dependency_licensing_warnings, false)

#fetcher_read_timeout(value = NULL) ⇒ Integer

The number of seconds to wait

Returns:

  • (Integer)

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

default(:fetcher_read_timeout, 60)

#fetcher_retries(value = NULL) ⇒ Integer

The number of retries before marking a download as failed

Returns:

  • (Integer)

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

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)

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

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)

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

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

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

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)

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

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

#package_tmp(value = NULL) ⇒ String

Deprecated.

Do not use this method.

Returns:

  • (String)

151
152
153
154
155
# File 'lib/omnibus/config.rb', line 151

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)

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

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)

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

default(:project_root) { Dir.pwd }

#publish_retries(value = NULL) ⇒ Integer

The number of times to try to publish an artifact

Returns:

  • (Integer)

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

default(:publish_retries, 2)

#publish_s3_access_key(value = NULL) ⇒ String?

The S3 access key to use for S3 artifact release.

Returns:

  • (String, nil)

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

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)

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

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)

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

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)

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

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)

255
256
257
258
259
260
# File 'lib/omnibus/config.rb', line 255

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)

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

default(:s3_accelerate, false)

#s3_access_key(value = NULL) ⇒ String?

The S3 access key to use with S3 caching.

Returns:

  • (String, nil)

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

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)

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

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)

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

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)

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

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)

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

default(:s3_iam_role_arn, nil)

#s3_profile(value = NULL) ⇒ String?

The AWS credentials profile to use with S3 caching.

Returns:

  • (String, nil)

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

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)

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

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)

320
321
322
# File 'lib/omnibus/config.rb', line 320

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)

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

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)

217
218
219
220
221
222
# File 'lib/omnibus/config.rb', line 217

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)

245
246
247
248
249
250
# File 'lib/omnibus/config.rb', line 245

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)

227
228
229
230
231
232
# File 'lib/omnibus/config.rb', line 227

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)

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

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

512
513
514
# File 'lib/omnibus/config.rb', line 512

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)

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

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)

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

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)

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

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)

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

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)

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

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)

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

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