Jobset: list known inputs in invalid input type response

[?]
Apr 30, 2021, 12:41 AM
WQYAGTX3RIB4PW6WZC7FDW3FNXMOJ4HTRGZMB4OVDWGPUKDSK2GAC

Dependencies

  • [2] ZDH6UX5U Jobset: add HTTP API test
  • [3] OOQ2D3KC * Refactoring: move fetchInput out of hydra_scheduler into a separate
  • [4] KYSBJAYN Allow dashes in jobset input names
  • [5] VZX6HJ3I Fix jobset input handling in the API
  • [6] ZFEN2MAO Simplify jobset cloning
  • [7] LZVO64YG Merge in the first bits of the API work
  • [8] TQVKZQUG Use the REST API in the web interface for editing jobsets
  • [9] ZCTQCN3E Use inputTypes from plugins to determine valid input types
  • [10] ODNCGFQ5 * Improved the navigation bar: don't include all projects (since that
  • [11] QUMWPGCU Add flake configuration to the web interface
  • [*] 3HZY24CX * Make jobsets viewable under

Change contents

  • edit in src/lib/Hydra/Controller/Jobset.pm at line 214
    [3.2152]
    [3.2152]
  • edit in src/lib/Hydra/Controller/Jobset.pm at line 216
    [3.2153]
    [3.2153]
    sub knownInputTypes {
    my ($c) = @_;
  • edit in src/lib/Hydra/Controller/Jobset.pm at line 219
    [3.2154]
    [3.1467]
    my @keys = keys %{$c->stash->{inputTypes}};
    my $types = "";
    my $counter = 0;
    foreach my $key (@keys) {
    $types = $types . "and ‘$key’" if ++$counter == scalar(@keys);
    $types = $types . "‘$key’, " if $counter != scalar(@keys);
    }
    return $types;
    }
  • edit in src/lib/Hydra/Controller/Jobset.pm at line 294
    [3.806]
    [3.2750]
    my $types = knownInputTypes($c);
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 296
    [3.2751][3.807:1009]()
    error($c, "Invalid input name ‘$name’.") unless $name =~ /^[[:alpha:]][\w-]*$/;
    error($c, "Invalid input type ‘$type’.") unless defined $c->stash->{inputTypes}->{$type};
    [3.2751]
    [3.0]
    badRequest($c, "Invalid input name ‘$name’.") unless $name =~ /^[[:alpha:]][\w-]*$/;
    badRequest($c, "Invalid input type ‘$type’; valid types: $types.") unless defined $c->stash->{inputTypes}->{$type};
  • edit in t/Controller/Jobset/http.t at line 157
    [2.4185]
    [2.4185]
    };
    subtest 'Update jobset "job" to have an invalid input type' => sub {
    my $jobsetupdate = request(PUT '/jobset/tests/job',
    Accept => 'application/json',
    Content_Type => 'application/json',
    Cookie => $cookie,
    Content => encode_json({
    enabled => 3,
    visible => JSON::true,
    name => "job",
    type => 0,
    nixexprinput => "ofborg",
    nixexprpath => "release.nix",
    inputs => {
    ofborg => {
    name => "ofborg",
    type => "123",
    value => "https://github.com/NixOS/ofborg.git released"
    }
    },
    description => "test jobset",
    checkinterval => 0,
    schedulingshares => 50,
    keepnr => 1
    })
    );
    ok(!$jobsetupdate->is_success);
    ok($jobsetupdate->content =~ m/Invalid input type.*valid types:/);