Controller/Build: pass log_uri to showLog in place of drvPath

This way, we can reuse the `showLog` sub for other things, such as
`view_runcommandlog` (which doesn't have a drvPath attached).
This commit is contained in:
Cole Helbling 2022-01-26 12:36:25 -08:00
parent ff390e89a6
commit 1d0076408b

View file

@ -126,13 +126,18 @@ sub view_nixlog : Chained('buildChain') PathPart('nixlog') {
$c->stash->{step} = $step; $c->stash->{step} = $step;
showLog($c, $mode, $step->drvpath); my $drvPath = $step->drvpath;
my $log_uri = $c->uri_for($c->controller('Root')->action_for("log"), [basename($drvPath)]);
showLog($c, $mode, $log_uri);
} }
sub view_log : Chained('buildChain') PathPart('log') { sub view_log : Chained('buildChain') PathPart('log') {
my ($self, $c, $mode) = @_; my ($self, $c, $mode) = @_;
showLog($c, $mode, $c->stash->{build}->drvpath);
my $drvPath = $c->stash->{build}->drvpath;
my $log_uri = $c->uri_for($c->controller('Root')->action_for("log"), [basename($drvPath)]);
showLog($c, $mode, $log_uri);
} }
@ -145,11 +150,9 @@ sub view_runcommandlog : Chained('buildChain') PathPart('runcommandlog') {
sub showLog { sub showLog {
my ($c, $mode, $drvPath) = @_; my ($c, $mode, $log_uri) = @_;
$mode //= "pretty"; $mode //= "pretty";
my $log_uri = $c->uri_for($c->controller('Root')->action_for("log"), [basename($drvPath)]);
if ($mode eq "pretty") { if ($mode eq "pretty") {
$c->stash->{log_uri} = $log_uri; $c->stash->{log_uri} = $log_uri;
$c->stash->{template} = 'log.tt'; $c->stash->{template} = 'log.tt';