rhc 1.23.7 → 1.24.4

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.
@@ -10,9 +10,9 @@ _rhc()
10
10
  if [[ "$cur" == -* ]]; then
11
11
  opts="--always-prefix --clean --config --debug --insecure --limit --mock --noprompt --password --raw --rhlogin --server --ssl-ca-file --ssl-client-cert-file --ssl-version --timeout --token"
12
12
  elif [ -z $cur ]; then
13
- opts="account alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert app app-configure app-create app-delete app-deploy app-force-stop app-reload app-restart app-scale-down app-scale-up app-show app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage deployment deployment-activate deployment-list deployment-show domain domain-configure domain-create domain-delete domain-leave domain-list domain-rename domain-show env env-list env-set env-show env-unset git-clone logout member member-add member-list member-remove member-update port-forward scp server setup snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-list sshkey-remove sshkey-show tail threaddump"
13
+ opts="account alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert app app-configure app-create app-delete app-deploy app-force-stop app-reload app-restart app-scale-down app-scale-up app-show app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage deployment deployment-activate deployment-list deployment-show domain domain-configure domain-create domain-delete domain-leave domain-list domain-rename domain-show env env-list env-set env-show env-unset git-clone logout member member-add member-list member-remove member-update port-forward scp server setup snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-list sshkey-remove sshkey-show tail team team-create team-delete team-leave team-list team-show threaddump"
14
14
  else
15
- opts="account account-logout activate-deployment add-alias add-authorization add-cartridge add-member add-sshkey alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert aliases app app-configure app-create app-delete app-deploy app-env app-force-stop app-reload app-restart app-scale-down app-scale-up app-scp app-show app-snapshot app-ssh app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list authorizations cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage cartridges configure-app configure-domain create-app create-domain delete-all-authorization delete-app delete-authorization delete-cert-alias delete-domain deploy deploy-app deployment deployment-activate deployment-list deployment-show deployments domain domain-configure domain-create domain-delete domain-leave domain-list domain-rename domain-show domains env env-add env-list env-remove env-set env-show env-unset force-stop-app git-clone leave-domain list-alias list-authorization list-cartridge list-deployment list-domain list-env list-member list-sshkey logout member member-add member-list member-remove member-update members port-forward reload-app reload-cartridge remove-alias remove-cartridge remove-member remove-sshkey rename-domain restart-app restart-cartridge restore-snapshot save-snapshot scale-cartridge scale-down-app scale-up-app scp server set-env setup show-app show-cartridge show-deployment show-domain show-env show-sshkey snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-list sshkey-remove sshkey-show start-app start-cartridge status-cartridge stop-app stop-cartridge storage-cartridge tail threaddump tidy-app unset-env update-cert-alias update-member"
15
+ opts="account account-logout activate-deployment add-alias add-authorization add-cartridge add-member add-sshkey alias alias-add alias-delete-cert alias-list alias-remove alias-update-cert aliases app app-configure app-create app-delete app-deploy app-env app-force-stop app-reload app-restart app-scale-down app-scale-up app-scp app-show app-snapshot app-ssh app-start app-stop app-tidy apps authorization authorization-add authorization-delete authorization-delete-all authorization-list authorizations cartridge cartridge-add cartridge-list cartridge-reload cartridge-remove cartridge-restart cartridge-scale cartridge-show cartridge-start cartridge-status cartridge-stop cartridge-storage cartridges configure-app configure-domain create-app create-domain create-team delete-all-authorization delete-app delete-authorization delete-cert-alias delete-domain delete-team deploy deploy-app deployment deployment-activate deployment-list deployment-show deployments domain domain-configure domain-create domain-delete domain-leave domain-list domain-rename domain-show domains env env-add env-list env-remove env-set env-show env-unset force-stop-app git-clone leave-domain leave-team list-alias list-authorization list-cartridge list-deployment list-domain list-env list-member list-sshkey list-team logout member member-add member-list member-remove member-update members port-forward reload-app reload-cartridge remove-alias remove-cartridge remove-member remove-sshkey rename-domain restart-app restart-cartridge restore-snapshot save-snapshot scale-cartridge scale-down-app scale-up-app scp server set-env setup show-app show-cartridge show-deployment show-domain show-env show-sshkey show-team snapshot snapshot-restore snapshot-save ssh sshkey sshkey-add sshkey-list sshkey-remove sshkey-show start-app start-cartridge status-cartridge stop-app stop-cartridge storage-cartridge tail team team-create team-delete team-leave team-list team-show teams threaddump tidy-app unset-env update-cert-alias update-member"
16
16
  fi
