Skip to content

Commit

Permalink
WIP add full chain support and update tests. (#46)
Browse files Browse the repository at this point in the history
add full chain TLS support

* update tests and travis to use full chain TLS.

* Bump version and update change log in prep for new release.

* Updade README to reflect new changes.
  • Loading branch information
hexfusion authored Apr 15, 2018
1 parent 0199e75 commit 0e4be6d
Show file tree
Hide file tree
Showing 39 changed files with 458 additions and 228 deletions.
26 changes: 21 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,31 @@ addons:
hosts:
- travis1.local
- travis1
- etcd1
env:
global:
- ETCD_VER=v3.3.0
- PATH=$PATH:/tmp/test-etcd/
- ETCD_VER=v3.3.3
- ETCDCTL_API=3
- ETCD_TEST_HOST=127.0.0.1
- ETCD_TEST_HOST=etcd1
- ETCD_TEST_PORT=2379
- ETCD_TEST_CAPATH=$BUILD_DIR/t/tls/ca.pem
- RELEASE_TESTING=1
- PATH=$PATH:/tmp/test-etcd/
- ETCD_NAME=member1
- ETCD_DEBUG=1
- ETCD_LISTEN_CLIENT_URLS=https://0.0.0.0:2379
- ETCD_ADVERTISE_CLIENT_URLS=https://etcd1:2379
- ETCD_INITIAL_ADVERTISE_PEER_URLS=https://etcd1:2380
- ETCD_LISTEN_PEER_URLS=https://etcd1:2380
- ETCD_LISTEN_PEER_URLS=https://0.0.0.0:2380
- ETCD_PEER_KEY_FILE=${TRAVIS_BUILD_DIR}/t/tls/etcd1-key.pem
- ETCD_PEER_CERT_FILE=${TRAVIS_BUILD_DIR}/t/tls/etcd1.pem
- ETCD_CERT_FILE=${TRAVIS_BUILD_DIR}/t/tls/server.pem
- ETCD_KEY_FILE=${TRAVIS_BUILD_DIR}/t/tls/server-key.pem
- ETCD_TRUSTED_CA_FILE=${TRAVIS_BUILD_DIR}/t/tls/ca.pem
- ETCD_CLIENT_CERT_FILE=${TRAVIS_BUILD_DIR}/t/tls/client.pem
- ETCD_CLIENT_KEY_FILE=${TRAVIS_BUILD_DIR}/t/tls/client-key.pem
- ETCD_CLIENT_CA_FILE=${TRAVIS_BUILD_DIR}/t/tls/ca.pem
- ETCD_PEER_CLIENT_CERT_AUTH=1
language: perl
perl:
- "5.24"
Expand Down Expand Up @@ -42,7 +58,7 @@ install:
- cpan-install --deps
- cpan-install --coverage
script:
- /tmp/test-etcd/etcd --name member1 --cert-file=$BUILD_DIR/t/tls/server.pem --key-file=$BUILD_DIR/t/tls/server-key.pem --advertise-client-urls=https://127.0.0.1:2379 --listen-client-urls=https://127.0.0.1:2379 &
- /tmp/test-etcd/etcd &
- sleep 3
- perl Makefile.PL
- make
Expand Down
11 changes: 11 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
Revision history for Net::Etcd
0.020
[ ENHANCEMENTS ]
* Add support for full chain TLS. Fixes GH #42
* Updated travis tests to use etcd v3.3.3

[ BREAKING ]
* Default value for api_version is now /v3beta.

[ ANNOUNCEMENT ]
* Default value for api_version will change to /v3 on the release of etcd v3.4

0.019
[ BUG FIX ]
* Resolved issue where chunked data was not properly handled in non streaming calls and would truncate data when buffer was full. Fixed By GH #40 - Thanks Ananth Kavuri (foobargeez)
Expand Down
13 changes: 11 additions & 2 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,23 @@ ACCESSORS
password
Authentication credentials, defaults to $ENV{ETCD_CLIENT_PASSWORD}

ca_file
Path to ca_file, defaults to $ENV{ETCD_CLIENT_CA_FILE}

key_file
Path to key_file, defaults to $ENV{ETCD_CLIENT_KEY_FILE}

cert_file
Path to cert_file, defaults to $ENV{ETCD_CLIENT_CERT_FILE}

cacert
Path to cacert, defaults to $ENV{ETCD_CERT_FILE}
Path to cacert, defaults to $ENV{ETCD_CLIENT_CACERT_FILE}.

ssl
To enable set to 1

api_version
defaults to /v3alpha
defaults to /v3beta

api_path
The full api path. Defaults to http://127.0.0.1:2379/v3alpha
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Build Status](https://api.travis-ci.org/hexfusion/perl-net-etcd.svg?branch=master)](https://travis-ci.org/hexfusion/perl-net-etcd)

i
# NAME

Net::Etcd - etcd v3 REST API.
Expand Down Expand Up @@ -89,17 +89,29 @@ Username for authentication, defaults to $ENV{ETCD\_CLIENT\_USERNAME}

Authentication credentials, defaults to $ENV{ETCD\_CLIENT\_PASSWORD}

## ca\_file

Path to ca\_file, defaults to $ENV{ETCD\_CLIENT\_CA\_FILE}

## key\_file

Path to key\_file, defaults to $ENV{ETCD\_CLIENT\_KEY\_FILE}

## cert\_file

Path to cert\_file, defaults to $ENV{ETCD\_CLIENT\_CERT\_FILE}

## cacert

Path to cacert, defaults to $ENV{ETCD\_CERT\_FILE}
Path to cacert, defaults to $ENV{ETCD\_CLIENT\_CACERT\_FILE}.

## ssl

To enable set to 1

## api\_version

defaults to /v3alpha
defaults to /v3beta

## api\_path

Expand Down
67 changes: 55 additions & 12 deletions lib/Net/Etcd.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use utf8;

package Net::Etcd;

# ABSTRACT: Provide access to the etcd v3 API.

use strict;
Expand Down Expand Up @@ -30,7 +32,7 @@ Net::Etcd - etcd v3 REST API.
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 SYNOPSIS
Expand Down Expand Up @@ -132,7 +134,7 @@ Username for authentication, defaults to $ENV{ETCD_CLIENT_USERNAME}
=cut

has name => (
is => 'ro',
is => 'ro',
default => $ENV{ETCD_CLIENT_USERNAME}
);

Expand All @@ -143,21 +145,55 @@ Authentication credentials, defaults to $ENV{ETCD_CLIENT_PASSWORD}
=cut

has password => (
is => 'ro',
is => 'ro',
default => $ENV{ETCD_CLIENT_PASSWORD}
);

=head2 ca_file
Path to ca_file, defaults to $ENV{ETCD_CLIENT_CA_FILE}
=cut

has ca_file => (
is => 'ro',
default => $ENV{ETCD_CLIENT_CA_FILE}
);

=head2 key_file
Path to key_file, defaults to $ENV{ETCD_CLIENT_KEY_FILE}
=cut

has key_file => (
is => 'ro',
default => $ENV{ETCD_CLIENT_KEY_FILE}
);

=head2 cert_file
Path to cert_file, defaults to $ENV{ETCD_CLIENT_CERT_FILE}
=cut

has cert_file => (
is => 'ro',
default => $ENV{ETCD_CLIENT_CERT_FILE}
);

=head2 cacert
Path to cacert, defaults to $ENV{ETCD_CERT_FILE}
Path to cacert, defaults to $ENV{ETCD_CLIENT_CACERT_FILE}.
=cut

has cacert => (
is => 'ro',
default => $ENV{ETCD_CERT_FILE}
is => 'ro',
default => $ENV{ETCD_CLIENT_CACERT_FILE}
);


=head2 ssl
To enable set to 1
Expand All @@ -171,14 +207,14 @@ has ssl => (

=head2 api_version
defaults to /v3alpha
defaults to /v3beta
=cut

has api_version => (
is => 'ro',
isa => Str,
default => '/v3alpha'
default => '/v3beta'
);

=head2 api_path
Expand All @@ -191,8 +227,15 @@ has api_path => ( is => 'lazy' );

sub _build_api_path {
my ($self) = @_;
return ( $self->ssl || $self->cacert ? 'https' : 'http' ) . '://'
. $self->host . ':'. $self->port . $self->api_version;
return ( $self->{ssl}
|| $self->{ca_file}
|| $self->{key_file}
|| $self->{cafile}
|| $self->{cert_file} ? 'https' : 'http' )
. '://'
. $self->host . ':'
. $self->port
. $self->api_version;
}

=head2 auth_token
Expand Down Expand Up @@ -276,8 +319,8 @@ sub role_perm {
my ( $self, $options ) = @_;
my $cb = pop if ref $_[-1] eq 'CODE';
my $perm = Net::Etcd::Auth::RolePermission->new(
etcd => $self,
cb => $cb,
etcd => $self,
cb => $cb,
( $options ? %$options : () ),
);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/Auth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Net::Etcd::Auth
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/Auth/Role.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Net::Etcd::Auth::Role
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/Auth/RolePermission.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Net::Etcd::Auth::RolePermission
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Net::Etcd::Config
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 ACCESSORS
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/KV.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Net::Etcd::KV
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/KV/Compare.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Net::Etcd::KV::Compare
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/KV/DeleteRange.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Net::Etcd::DeleteRange
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/KV/Op.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Net::Etcd::KV::Op
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/KV/Put.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Net::Etcd::Put
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/KV/Range.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Net::Etcd::Range
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/KV/Txn.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Net::Etcd::KV::Txn
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/Lease.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Net::Etcd::Lease
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';

=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/Maintenance.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Net::Etcd::Maintenance
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';
=head1 SYNOPSIS
# defrag member's backend database
Expand Down
2 changes: 1 addition & 1 deletion lib/Net/Etcd/Member.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Net::Etcd::Maintenance
=cut

our $VERSION = '0.019';
our $VERSION = '0.020';
=head1 SYNOPSIS
# list members
Expand Down
Loading

0 comments on commit 0e4be6d

Please sign in to comment.