| 1 | package Docker::Registry::Azure; | ||||||||||
| 2 | 1 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use Types::Standard qw/Str/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 1 | extends 'Docker::Registry::V2'; | |||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | has '+url' => (lazy => 1, default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||
| 8 | 1 | my $self = shift; | |||||||||
| 9 | 1 | ▶ | die "Must specify name" if (not defined $self->name); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 10 | 1 | sprintf 'https://%s.azurecr.io', $self->name; | |||||||||
| 11 | 1 | }); | |||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | around build_auth => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.9
| |||||||||||
| 14 | 1 | my ($orig, $self) = @_; | |||||||||
| 15 | 1 | ▶ | if (defined $self->password) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | # We're using the "Admin Account" mode | ||||||||||
| 17 | # https://docs.microsoft.com/en-us/azure/container-registry/container-registry-authentication#admin-account | ||||||||||
| 18 | 1 | require Docker::Registry::Auth::Basic; | |||||||||
| 19 | 1 | Docker::Registry::Auth::Basic->new( | |||||||||
| 20 | username => $self->name, | ||||||||||
| 21 | password => $self->password, | ||||||||||
| 22 | ); | ||||||||||
| 23 | } else { | ||||||||||
| 24 | # We're using Service Principal mode | ||||||||||
| 25 | 0 | require Docker::Registry::Auth::AzureServicePrincipal; | |||||||||
| 26 | 0 | Docker::Registry::Auth::AzureServicePrincipal->new; | |||||||||
| 27 | } | ||||||||||
| 28 | 1 | }; | |||||||||
| 29 | |||||||||||
| 30 | 1 | has name => (is => 'ro', isa => Str); | |||||||||
| 31 | 1 | has password => (is => 'ro', isa => Str); | |||||||||
| 32 | |||||||||||
| 33 | 1 | 1; | |||||||||