class Builderator::Config::File
DSL Loader for a configuration file
Attributes
date[R]
policies[R]
source[R]
type[R]
Public Class Methods
from_file(source, **options)
click to toggle source
DSL Loaders
# File lib/builderator/config/file.rb, line 17 def from_file(source, **options) new({}, options.merge(:type => :file, :source => source)) end
from_json(source, **options)
click to toggle source
# File lib/builderator/config/file.rb, line 21 def from_json(source, **options) new({}, options.merge(:type => :json, :source => source)) end
lookup_cache()
click to toggle source
# File lib/builderator/config/file.rb, line 25 def lookup_cache @lookup_cache ||= {} end
new(attributes = {}, options = {}, &block)
click to toggle source
Calls superclass method
Builderator::Config::Attributes::new
# File lib/builderator/config/file.rb, line 35 def initialize(attributes = {}, options = {}, &block) @policies = {} @date = Time.now.utc @type = options.fetch(:type, :code) @source = options.fetch(:source, nil) super(attributes, options, &block) end
Public Instance Methods
autoversion()
click to toggle source
Enable/disable auto-versioning features
# File lib/builderator/config/file.rb, line 115 namespace :autoversion do attribute :create_tags attribute :search_tags end
aws()
click to toggle source
AWS configurations
# File lib/builderator/config/file.rb, line 166 namespace :aws do attribute :region attribute :access_key attribute :secret_key end
cleaner()
click to toggle source
Cleaner Parameters
# File lib/builderator/config/file.rb, line 351 namespace :cleaner do attribute :commit attribute :force attribute :filters, Hash attribute :group_by, :type => :list attribute :sort_by attribute :keep namespace :limits do attribute :images attribute :launch_configs attribute :snapshots attribute :volumes end end
cleanup()
click to toggle source
Option to disable cleanup of build resources
# File lib/builderator/config/file.rb, line 400 attribute :cleanup
compile()
click to toggle source
Calls superclass method
Builderator::Config::Attributes#compile
# File lib/builderator/config/file.rb, line 45 def compile clean ## Clear dirty flag before re-parsing file or block case @type when :file instance_eval(IO.read(source), source, 0) super(false) when :json update = Rash.coerce(JSON.parse(IO.read(source))) unless @attributes == update dirty(true) @attributes = update end else instance_eval(&@block) if @block super(false) end ## Overlay policies policy.each do |name, policy| if policy.has?(:path) next unless ::File.exist?(policy.path) policies[name] ||= self.class.from_file(policy.path) elsif policy.has?(:json) next unless ::File.exist?(policy.json) policies[name] ||= self.class.from_json(policy.json) end policies[name].compile dirty(policies[name].dirty) end self end
cookbook()
click to toggle source
Cookbook build options
# File lib/builderator/config/file.rb, line 142 namespace :cookbook do attribute :path attribute :berkshelf_config attribute :sources, :type => :list, :singular => :add_source attribute :metadata collection :depends do attribute :version attribute :git attribute :github attribute :branch attribute :tag attribute :ref attribute :rel attribute :path, :relative => true end end
generator()
click to toggle source
Generator Options
# File lib/builderator/config/file.rb, line 370 namespace :generator do collection :project do namespace :builderator do attribute :version end namespace :ruby do attribute :version end namespace :vagrant do attribute :install attribute :version collection :plugin do attribute :version end end collection :resource do attribute :path, :type => :list attribute :action attribute :template end end end
local()
click to toggle source
Local resource paths
# File lib/builderator/config/file.rb, line 123 namespace :local do attribute :cookbook_path attribute :data_bag_path attribute :environment_path end
lookup(source, query)
click to toggle source
Use the Data controller to fetch IDs from the EC2 API at compile time
# File lib/builderator/config/file.rb, line 85 def lookup(source, query) self.class.lookup_cache[cache_key(query)] ||= Control::Data.lookup(source, query) end
relative(*path)
click to toggle source
Helper to resolve absolute paths relative to this `File`. Only works for `File`s with valid filesystem source attributes!
# File lib/builderator/config/file.rb, line 96 def relative(*path) Pathname.new(source).join(*(['..', path].flatten)).expand_path end
vendor()
click to toggle source
Configure resources that must be fetched for a build
# File lib/builderator/config/file.rb, line 336 collection :vendor do attribute :path, :relative => true attribute :git attribute :github attribute :remote attribute :branch attribute :tag attribute :ref attribute :rel end
vendored(name, *path)
click to toggle source
Helper to resolve paths to vendored files
# File lib/builderator/config/file.rb, line 90 def vendored(name, *path) Util.vendor(name, *path) end
Private Instance Methods
cache_key(query)
click to toggle source
Helper to generate unique, predictable keys for caching
# File lib/builderator/config/file.rb, line 405 def cache_key(query) query.keys.sort.map { |k| "#{k}:#{query[k]}" }.join('|') end