Merge pull request #937 from DeterminateSystems/flesh-out-api

hydra-api: flesh out Jobset, JobsetInput schemas; implement DELETE /jobset/{project-id}/{jobset-id}
This commit is contained in:
Graham Christensen
2021-04-28 13:43:04 -04:00
committed by GitHub
7 changed files with 380 additions and 88 deletions

View File

@ -231,7 +231,7 @@ sub updateJobset {
if ($type == 0) {
($nixExprPath, $nixExprInput) = nixExprPathFromParams $c;
} elsif ($type == 1) {
$flake = trim($c->stash->{params}->{"flakeref"});
$flake = trim($c->stash->{params}->{"flake"});
error($c, "Invalid flake URI $flake.") if $flake !~ /^[a-zA-Z]/;
} else {
error($c, "Invalid jobset type.");
@ -270,8 +270,8 @@ sub updateJobset {
$jobset->jobsetinputs->delete;
if ($type == 0) {
foreach my $name (keys %{$c->stash->{params}->{inputs}}) {
my $inputData = $c->stash->{params}->{inputs}->{$name};
foreach my $name (keys %{$c->stash->{params}->{jobsetinputs}}) {
my $inputData = $c->stash->{params}->{jobsetinputs}->{$name};
my $type = $inputData->{type};
my $value = $inputData->{value};
my $emailresponsible = defined $inputData->{emailresponsible} ? 1 : 0;

View File

@ -27,8 +27,8 @@ sub login_POST {
my $username = $c->stash->{params}->{username} // "";
my $password = $c->stash->{params}->{password} // "";
error($c, "You must specify a user name.") if $username eq "";
error($c, "You must specify a password.") if $password eq "";
badRequest($c, "You must specify a user name.") if $username eq "";
badRequest($c, "You must specify a password.") if $password eq "";
if ($c->get_auth_realm('ldap') && $c->authenticate({username => $username, password => $password}, 'ldap')) {
doLDAPLogin($self, $c, $username);
@ -37,7 +37,11 @@ sub login_POST {
accessDenied($c, "Bad username or password.")
}
currentUser_GET($self, $c);
$self->status_found(
$c,
location => $c->uri_for("current-user"),
entity => {}
);
}

View File

@ -135,6 +135,13 @@ __PACKAGE__->has_many(
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5uKwEhDXso4IR1TFmwRxiA
my %hint = (
string_columns => [
"name",
"type"
],
boolean_columns => [
"emailresponsible"
],
relations => {
"jobsetinputalts" => "value"
}

View File

@ -412,12 +412,30 @@ __PACKAGE__->add_column(
my %hint = (
columns => [
"errortime",
"lastcheckedtime",
"triggertime",
"enabled",
"errormsg",
"fetcherrormsg",
"emailoverride",
"keepnr",
"checkinterval",
"schedulingshares",
"starttime"
],
string_columns => [
"name",
"project",
"description",
"nixexprinput",
"nixexprpath",
"nixexprinput"
"errormsg",
"emailoverride",
"fetcherrormsg",
"type",
"flake"
],
boolean_columns => [
"enableemail",
"hidden"
],
eager_relations => {
jobsetinputs => "name"

View File

@ -46,8 +46,8 @@
<thead>
<tr><th></th><th>Input name</th><th>Type</th><th style="width: 50%">Value</th><th>Notify committers</th></tr>
</thead>
<tbody class="inputs">
[% inputs = createFromEval ? eval.jobsetevalinputs : jobset.jobsetinputs; FOREACH input IN inputs %]
<tbody class="jobsetinputs">
[% jobsetinputs = createFromEval ? eval.jobsetevalinputs : jobset.jobsetinputs; FOREACH input IN jobsetinputs %]
[% INCLUDE renderJobsetInput input=input baseName="input-$input.name" %]
[% END %]
<tr>
@ -111,9 +111,9 @@
</div>
<div class="form-group row show-on-flake">
<label class="col-form-label col-sm-3" for="editjobsetflakeref">Flake URI</label>
<label class="col-form-label col-sm-3" for="editjobsetflake">Flake URI</label>
<div class="col-sm-9">
<input type="text" class="form-control" id="editjobsetflakeref" name="flakeref" [% HTML.attributes(value => jobset.flake) %]/>
<input type="text" class="form-control" id="editjobsetflake" name="flake" [% HTML.attributes(value => jobset.flake) %]/>
</div>
</div>
@ -220,8 +220,8 @@
$("#submit-jobset").click(function() {
var formElements = $(this).parents("form").serializeArray();
var data = { 'inputs': {} };
var inputs = {};
var data = { 'jobsetinputs': {} };
var jobsetinputs = {};
for (var i = 0; formElements.length > i; i++) {
var elem = formElements[i];
var match = elem.name.match(/^input-([\w-]+)-(\w+)$/);
@ -233,13 +233,13 @@
if (baseName === "template") continue;
if (!(baseName in inputs))
inputs[baseName] = {};
if (!(baseName in jobsetinputs))
jobsetinputs[baseName] = {};
if (param === "name")
data.inputs[elem.value] = inputs[baseName];
data.jobsetinputs[elem.value] = jobsetinputs[baseName];
else
inputs[baseName][param] = elem.value;
jobsetinputs[baseName][param] = elem.value;
}
}
redirectJSON({