17
17
  else
18
18
  prev="${COMP_WORDS[@]:0:COMP_CWORD}"
@@ -78,7 +78,7 @@ _rhc()
78
78
 
79
79
  "rhc add-member")
80
80
  if [[ "$cur" == -* ]]; then
81
- opts="--global --ids --namespace --role --type"
81
+ opts="--global --ids --namespace --role --team-id --team-name --type"
82
82
  else
83
83
  opts=""
84
84
  fi
@@ -780,6 +780,14 @@ _rhc()
780
780
  fi
781
781
  ;;
782
782
 
783
+ "rhc create-team")
784
+ if [[ "$cur" == -* ]]; then
785
+ opts="--team-name"
786
+ else
787
+ opts=""
788
+ fi
789
+ ;;
790
+
783
791
  "rhc delete-all-authorization")
784
792
  if [[ "$cur" == -* ]]; then
785
793
  opts=""
@@ -820,6 +828,14 @@ _rhc()
820
828
  fi
821
829
  ;;
822
830
 
831
+ "rhc delete-team")
832
+ if [[ "$cur" == -* ]]; then
833
+ opts="--team-id --team-name"
834
+ else
835
+ opts=""
836
+ fi
837
+ ;;
838
+
823
839
  "rhc deploy")
824
840
  if [[ "$cur" == -* ]]; then
825
841
  opts="--app --application-id --force-clean-build --hot-deploy --namespace --no-force-clean-build --no-hot-deploy --ref"
@@ -1156,6 +1172,14 @@ _rhc()
1156
1172
  fi
1157
1173
  ;;
1158
1174
 
1175
+ "rhc leave-team")
1176
+ if [[ "$cur" == -* ]]; then
1177
+ opts="--team-id --team-name"
1178
+ else
1179
+ opts=""
1180
+ fi
1181
+ ;;
1182
+
1159
1183
  "rhc list-alias")
1160
1184
  if [[ "$cur" == -* ]]; then
1161
1185
  opts="--app --application-id --namespace"
@@ -1206,7 +1230,7 @@ _rhc()
1206
1230
 
1207
1231
  "rhc list-member")
1208
1232
  if [[ "$cur" == -* ]]; then
1209
- opts="--all --app --ids --namespace --target"
1233
+ opts="--all --app --ids --namespace --target --team-id --team-name"
1210
1234
  else
1211
1235
  opts=""
1212
1236
  fi
@@ -1220,6 +1244,14 @@ _rhc()
1220
1244
  fi
1221
1245
  ;;
1222
1246
 
1247
+ "rhc list-team")
1248
+ if [[ "$cur" == -* ]]; then
1249
+ opts="--mine"
1250
+ else
1251
+ opts=""
1252
+ fi
1253
+ ;;
1254
+
1223
1255
  "rhc logout")
1224
1256
  if [[ "$cur" == -* ]]; then
1225
1257
  opts="--all"
@@ -1238,7 +1270,7 @@ _rhc()
1238
1270
 
1239
1271
  "rhc member add")
1240
1272
  if [[ "$cur" == -* ]]; then
1241
- opts="--global --ids --namespace --role --type"
1273
+ opts="--global --ids --namespace --role --team-id --team-name --type"
1242
1274
  else
1243
1275
  opts=""
1244
1276
  fi
@@ -1246,7 +1278,7 @@ _rhc()
1246
1278
 
1247
1279
  "rhc member list")
1248
1280
  if [[ "$cur" == -* ]]; then
1249
- opts="--all --app --ids --namespace --target"
1281
+ opts="--all --app --ids --namespace --target --team-id --team-name"
1250
1282
  else
1251
1283
  opts=""
1252
1284
  fi
@@ -1254,7 +1286,7 @@ _rhc()
1254
1286
 
