ocp 0.0.22 → 0.0.23

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ccdfe7d455959bfe2dc96f5b9e3468dd0d35e62d
4
- data.tar.gz: 38ee466cf318a474f7229b0c4302b7b617038624
3
+ metadata.gz: 8ecbd011a0c1a18e8f5abb16ebcffbe09fc28e1a
4
+ data.tar.gz: c101a6752ae285d142c5f25e6fb21d3eba9c8bfc
5
5
  SHA512:
6
- metadata.gz: 593bc791c604652f4527e6990367f3afca56d0218251afa77023c42c49dedd08dbdd5e9303ec725e4b099b743b443a13223aafc1ee96e6df90c091bfc6467361
7
- data.tar.gz: 8ca99875cbb61a46eccd0c42716baf8666051beb4d2989524d4a666ab1caa8534011c1f7d829e4e7e6418617234549093e6405376ff91bc4ad846331b94e2a18
6
+ metadata.gz: 7673e83186ffd1801585ffea57c2555c77026f3f2543bf0b8132ae13b5ea620a3f837f39026ee62116121786b97bb760fe4c8c5f268a11bbe3cf6729e04bd74f
7
+ data.tar.gz: d57213a2eeb1d6f44a11830fb3fdb82317174bc3f8834f4f63c9333c4e626c3f42a605991d2b098ad6f58cabe05ed5be77bf48ffb4f9000cd38919523cd16864
@@ -35,6 +35,16 @@ class Project < OcpApi
35
35
  return data
36
36
  end
37
37
 
38
+ def list_projects_array
39
+ array = Array.new
40
+ project_list = JSON.parse listprojects
41
+ list = project_list['items']
42
+ list.each do |key|
43
+ array.push key['metadata']['name']
44
+ end
45
+ return array
46
+ end
47
+
38
48
  def exists?(project_name)
39
49
  project_list = listprojects
40
50
  data = JSON.parse project_list
@@ -46,6 +46,7 @@ class RoleBinding < OcpApi
46
46
  return data
47
47
  end
48
48
 
49
+
49
50
  def to_s
50
51
  data = nil
51
52
  data = list
@@ -1,6 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'yaml'
3
3
  require 'commander'
4
+ require 'json'
4
5
 
5
6
 
6
7
  load 'exceptions/MissingRequiredOptionException.rb'
@@ -95,6 +96,43 @@ class OcpCommander
95
96
  end
96
97
  end
97
98
 
99
+ command :list_projects_by_user do |c|
100
+ c.syntax = 'ocp projectexists [options]'
101
+ c.summary = 'List projects by user'
102
+ c.description = 'List projects by user'
103
+ c.option '--username USERNAME', String, 'The user to search by'
104
+ c.option '--role ROLE', String, 'The optional role to filter by'
105
+ c.action do |args, options|
106
+ # Do something or c.when_called Ocp::Commands::Getapi
107
+ valid_project_list = Array.new
108
+ proj = Project.new
109
+ proj.setup_by_config_file(options.config, options.pretty, options.debug)
110
+
111
+ proj.list_projects_array.each do |projname|
112
+ role_bindings = RoleBinding.new(projname)
113
+
114
+ bindings_list = JSON.parse role_bindings.to_s
115
+ list = bindings_list['items']
116
+ list.each do |key|
117
+
118
+ unless options.role.nil?
119
+ if key['metadata']['name'].eql? options.role and !key['userNames'].nil? and key['userNames'].include? options.username
120
+ valid_project_list.push projname
121
+ end
122
+ else
123
+ if !key['userNames'].nil? and key['userNames'].include? options.username
124
+ valid_project_list.push projname
125
+ end
126
+ end
127
+ end
128
+
129
+ end
130
+
131
+ puts "#{valid_project_list}"
132
+
133
+ end
134
+ end
135
+
98
136
  command :createproject do |c|
99
137
  c.syntax = 'ocp createproject [options]'
100
138
  c.summary = 'Create a project request'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Evensen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-27 00:00:00.000000000 Z
11
+ date: 2016-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander