Class: Dapp::Build::Stage::Base
- Inherits:
-
Object
- Object
- Dapp::Build::Stage::Base
- Includes:
- Helper::Sha256, Helper::Trivia
- Defined in:
- lib/dapp/build/stage/base.rb
Overview
Base of all stages
Direct Known Subclasses
AppInstall, AppSetup, From, InfraInstall, InfraSetup, SourceBase
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#next_stage ⇒ Object
Returns the value of attribute next_stage.
-
#prev_stage ⇒ Object
Returns the value of attribute prev_stage.
Instance Method Summary collapse
-
#build! ⇒ Object
rubocop:disable Metrics/AbcSize.
- #image ⇒ Object
-
#initialize(application, next_stage) ⇒ Base
constructor
A new instance of Base.
-
#save_in_cache! ⇒ Object
rubocop:enable Metrics/AbcSize.
- #signature ⇒ Object
Methods included from Helper::Trivia
class_to_lowercase, #class_to_lowercase, #delete_file, #kwargs, #to_mb
Methods included from Helper::Sha256
Constructor Details
#initialize(application, next_stage) ⇒ Base
Returns a new instance of Base.
12 13 14 15 16 17 |
# File 'lib/dapp/build/stage/base.rb', line 12 def initialize(application, next_stage) @application = application @next_stage = next_stage @next_stage.prev_stage = self end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
10 11 12 |
# File 'lib/dapp/build/stage/base.rb', line 10 def application @application end |
#next_stage ⇒ Object
Returns the value of attribute next_stage.
9 10 11 |
# File 'lib/dapp/build/stage/base.rb', line 9 def next_stage @next_stage end |
#prev_stage ⇒ Object
Returns the value of attribute prev_stage.
9 10 11 |
# File 'lib/dapp/build/stage/base.rb', line 9 def prev_stage @prev_stage end |
Instance Method Details
#build! ⇒ Object
rubocop:disable Metrics/AbcSize
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/dapp/build/stage/base.rb', line 20 def build! return if image.tagged? && !application.log_verbose? prev_stage.build! if prev_stage begin if image.tagged? application.log_state(name, state: application.t(code: 'state.using_cache')) elsif application.dry_run? application.log_state(name, state: application.t(code: 'state.build'), styles: { status: :success }) else application.log_process(name, process: application.t(code: 'status.process.building'), short: should_be_not_detailed?) do image_build! end end ensure log_build end end |
#image ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/dapp/build/stage/base.rb', line 49 def image @image ||= begin StageImage.new(name: image_name, from: from_image).tap do |image| image.add_volume "#{application.build_path}:#{application.container_build_path}" yield image if block_given? end end end |
#save_in_cache! ⇒ Object
rubocop:enable Metrics/AbcSize
39 40 41 42 43 |
# File 'lib/dapp/build/stage/base.rb', line 39 def save_in_cache! return if image.tagged? prev_stage.save_in_cache! if prev_stage image.tag!(log_verbose: application.log_verbose?, log_time: application.log_time?) unless application.dry_run? end |
#signature ⇒ Object
45 46 47 |
# File 'lib/dapp/build/stage/base.rb', line 45 def signature hashsum prev_stage.signature end |