1255
1287
  "rhc member remove")
1256
1288
  if [[ "$cur" == -* ]]; then
1257
- opts="--all --ids --namespace --type"
1289
+ opts="--all --ids --namespace --team-id --team-name --type"
1258
1290
  else
1259
1291
  opts=""
1260
1292
  fi
@@ -1270,7 +1302,7 @@ _rhc()
1270
1302
 
1271
1303
  "rhc member-add")
1272
1304
  if [[ "$cur" == -* ]]; then
1273
- opts="--global --ids --namespace --role --type"
1305
+ opts="--global --ids --namespace --role --team-id --team-name --type"
1274
1306
  else
1275
1307
  opts=""
1276
1308
  fi
@@ -1278,7 +1310,7 @@ _rhc()
1278
1310
 
1279
1311
  "rhc member-list")
1280
1312
  if [[ "$cur" == -* ]]; then
1281
- opts="--all --app --ids --namespace --target"
1313
+ opts="--all --app --ids --namespace --target --team-id --team-name"
1282
1314
  else
1283
1315
  opts=""
1284
1316
  fi
@@ -1286,7 +1318,7 @@ _rhc()
1286
1318
 
1287
1319
  "rhc member-remove")
1288
1320
  if [[ "$cur" == -* ]]; then
1289
- opts="--all --ids --namespace --type"
1321
+ opts="--all --ids --namespace --team-id --team-name --type"
1290
1322
  else
1291
1323
  opts=""
1292
1324
  fi
@@ -1302,7 +1334,7 @@ _rhc()
1302
1334
 
1303
1335
  "rhc members")
1304
1336
  if [[ "$cur" == -* ]]; then
1305
- opts="--all --app --ids --namespace --target"
1337
+ opts="--all --app --ids --namespace --target --team-id --team-name"
1306
1338
  else
1307
1339
  opts=""
1308
1340
  fi
@@ -1350,7 +1382,7 @@ _rhc()
1350
1382
 
1351
1383
  "rhc remove-member")
1352
1384
  if [[ "$cur" == -* ]]; then
1353
- opts="--all --ids --namespace --type"
1385
+ opts="--all --ids --namespace --team-id --team-name --type"
1354
1386
  else
1355
1387
  opts=""
1356
1388
  fi
@@ -1508,6 +1540,14 @@ _rhc()
1508
1540
  fi
1509
1541
  ;;
1510
1542
 
1543
+ "rhc show-team")
1544
+ if [[ "$cur" == -* ]]; then
1545
+ opts="--team-id --team-name"
1546
+ else
1547
+ opts=""
1548
+ fi
1549
+ ;;
1550
+
1511
1551
  "rhc snapshot")
1512
1552
  if [[ "$cur" == -* ]]; then
1513
1553
  opts=""
@@ -1684,6 +1724,102 @@ _rhc()
1684
1724
  fi
1685
1725
  ;;
1686
1726
 
