Merge pull request #858 from Infinisil/fix-declarative-flakes

Fix transition from declarative non-flake to flake jobset
This commit is contained in:
Graham Christensen 2021-02-02 11:04:05 -05:00 committed by GitHub
commit 6de9c6540c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -49,6 +49,18 @@ sub updateDeclarativeJobset {
$update{$key} = $declSpec->{$key};
delete $declSpec->{$key};
}
# Ensure jobset constraints are met, only have nixexpr{path,input} or
# flakes set if the type is 0 or 1 respectively. So in the update we need
# to null the field of the other type.
if (defined $update{type}) {
if ($update{type} == 0) {
$update{flake} = undef;
} elsif ($update{type} == 1) {
$update{nixexprpath} = undef;
$update{nixexprinput} = undef;
}
}
$db->txn_do(sub {
my $jobset = $project->jobsets->update_or_create(\%update);
$jobset->jobsetinputs->delete;