Class: Tebako::LayerPlanner
- Inherits:
-
Object
- Object
- Tebako::LayerPlanner
- Defined in:
- lib/tebako/layer_planner.rb
Overview
Produces a deterministic, bounded set of independently cached package layers.
Defined Under Namespace
Classes: Layer
Constant Summary collapse
- SCHEMA_VERSION =
1- DEFAULT_MAX_LAYERS =
12- DEFAULT_MIN_LAYER_SIZE =
256 * 1024
- SEMANTIC_DIRECTORIES =
%w[app assets config lib public views].freeze
Instance Method Summary collapse
-
#initialize(data_src_dir:, ruby_api_version:, workspace:, strategy: "coarse", max_layers: DEFAULT_MAX_LAYERS, min_layer_size: DEFAULT_MIN_LAYER_SIZE, single_mount: false) ⇒ LayerPlanner
constructor
A new instance of LayerPlanner.
- #plan ⇒ Object
Constructor Details
#initialize(data_src_dir:, ruby_api_version:, workspace:, strategy: "coarse", max_layers: DEFAULT_MAX_LAYERS, min_layer_size: DEFAULT_MIN_LAYER_SIZE, single_mount: false) ⇒ LayerPlanner
Returns a new instance of LayerPlanner.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/tebako/layer_planner.rb', line 23 def initialize(data_src_dir:, ruby_api_version:, workspace:, strategy: "coarse", max_layers: DEFAULT_MAX_LAYERS, min_layer_size: DEFAULT_MIN_LAYER_SIZE, single_mount: false) @data_src_dir = data_src_dir @ruby_api_version = ruby_api_version @workspace = workspace @strategy = strategy @max_layers = max_layers @min_layer_size = min_layer_size @single_mount = single_mount end |
Instance Method Details
#plan ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/tebako/layer_planner.rb', line 34 def plan layers = if @single_mount [Layer.new(mount_point: "application", source: @data_src_dir, category: "application_capsule")] else @strategy == "semantic" ? semantic_plan : coarse_plan end status = @single_mount ? "capsule" : @strategy Tebako::BuildReporter.record( stage: "layer_plan", status: status, reason: "#{layers.length} deterministic application layers selected", details: { "schema_version" => SCHEMA_VERSION, "layers" => layers.map(&:mount_point) } ) layers rescue SystemCallError => e Tebako::BuildReporter.record( stage: "layer_plan", status: "fallback", reason: "semantic planning failed; using coarse layers: #{e.}" ) coarse_plan end |