diff --git a/Changes b/Changes index 71f1355..afc3bc5 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Net::Etcd +0.014 +[ BUG FIX ] +* Resolved bug which prevented range delete transaction from completing. Closed via GH #25 Thanks Ananth Kavuri! + 0.013 [ ENHANCEMENTS ] * Add Net::Etcd::Auth::RolePermission class allowing roles to be defined by key/range. diff --git a/MANIFEST b/MANIFEST index 7b6bc47..4b9ce11 100644 --- a/MANIFEST +++ b/MANIFEST @@ -14,6 +14,7 @@ lib/Net/Etcd/Maintenance.pm lib/Net/Etcd/Role/Actions.pm lib/Net/Etcd/KV.pm lib/Net/Etcd/KV/Compare.pm +lib/Net/Etcd/KV/DeleteRange.pm lib/Net/Etcd/KV/Op.pm lib/Net/Etcd/KV/Put.pm lib/Net/Etcd/KV/Range.pm diff --git a/README b/README index 242644c..4eb12d3 100644 --- a/README +++ b/README @@ -23,6 +23,9 @@ SYNOPSIS # return array { key => value } pairs from range request. my @users = $range->all + # delete single key + $etcd->deleterange({ key => 'test0' }); + # watch key range, streaming. $watch = $etcd->watch( { key => 'foo', range_end => 'fop'}, sub { my ($result) = @_; @@ -39,7 +42,10 @@ SYNOPSIS $etcd->user( { name => 'samba', password => 'foo' } )->add; # add new user role - $role = $etcd->role( { name => 'myrole' } )->add; + $role = $etcd->role( { name => 'myrole' } )->add; + + # grant read permission for the foo key to myrole + $etcd->role_perm( { name => 'myrole', key => 'foo', permType => 'READWRITE' } )->grant; # grant role $etcd->user_role( { user => 'samba', role => 'myrole' } )->grant; @@ -86,6 +92,12 @@ PUBLIC METHODS $etcd->role({ role => 'foo' }); + role_perm + See Net::Etcd::Auth::RolePermission + + Grants or revoke permission of a specified key or range to a specified + role. + user_role See Net::Etcd::User::Role @@ -95,8 +107,8 @@ PUBLIC METHODS See Net::Etcd::Auth $etcd->auth({ name => 'samba', password => 'foo' })->authenticate; - $etcd->auth()->enable; - $etcd->auth()->disable + $etcd->auth()->enable; + $etcd->auth()->disable lease See Net::Etcd::Lease @@ -118,6 +130,11 @@ PUBLIC METHODS $etcd->put({ key =>'foo1', value => 'bar' }); + deleterange + See Net::Etcd::KV::DeleteRange + + $etcd->deleterange({ key=>'test0' }); + range See Net::Etcd::KV::Range @@ -132,7 +149,7 @@ PUBLIC METHODS See Net::Etcd::KV::Op $etcd->op({ request_put => $put }); - $etcd->op({ request_delete_range => $range }); + $etcd->op({ request_delete_range => $range }); compare See Net::Etcd::KV::Compare @@ -144,7 +161,10 @@ PUBLIC METHODS Initialize configuration checks to see it etcd is installed locally. AUTHOR - Sam Batschelet, + Sam Batschelet (hexfusion) + +CONTRIBUTORS + Ananth Kavuri ACKNOWLEDGEMENTS The etcd developers and community. @@ -155,6 +175,8 @@ CAVEATS for latest details. + Authentication provided by this module will only work with etcd v3.3.0+ + LICENSE AND COPYRIGHT Copyright 2017 Sam Batschelet (hexfusion). diff --git a/README.md b/README.md index e764748..33c8af3 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,9 @@ Net::Etcd - etcd v3 REST API. # return array { key => value } pairs from range request. my @users = $range->all + # delete single key + $etcd->deleterange({ key => 'test0' }); + # watch key range, streaming. $watch = $etcd->watch( { key => 'foo', range_end => 'fop'}, sub { my ($result) = @_; @@ -43,7 +46,10 @@ Net::Etcd - etcd v3 REST API. $etcd->user( { name => 'samba', password => 'foo' } )->add; # add new user role - $role = $etcd->role( { name => 'myrole' } )->add; + $role = $etcd->role( { name => 'myrole' } )->add; + + # grant read permission for the foo key to myrole + $etcd->role_perm( { name => 'myrole', key => 'foo', permType => 'READWRITE' } )->grant; # grant role $etcd->user_role( { user => 'samba', role => 'myrole' } )->grant; @@ -101,6 +107,12 @@ See [Net::Etcd::Auth::Role](https://metacpan.org/pod/Net::Etcd::Auth::Role) $etcd->role({ role => 'foo' }); +## role\_perm + +See [Net::Etcd::Auth::RolePermission](https://metacpan.org/pod/Net::Etcd::Auth::RolePermission) + +Grants or revoke permission of a specified key or range to a specified role. + ## user\_role See [Net::Etcd::User::Role](https://metacpan.org/pod/Net::Etcd::User::Role) @@ -112,8 +124,8 @@ See [Net::Etcd::User::Role](https://metacpan.org/pod/Net::Etcd::User::Role) See [Net::Etcd::Auth](https://metacpan.org/pod/Net::Etcd::Auth) $etcd->auth({ name => 'samba', password => 'foo' })->authenticate; - $etcd->auth()->enable; - $etcd->auth()->disable + $etcd->auth()->enable; + $etcd->auth()->disable ## lease @@ -139,6 +151,12 @@ See [Net::Etcd::KV::Put](https://metacpan.org/pod/Net::Etcd::KV::Put) $etcd->put({ key =>'foo1', value => 'bar' }); +## deleterange + +See [Net::Etcd::KV::DeleteRange](https://metacpan.org/pod/Net::Etcd::KV::DeleteRange) + + $etcd->deleterange({ key=>'test0' }); + ## range See [Net::Etcd::KV::Range](https://metacpan.org/pod/Net::Etcd::KV::Range) @@ -156,7 +174,7 @@ See [Net::Etcd::KV::Txn](https://metacpan.org/pod/Net::Etcd::KV::Txn) See [Net::Etcd::KV::Op](https://metacpan.org/pod/Net::Etcd::KV::Op) $etcd->op({ request_put => $put }); - $etcd->op({ request_delete_range => $range }); + $etcd->op({ request_delete_range => $range }); ## compare @@ -171,7 +189,11 @@ Initialize configuration checks to see it etcd is installed locally. # AUTHOR -Sam Batschelet, <sbatschelet at mac.com> +Sam Batschelet (hexfusion) + +# CONTRIBUTORS + +Ananth Kavuri # ACKNOWLEDGEMENTS @@ -179,14 +201,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 [api\_reference\_v3](https://github.com/coreos/etcd/blob/master/Documentation/dev-guide/api_reference_v3.md) for latest details. +Authentication provided by this module will only work with etcd v3.3.0+ + # LICENSE AND COPYRIGHT Copyright 2017 Sam Batschelet (hexfusion). diff --git a/lib/Net/Etcd.pm b/lib/Net/Etcd.pm index 16fb59e..aefc781 100644 --- a/lib/Net/Etcd.pm +++ b/lib/Net/Etcd.pm @@ -73,7 +73,7 @@ our $VERSION = '0.014'; $etcd->user( { name => 'samba', password => 'foo' } )->add; # add new user role - $role = $etcd->role( { name => 'myrole' } )->add; + $role = $etcd->role( { name => 'myrole' } )->add; # grant read permission for the foo key to myrole $etcd->role_perm( { name => 'myrole', key => 'foo', permType => 'READWRITE' } )->grant; @@ -230,13 +230,13 @@ Grants or revoke permission of a specified key or range to a specified role. =cut sub role_perm { - my ( $self, $options ) = @_; + my ( $self, $options ) = @_; my $cb = pop if ref $_[-1] eq 'CODE'; my $perm = Net::Etcd::Auth::RolePermission->new( etcd => $self, cb => $cb, ( $options ? %$options : () ), - ); + ); } =head2 user_role @@ -262,8 +262,8 @@ sub user_role { See L $etcd->auth({ name => 'samba', password => 'foo' })->authenticate; - $etcd->auth()->enable; - $etcd->auth()->disable + $etcd->auth()->enable; + $etcd->auth()->disable =cut @@ -368,7 +368,7 @@ See L See L $etcd->op({ request_put => $put }); - $etcd->op({ request_delete_range => $range }); + $etcd->op({ request_delete_range => $range }); =cut @@ -398,13 +398,17 @@ sub BUILD { $msg .= ">> Please install etcd - https://coreos.com/etcd/docs/latest/"; die $msg; } - # set the intial auth token + # set the intial auth token $self->auth()->authenticate; } =head1 AUTHOR -Sam Batschelet, +Sam Batschelet (hexfusion) + +=head1 CONTRIBUTORS + +Ananth Kavuri =head1 ACKNOWLEDGEMENTS @@ -416,6 +420,8 @@ The L v3 API is in heavy development and ca L for latest details. +Authentication provided by this module will only work with etcd v3.3.0+ + =head1 LICENSE AND COPYRIGHT Copyright 2017 Sam Batschelet (hexfusion). diff --git a/t/pod-spelling.t b/t/pod-spelling.t index 049932b..5f1e4aa 100644 --- a/t/pod-spelling.t +++ b/t/pod-spelling.t @@ -60,4 +60,7 @@ paxosdb Txn MultiOp txn - +Ananth +Kavuri +READWRITE +permType