App-Docker-Client
view release on metacpan or search on metacpan
lib/App/Docker/Client.pm view on Meta::CPAN
return if $code !~ m/^(\d{3})$/;
$self->{_valid_codes}->{$code} = 1;
return $self;
}
=head2 without_valid_code
=cut
sub without_valid_code {
my ( $self, $code ) = @_;
return if $code !~ m/^(\d{3})$/;
$self->{_valid_codes}->{$code} = 0;
return $self;
}
=head2 show_progress
=cut
sub show_progress {
my ( $self, $show_progress ) = @_;
$self->{show_progress} = $show_progress ? $show_progress == 0 ? () : 1 : 1;
return $self;
}
=head2 attach
=cut
sub attach {
my ( $self, $path, $query, $input, $output ) = @_;
my $cv = AnyEvent->condvar;
my $callback = sub {
my ( $fh, $headers ) = @_;
$fh->on_error( sub { $cv->send } );
$fh->on_eof( sub { $cv->send } );
my $out_hndl = AnyEvent::Handle->new( fh => $output );
$fh->on_read(
sub {
my ($handle) = @_;
$handle->unshift_read(
sub {
my ($h) = @_;
my $length = length $h->{rbuf};
$out_hndl->push_write( $h->{rbuf} );
substr $h->{rbuf}, 0, $length, '';
}
);
}
);
my $in_hndl = AnyEvent::Handle->new( fh => $input );
$in_hndl->on_read(
sub {
my ($h) = @_;
$h->push_read(
line => sub {
my ( $h2, $line, $eol ) = @_;
$fh->push_write( $line . $eol );
}
);
}
);
$in_hndl->on_eof( sub { $cv->send } );
};
http_request(
POST => $self->uri( $path, %$query )->as_string,
(
want_body_handle => 1,
(
$self->ssl_opts
? (
tls_ctx => {
verify => 1,
verify_peername => "https",
ca_file => $self->{ssl_opts}->{SSL_ca_file},
cert_file => $self->{ssl_opts}->{SSL_cert_file},
key_file => $self->{ssl_opts}->{SSL_key_file},
}
)
: ()
),
),
$callback
);
return $cv;
}
=head2 authority
Getter/Setter for internal hash key authority.
=cut
sub authority {
return $_[0]->{authority} || '/var/run/docker.sock' unless $_[1];
$_[0]->{authority} = $_[1];
return $_[0]->{authority};
}
=head2 scheme
Getter/Setter for internal hash key scheme.
=cut
sub scheme {
return $_[0]->{scheme} || 'http' unless $_[1];
$_[0]->{scheme} = $_[1];
return $_[0]->{scheme};
}
=head2 ssl_opts
Getter/Setter for internal hash key ssl_opts.
=cut
( run in 1.702 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )