lib/omnibus/config.rb in omnibus-3.0.0 vs lib/omnibus/config.rb in omnibus-3.1.0
- old
+ new
@@ -1,8 +1,7 @@
#
-# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
-# License:: Apache License, Version 2.0
+# Copyright 2012-2014 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
@@ -14,12 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
require 'mixlib/config'
-require 'omnibus/exceptions'
-require 'json'
module Omnibus
# Global configuration object for Omnibus runs.
#
# @todo Write a {http://yardoc.org/guides/extending-yard/writing-handlers.html
@@ -27,67 +24,77 @@
# the default value to show up in the docs without having to type
# it out twice, which I'm doing now for benefit of viewers of the Yard docs.
class Config
extend Mixlib::Config
+ # Converts a given path to a platform specific path based on windows or
+ # linux.
+ def self.platformize_omnibus_path(path)
+ if Ohai.platform == 'windows'
+ File.join('C:\\omnibus-ruby', path).gsub(File::SEPARATOR, File::ALT_SEPARATOR)
+ else
+ File.join('/var/cache/omnibus', path)
+ end
+ end
+
# @!group Directory Configuration Parameters
# @!attribute [rw] cache_dir
# The absolute path to the directory on the virtual machine where
# code will be cached.
#
# Defaults to `"/var/cache/omnibus/cache"`.
#
# @return [String]
- default :cache_dir, '/var/cache/omnibus/cache'
+ default(:cache_dir) { platformize_omnibus_path('cache') }
# @!attribute [rw] install_path_cache_dir
# The absolute path to the directory on the virtual machine where
# install paths will be progressively cached.
#
# Defaults to `"/var/cache/omnibus/cache/install_path"`.
#
# @return [String]
- default :install_path_cache_dir, '/var/cache/omnibus/cache/install_path'
+ default(:install_path_cache_dir) { platformize_omnibus_path('cache/install_path') }
# @!attribute [rw] source_dir
# The absolute path to the directory on the virtual machine where
# source code will be downloaded.
#
# Defaults to `"/var/cache/omnibus/src"`.
#
# @return [String]
- default :source_dir, '/var/cache/omnibus/src'
+ default(:source_dir) { platformize_omnibus_path('src') }
# @!attribute [rw] build_dir
# The absolute path to the directory on the virtual machine where
# software will be built.
#
# Defaults to `"/var/cache/omnibus/build"`.
#
# @return [String]
- default :build_dir, '/var/cache/omnibus/build'
+ default(:build_dir) { platformize_omnibus_path('build') }
# @!attribute [rw] package_dir
# The absolute path to the directory on the virtual machine where
# packages will be constructed.
#
# Defaults to `"/var/cache/omnibus/pkg"`.
#
# @return [String]
- default :package_dir, '/var/cache/omnibus/pkg'
+ default(:package_dir) { platformize_omnibus_path('pkg') }
# @!attribute [rw] package_tmp
# The absolute path to the directory on the virtual machine where
# packagers will store intermediate packaging products. Some packaging
# methods (notably fpm) handle this internally so not all packagers will
# use this setting.
#
# Defaults to `"/var/cache/omnibus/pkg-tmp"`.
#
# @return [String]
- default :package_tmp, '/var/cache/omnibus/pkg-tmp'
+ default(:package_tmp) { platformize_omnibus_path('pkg-tmp') }
# @!attribute [rw] project_dir
# The relative path of the directory containing {Omnibus::Project}
# DSL files. This is relative to {#project_root}.
#
@@ -110,11 +117,11 @@
# {Omnibus::Software} DSL files.
#
# Defaults to the current working directory.
#
# @return [String]
- default :project_root, Dir.pwd
+ default(:project_root) { Dir.pwd }
# @!attribute [rw] install_dir
# Installation directory
#
# Defaults to `"/opt/chef"`.
@@ -125,11 +132,11 @@
# @return [String]
default :install_dir, '/opt/chef'
# @!endgroup
- # @!group DMG configuration options
+ # @!group DMG / PKG configuration options
# @!attribute [rw] build_dmg
# Package OSX pkg files inside a DMG
#
# @return [Boolean]
@@ -147,10 +154,26 @@
# the DMG window.
#
# @return [String]
default :dmg_pkg_position, '535, 50'
+ # @!attribute [rw] sign_pkg
+ # Sign the pkg package.
+ #
+ # Default is false.
+ #
+ # @return [Boolean]
+ default :sign_pkg, false
+
+ # @!attribute [rw] signing_identity
+ # The identity to sign the pkg with.
+ #
+ # Default is nil. Required if sign_pkg is set.
+ #
+ # @return [String]
+ default :signing_identity, nil
+
# @!endgroup
# @!group S3 Caching Configuration Parameters
# @!attribute [rw] use_s3_caching
@@ -243,19 +266,21 @@
# @!endgroup
# @!group Build Version Parameters
# @!attribute [rw] append_timestamp
+ # Append the current timestamp to the version identifier.
#
# @return [Boolean]
default :append_timestamp, true
# # @!endgroup
# @!group Build Control Parameters
# @! attribute [rw] build_retries
+ # The number of times to retry the build before failing.
#
# @return [Integer, nil]
default :build_retries, 3
# @!group Validation Methods
@@ -272,10 +297,10 @@
# @raise [InvalidS3Configuration]
def self.valid_s3_config?
if use_s3_caching
unless s3_bucket
- fail InvalidS3Configuration.new(s3_bucket, s3_access_key, s3_secret_key)
+ raise InvalidS3Configuration.new(s3_bucket, s3_access_key, s3_secret_key)
end
end
end
# @!endgroup