1727
+ "rhc team")
1728
+ if [[ "$cur" == -* ]]; then
1729
+ opts=""
1730
+ else
1731
+ opts="create show list delete leave"
1732
+ fi
1733
+ ;;
1734
+
1735
+ "rhc team create")
1736
+ if [[ "$cur" == -* ]]; then
1737
+ opts="--team-name"
1738
+ else
1739
+ opts=""
1740
+ fi
1741
+ ;;
1742
+
1743
+ "rhc team delete")
1744
+ if [[ "$cur" == -* ]]; then
1745
+ opts="--team-id --team-name"
1746
+ else
1747
+ opts=""
1748
+ fi
1749
+ ;;
1750
+
1751
+ "rhc team leave")
1752
+ if [[ "$cur" == -* ]]; then
1753
+ opts="--team-id --team-name"
1754
+ else
1755
+ opts=""
1756
+ fi
1757
+ ;;
1758
+
1759
+ "rhc team list")
1760
+ if [[ "$cur" == -* ]]; then
1761
+ opts="--mine"
1762
+ else
1763
+ opts=""
1764
+ fi
1765
+ ;;
1766
+
1767
+ "rhc team show")
1768
+ if [[ "$cur" == -* ]]; then
1769
+ opts="--team-id --team-name"
1770
+ else
1771
+ opts=""
1772
+ fi
1773
+ ;;
1774
+
1775
+ "rhc team-create")
1776
+ if [[ "$cur" == -* ]]; then
1777
+ opts="--team-name"
1778
+ else
1779
+ opts=""
1780
+ fi
1781
+ ;;
1782
+
1783
+ "rhc team-delete")
1784
+ if [[ "$cur" == -* ]]; then
1785
+ opts="--team-id --team-name"
1786
+ else
1787
+ opts=""
1788
+ fi
1789
+ ;;
1790
+
1791
+ "rhc team-leave")
1792
+ if [[ "$cur" == -* ]]; then
1793
+ opts="--team-id --team-name"
1794
+ else
1795
+ opts=""
1796
+ fi
1797
+ ;;
1798
+
1799
+ "rhc team-list")
1800
+ if [[ "$cur" == -* ]]; then
1801
+ opts="--mine"
1802
+ else
1803
+ opts=""
1804
+ fi
1805
+ ;;
1806
+
1807
+ "rhc team-show")
1808
+ if [[ "$cur" == -* ]]; then
1809
+ opts="--team-id --team-name"
1810
+ else
1811
+ opts=""
1812
+ fi
1813
+ ;;
1814
+
1815
+ "rhc teams")
1816
+ if [[ "$cur" == -* ]]; then
1817
+ opts="--mine"
1818
+ else
1819
+ opts=""
1820
+ fi
1821
+ ;;
1822
+
1687
1823
  "rhc threaddump")
1688
1824
  if [[ "$cur" == -* ]]; then
1689
1825
  opts="--app --application-id --namespace"
@@ -104,7 +104,7 @@ describe "rhc member scenarios" do
104
104
  members.any?{ |m| m.id == other_users[user1].id && m.editor? }.should be_true
105
105
  members.any?{ |m| m.id == other_users[user2].id && m.editor? }.should be_true
106
106
 
107
- r = rhc 'remove-member', domain.name, '--all'
107
+ r = rhc 'remove-member', '-n', domain.name, '--all'
108
108
  r.status.should == 0
109
109
  r.stdout.should match "Removing all members from domain.*done"
110
110
  members = client.find_domain(domain.name).members
@@ -116,8 +116,8 @@ module RHC::Commands
116
116
  :url => (cartridge.url if cartridge.custom?),
117
117
  :gear_size => options.gear_size || cartridge.gear_profile,
118
118
  :additional_gear_storage => (cartridge.additional_gear_storage if cartridge.additional_gear_storage > 0),
119
- :scales_from => (cartridge.scales_from if cartridge.scalable?),
120
- :scales_to => (cartridge.scales_to if cartridge.scalable?)
119
+ :scales_from => (cartridge.scales_from if scaling && cartridge.scalable?),
120
+ :scales_to => (cartridge.scales_to if scaling && cartridge.scalable?)
121
121
  }.reject{|k,v| v.nil? }
122
122
  end
123
123
  end
@@ -130,6 +130,7 @@ module RHC::Commands
130
130
  def remove(cartridge)
131
131
  rest_app = find_app(:include => :cartridges)
132
132
  rest_cartridge = check_cartridges(cartridge, :from => rest_app.cartridges).first
133
+ external_zero_gears = external_zero_gears_cartridge?(rest_cartridge)
133
134
 
134
135
  confirm_action "Removing a cartridge is a destructive operation that may result in loss of data associated with the cartridge.\n\nAre you sure you wish to remove #{rest_cartridge.name} from '#{rest_app.name}'?"
135
136
 
@@ -139,6 +140,8 @@ module RHC::Commands
139
140
 
140
141
  paragraph{ rest_cartridge.messages.each { |msg| success msg } }
141
142
 
143
+ paragraph{ warn 'There may be external resources or accounts associated with this external cartridge that need to be removed manually.' } if external_zero_gears
144
+
142
145
  0
143
146
  end
144
147
 
@@ -325,5 +328,9 @@ module RHC::Commands
325
328
  end
326
329
  resp
327
330
  end
