Class: Drunker::Executor::Builder
- Inherits:
-
Object
- Object
- Drunker::Executor::Builder
- Defined in:
- lib/drunker/executor/builder.rb
Constant Summary collapse
- IN_PROGRESS =
"IN_PROGRESS"
- SUCCEEDED =
"SUCCEEDED"
- FAILED =
"FAILED"
- TIMED_OUT =
"TIMED_OUT"
- STOPPED =
"STOPPED"
- RETRY_LIMIT =
3
- PHASE_ACCESS_DENIED =
"ACCESS_DENIED"
Instance Attribute Summary collapse
-
#build_id ⇒ Object
readonly
Returns the value of attribute build_id.
Instance Method Summary collapse
-
#access_denied? ⇒ Boolean
Sometimes ‘* is not authorized to perform` or `Not authorized to perform` error occurs…
- #errors ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(project_name:, targets:, artifact:, config:, logger:) ⇒ Builder
constructor
A new instance of Builder.
- #ran? ⇒ Boolean
- #refresh ⇒ Object
- #retriable? ⇒ Boolean
- #retry ⇒ Object
- #run ⇒ Object
- #running? ⇒ Boolean
- #success? ⇒ Boolean
Constructor Details
#initialize(project_name:, targets:, artifact:, config:, logger:) ⇒ Builder
Returns a new instance of Builder.
15 16 17 18 19 20 21 22 23 |
# File 'lib/drunker/executor/builder.rb', line 15 def initialize(project_name:, targets:, artifact:, config:, logger:) @project_name = project_name @targets = targets @artifact = artifact @config = config @client = Aws::CodeBuild::Client.new(config.) @retry_count = 0 @logger = logger end |
Instance Attribute Details
#build_id ⇒ Object (readonly)
Returns the value of attribute build_id.
13 14 15 |
# File 'lib/drunker/executor/builder.rb', line 13 def build_id @build_id end |
Instance Method Details
#access_denied? ⇒ Boolean
Sometimes ‘* is not authorized to perform` or `Not authorized to perform` error occurs… It is judged that this is not a problem by user setting.
45 46 47 48 49 50 51 52 |
# File 'lib/drunker/executor/builder.rb', line 45 def access_denied? return false unless failed? result.builds[0].phases.any? do |phase| phase.contexts&.any? do |context| context.status_code == PHASE_ACCESS_DENIED && (context.) end end end |
#errors ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/drunker/executor/builder.rb', line 74 def errors return unless failed? result.builds[0].phases.each_with_object([]) do |phase, results| phase.contexts&.each do |context| results << { phase_type: phase.phase_type, phase_status: phase.phase_status, status: context.status_code, message: context. } end end end |
#failed? ⇒ Boolean
62 63 64 |
# File 'lib/drunker/executor/builder.rb', line 62 def failed? ran? && status == FAILED end |
#ran? ⇒ Boolean
54 55 56 |
# File 'lib/drunker/executor/builder.rb', line 54 def ran? !!build_id end |
#refresh ⇒ Object
70 71 72 |
# File 'lib/drunker/executor/builder.rb', line 70 def refresh @result = nil end |
#retriable? ⇒ Boolean
33 34 35 |
# File 'lib/drunker/executor/builder.rb', line 33 def retriable? retry_count < RETRY_LIMIT end |
#retry ⇒ Object
37 38 39 40 41 |
# File 'lib/drunker/executor/builder.rb', line 37 def retry logger.info("Retrying build: #{build_id}") @retry_count += 1 run end |
#run ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/drunker/executor/builder.rb', line 25 def run @build_id = client.start_build(project_name: project_name, buildspec_override: buildspec).build.id refresh logger.info("Started build: #{build_id}") logger.debug("buildspec: #{buildspec}") build_id end |
#running? ⇒ Boolean
58 59 60 |
# File 'lib/drunker/executor/builder.rb', line 58 def running? ran? && status == IN_PROGRESS end |
#success? ⇒ Boolean
66 67 68 |
# File 'lib/drunker/executor/builder.rb', line 66 def success? ran? && status == SUCCEEDED end |