Docker-Registry

 view release on metacpan or  search on metacpan

examples/gce_sa_explicit.pl  view on Meta::CPAN

use Docker::Registry::Auth::GCEServiceAccount;

my $ce = $ENV{ CLIENT_EMAIL } // die "Please set ENV CLIENT_EMAIL";
my $pk = $ENV{ PRIVATE_KEY } // die "Please set ENV PRIVATE_KEY";
#passing a repo is because sometimes your credentials don't let you list
#the repositories, but you can see the tags of a repo if you know its name
my $repo = $ARGV[0];

my $sa = Docker::Registry::Auth::GCEServiceAccount->new(
  client_email => $ce,
  private_key => $pk,
);

my $r = Docker::Registry::GCE->new(
  auth => $sa,
);

#$r->caller->debug(1);

if (defined $repo) {
  print Dumper($r->repository_tags(repository => $repo));

lib/Docker/Registry/Auth/GCEServiceAccount.pm  view on Meta::CPAN

  });

  has client_email => (is => 'ro', isa => Str, lazy => 1, default => sub {
    my $self = shift;
    my $value = $self->service_account->{ client_email };
    Docker::Registry::Auth::Exception->throw({
      message => "client_email entry not found in service_account information",
    }) if (not defined $value);
    return $value;
  });
  has private_key => (is => 'ro', isa => Str, lazy => 1, default => sub {
    my $self = shift;
    my $value = $self->service_account->{ private_key };
    Docker::Registry::Auth::Exception->throw({
      message => "private_key entry not found in service_account information",
    }) if (not defined $value);
    return $value;
  });

  has scopes => (is => 'ro', isa => ArrayRef[Str], default => sub {
    [ 'https://www.googleapis.com/auth/devstorage.read_only' ];
  });

  has time_source => (is => 'ro', isa => CodeRef, default => sub {
    return sub { time };
  });

  has expiry => (is => 'ro', isa => Int, default => 300);

  has signed_jwt => (is => 'ro', isa => Str, lazy => 1, default => sub {
    my $self = shift;
    my $scope = join ' ', @{ $self->scopes };

    my $time = $self->time_source->();
    my $key = $self->private_key;

    return encode_jwt(
      payload => {
        iss => $self->client_email,
        scope => $scope,
        aud => $self->auth_url,
        iat => $time,
        exp => $time + $self->expiry,
      },
      alg => 'RS256',

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.217 second using v1.00-cache-2.02-grep-82fe00e-cpan-2cc899e4a130 )