331
+
332
+ def external_zero_gears_cartridge?(rest_cartridge)
333
+ rest_cartridge.external? && rest_cartridge.current_scale == 0
334
+ end
328
335
  end
329
336
  end
@@ -2,53 +2,82 @@ require 'rhc/commands/base'
2
2
 
3
3
  module RHC::Commands
4
4
  class Member < Base
5
- summary "Manage membership on domains"
5
+ summary "Manage membership on domains and teams"
6
6
  syntax "<action>"
7
7
  description <<-DESC
8
- Developers can collaborate on applications by adding people or teams to
9
- domains as members: each member has a role (admin, editor, or viewer),
10
- and those roles determine what the user can do with the domain and the
11
- applications contained within.
8
+ Domain Membership
9
+ Developers can collaborate on applications by adding people or teams to
10
+ domains as members. Each member has a role (admin, edit, or view),
11
+ and those roles determine what the user can do with the domain and the
12
+ applications contained within.
12
13
 
13
- Roles:
14
+ Domain Member Roles
14
15
 
15
- view - able to see information about the domain and its apps, but not make any changes
16
- edit - create, update, and delete applications, and has Git and SSH access
17
- admin - can update membership of a domain
16
+ view - able to see the domain and its apps, but not make any changes
17
+ edit - create, update, and delete applications, and has Git and SSH access
18
+ admin - can update membership of a domain
19
+
20
+ The default role granted to domain members is 'edit' - use the '--role'
21
+ argument to specify a different role. When adding and removing members, you
22
+ can use their 'login' value (typically their email or a short unique name for
23
+ them), or their 'id'. Both login and ID are visible via the 'rhc account'
24
+ command.
25
+
26
+ To see existing members of a domain or application, use:
27
+
28
+ rhc members -n DOMAIN_NAME [-a APP_NAME]
29
+
30
+ To change the role for a domain member, simply call the update-member command
31
+ with the new role. You cannot change the role of the owner.
32
+
33
+ Team Membership
34
+ People who typically share the same role can be added to a team. The team can
35
+ then be added as a member of a domain, and all of the people in the team will
36
+ inherit the team's role on the domain.
37
+
38
+ If a person is a member of multiple teams which are members of a domain, or
39
+ is also added as a domain member individually, their effective role is the
40
+ higher of their individual role or their teams' roles on the domain.
18
41
 
19
- The default role granted to members when added is 'edit' - use the '--role'
20
- argument to use another. When adding and removing members, you can use their
21
- 'login' value (typically their email or a short unique name for them) or their
22
- 'id'. Both login and ID are visible via the 'rhc account' command.
42
+ Team Member Roles
43
+ view - able to see information about the team and its members, and
44
+ has access to all domains the team is a member of
23
45
 
24
- To see existing members of a domain or application, use:
46
+ To see existing members of a team, use:
25
47
 
26
- rhc members -n <domain_name> [-a <app_name>]
48
+ rhc members -t TEAM_NAME
27
49
 
28
- To change the role for a user, simply call the add-member command with the new role. You
29
- cannot change the role of the owner.
30
50
  DESC
31
51
  syntax "<action>"
32
52
  default_action :help
33
53
 
34
- summary "List members of a domain or application"
35
- syntax "<domain_or_app_name> [-n DOMAIN_NAME] [-a APP_NAME] [--all]"
54
+ summary "List members of a domain, application, or team"
55
+ syntax [
56
+ "<domain_name>[/<app_name>] [--all]",
57
+ "-n DOMAIN_NAME [--all]",
58
+ "-n DOMAIN_NAME -a APP_NAME [--all]",
59
+ nil,
60
+ "-t TEAM_NAME"
61
+ ]
36
62
  description <<-DESC
37
- Show the existing members of a domain or application - you can pass the name
38
- of your domain with '-n', the name of your application with '-a', or combine
39
- them in the first argument to the command like:
63
+ Show the existing members of a domain, application, or team.
40
64
 
41
- rhc members <domain_name>/[<app_name>]
65
+ To show the members of a domain or application, you can pass the name of your
66
+ domain with '-n', the name of your application with '-a', or combine them in
67
+ the first argument to the command like:
68
+ rhc members <domain_name>[/<app_name>]
42
69
 
