From 9963a7491018ad2a8be1596a5fb72a8ec59b5fde Mon Sep 17 00:00:00 2001 From: Sam Batschelet Date: Sat, 17 Jun 2017 18:07:45 -0400 Subject: [PATCH] Bunp up version for release. --- .travis.yml | 2 +- Changes | 5 +++ MANIFEST | 12 ++--- README | 86 +++++++++++++++++++++++++++++------- README.md | 86 +++++++++++++++++++++++++++++------- lib/Net/Etcd.pm | 2 +- lib/Net/Etcd/Auth.pm | 2 +- lib/Net/Etcd/Auth/Role.pm | 2 +- lib/Net/Etcd/Config.pm | 2 +- lib/Net/Etcd/KV.pm | 2 +- lib/Net/Etcd/KV/Compare.pm | 2 +- lib/Net/Etcd/KV/Op.pm | 2 +- lib/Net/Etcd/KV/Put.pm | 2 +- lib/Net/Etcd/KV/Range.pm | 2 +- lib/Net/Etcd/KV/Txn.pm | 2 +- lib/Net/Etcd/Lease.pm | 2 +- lib/Net/Etcd/Maintenance.pm | 2 +- lib/Net/Etcd/Role/Actions.pm | 2 +- lib/Net/Etcd/User.pm | 2 +- lib/Net/Etcd/User/Role.pm | 2 +- lib/Net/Etcd/Watch.pm | 2 +- t/{05-watch.t => 06-watch.t} | 0 22 files changed, 169 insertions(+), 54 deletions(-) rename t/{05-watch.t => 06-watch.t} (100%) diff --git a/.travis.yml b/.travis.yml index 024d652..6128438 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,4 +41,4 @@ install: script: - perl Makefile.PL - make - - make test + - prove -b -r -s -j$(test-jobs) $(test-files) diff --git a/Changes b/Changes index 531430c..59cf788 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,9 @@ Revision history for Net::Etcd +0.012 +[ ENHANCEMENTS ] +* Add full support for header based authentication via grpc-gateway. Requires etcd 3.1.0+ +* Improve POD + 0.011 [ ENHANCEMENTS ] * Add full support for Txn with tests. Recommended for use with etcd 3.2.0+ diff --git a/MANIFEST b/MANIFEST index 53952e4..bb3f7e1 100644 --- a/MANIFEST +++ b/MANIFEST @@ -21,13 +21,15 @@ lib/Net/Etcd/User.pm lib/Net/Etcd/User/Role.pm lib/Net/Etcd/Watch.pm t/00-load.t -t/key_value.t -t/lease.t +t/01-key_value.t +t/02-lease.t t/manifest.t +t/03-maint.t t/pod-coverage.t t/pod-spelling.t t/pod.t -t/txn.t -t/user.t -t/watch.t +t/04-txn.t +t/05-user.t +t/06-watch.t +t/99-auth.t .travis.yml diff --git a/README b/README index 52fcbd5..242644c 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ NAME - Net::Etcd + Net::Etcd - etcd v3 REST API. SYNOPSIS Etcd v3.1.0 or greater is required. To use the v3 API make sure to set environment @@ -35,58 +35,110 @@ SYNOPSIS # attach lease to put $etcd->put( { key => 'foo2', value => 'bar2', lease => 7587821338341002662 } ); + # add new user + $etcd->user( { name => 'samba', password => 'foo' } )->add; + + # add new user role + $role = $etcd->role( { name => 'myrole' } )->add; + + # grant role + $etcd->user_role( { user => 'samba', role => 'myrole' } )->grant; + DESCRIPTION Net::Etcd is object oriented interface to the v3 REST API provided by the etcd grpc-gateway . ACCESSORS host + The etcd host. Defaults to 127.0.0.1 + port - username + Default 2379. + + name + Username for authentication + password + Authentication credentials + ssl - api_root - api_prefix + To enable set to 1 + + api_version defaults to /v3alpha api_path + The full api path. Defaults to http://127.0.0.1:2379/v3alpha + auth_token + The token that is passed during authentication. This is generated during + the authentication process and stored until no longer valid or username + is changed. + PUBLIC METHODS watch - Returns a Net::Etcd::Watch object. + See Net::Etcd::Watch $etcd->watch({ key =>'foo', range_end => 'fop' }) role - Returns a Net::Etcd::Auth::Role object. + See Net::Etcd::Auth::Role $etcd->role({ role => 'foo' }); user_role - Returns a Net::Etcd::User::Role object. + See Net::Etcd::User::Role $etcd->user_role({ name => 'samba', role => 'foo' }); auth - Returns a Net::Etcd::Auth object. + See Net::Etcd::Auth + + $etcd->auth({ name => 'samba', password => 'foo' })->authenticate; + $etcd->auth()->enable; + $etcd->auth()->disable lease - Returns a Net::Etcd::Lease object. + See Net::Etcd::Lease + + $etcd->lease( { ID => 7587821338341002662, TTL => 20 } )->grant; maintenance - Returns a Net::Etcd::Maintenance object. + See Net::Etcd::Maintenance + + $etcd->maintenance()->snapshot user - Returns a Net::Etcd::User object. + See Net::Etcd::User + + $etcd->user( { name => 'samba', password => 'foo' } )->add; put - Returns a Net::Etcd::KV::Put object. + See Net::Etcd::KV::Put + + $etcd->put({ key =>'foo1', value => 'bar' }); range - Returns a Net::Etcd::KV::Range object. + See Net::Etcd::KV::Range + + $etcd->range({ key =>'test0', range_end => 'test100' }); txn - Returns a Net::Etcd::KV::Txn object. + See Net::Etcd::KV::Txn + + $etcd->txn({ compare => \@compare, success => \@op }); + + op + See Net::Etcd::KV::Op + + $etcd->op({ request_put => $put }); + $etcd->op({ request_delete_range => $range }); + + compare + See Net::Etcd::KV::Compare + + $etcd->compare( { key => 'foo', result => 'EQUAL', target => 'VALUE', value => 'baz' }); + $etcd->compare( { key => 'foo', target => 'CREATE', result => 'NOT_EQUAL', create_revision => '2' }); configuration Initialize configuration checks to see it etcd is installed locally. @@ -99,9 +151,9 @@ ACKNOWLEDGEMENTS CAVEATS The etcd v3 API is in heavy development - and can change at anytime please see - https://github.com/coreos/etcd/blob/master/Documentation/dev-guide/api_r - eference_v3.md for latest details. + and can change at anytime please see api_reference_v3 + for latest details. LICENSE AND COPYRIGHT Copyright 2017 Sam Batschelet (hexfusion). diff --git a/README.md b/README.md index 9a1fbf6..e764748 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # NAME -Net::Etcd +Net::Etcd - etcd v3 REST API. # SYNOPSIS @@ -39,6 +39,15 @@ Net::Etcd # attach lease to put $etcd->put( { key => 'foo2', value => 'bar2', lease => 7587821338341002662 } ); + # add new user + $etcd->user( { name => 'samba', password => 'foo' } )->add; + + # add new user role + $role = $etcd->role( { name => 'myrole' } )->add; + + # grant role + $etcd->user_role( { user => 'samba', role => 'myrole' } )->grant; + # DESCRIPTION [Net::Etcd](https://metacpan.org/pod/Net::Etcd) is object oriented interface to the v3 REST API provided by the etcd [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway). @@ -47,71 +56,114 @@ Net::Etcd ## host +The etcd host. Defaults to 127.0.0.1 + ## port -## username +Default 2379. + +## name + +Username for authentication ## password +Authentication credentials + ## ssl -## api\_root +To enable set to 1 -## api\_prefix +## api\_version defaults to /v3alpha ## api\_path +The full api path. Defaults to http://127.0.0.1:2379/v3alpha + ## auth\_token +The token that is passed during authentication. This is generated during the +authentication process and stored until no longer valid or username is changed. + # PUBLIC METHODS ## watch -Returns a [Net::Etcd::Watch](https://metacpan.org/pod/Net::Etcd::Watch) object. +See [Net::Etcd::Watch](https://metacpan.org/pod/Net::Etcd::Watch) $etcd->watch({ key =>'foo', range_end => 'fop' }) ## role -Returns a [Net::Etcd::Auth::Role](https://metacpan.org/pod/Net::Etcd::Auth::Role) object. +See [Net::Etcd::Auth::Role](https://metacpan.org/pod/Net::Etcd::Auth::Role) $etcd->role({ role => 'foo' }); ## user\_role -Returns a [Net::Etcd::User::Role](https://metacpan.org/pod/Net::Etcd::User::Role) object. +See [Net::Etcd::User::Role](https://metacpan.org/pod/Net::Etcd::User::Role) $etcd->user_role({ name => 'samba', role => 'foo' }); ## auth -Returns a [Net::Etcd::Auth](https://metacpan.org/pod/Net::Etcd::Auth) object. +See [Net::Etcd::Auth](https://metacpan.org/pod/Net::Etcd::Auth) + + $etcd->auth({ name => 'samba', password => 'foo' })->authenticate; + $etcd->auth()->enable; + $etcd->auth()->disable ## lease -Returns a [Net::Etcd::Lease](https://metacpan.org/pod/Net::Etcd::Lease) object. +See [Net::Etcd::Lease](https://metacpan.org/pod/Net::Etcd::Lease) + + $etcd->lease( { ID => 7587821338341002662, TTL => 20 } )->grant; ## maintenance -Returns a [Net::Etcd::Maintenance](https://metacpan.org/pod/Net::Etcd::Maintenance) object. +See [Net::Etcd::Maintenance](https://metacpan.org/pod/Net::Etcd::Maintenance) + + $etcd->maintenance()->snapshot ## user -Returns a [Net::Etcd::User](https://metacpan.org/pod/Net::Etcd::User) object. +See [Net::Etcd::User](https://metacpan.org/pod/Net::Etcd::User) + + $etcd->user( { name => 'samba', password => 'foo' } )->add; ## put -Returns a [Net::Etcd::KV::Put](https://metacpan.org/pod/Net::Etcd::KV::Put) object. +See [Net::Etcd::KV::Put](https://metacpan.org/pod/Net::Etcd::KV::Put) + + $etcd->put({ key =>'foo1', value => 'bar' }); ## range -Returns a [Net::Etcd::KV::Range](https://metacpan.org/pod/Net::Etcd::KV::Range) object. +See [Net::Etcd::KV::Range](https://metacpan.org/pod/Net::Etcd::KV::Range) + + $etcd->range({ key =>'test0', range_end => 'test100' }); ## txn -Returns a [Net::Etcd::KV::Txn](https://metacpan.org/pod/Net::Etcd::KV::Txn) object. +See [Net::Etcd::KV::Txn](https://metacpan.org/pod/Net::Etcd::KV::Txn) + + $etcd->txn({ compare => \@compare, success => \@op }); + +## op + +See [Net::Etcd::KV::Op](https://metacpan.org/pod/Net::Etcd::KV::Op) + + $etcd->op({ request_put => $put }); + $etcd->op({ request_delete_range => $range }); + +## compare + +See [Net::Etcd::KV::Compare](https://metacpan.org/pod/Net::Etcd::KV::Compare) + + $etcd->compare( { key => 'foo', result => 'EQUAL', target => 'VALUE', value => 'baz' }); + $etcd->compare( { key => 'foo', target => 'CREATE', result => 'NOT_EQUAL', create_revision => '2' }); ## configuration @@ -127,8 +179,12 @@ The [etcd](https://github.com/coreos/etcd) developers and community. # CAVEATS +Authentication will not be available until etcd release 3.2.1. For testing puposes you can use my pre-release. + +[v3.2.0_plus_git](https://github.com/hexfusion/etcd/releases/tag/v3.2.0_plus_git) + The [etcd](https://github.com/coreos/etcd) v3 API is in heavy development and can change at anytime please see -https://github.com/coreos/etcd/blob/master/Documentation/dev-guide/api\_reference\_v3.md + [api\_reference\_v3](https://github.com/coreos/etcd/blob/master/Documentation/dev-guide/api_reference_v3.md) for latest details. # LICENSE AND COPYRIGHT diff --git a/lib/Net/Etcd.pm b/lib/Net/Etcd.pm index 929ae85..b8287f3 100644 --- a/lib/Net/Etcd.pm +++ b/lib/Net/Etcd.pm @@ -28,7 +28,7 @@ Net::Etcd - etcd v3 REST API. =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 SYNOPSIS diff --git a/lib/Net/Etcd/Auth.pm b/lib/Net/Etcd/Auth.pm index 0df5746..76517af 100644 --- a/lib/Net/Etcd/Auth.pm +++ b/lib/Net/Etcd/Auth.pm @@ -26,7 +26,7 @@ Net::Etcd::Auth =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Auth/Role.pm b/lib/Net/Etcd/Auth/Role.pm index 2b06a3a..268a181 100644 --- a/lib/Net/Etcd/Auth/Role.pm +++ b/lib/Net/Etcd/Auth/Role.pm @@ -20,7 +20,7 @@ Net::Etcd::Auth::Role =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Config.pm b/lib/Net/Etcd/Config.pm index 14801d8..0a882d0 100644 --- a/lib/Net/Etcd/Config.pm +++ b/lib/Net/Etcd/Config.pm @@ -13,7 +13,7 @@ Net::Etcd::Config =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 ACCESSORS diff --git a/lib/Net/Etcd/KV.pm b/lib/Net/Etcd/KV.pm index a141c81..c8cf7c1 100644 --- a/lib/Net/Etcd/KV.pm +++ b/lib/Net/Etcd/KV.pm @@ -24,7 +24,7 @@ Net::Etcd::KV =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/KV/Compare.pm b/lib/Net/Etcd/KV/Compare.pm index 3aadf76..d23952b 100644 --- a/lib/Net/Etcd/KV/Compare.pm +++ b/lib/Net/Etcd/KV/Compare.pm @@ -20,7 +20,7 @@ Net::Etcd::KV::Compare =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/KV/Op.pm b/lib/Net/Etcd/KV/Op.pm index 8f6431f..a3f3183 100644 --- a/lib/Net/Etcd/KV/Op.pm +++ b/lib/Net/Etcd/KV/Op.pm @@ -20,7 +20,7 @@ Net::Etcd::KV::Op =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/KV/Put.pm b/lib/Net/Etcd/KV/Put.pm index 70a55d9..1473f0e 100644 --- a/lib/Net/Etcd/KV/Put.pm +++ b/lib/Net/Etcd/KV/Put.pm @@ -19,7 +19,7 @@ Net::Etcd::Put =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/KV/Range.pm b/lib/Net/Etcd/KV/Range.pm index 0e23be3..e80602f 100644 --- a/lib/Net/Etcd/KV/Range.pm +++ b/lib/Net/Etcd/KV/Range.pm @@ -20,7 +20,7 @@ Net::Etcd::Range =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/KV/Txn.pm b/lib/Net/Etcd/KV/Txn.pm index 2850bb1..ce77777 100644 --- a/lib/Net/Etcd/KV/Txn.pm +++ b/lib/Net/Etcd/KV/Txn.pm @@ -20,7 +20,7 @@ Net::Etcd::KV::Txn =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Lease.pm b/lib/Net/Etcd/Lease.pm index 1222c86..4dc2a38 100644 --- a/lib/Net/Etcd/Lease.pm +++ b/lib/Net/Etcd/Lease.pm @@ -20,7 +20,7 @@ Net::Etcd::Lease =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Maintenance.pm b/lib/Net/Etcd/Maintenance.pm index 4f651b4..8189bc9 100644 --- a/lib/Net/Etcd/Maintenance.pm +++ b/lib/Net/Etcd/Maintenance.pm @@ -18,7 +18,7 @@ Net::Etcd::Maintenance =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Role/Actions.pm b/lib/Net/Etcd/Role/Actions.pm index b5ed341..a1518fc 100644 --- a/lib/Net/Etcd/Role/Actions.pm +++ b/lib/Net/Etcd/Role/Actions.pm @@ -22,7 +22,7 @@ Net::Etcd::Role::Actions =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; has etcd => ( is => 'ro', diff --git a/lib/Net/Etcd/User.pm b/lib/Net/Etcd/User.pm index 39602c0..58e31b9 100644 --- a/lib/Net/Etcd/User.pm +++ b/lib/Net/Etcd/User.pm @@ -20,7 +20,7 @@ Net::Etcd::User =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/User/Role.pm b/lib/Net/Etcd/User/Role.pm index a96746b..7aa3226 100644 --- a/lib/Net/Etcd/User/Role.pm +++ b/lib/Net/Etcd/User/Role.pm @@ -17,7 +17,7 @@ Net::Etcd::User::Role =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/lib/Net/Etcd/Watch.pm b/lib/Net/Etcd/Watch.pm index ac0ef28..a703ebb 100644 --- a/lib/Net/Etcd/Watch.pm +++ b/lib/Net/Etcd/Watch.pm @@ -20,7 +20,7 @@ Net::Etcd::Range =cut -our $VERSION = '0.011'; +our $VERSION = '0.012'; =head1 DESCRIPTION diff --git a/t/05-watch.t b/t/06-watch.t similarity index 100% rename from t/05-watch.t rename to t/06-watch.t