Add flake configuration to the web interface

This commit is contained in:
Eelco Dolstra
2019-05-10 23:39:55 +02:00
parent 6ee6ec3bda
commit f9f595cd21
7 changed files with 124 additions and 31 deletions

View File

@ -223,12 +223,19 @@ sub updateJobset {
error($c, "Cannot rename jobset to $jobsetName since that identifier is already taken.")
if $jobsetName ne $oldName && defined $c->stash->{project}->jobsets->find({ name => $jobsetName });
# When the expression is in a .scm file, assume it's a Guile + Guix
# build expression.
my $exprType =
$c->stash->{params}->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix";
my $type = int($c->stash->{params}->{"type"}) // 0;
my ($nixExprPath, $nixExprInput) = nixExprPathFromParams $c;
my ($nixExprPath, $nixExprInput);
my $flake;
if ($type == 0) {
($nixExprPath, $nixExprInput) = nixExprPathFromParams $c;
} elsif ($type == 1) {
$flake = trim($c->stash->{params}->{"flakeref"});
error($c, "Invalid flake URI $flake.") if $flake !~ /^[a-zA-Z]/;
} else {
error($c, "Invalid jobset type.");
}
my $enabled = int($c->stash->{params}->{enabled});
die if $enabled < 0 || $enabled > 2;
@ -251,6 +258,8 @@ sub updateJobset {
, checkinterval => $checkinterval
, triggertime => ($enabled && $checkinterval > 0) ? $jobset->triggertime // time() : undef
, schedulingshares => $shares
, type => $type
, flake => $flake
});
$jobset->project->jobsetrenames->search({ from_ => $jobsetName })->delete;
@ -260,23 +269,25 @@ sub updateJobset {
# Set the inputs of this jobset.
$jobset->jobsetinputs->delete;
foreach my $name (keys %{$c->stash->{params}->{inputs}}) {
my $inputData = $c->stash->{params}->{inputs}->{$name};
my $type = $inputData->{type};
my $value = $inputData->{value};
my $emailresponsible = defined $inputData->{emailresponsible} ? 1 : 0;
if ($type == 0) {
foreach my $name (keys %{$c->stash->{params}->{inputs}}) {
my $inputData = $c->stash->{params}->{inputs}->{$name};
my $type = $inputData->{type};
my $value = $inputData->{value};
my $emailresponsible = defined $inputData->{emailresponsible} ? 1 : 0;
error($c, "Invalid input name $name.") unless $name =~ /^[[:alpha:]][\w-]*$/;
error($c, "Invalid input type $type.") unless defined $c->stash->{inputTypes}->{$type};
error($c, "Invalid input name $name.") unless $name =~ /^[[:alpha:]][\w-]*$/;
error($c, "Invalid input type $type.") unless defined $c->stash->{inputTypes}->{$type};
my $input = $jobset->jobsetinputs->create(
{ name => $name,
type => $type,
emailresponsible => $emailresponsible
});
my $input = $jobset->jobsetinputs->create(
{ name => $name,
type => $type,
emailresponsible => $emailresponsible
});
$value = checkInputValue($c, $name, $type, $value);
$input->jobsetinputalts->create({altnr => 0, value => $value});
$value = checkInputValue($c, $name, $type, $value);
$input->jobsetinputalts->create({altnr => 0, value => $value});
}
}
}

View File

@ -191,6 +191,11 @@ __PACKAGE__->table("Builds");
default_value: 0
is_nullable: 0
=head2 notificationpendingsince
data_type: 'integer'
is_nullable: 1
=cut
__PACKAGE__->add_columns(
@ -252,6 +257,8 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 1 },
"keep",
{ data_type => "integer", default_value => 0, is_nullable => 0 },
"notificationpendingsince",
{ data_type => "integer", is_nullable => 1 },
);
=head1 PRIMARY KEY
@ -537,8 +544,8 @@ __PACKAGE__->many_to_many(
);
# Created by DBIx::Class::Schema::Loader v0.07043 @ 2016-02-12 17:20:42
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:/8aVtXu/+o0jmKHnSzwt+g
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2019-05-10 22:30:12
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:YK8Fc+37UAcL0u6ziOc5xQ
__PACKAGE__->has_many(
"dependents",

View File

@ -56,12 +56,12 @@ __PACKAGE__->table("Jobsets");
data_type: 'text'
is_foreign_key: 1
is_nullable: 0
is_nullable: 1
=head2 nixexprpath
data_type: 'text'
is_nullable: 0
is_nullable: 1
=head2 errormsg
@ -139,6 +139,17 @@ __PACKAGE__->table("Jobsets");
data_type: 'integer'
is_nullable: 1
=head2 type
data_type: 'integer'
default_value: 0
is_nullable: 0
=head2 flake
data_type: 'text'
is_nullable: 1
=cut
__PACKAGE__->add_columns(
@ -149,9 +160,9 @@ __PACKAGE__->add_columns(
"description",
{ data_type => "text", is_nullable => 1 },
"nixexprinput",
{ data_type => "text", is_foreign_key => 1, is_nullable => 0 },
{ data_type => "text", is_foreign_key => 1, is_nullable => 1 },
"nixexprpath",
{ data_type => "text", is_nullable => 0 },
{ data_type => "text", is_nullable => 1 },
"errormsg",
{ data_type => "text", is_nullable => 1 },
"errortime",
@ -180,6 +191,10 @@ __PACKAGE__->add_columns(
{ data_type => "boolean", is_nullable => 1 },
"starttime",
{ data_type => "integer", is_nullable => 1 },
"type",
{ data_type => "integer", default_value => 0, is_nullable => 0 },
"flake",
{ data_type => "text", is_nullable => 1 },
);
=head1 PRIMARY KEY
@ -282,7 +297,12 @@ __PACKAGE__->belongs_to(
"jobsetinput",
"Hydra::Schema::JobsetInputs",
{ jobset => "name", name => "nixexprinput", project => "project" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
{
is_deferrable => 0,
join_type => "LEFT",
on_delete => "NO ACTION",
on_update => "NO ACTION",
},
);
=head2 jobsetinputs
@ -352,8 +372,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.07045 @ 2017-03-09 13:03:05
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ivYvsUyhEeaeI4EmRQ0/QQ
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2019-05-11 00:03:52
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:UVG1D59bXaQ1TUEF237tXQ
my %hint = (
columns => [