43
- The owner is always listed first. To see the unique ID of members, pass
44
- '--ids'.
70
+ To show the members of a team, you can pass the name of the team with '-t':
71
+ rhc members -t TEAM_NAME
72
+
73
+ The owner is always listed first. To see the unique ID of members, pass '--ids'.
45
74
  DESC
46
75
  option ['--ids'], "Display the IDs of each member", :optional => true
47
76
  option ['--all'], "Display all members, including members of teams", :optional => true
48
- takes_application_or_domain :argument => true
77
+ takes_membership_container :argument => true
49
78
  alias_action :members, :root_command => true
50
- def list(path)
51
- target = find_app_or_domain(path)
79
+ def list(_)
80
+ target = find_membership_container
52
81
 
53
82
  members = target.members
54
83
  if options.all
@@ -98,48 +127,66 @@ module RHC::Commands
98
127
  0
99
128
  end
100
129
 
101
- summary "Add a member on a domain"
102
- syntax "(<login>... | <team name>... | <id>...) [-n DOMAIN_NAME] [--role view|edit|admin] [--ids] [--type user|team] [--global]"
130
+ summary "Add a member to a domain or team"
131
+ syntax [
132
+ "-n DOMAIN_NAME [--role view|edit|admin] <login>...",
133
+ "-n DOMAIN_NAME [--role view|edit|admin] <team_name>... --type team [--global]",
134
+ "-n DOMAIN_NAME [--role view|edit|admin] <id>... --ids [--type user|team]",
135
+ nil,
136
+ "-t TEAM_NAME <login>...",
137
+ "-t TEAM_NAME <id>... --ids",
138
+ ]
103
139
  description <<-DESC
104
- Adds members on a domain by passing a user login, team name, or ID for each
105
- member. The login and ID for each account are displayed in 'rhc account'.
106
- To change the role for an existing domain member, use the 'rhc member update'
107
- command.
140
+ Domain Membership
141
+ Add members to a domain by passing a user login, team name, or ID for each
142
+ member. The login and ID for each account are displayed in 'rhc account'.
143
+ To change the role for an existing domain member, use the 'rhc member update'
144
+ command.
108
145
 
109
- Roles
110
- view - able to see information about the domain and its apps,
111
- but not make any changes
112
- edit - create, update, and delete applications, and has Git
113
- and SSH access
114
- admin - can update membership of a domain
146
+ Domain Member Roles
147
+ view - able to see information about the domain and its apps,
148
+ but not make any changes
149
+ edit - create, update, and delete applications, and has Git
150
+ and SSH access
151
+ admin - can update membership of a domain
152
+
153
+ The default role granted to domain members is 'edit'.
154
+ Use the '--role' argument for 'view' or 'admin'.
115
155
 
116
- The default role granted to members when added is 'edit' - use the '--role'
117
- argument for 'view' or 'admin'.
156
+ Team Membership
157
+ Add users to a team by passing a user login, or ID for each member.
158
+
159
+ Team Member Roles
160
+ view - able to see information about the team and its members, and
161
+ has access to all domains the team is a member of
118
162
 
119
163
  Examples
120
164
  rhc add-member sally joe -n mydomain
121
165
  Gives the accounts with logins 'sally' and 'joe' edit access on mydomain
122
166
 
123
- rhc add-member bob@example.com --role admin -n mydomain
124
- Gives the account with login 'bob@example.com' admin access on mydomain
167
+ rhc add-member bob --role admin -n mydomain
168
+ Gives the account with login 'bob' admin access on mydomain
125
169
 
126
170
  rhc add-member team1 --type team --role admin -n mydomain
127
171
  Gives your team named 'team1' admin access on mydomain
128
172
 
173
+ rhc add-member steve -t team1
174
+ Adds the account with login 'steve' as a member of your team named 'team1'
129
175
  DESC
