blib/lib/App/Netdisco/Util/JobAction.pm untested

filter: Statementstmt 0.0% 0 / 17 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 32 CC 2 SCAR 12.8
CC
2
Cov
0%
action_is_refused
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.6
1 package App::Netdisco::Util::JobAction;
2  
3 use strict;
4 use warnings;
5  
6 use base 'Exporter';
7 our @EXPORT = ();
8 our @EXPORT_OK = qw/
9 action_is_refused
10 /;
11 our %EXPORT_TAGS = (all => \@EXPORT_OK);
12  
13 =head1 NAME
14  
15 App::Netdisco::Util::JobAction
16  
17 =head1 DESCRIPTION
18  
19 Job actions which the web frontend and the API will not queue.
20  
21 There are no default exports, however the C<:all> tag will export all
22 subroutines.
23  
24 =head1 EXPORT_OK
25  
26 =head2 action_is_refused( $action )
27  
28 Returns true if C<$action> names a worker intended to be run only with
29 C<netdisco-do> on the backend host, where the caller already holds the
30 privilege queueing it would otherwise confer.
31  
32 =cut
33  
34 my %refused_action = map {($_ => 1)} qw/
35 hook scheduler psql getapikey dumpconfig dumpinfocache show
36 /;
37  
38 # the backend keys its workers on the lowercased action ahead of the
39 # namespace, so the same shape decides what is refused
40 sub action_is_refused {
41 my ($base) = split m/::/, lc(shift || '');
42 return (($base and exists $refused_action{$base}) ? 1 : 0);
43 }
44  
45 1;