riak-cs-user-mgmt 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "fog", git: "git://github.com/hectcastro/fog.git", ref: "hc-riakcs-usage-connection-options"
6
+
7
+ group :development do
8
+ gem "rake", "~> 10.1.0"
9
+ gem "aruba", "~> 0.5.3"
10
+ gem "ronn", "~> 0.7.3"
11
+ end
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # riak-cs-user-mgmt
2
+
3
+ `mgmt` is a command-line tool that aids in [Riak
4
+ CS](https://github.com/basho/riak_cs) user management.
5
+
6
+ ## Installation
7
+
8
+ ```bash
9
+ $ git clone git://github.com/hectcastro/riak-cs-user-mgmt.git
10
+ $ cd riak-cs-user-mgmt
11
+ $ rake install
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```bash
17
+ $ mgmt list
18
+ email display_name name key_id key_secret id status
19
+ ...
20
+ $ mgmt create -v test3 test3@example.com
21
+ {"email":"test3@example.com","display_name":"test3","name":"test3","key_id":"LLBMUDS0KC7D3VRV6PZS","key_secret":"NJKY-7bNU9d7G_EioIMj1UIV4qmM7Ov8ryhK1w==","id":"1270290a292867033583634dcf195d6387886e54cf91a1833fa6750b45ff72bd","status":"enabled"}
22
+ ```
23
+
24
+ ## Testing
25
+
26
+ The test suite for `riak-cs-user-mgmt` was built using
27
+ [Cucumber](https://github.com/cucumber/cucumber) and
28
+ [Aruba](https://github.com/cucumber/aruba). In order to run the tests, you'll
29
+ need an active instnace of Riak.
30
+
31
+ ```bash
32
+ $ cucumber features/
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/mgmt ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require "mgmt/cli"
6
+
7
+ Mgmt::CLI.start
@@ -0,0 +1,28 @@
1
+ Feature: Create
2
+ Scenario: No arguments
3
+ When I run `mgmt create`
4
+ And the stderr should contain:
5
+ """
6
+ ERROR: mgmt create was called with no arguments
7
+ Usage: "mgmt create [NAME] [EMAIL]".
8
+ """
9
+
10
+ Scenario: Only a name argument
11
+ When I run `mgmt create name`
12
+ And the stderr should contain:
13
+ """
14
+ ERROR: mgmt create was called with arguments ["name"]
15
+ Usage: "mgmt create [NAME] [EMAIL]".
16
+ """
17
+
18
+ Scenario: A name and an e-mail address
19
+ When I run `mgmt create name admin@admin.com`
20
+ Then the exit status should be 0
21
+
22
+ Scenario: A name and an e-mail address that already exists
23
+ When I run `mgmt create name admin@admin.com`
24
+ Then the exit status should be 1
25
+ And the stderr should contain:
26
+ """
27
+ User already exists.
28
+ """
@@ -0,0 +1,11 @@
1
+ Feature: List
2
+ Scenario: No arguments
3
+ When I run `mgmt list`
4
+ Then the exit status should be 0
5
+ And the output should contain "email"
6
+ And the output should contain "display_name"
7
+ And the output should contain "name"
8
+ And the output should contain "key_id"
9
+ And the output should contain "key_secret"
10
+ And the output should contain "id"
11
+ And the output should contain "status"
@@ -0,0 +1,5 @@
1
+ require "aruba/cucumber"
2
+
3
+ Before do
4
+ @aruba_timeout_seconds = 5
5
+ end
data/lib/mgmt.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "mgmt/version"
2
+
3
+ module Mgmt
4
+ class AppDoesNotExist < Exception; end
5
+ end
data/lib/mgmt/cli.rb ADDED
@@ -0,0 +1,55 @@
1
+ require "mgmt"
2
+ require "thor"
3
+ require "fog"
4
+
5
+ class Mgmt::CLI < Thor
6
+ class_option :verbose, type: :boolean, aliases: "-v", desc: "Increase verbosity."
7
+
8
+ desc "create [NAME] [EMAIL]", "Create a new user"
9
+ def create(name, email)
10
+ begin
11
+ response = client.create_user(email, name)
12
+ say(JSON.generate(response.body)) if options[:verbose]
13
+ rescue Fog::RiakCS::Provisioning::UserAlreadyExists => e
14
+ error("User already exists.")
15
+ exit(1)
16
+ end
17
+ end
18
+
19
+ desc "list", "List the users in the system"
20
+ def list
21
+ response = client.list_users
22
+ headers = response.body.first.keys
23
+ users = response.body.map(&:values)
24
+ print_table([ headers, *users ])
25
+ end
26
+
27
+ private
28
+
29
+ def client
30
+ Fog::RiakCS::Provisioning.new(
31
+ riakcs_access_key_id: options["access_key"],
32
+ riakcs_secret_access_key: options["secret_key"],
33
+ host: "s3.amazonaws.com",
34
+ port: 80,
35
+ connection_options: {
36
+ proxy: "http://localhost:8080"
37
+ }
38
+ )
39
+ end
40
+
41
+ def options
42
+ original_options = super
43
+ default_options = {
44
+ "access_key" => ENV["RIAKCS_ACCESS_KEY_ID"],
45
+ "secret_key" => ENV["RIAKCS_SECRET_ACCESS_KEY"]
46
+ }
47
+
48
+ if default_options["access_key"].nil? && default_options["secret_key"].nil?
49
+ error("Please set your RIAKCS_ACCESS_KEY_ID and RIAKCS_SECRET_ACCESS_KEY enviromental variables.")
50
+ exit(1)
51
+ end
52
+
53
+ Thor::CoreExt::HashWithIndifferentAccess.new(original_options.merge(default_options))
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ module Mgmt
2
+ VERSION = "0.1.0"
3
+ end
data/man/mgmt.1 ADDED
@@ -0,0 +1,67 @@
1
+ .\" generated with Ronn/v0.7.3
2
+ .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
+ .
4
+ .TH "MGMT" "1" "July 2013" "" ""
5
+ .
6
+ .SH "NAME"
7
+ \fBmgmt\fR \- manage users in Riak CS
8
+ .
9
+ .SH "SYNOPSIS"
10
+ \fBmgmt create admin admin@admin\.com\fR
11
+ .
12
+ .SH "DESCRIPTION"
13
+ \fBmgmt\fR is a command\-line tool that aids in Riak CS user management\.
14
+ .
15
+ .SH "RUNNING"
16
+ \fBmgmt create\fR is used to create users within Riak CS\.
17
+ .
18
+ .P
19
+ If a valid username ane e\-mail address is provided, \fBmgmt\fR will create that user in Riak CS\.
20
+ .
21
+ .P
22
+ \fBmgmt list\fR is used to list the users in Riak CS\.
23
+ .
24
+ .SH "OPTIONS"
25
+ These options control all modes of \fBmgmt\fR\'s operation:
26
+ .
27
+ .TP
28
+ \fB\-v\fR, \fB\-\-verbose\fR
29
+ Increase verbosity\.
30
+ .
31
+ .SH "CONFIGURATION"
32
+ \fBmgmt\fR expects the following environmental variables to be present when it is invoked:
33
+ .
34
+ .IP "\(bu" 4
35
+ \fBRIAKCS_ACCESS_KEY_ID\fR: Your Riak CS access key ID\.
36
+ .
37
+ .IP "\(bu" 4
38
+ \fBRIAKCS_SECRET_ACCESS_KEY\fR Your Riak CS secret access key\.
39
+ .
40
+ .IP "" 0
41
+ .
42
+ .SH "EXAMPLE"
43
+ Create a user named \fBadmin\fR with the e\-mail address \fBadmin@admin\.com\fR:
44
+ .
45
+ .IP "" 4
46
+ .
47
+ .nf
48
+
49
+ $ mgmt create admin admin@admin\.com
50
+ .
51
+ .fi
52
+ .
53
+ .IP "" 0
54
+ .
55
+ .P
56
+ List all of the users in the system:
57
+ .
58
+ .IP "" 4
59
+ .
60
+ .nf
61
+
62
+ $ mgmt list
63
+ .
64
+ .fi
65
+ .
66
+ .IP "" 0
67
+
data/man/mgmt.1.html ADDED
@@ -0,0 +1,136 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv='content-type' value='text/html;charset=utf8'>
5
+ <meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
6
+ <title>mgmt(1) - manage users in Riak CS</title>
7
+ <style type='text/css' media='all'>
8
+ /* style: man */
9
+ body#manpage {margin:0}
10
+ .mp {max-width:100ex;padding:0 9ex 1ex 4ex}
11
+ .mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
12
+ .mp h2 {margin:10px 0 0 0}
13
+ .mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
14
+ .mp h3 {margin:0 0 0 4ex}
15
+ .mp dt {margin:0;clear:left}
16
+ .mp dt.flush {float:left;width:8ex}
17
+ .mp dd {margin:0 0 0 9ex}
18
+ .mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
19
+ .mp pre {margin-bottom:20px}
20
+ .mp pre+h2,.mp pre+h3 {margin-top:22px}
21
+ .mp h2+pre,.mp h3+pre {margin-top:5px}
22
+ .mp img {display:block;margin:auto}
23
+ .mp h1.man-title {display:none}
24
+ .mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
25
+ .mp h2 {font-size:16px;line-height:1.25}
26
+ .mp h1 {font-size:20px;line-height:2}
27
+ .mp {text-align:justify;background:#fff}
28
+ .mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
29
+ .mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
30
+ .mp u {text-decoration:underline}
31
+ .mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
32
+ .mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
33
+ .mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
34
+ .mp b.man-ref {font-weight:normal;color:#434241}
35
+ .mp pre {padding:0 4ex}
36
+ .mp pre code {font-weight:normal;color:#434241}
37
+ .mp h2+pre,h3+pre {padding-left:0}
38
+ ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
39
+ ol.man-decor {width:100%}
40
+ ol.man-decor li.tl {text-align:left}
41
+ ol.man-decor li.tc {text-align:center;letter-spacing:4px}
42
+ ol.man-decor li.tr {text-align:right;float:right}
43
+ </style>
44
+ </head>
45
+ <!--
46
+ The following styles are deprecated and will be removed at some point:
47
+ div#man, div#man ol.man, div#man ol.head, div#man ol.man.
48
+
49
+ The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
50
+ .man-navigation should be used instead.
51
+ -->
52
+ <body id='manpage'>
53
+ <div class='mp' id='man'>
54
+
55
+ <div class='man-navigation' style='display:none'>
56
+ <a href="#NAME">NAME</a>
57
+ <a href="#SYNOPSIS">SYNOPSIS</a>
58
+ <a href="#DESCRIPTION">DESCRIPTION</a>
59
+ <a href="#RUNNING">RUNNING</a>
60
+ <a href="#OPTIONS">OPTIONS</a>
61
+ <a href="#CONFIGURATION">CONFIGURATION</a>
62
+ <a href="#EXAMPLE">EXAMPLE</a>
63
+ </div>
64
+
65
+ <ol class='man-decor man-head man head'>
66
+ <li class='tl'>mgmt(1)</li>
67
+ <li class='tc'></li>
68
+ <li class='tr'>mgmt(1)</li>
69
+ </ol>
70
+
71
+ <h2 id="NAME">NAME</h2>
72
+ <p class="man-name">
73
+ <code>mgmt</code> - <span class="man-whatis">manage users in Riak CS</span>
74
+ </p>
75
+
76
+ <h2 id="SYNOPSIS">SYNOPSIS</h2>
77
+
78
+ <p><code>mgmt create admin admin@admin.com</code></p>
79
+
80
+ <h2 id="DESCRIPTION">DESCRIPTION</h2>
81
+
82
+ <p><strong>mgmt</strong> is a command-line tool that aids in Riak CS user management.</p>
83
+
84
+ <h2 id="RUNNING">RUNNING</h2>
85
+
86
+ <p><code>mgmt create</code> is used to create users within Riak CS.</p>
87
+
88
+ <p>If a valid username ane e-mail address is provided, <code>mgmt</code> will create that
89
+ user in Riak CS.</p>
90
+
91
+ <p><code>mgmt list</code> is used to list the users in Riak CS.</p>
92
+
93
+ <h2 id="OPTIONS">OPTIONS</h2>
94
+
95
+ <p>These options control all modes of <code>mgmt</code>'s operation:</p>
96
+
97
+ <dl>
98
+ <dt><code>-v</code>, <code>--verbose</code></dt><dd>Increase verbosity.</dd>
99
+ </dl>
100
+
101
+
102
+ <h2 id="CONFIGURATION">CONFIGURATION</h2>
103
+
104
+ <p><code>mgmt</code> expects the following environmental variables to be present when it is
105
+ invoked:</p>
106
+
107
+ <ul>
108
+ <li><code>RIAKCS_ACCESS_KEY_ID</code>:
109
+ Your Riak CS access key ID.</li>
110
+ <li><code>RIAKCS_SECRET_ACCESS_KEY</code>
111
+ Your Riak CS secret access key.</li>
112
+ </ul>
113
+
114
+
115
+ <h2 id="EXAMPLE">EXAMPLE</h2>
116
+
117
+ <p>Create a user named <code>admin</code> with the e-mail address <code>admin@admin.com</code>:</p>
118
+
119
+ <pre><code>$ mgmt create admin admin@admin.com
120
+ </code></pre>
121
+
122
+ <p>List all of the users in the system:</p>
123
+
124
+ <pre><code>$ mgmt list
125
+ </code></pre>
126
+
127
+
128
+ <ol class='man-decor man-foot man foot'>
129
+ <li class='tl'></li>
130
+ <li class='tc'>July 2013</li>
131
+ <li class='tr'>mgmt(1)</li>
132
+ </ol>
133
+
134
+ </div>
135
+ </body>
136
+ </html>
data/man/mgmt.1.ronn ADDED
@@ -0,0 +1,46 @@
1
+ mgmt(1) -- manage users in Riak CS
2
+ =======================================================================
3
+
4
+ ## SYNOPSIS ##
5
+
6
+ `mgmt create admin admin@admin.com`
7
+
8
+ ## DESCRIPTION ##
9
+
10
+ __mgmt__ is a command-line tool that aids in Riak CS user management.
11
+
12
+ ## RUNNING ##
13
+
14
+ `mgmt create` is used to create users within Riak CS.
15
+
16
+ If a valid username ane e-mail address is provided, `mgmt` will create that
17
+ user in Riak CS.
18
+
19
+ `mgmt list` is used to list the users in Riak CS.
20
+
21
+ ## OPTIONS ##
22
+
23
+ These options control all modes of `mgmt`'s operation:
24
+
25
+ * `-v`, `--verbose`:
26
+ Increase verbosity.
27
+
28
+ ## CONFIGURATION ##
29
+
30
+ `mgmt` expects the following environmental variables to be present when it is
31
+ invoked:
32
+
33
+ * `RIAKCS_ACCESS_KEY_ID`:
34
+ Your Riak CS access key ID.
35
+ * `RIAKCS_SECRET_ACCESS_KEY`
36
+ Your Riak CS secret access key.
37
+
38
+ ## EXAMPLE ##
39
+
40
+ Create a user named `admin` with the e-mail address `admin@admin.com`:
41
+
42
+ $ mgmt create admin admin@admin.com
43
+
44
+ List all of the users in the system:
45
+
46
+ $ mgmt list
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "mgmt/version"
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "riak-cs-user-mgmt"
8
+ gem.version = Mgmt::VERSION
9
+ gem.authors = ["Hector Castro"]
10
+ gem.email = ["hector@basho.com"]
11
+ gem.homepage = "https://hectcastro.github.com/riak-cs-user-mgmt"
12
+ gem.summary = %q{`mgmt` is a command-line tool that aids in Riak CS user management.}
13
+ gem.description = gem.summary
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.test_files = gem.files.grep(%r{^(features)/})
17
+ gem.executables = ["mgmt"]
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "thor"
21
+
22
+ gem.add_development_dependency "bundler", "~> 1.3"
23
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: riak-cs-user-mgmt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Hector Castro
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: bundler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.3'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.3'
46
+ description: ! '`mgmt` is a command-line tool that aids in Riak CS user management.'
47
+ email:
48
+ - hector@basho.com
49
+ executables:
50
+ - mgmt
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - README.md
57
+ - Rakefile
58
+ - bin/mgmt
59
+ - features/create.feature
60
+ - features/list.feature
61
+ - features/support/env.rb
62
+ - lib/mgmt.rb
63
+ - lib/mgmt/cli.rb
64
+ - lib/mgmt/version.rb
65
+ - man/mgmt.1
66
+ - man/mgmt.1.html
67
+ - man/mgmt.1.ronn
68
+ - riak-cs-user-mgmt.gemspec
69
+ homepage: https://hectcastro.github.com/riak-cs-user-mgmt
70
+ licenses: []
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.23
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: ! '`mgmt` is a command-line tool that aids in Riak CS user management.'
93
+ test_files:
94
+ - features/create.feature
95
+ - features/list.feature
96
+ - features/support/env.rb