130
- takes_domain
131
- option ['--ids'], "Treat the arguments as a list of IDs", :optional => true
132
- option ['-r', '--role ROLE'], "The role to give to each member - view, edit, or admin (default is 'edit')", :type => Role, :optional => true
133
- option ['--type TYPE'], "Type of argument(s) being passed. Accepted values are either 'team' or 'user' (default is 'user').", :optional => true
134
- option ['--global'], "Use global-scoped teams. Must be used with '--type team'.", :optional => true
176
+ takes_membership_container :writable => true
177
+ option ['--ids'], "Add member(s) by ID", :optional => true
178
+ option ['-r', '--role ROLE'], "The role to give to each member - view, edit, or admin (default is 'edit' for domains, 'view' for teams)", :type => Role, :optional => true
179
+ option ['--type TYPE'], "Type of member(s) being added - user or team (default is 'user').", :optional => true
180
+ option ['--global'], "Add global-scoped teams as members. Must be used with '--type team'.", :optional => true
135
181
  argument :members, "A list of members (user logins, team names, or IDs) to add. Pass --ids to treat this as a list of IDs.", [], :type => :list
136
182
  def add(members)
137
- target = find_domain
138
- role = get_role_option(options)
183
+ target = find_membership_container :writable => true
184
+
185
+ role = get_role_option(options, target)
139
186
  type = get_type_option(options)
140
187
  global = !!options.global
141
188
 
142
- raise ArgumentError, 'You must pass at least one user login, team name, or ID to this command.' unless members.present?
189
+ raise ArgumentError, 'You must pass at least one member to this command.' unless members.present?
143
190
  raise ArgumentError, "The --global option can only be used with '--type team'." if global && !team?(type)
144
191
 
145
192
  say "Adding #{pluralize(members.length, role_name(role))} to #{target.class.model_name.downcase} ... "
@@ -153,7 +200,11 @@ module RHC::Commands
153
200
  end
154
201
 
155
202
  summary "Update a member on a domain"
156
- syntax "(<login>... | <team name>... | <id>...) --role view|edit|admin [-n DOMAIN_NAME] [--ids] [--type user|team]"
203
+ syntax [
204
+ "-n DOMAIN_NAME --role view|edit|admin <login>...",
205
+ "-n DOMAIN_NAME --role view|edit|admin <team_name>... --type team",
206
+ "-n DOMAIN_NAME --role view|edit|admin <id>... --ids [--type user|team]",
207
+ ]
157
208
  description <<-DESC
158
209
  Updates members on a domain by passing a user login, team name, or ID for
159
210
  each member. You can use the 'rhc members' command to list the existing
@@ -166,31 +217,28 @@ module RHC::Commands
166
217
  and SSH access
167
218
  admin - can update membership of a domain
168
219
 
169
- The default role granted to members when added is 'edit' - use the '--role'
170
- argument for 'view' or 'admin'.
171
-
172
220
  Examples
173
- rhc update-member bob@example.com --role view -n mydomain
174
- Adds or updates the member with login 'bob@example.com' to 'admin' role on mydomain
221
+ rhc update-member -n mydomain --role view bob
222
+ Adds or updates the user with login 'bob' to 'admin' role on mydomain
175
223
 
176
- rhc update-member team1 --type team --role admin -n mydomain
224
+ rhc update-member -n mydomain --role admin team1 --type team
177
225
  Updates the team member with name 'team1' to the 'admin' role on mydomain
178
226
 
179
- rhc update-member team1_id --type team --role admin -n mydomain --ids
227
+ rhc update-member -n mydomain --role admin team1_id --ids --type team
180
228
  Adds or updates the team with ID 'team1_id' to the 'admin' role on mydomain
181
229
 
182
230
  DESC
183
231
  takes_domain
184
- option ['--ids'], "Treat the arguments as a list of IDs", :optional => true
185
- option ['-r', '--role ROLE'], "The role to give to each member - view, edit, or admin (default is 'edit')", :type => Role, :optional => true
186
- option ['--type TYPE'], "Type of argument(s) being passed. Accepted values are either 'team' or 'user' (default is 'user').", :optional => true
232
+ option ['--ids'], "Update member(s) by ID", :optional => true
233
+ option ['-r', '--role ROLE'], "The role to give to each member - view, edit, or admin", :type => Role, :optional => false
234
+ option ['--type TYPE'], "Type of member(s) being updated - user or team (default is 'user').", :optional => true
187
235
  argument :members, "A list of members (user logins, team names, or IDs) to update. Pass --ids to treat this as a list of IDs.", [], :type => :list
