magellan-cli 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d6704f43cf56d986b9ff84182bc449ff4cab94b
4
- data.tar.gz: 7288afebe3ad3db21870424d976e52d9467a4bfc
3
+ metadata.gz: dbc08ed4c015f59402a778c3ac90c9c29f8a3ec7
4
+ data.tar.gz: 00fd6124ff5fd4e6dfcb9dfcc95391c52ea95ee6
5
5
  SHA512:
6
- metadata.gz: 1c84ff3dce8dd50cd767f14ba1cb8bcb503acd0fe81cebbec878a1e0e7fbc51ab5cddb0007915a9248478694bec73997bca4d3337094797ea55329e9f292ca8d
7
- data.tar.gz: 954f8c14b5bbf532fab82cc1f02aa1ef89396eaa88d89b25b89c07a759f82d6adbcbfbea667f61fe70d8f182faf51e37d9dd166a5a621075e2d15a9e5f8025a4
6
+ metadata.gz: c5984f8fe6013b4c44e62bbf7276d79d1cf2ea6ea03e5c1abf58ca11648f6fa3b84d502a31c19412143f498bca3db99f9c3d3ce5455ddaec9bdc8ed3de3a1668
7
+ data.tar.gz: 038c1d6783ca431ab4baaf979ad60019a26c24b7cce283246b9b4f62b1f45b0c96e6c41293d0258848e99f0ae7158149499057486eed04341bb3f4ec7ce6ad9c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- magellan-cli (0.6.4)
4
+ magellan-cli (0.6.5)
5
5
  activesupport (~> 4.1.4)
6
6
  groovenauts-thor
7
7
  httpclient (~> 2.5)
@@ -84,6 +84,11 @@ en:
84
84
  show: "Show the detail of the %{res_name} specified by ID"
85
85
  select: "Select the %{res_name} by NAME"
86
86
  deselect: "Deselect the %{res_name}"
87
+ authority:
88
+ cmd:
89
+ select: "Select the %{resource_name} by ID"
90
+ delete: "Delete the %{resource_name} specified by ID"
91
+ create: "Create a new %{resource_name} with PROJECT_ROLE STAGE_ROLE STAGE_TYPE"
87
92
  client_version:
88
93
  cmd:
89
94
  select: "Select the %{resource_name} by VERSION"
@@ -82,6 +82,11 @@ ja:
82
82
  show: "IDで指定された%{res_name}の詳細を表示します"
83
83
  select: "NAMEを指定して%{res_name}を選択します"
84
84
  deselect: "%{res_name}の選択を解除します"
85
+ authority:
86
+ cmd:
87
+ select: "ID を指定して%{resource_name}を選択します"
88
+ delete: "ID を指定して%{resource_name}を削除します"
89
+ create: "PROJECT_ROLE STAGE_ROLE STAGE_TYPE を指定して%{resource_name}を登録します"
85
90
  client_version:
86
91
  cmd:
87
92
  select: "VERSIONを指定して%{resource_name}を選択します"
@@ -15,6 +15,7 @@ module Magellan
15
15
  autoload :Project , "magellan/cli/resources/project"
16
16
  autoload :Stage , "magellan/cli/resources/stage"
17
17
  autoload :ClientVersion , "magellan/cli/resources/client_version"
18
+ autoload :Authority , "magellan/cli/resources/authority"
18
19
 
19
20
  autoload :TransactionRouter, "magellan/cli/resources/transaction_router"
20
21
  autoload :Worker , "magellan/cli/resources/worker"
@@ -32,6 +33,7 @@ module Magellan
32
33
  "Organization" => "organization",
33
34
  "Team" => "team",
34
35
  "Project" => "project",
36
+ "Authority" => "authority",
35
37
  "Stage" => "stage",
36
38
  "ClientVersion" => "client_version",
37
39
  #"TransactionRouter" => "tr",
