« lib/IO/K8s/ApiextensionsApiserver/Pkg/Apis/Apiextensions/V1/JSONSchemaPropsOrStringArray.pm
↑ Summary
lib/IO/K8s/Types/Net.pm »
| 1 | package IO::K8s::Role::MiddlewareBuilder; | ||||||||||||||||||
| 2 | # ABSTRACT: Role for building Traefik middleware configuration | ||||||||||||||||||
| 3 | 8 | our $VERSION = '1.112'; | |||||||||||||||||
| 4 | 8 | ▶ | use Moo::Role; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | |||||||||||||||||||
| 6 | # The fluent setters below build the spec through IO::K8s::Role::SpecBuilder | ||||||||||||||||||
| 7 | # rather than by hand, so that role is a hard dependency of this one (k103). | ||||||||||||||||||
| 8 | # IO::K8s::Role::APIObject composes SpecBuilder for every top-level Kind, so | ||||||||||||||||||
| 9 | # these are satisfied for anything built with IO::K8s::APIObject; a class | ||||||||||||||||||
| 10 | # that composes this role without them now fails at composition time, | ||||||||||||||||||
| 11 | # naming the missing method, instead of at the first setter call. | ||||||||||||||||||
| 12 | 8 | requires qw( spec_hash spec_set ); | |||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | |||||||||||||||||||
| 15 | 3 | ▶ | sub rate_limit { | ||||||||||||||||
|
Subroutine
rate_limit: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||
| 16 | 3 | my ($self, %opts) = @_; | |||||||||||||||||
| 17 | $self->spec_set('rateLimit', { | ||||||||||||||||||
| 18 | $opts{average} ? (average => $opts{average}) : (), | ||||||||||||||||||
| 19 | $opts{burst} ? (burst => $opts{burst}) : (), | ||||||||||||||||||
| 20 | 3 | ▶ | $opts{period} ? (period => $opts{period}) : (), | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 21 | }); | ||||||||||||||||||
| 22 | 3 | return $self; | |||||||||||||||||
| 23 | } | ||||||||||||||||||
| 24 | |||||||||||||||||||
| 25 | |||||||||||||||||||
| 26 | 2 | ▶ | sub basic_auth { | ||||||||||||||||
|
Subroutine
basic_auth: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||
| 27 | 2 | my ($self, %opts) = @_; | |||||||||||||||||
| 28 | $self->spec_set('basicAuth', { | ||||||||||||||||||
| 29 | $opts{secret} ? (secret => $opts{secret}) : (), | ||||||||||||||||||
| 30 | 2 | ▶ | $opts{realm} ? (realm => $opts{realm}) : (), | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 31 | }); | ||||||||||||||||||
| 32 | 2 | return $self; | |||||||||||||||||
| 33 | } | ||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | |||||||||||||||||||
| 36 | 2 | ▶ | sub strip_prefix { | ||||||||||||||||
|
Subroutine
strip_prefix: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 37 | 2 | my ($self, @prefixes) = @_; | |||||||||||||||||
| 38 | 2 | $self->spec_set('stripPrefix', { prefixes => \@prefixes }); | |||||||||||||||||
| 39 | 2 | return $self; | |||||||||||||||||
| 40 | } | ||||||||||||||||||
| 41 | |||||||||||||||||||
| 42 | |||||||||||||||||||
| 43 | 2 | ▶ | sub redirect_https { | ||||||||||||||||
|
Subroutine
redirect_https: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 44 | 2 | my ($self) = @_; | |||||||||||||||||
| 45 | 2 | $self->spec_set('redirectScheme', { scheme => 'https', permanent => 1 }); | |||||||||||||||||
| 46 | 2 | return $self; | |||||||||||||||||
| 47 | } | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | |||||||||||||||||||
| 50 | 4 | ▶ | sub add_request_header { | ||||||||||||||||
|
Subroutine
add_request_header: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 51 | 4 | my ($self, $key, $value) = @_; | |||||||||||||||||
| 52 | # Header names may legally contain dots; write into the map directly. | ||||||||||||||||||
| 53 | 4 | $self->spec_hash('headers.customRequestHeaders')->{$key} = $value; | |||||||||||||||||
| 54 | 4 | return $self; | |||||||||||||||||
| 55 | } | ||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | |||||||||||||||||||
| 58 | 2 | ▶ | sub add_response_header { | ||||||||||||||||
|
Subroutine
add_response_header: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 59 | 2 | my ($self, $key, $value) = @_; | |||||||||||||||||
| 60 | 2 | $self->spec_hash('headers.customResponseHeaders')->{$key} = $value; | |||||||||||||||||
| 61 | 2 | return $self; | |||||||||||||||||
| 62 | } | ||||||||||||||||||
| 63 | |||||||||||||||||||
| 64 | 8 | 1; | |||||||||||||||||
| 65 | |||||||||||||||||||
| 66 | __END__ | ||||||||||||||||||