188
236
  def update(members)
189
237
  target = find_domain
190
- role = get_role_option(options)
238
+ role = get_role_option(options, target)
191
239
  type = get_type_option(options)
192
240
 
193
- raise ArgumentError, 'You must pass at least one user login, team name, or ID to this command.' unless members.present?
241
+ raise ArgumentError, 'You must pass at least one member to this command.' unless members.present?
194
242
 
195
243
  say "Updating #{pluralize(members.length, role_name(role))} to #{target.class.model_name.downcase} ... "
196
244
 
@@ -202,22 +250,33 @@ module RHC::Commands
202
250
  0
203
251
  end
204
252
 
205
- summary "Remove a member from a domain"
206
- syntax "(<login>... | <team name>... | <id>...) [-n DOMAIN_NAME] [--ids] [--type user|team]"
253
+ summary "Remove a member from a domain or team"
254
+ syntax [
255
+ "-n DOMAIN_NAME <login>...",
256
+ "-n DOMAIN_NAME <team_name>... --type team",
257
+ "-n DOMAIN_NAME <id>... --ids [--type user|team]",
258
+ nil,
259
+ "-t TEAM_NAME <login>...",
260
+ "-t TEAM_NAME <id>... --ids",
261
+ ]
207
262
  description <<-DESC
208
263
  Remove members from a domain by passing a user login, team name, or ID for each
209
264
  member you wish to remove. View the list of existing members with
210
- 'rhc members <domain_name>'.
265
+ rhc members -n DOMAIN_NAME
211
266
 
212
- Pass '--all' to remove all but the owner from the domain.
267
+ Remove members from a team by passing a user login, or ID for each
268
+ member you wish to remove. View the list of existing members with
269
+ rhc members -t TEAM_NAME
270
+
271
+ Pass '--all' to remove all members but the owner.
213
272
  DESC
214
- takes_domain
215
- option ['--ids'], "Treat the arguments as a list of IDs"
216
- option ['--all'], "Remove all members from this domain."
217
- option ['--type TYPE'], "Type of argument(s) being passed. Accepted values are either 'team' or 'user' (default is 'user').", :optional => true
218
- argument :members, "A list of members (user logins, team names, or IDs) to remove from the domain. Pass --ids to treat this as a list of IDs.", [], :type => :list
273
+ takes_membership_container :writable => true
274
+ option ['--ids'], "Remove member(s) by ID."
275
+ option ['--all'], "Remove all members"
276
+ option ['--type TYPE'], "Type of member(s) being removed - user or team (default is 'user').", :optional => true
277
+ argument :members, "A list of members (user logins, team names, or IDs) to remove. Pass --ids to treat this as a list of IDs.", [], :type => :list
219
278
  def remove(members)
220
- target = find_domain
279
+ target = find_membership_container :writable => true
221
280
  type = get_type_option(options)
222
281
 
223
282
  if options.all
@@ -226,7 +285,7 @@ module RHC::Commands
226
285
  success "done"
227
286
 
228
287
  else
229
- raise ArgumentError, 'You must pass at least one user login, team name, or ID to this command.' unless members.present?
288
+ raise ArgumentError, 'You must pass at least one member to this command.' unless members.present?
230
289
 
231
290
  say "Removing #{pluralize(members.length, 'member')} from #{target.class.model_name.downcase} ... "
232
291
 
@@ -240,22 +299,13 @@ module RHC::Commands
240
299
  end
241
300
 
242
301
  protected
243
- def get_role_option(options, default_value='edit')
244
- options.role || default_value
302
+ def get_role_option(options, target)
303
+ options.role || target.default_member_role
245
304
  end
246
305
 
247
- def get_type_option(options, default_value='user')
306
+ def get_type_option(options)
248
307
  type = options.__hash__[:type]
249
- case type
250
- when 'team'
251
- type
252
- when 'user'
253
- type
254
- when nil
255
- default_value
256
- else
257
- raise ArgumentError, "The type '#{type}' is not valid. Type must be 'user' or 'team'."
258
- end
308
+ type || 'user'
259
309
  end
260
310
 
261
311
  def changes_for(members, role, type)