forked from lix-project/hydra
Jobsets: update schema to align with the API
To further align with the API, we return custom JSON in order to display a `visible` field rather than `hidden` -- a `PUT` request expects `visible`, while a `GET` request returns `hidden`. This also allows us to rename the `jobsetinputs` field to `inputs` for the same reason: `PUT` expects `inputs`, while `GET` returns `jobsetinputs`.
This commit is contained in:
parent
d23f431889
commit
f1dd5d202e
|
@ -642,8 +642,8 @@ components:
|
||||||
enableemail:
|
enableemail:
|
||||||
description: when true the jobset sends emails when previously-successful builds fail
|
description: when true the jobset sends emails when previously-successful builds fail
|
||||||
type: boolean
|
type: boolean
|
||||||
hidden:
|
visible:
|
||||||
description: when false the jobset is visible in the web frontend
|
description: when true the jobset is visible in the web frontend
|
||||||
type: boolean
|
type: boolean
|
||||||
emailoverride:
|
emailoverride:
|
||||||
description: email address to send notices to instead of the package maintainer (can be a comma separated list)
|
description: email address to send notices to instead of the package maintainer (can be a comma separated list)
|
||||||
|
@ -667,12 +667,12 @@ components:
|
||||||
type: integer
|
type: integer
|
||||||
type:
|
type:
|
||||||
description: the type of the jobset
|
description: the type of the jobset
|
||||||
type: string
|
type: integer
|
||||||
flake:
|
flake:
|
||||||
nullable: true
|
nullable: true
|
||||||
description: the flake uri to evaluate
|
description: the flake uri to evaluate
|
||||||
type: string
|
type: string
|
||||||
jobsetinputs:
|
inputs:
|
||||||
description: inputs configured for this jobset
|
description: inputs configured for this jobset
|
||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
|
|
|
@ -270,8 +270,8 @@ sub updateJobset {
|
||||||
$jobset->jobsetinputs->delete;
|
$jobset->jobsetinputs->delete;
|
||||||
|
|
||||||
if ($type == 0) {
|
if ($type == 0) {
|
||||||
foreach my $name (keys %{$c->stash->{params}->{jobsetinputs}}) {
|
foreach my $name (keys %{$c->stash->{params}->{inputs}}) {
|
||||||
my $inputData = $c->stash->{params}->{jobsetinputs}->{$name};
|
my $inputData = $c->stash->{params}->{inputs}->{$name};
|
||||||
my $type = $inputData->{type};
|
my $type = $inputData->{type};
|
||||||
my $value = $inputData->{value};
|
my $value = $inputData->{value};
|
||||||
my $emailresponsible = defined $inputData->{emailresponsible} ? 1 : 0;
|
my $emailresponsible = defined $inputData->{emailresponsible} ? 1 : 0;
|
||||||
|
|
|
@ -410,40 +410,40 @@ __PACKAGE__->add_column(
|
||||||
"+id" => { retrieve_on_insert => 1 }
|
"+id" => { retrieve_on_insert => 1 }
|
||||||
);
|
);
|
||||||
|
|
||||||
my %hint = (
|
sub as_json {
|
||||||
columns => [
|
my $self = shift;
|
||||||
"errortime",
|
|
||||||
"lastcheckedtime",
|
|
||||||
"triggertime",
|
|
||||||
"enabled",
|
|
||||||
"keepnr",
|
|
||||||
"checkinterval",
|
|
||||||
"schedulingshares",
|
|
||||||
"starttime"
|
|
||||||
],
|
|
||||||
string_columns => [
|
|
||||||
"name",
|
|
||||||
"project",
|
|
||||||
"description",
|
|
||||||
"nixexprinput",
|
|
||||||
"nixexprpath",
|
|
||||||
"errormsg",
|
|
||||||
"emailoverride",
|
|
||||||
"fetcherrormsg",
|
|
||||||
"type",
|
|
||||||
"flake"
|
|
||||||
],
|
|
||||||
boolean_columns => [
|
|
||||||
"enableemail",
|
|
||||||
"hidden"
|
|
||||||
],
|
|
||||||
eager_relations => {
|
|
||||||
jobsetinputs => "name"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
sub json_hint {
|
my %json = (
|
||||||
return \%hint;
|
# columns
|
||||||
|
"errortime" => $self->get_column("errortime"),
|
||||||
|
"lastcheckedtime" => $self->get_column("lastcheckedtime"),
|
||||||
|
"triggertime" => $self->get_column("triggertime"),
|
||||||
|
"enabled" => $self->get_column("enabled"),
|
||||||
|
"keepnr" => $self->get_column("keepnr"),
|
||||||
|
"checkinterval" => $self->get_column("checkinterval"),
|
||||||
|
"schedulingshares" => $self->get_column("schedulingshares"),
|
||||||
|
"starttime" => $self->get_column("starttime"),
|
||||||
|
|
||||||
|
# string_columns
|
||||||
|
"name" => $self->get_column("name") // "",
|
||||||
|
"project" => $self->get_column("project") // "",
|
||||||
|
"description" => $self->get_column("description") // "",
|
||||||
|
"nixexprinput" => $self->get_column("nixexprinput") // "",
|
||||||
|
"nixexprpath" => $self->get_column("nixexprpath") // "",
|
||||||
|
"errormsg" => $self->get_column("errormsg") // "",
|
||||||
|
"emailoverride" => $self->get_column("emailoverride") // "",
|
||||||
|
"fetcherrormsg" => $self->get_column("fetcherrormsg") // "",
|
||||||
|
"type" => $self->get_column("type") // "",
|
||||||
|
"flake" => $self->get_column("flake") // "",
|
||||||
|
|
||||||
|
# boolean_columns
|
||||||
|
"enableemail" => $self->get_column("enableemail") ? JSON::true : JSON::false,
|
||||||
|
"visible" => $self->get_column("hidden") ? JSON::false : JSON::true,
|
||||||
|
|
||||||
|
"inputs" => { map { $_->name => $_ } $self->jobsetinputs }
|
||||||
|
);
|
||||||
|
|
||||||
|
return \%json;
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -46,8 +46,8 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr><th></th><th>Input name</th><th>Type</th><th style="width: 50%">Value</th><th>Notify committers</th></tr>
|
<tr><th></th><th>Input name</th><th>Type</th><th style="width: 50%">Value</th><th>Notify committers</th></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="jobsetinputs">
|
<tbody class="inputs">
|
||||||
[% jobsetinputs = createFromEval ? eval.jobsetevalinputs : jobset.jobsetinputs; FOREACH input IN jobsetinputs %]
|
[% inputs = createFromEval ? eval.jobsetevalinputs : jobset.jobsetinputs; FOREACH input IN inputs %]
|
||||||
[% INCLUDE renderJobsetInput input=input baseName="input-$input.name" %]
|
[% INCLUDE renderJobsetInput input=input baseName="input-$input.name" %]
|
||||||
[% END %]
|
[% END %]
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -220,8 +220,8 @@
|
||||||
|
|
||||||
$("#submit-jobset").click(function() {
|
$("#submit-jobset").click(function() {
|
||||||
var formElements = $(this).parents("form").serializeArray();
|
var formElements = $(this).parents("form").serializeArray();
|
||||||
var data = { 'jobsetinputs': {} };
|
var data = { 'inputs': {} };
|
||||||
var jobsetinputs = {};
|
var inputs = {};
|
||||||
for (var i = 0; formElements.length > i; i++) {
|
for (var i = 0; formElements.length > i; i++) {
|
||||||
var elem = formElements[i];
|
var elem = formElements[i];
|
||||||
var match = elem.name.match(/^input-([\w-]+)-(\w+)$/);
|
var match = elem.name.match(/^input-([\w-]+)-(\w+)$/);
|
||||||
|
@ -233,13 +233,13 @@
|
||||||
|
|
||||||
if (baseName === "template") continue;
|
if (baseName === "template") continue;
|
||||||
|
|
||||||
if (!(baseName in jobsetinputs))
|
if (!(baseName in inputs))
|
||||||
jobsetinputs[baseName] = {};
|
inputs[baseName] = {};
|
||||||
|
|
||||||
if (param === "name")
|
if (param === "name")
|
||||||
data.jobsetinputs[elem.value] = jobsetinputs[baseName];
|
data.inputs[elem.value] = inputs[baseName];
|
||||||
else
|
else
|
||||||
jobsetinputs[baseName][param] = elem.value;
|
inputs[baseName][param] = elem.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
redirectJSON({
|
redirectJSON({
|
||||||
|
|
|
@ -46,7 +46,7 @@ subtest 'Create new jobset "job" as flake type' => sub {
|
||||||
Cookie => $cookie,
|
Cookie => $cookie,
|
||||||
Content => encode_json({
|
Content => encode_json({
|
||||||
enabled => 2,
|
enabled => 2,
|
||||||
visible => 1,
|
visible => JSON::true,
|
||||||
name => "job",
|
name => "job",
|
||||||
type => 1,
|
type => 1,
|
||||||
description => "test jobset",
|
description => "test jobset",
|
||||||
|
@ -76,8 +76,8 @@ subtest 'Read newly-created jobset "job"' => sub {
|
||||||
errormsg => "",
|
errormsg => "",
|
||||||
fetcherrormsg => "",
|
fetcherrormsg => "",
|
||||||
flake => "github:nixos/nix",
|
flake => "github:nixos/nix",
|
||||||
hidden => JSON::false,
|
visible => JSON::true,
|
||||||
jobsetinputs => {},
|
inputs => {},
|
||||||
keepnr => 3,
|
keepnr => 3,
|
||||||
lastcheckedtime => undef,
|
lastcheckedtime => undef,
|
||||||
name => "job",
|
name => "job",
|
||||||
|
@ -99,12 +99,12 @@ subtest 'Update jobset "job" to legacy type' => sub {
|
||||||
Cookie => $cookie,
|
Cookie => $cookie,
|
||||||
Content => encode_json({
|
Content => encode_json({
|
||||||
enabled => 3,
|
enabled => 3,
|
||||||
visible => 1,
|
visible => JSON::true,
|
||||||
name => "job",
|
name => "job",
|
||||||
type => 0,
|
type => 0,
|
||||||
nixexprinput => "ofborg",
|
nixexprinput => "ofborg",
|
||||||
nixexprpath => "release.nix",
|
nixexprpath => "release.nix",
|
||||||
jobsetinputs => {
|
inputs => {
|
||||||
ofborg => {
|
ofborg => {
|
||||||
name => "ofborg",
|
name => "ofborg",
|
||||||
type => "git",
|
type => "git",
|
||||||
|
@ -134,15 +134,13 @@ subtest 'Update jobset "job" to legacy type' => sub {
|
||||||
errormsg => "",
|
errormsg => "",
|
||||||
fetcherrormsg => "",
|
fetcherrormsg => "",
|
||||||
flake => "",
|
flake => "",
|
||||||
hidden => JSON::false,
|
visible => JSON::true,
|
||||||
jobsetinputs => {
|
inputs => {
|
||||||
ofborg => {
|
ofborg => {
|
||||||
name => "ofborg",
|
name => "ofborg",
|
||||||
type => "git",
|
type => "git",
|
||||||
emailresponsible => JSON::false,
|
emailresponsible => JSON::false,
|
||||||
jobsetinputalts => [
|
value => "https://github.com/NixOS/ofborg.git released"
|
||||||
"https://github.com/NixOS/ofborg.git released"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
keepnr => 1,
|
keepnr => 1,
|
||||||
|
|
|
@ -81,14 +81,14 @@ subtest "projects" => sub {
|
||||||
};
|
};
|
||||||
|
|
||||||
subtest "jobsets" => sub {
|
subtest "jobsets" => sub {
|
||||||
my $result = request_json({ uri => '/jobset/sample/default', method => 'PUT', data => { nixexprpath => "default.nix", nixexprinput => "my-src", jobsetinputs => { "my-src" => { type => "path", value => $jobsetdir } }, enabled => "1", visible => "1", checkinterval => "3600"} });
|
my $result = request_json({ uri => '/jobset/sample/default', method => 'PUT', data => { nixexprpath => "default.nix", nixexprinput => "my-src", inputs => { "my-src" => { type => "path", value => $jobsetdir } }, enabled => "1", visible => "1", checkinterval => "3600"} });
|
||||||
is($result->code(), 201, "PUTting a new jobset creates it");
|
is($result->code(), 201, "PUTting a new jobset creates it");
|
||||||
|
|
||||||
my $jobset = decode_json(request_json({ uri => '/jobset/sample/default' })->content());
|
my $jobset = decode_json(request_json({ uri => '/jobset/sample/default' })->content());
|
||||||
|
|
||||||
ok(exists $jobset->{jobsetinputs}->{"my-src"}, "The new jobset has a 'my-src' input");
|
ok(exists $jobset->{inputs}->{"my-src"}, "The new jobset has a 'my-src' input");
|
||||||
|
|
||||||
is($jobset->{jobsetinputs}->{"my-src"}->{"jobsetinputalts"}->[0], $jobsetdir, "The 'my-src' input is in $jobsetdir");
|
is($jobset->{inputs}->{"my-src"}->{value}, $jobsetdir, "The 'my-src' input is in $jobsetdir");
|
||||||
};
|
};
|
||||||
|
|
||||||
subtest "evaluation" => sub {
|
subtest "evaluation" => sub {
|
||||||
|
|
Loading…
Reference in a new issue