@@ -6,6 +6,7 @@ use warnings;
66use base ' Hydra::Base::Controller::NixChannel' ;
77use Hydra::Helper::Nix;
88use Hydra::Helper::CatalystUtils;
9+ use Hydra::Controller::API;
910use File::Basename;
1011use File::stat ;
1112use Data::Dump qw( dump) ;
@@ -569,13 +570,52 @@ sub bump : Chained('buildChain') PathPart('bump') {
569570}
570571
571572
573+ sub buildStepToHash {
574+ my ($buildstep ) = @_ ;
575+ return {
576+ build => $buildstep -> get_column(' build' ),
577+ busy => $buildstep -> busy,
578+ drvpath => $buildstep -> drvpath,
579+ errormsg => $buildstep -> errormsg,
580+ isnondeterministic => $buildstep -> isnondeterministic,
581+ machine => $buildstep -> machine,
582+ overhead => $buildstep -> overhead,
583+ # The propagatedfrom field will hold a Build type if it was propagated, we'd like to display that info, so we
584+ # convert the that record to a hash here and inline it, we already have the data on hand and it saves clients a
585+ # request to obtain the actual reason why something happened.
586+ propagatedfrom => defined ($buildstep -> propagatedfrom) ? Hydra::Controller::API::buildToHash($buildstep -> propagatedfrom) : undef ,
587+ starttime => $buildstep -> starttime,
588+ status => $buildstep -> status,
589+ stepnr => $buildstep -> stepnr,
590+ stoptime => $buildstep -> stoptime,
591+ system => $buildstep -> system ,
592+ timesbuilt => $buildstep -> timesbuilt,
593+ type => $buildstep -> type,
594+ haserrormsg => defined ($buildstep -> errormsg) && $buildstep -> errormsg ne " " ? JSON::MaybeXS::true : JSON::MaybeXS::false
595+ };
596+ }
597+
598+
572599sub get_info : Chained(' buildChain' ) PathPart(' api/get-info' ) Args(0) {
573600 my ($self , $c ) = @_ ;
574601 my $build = $c -> stash-> {build };
602+
603+ # Since this is the detailed info of the build, lets start with populating it with
604+ # the info we can obtain form the build.
605+ $c -> stash-> {json } = Hydra::Controller::API::buildToHash($build );
606+
607+ # Provide the original get-info endpoint attributes.
575608 $c -> stash-> {json }-> {buildId } = $build -> id;
576609 $c -> stash-> {json }-> {drvPath } = $build -> drvpath;
577610 my $out = getMainOutput($build );
578611 $c -> stash-> {json }-> {outPath } = $out -> path if defined $out ;
612+
613+ # Finally, provide information about all the buildsteps that made up this build.
614+ my @buildsteps = $build -> buildsteps-> search({}, {order_by => " stepnr asc" });
615+ my @buildsteplist ;
616+ push @buildsteplist , buildStepToHash($_ ) foreach @buildsteps ;
617+ $c -> stash-> {json }-> {steps } = \@buildsteplist ;
618+
579619 $c -> forward(' View::JSON' );
580620}
581621
0 commit comments