@@ -0,0 +1,73 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "magellan/cli/resources"
3
+
4
+ module Magellan
5
+ module Cli
6
+ module Resources
7
+
8
+ class Authority < Base
9
+ self.resource_key = "magellan~auth~authority"
10
+ self.resource_dependency = { "team" => Team.parameter_name }
11
+ self.hidden_fields = %w[auth_type created_at updated_at].map(&:freeze).freeze
12
+ self.field_associations = {"team_id" => {name: "team", class: "Organization"},
13
+ "auth_id" => {name: "project", class: "Project"} }
14
+
15
+ desc "update ATTRIBUTES", I18n.t(:update, scope: [:resources, :common, :cmd], resource_name: resource_name)
16
+ def update(attrs)
17
+ s = load_selection!(self.class)
18
+ attrs = JSON.parse(File.readable?(attrs) ? File.read(attrs) : attrs)
19
+ put_json("/admin/#{resource_key}/#{s['id']}/edit", {"magellan_auth_authority" => attrs})
20
+ end
21
+
22
+ desc "create PROJECT_ROLE STAGE_ROLE STAGE_TYPE", I18n.t(:create, scope: [:resources, :authority, :cmd], resource_name: resource_name)
23
+ def create(project_role, stage_role, stage_type)
24
+ team = load_selection!(Team)
25
+ project = load_selection!(Project)
26
+ unless %w{ owner admin reader }.include?(project_role)
27
+ raise Magellan::Cli::Error, "PROJECT_ROLE must be owner/admin/reader"
28
+ end
29
+ unless %w{ read read_write }.include?(stage_role)
30
+ raise Magellan::Cli::Error, "STAGE_ROLE must be read/read_write"
31
+ end
32
+ unless %w{ development staging production }.include?(stage_type) or /\A\d\z/ =~ stage_type
33
+ raise Magellan::Cli::Error, "STAGE_TYPE must be development/staging/production or 0-9 (single digit)"
34
+ end
35
+ stage_type_map = {
36
+ "development" => 1,
37
+ "staging" => 2,
38
+ "production" => 3,
39
+ }
40
+ (1..9).each do |i| stage_type_map[i.to_s] = i end
41
+ params = {
42
+ parameter_name => {
43
+ "auth_id" => project["id"],
44
+ "auth_type" => "Project",
45
+ "team_id" => team["id"],
46
+ "project_role" => project_role,
47
+ "stage_role" => stage_role,
48
+ "stage_type" => stage_type_map[stage_type],
49
+ }
50
+ }
51
+ post_json("/admin/#{resource_key}/new.json", params)
52
+ end
53
+
54
+ desc "select ID", I18n.t(:select, scope: [:resources, :authority, :cmd], resource_name: resource_name)
55
+ def select(id)
56
+ q = build_query("id" => id)
57
+ update_first_result(self.class.parameter_name, id, "/admin/#{resource_key}.json", q)
58
+ update_selections! do |s|
59
+ self.class.deselect_dependants(s)
60
+ end
61
+ end
62
+
63
+ desc "delete ID", I18n.t(:delete, scope: [:resources, :authority, :cmd], resource_name: resource_name)
64
+ def delete(id)
65
+ q = build_query("id" => id).update(default_query)
66
+ r = get_first_result!(self.class.resource_name, id, "/admin/#{resource_key}.json", q)
67
+ super("/admin/#{resource_key}/#{r['id']}/delete")
68
+ log_success("OK")
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -1,5 +1,5 @@
1
1
  module Magellan
2
2
  module Cli
3
- VERSION = "0.6.4"
3
+ VERSION = "0.6.5"
4
4
  end
5
5
  end
@@ -0,0 +1,7 @@
1
+ ---
2
+ magellan_auth_organization:
3
+ id: 1
4
+ name: org1
5
+ magellan_auth_team:
6
+ id: 1
7
+ name: team1
@@ -25,9 +25,9 @@ describe Magellan::Cli::Resources::Project do
25
25
  cmd.list
26
26
  end
27
27
 
28
- let(:org_res_body){ [{"id":8,"name":"test1","email":"","creator_id":4,"created_at":"2015-02-18T14:27:16.000Z","updated_at":"2015-02-18T14:27:16.000Z","max_project_count":1,"max_team_count":100}] }
28
+ let(:org_res_body){ [{id:8,name:"test1",email:"",creator_id:4,created_at:"2015-02-18T14:27:16.000Z",updated_at:"2015-02-18T14:27:16.000Z",max_project_count:1,max_team_count:100}] }
29
29
  let(:org_res){ double(:org_res, status: 200, body: org_res_body.to_json) }
30
- let(:list_res_body){ [{"id":9,"organization_id":8,"default_nebula_id":2,"name":"Project1","icon_url":nil,"consumer_key":"test1.Project1","consumer_secret":"a5etckpurpy0od3keo25iw77mtllo2fb","created_at":"2015-02-18T14:27:21.000Z","updated_at":"2015-02-18T14:27:21.000Z","max_stage_count":2}] }
30
+ let(:list_res_body){ [{id:9,organization_id:8,default_nebula_id:2,name:"Project1",icon_url:nil,consumer_key:"test1.Project1",consumer_secret:"a5etckpurpy0od3keo25iw77mtllo2fb",created_at:"2015-02-18T14:27:21.000Z",updated_at:"2015-02-18T14:27:21.000Z",max_stage_count:2}] }
31
31
  let(:list_res){ double(:res, status: 200, body: list_res_body.to_json) }
32
32
  it do
33
33
  buf = StringIO.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magellan-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - akm2000
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-24 00:00:00.000000000 Z
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -205,6 +205,7 @@ files:
205
205
  - lib/magellan/cli/messaging/mqtt.rb
206
206
  - lib/magellan/cli/reference_generator.rb
207
207
  - lib/magellan/cli/resources.rb
208
+ - lib/magellan/cli/resources/authority.rb
208
209
  - lib/magellan/cli/resources/base.rb
209
210
  - lib/magellan/cli/resources/client_version.rb
210
211
  - lib/magellan/cli/resources/cloudsql.rb
@@ -242,6 +243,7 @@ files:
242
243
  - reference/ja/stage.md
243
244
  - reference/ja/team.md
244
245
  - reference/ja/worker.md
246
+ - spec/.magellan-cli.original
245
247
  - spec/magellan/cli/Magellan.yml
246
248
  - spec/magellan/cli/command_spec.rb
247
249
  - spec/magellan/cli/file_access_spec.rb
@@ -284,11 +286,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
284
286
  version: '0'
285
287
  requirements: []
286
288
  rubyforge_project:
287
- rubygems_version: 2.4.5
289
+ rubygems_version: 2.4.6
288
290
  signing_key:
289
291
  specification_version: 4
290
292
  summary: commandline tools for magellanic cloud service.
291
293
  test_files:
294
+ - spec/.magellan-cli.original
292
295
  - spec/magellan/cli/Magellan.yml
293
296
  - spec/magellan/cli/command_spec.rb
294
297
  - spec/magellan/cli/file_access_spec.rb