magellan-cli 0.5.0 → 0.5.1
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/magellan/cli/file_access.rb +1 -1
- data/lib/magellan/cli/http.rb +2 -3
- data/lib/magellan/cli/locales/en.yml +1 -1
- data/lib/magellan/cli/locales/ja.yml +1 -1
- data/lib/magellan/cli/resources/base.rb +7 -7
- data/lib/magellan/cli/resources/client_version.rb +1 -1
- data/lib/magellan/cli/resources/deletable.rb +1 -1
- data/lib/magellan/cli/resources/project.rb +1 -1
- data/lib/magellan/cli/resources/stage.rb +4 -4
- data/lib/magellan/cli/version.rb +1 -1
- data/spec/magellan/cli/resources/project_spec.rb +29 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cc1cfe804181bf307d673744563f0c87ca43b26
|
4
|
+
data.tar.gz: ada7eb304a551d0d515020758e0f0cc2ab40507e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bc4d0418e9795a74313d677ab79d3ed68eecc744d5eac394aed7ccd064f1aedb588fcc000ad8bf8eb7a56dadb63bfc0e8cefd671f17d312b9365bc906679ed0
|
7
|
+
data.tar.gz: 07bbce30a3b61dd1d4f96f6362228b686a3a497b7810c01ac256eeafcfde9cd0f144aa81f1279ca7643d4e6df3456b2990706af7deb61db973ef565a2dd709ac
|
data/Gemfile.lock
CHANGED
data/lib/magellan/cli/http.rb
CHANGED
@@ -49,9 +49,8 @@ module Magellan
|
|
49
49
|
if obj and obj.is_a?(Hash) and obj["message"]
|
50
50
|
fatal(obj["message"])
|
51
51
|
else
|
52
|
-
msg = "HTTP Error: status=#{res.status}"
|
53
|
-
msg
|
54
|
-
log_error(msg)
|
52
|
+
msg = "HTTP Error: status=#{res.status}\n#{res.body}"
|
53
|
+
log_verbose(msg)
|
55
54
|
end
|
56
55
|
end
|
57
56
|
end
|
@@ -69,7 +69,7 @@ en:
|
|
69
69
|
default_query:
|
70
70
|
not_selected: "No %{label} selected"
|
71
71
|
get_first_result:
|
72
|
-
not_found: "%{
|
72
|
+
not_found: "%{resource_name} not found for %{name}"
|
73
73
|
common:
|
74
74
|
cmd:
|
75
75
|
create: "Create a new %{resource_name} with NAME"
|
@@ -14,7 +14,7 @@ module Magellan
|
|
14
14
|
module Cli
|
15
15
|
module Resources
|
16
16
|
|
17
|
-
class NotFound <
|
17
|
+
class NotFound < Magellan::Cli::Error
|
18
18
|
end
|
19
19
|
|
20
20
|
class Base < ::Magellan::Cli::Http
|
@@ -53,19 +53,19 @@ module Magellan
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
def get_first_result!(name, path, query)
|
56
|
+
def get_first_result!(resource_name, name, path, query)
|
57
57
|
results = get_json(path, query)
|
58
|
-
raise NotFound, I18n.t(:not_found, scope: [:resources, :base, :get_first_result],
|
58
|
+
raise NotFound, I18n.t(:not_found, scope: [:resources, :base, :get_first_result], resource_name: resource_name, name: name) if results.blank? || results.first.blank?
|
59
59
|
results.first
|
60
60
|
end
|
61
61
|
|
62
|
-
def update_first_result(name, path, query, fields = nil)
|
62
|
+
def update_first_result(resource_name, name, path, query, fields = nil)
|
63
63
|
fields ||= ["id", self.class.caption_attr].compact
|
64
|
-
r = get_first_result!(name, path, query)
|
64
|
+
r = get_first_result!(resource_name, name, path, query)
|
65
65
|
obj = fields.each_with_object({}) do |f, d|
|
66
66
|
d[f] = r[f]
|
67
67
|
end
|
68
|
-
update_selections!(
|
68
|
+
update_selections!(resource_name => obj)
|
69
69
|
return r
|
70
70
|
end
|
71
71
|
|
@@ -168,7 +168,7 @@ module Magellan
|
|
168
168
|
|
169
169
|
def select(name)
|
170
170
|
q = build_query(self.class.caption_attr => name).update(default_query)
|
171
|
-
update_first_result(self.class.parameter_name, "/admin/#{self.class.resource_key}.json", q)
|
171
|
+
update_first_result(self.class.parameter_name, name, "/admin/#{self.class.resource_key}.json", q)
|
172
172
|
end
|
173
173
|
|
174
174
|
def deselect
|
@@ -32,7 +32,7 @@ module Magellan
|
|
32
32
|
desc "delete VERSION", I18n.t(:delete, scope: [:resources, :client_version, :cmd], resource_name: resource_name)
|
33
33
|
def delete(version)
|
34
34
|
q = build_query("version" => version).update(default_query)
|
35
|
-
r = get_first_result!(self.class.resource_name, "/admin/#{resource_key}.json", q)
|
35
|
+
r = get_first_result!(self.class.resource_name, version, "/admin/#{resource_key}.json", q)
|
36
36
|
super("/admin/#{resource_key}/#{r['id']}/delete")
|
37
37
|
log_success("OK")
|
38
38
|
end
|
@@ -13,7 +13,7 @@ module Magellan
|
|
13
13
|
desc "delete NAME", I18n.t(:delete, scope: [:resources, :common, :cmd], resource_name: resource_name)
|
14
14
|
def delete(name)
|
15
15
|
q = build_query("name" => name).update(default_query)
|
16
|
-
r = get_first_result!(self.class.resource_name, "/admin/#{resource_key}.json", q)
|
16
|
+
r = get_first_result!(self.class.resource_name, name, "/admin/#{resource_key}.json", q)
|
17
17
|
super("/admin/#{resource_key}/#{r['id']}/delete")
|
18
18
|
log_success("OK")
|
19
19
|
end
|
@@ -9,7 +9,7 @@ module Magellan
|
|
9
9
|
include Deletable
|
10
10
|
|
11
11
|
self.resource_key = "project"
|
12
|
-
self.resource_dependency =
|
12
|
+
self.resource_dependency = { "organization" => Organization.parameter_name }
|
13
13
|
self.hidden_fields = %w[default_nebula_id created_at updated_at].map(&:freeze).freeze
|
14
14
|
self.field_associations = {"organization_id" => {name: "organization", class: "Organization"} }
|
15
15
|
|
@@ -43,15 +43,15 @@ module Magellan
|
|
43
43
|
end
|
44
44
|
|
45
45
|
q = build_query("name" => name).update(default_query)
|
46
|
-
r = update_first_result(parameter_name, "/admin/stage~title.json", q)
|
46
|
+
r = update_first_result(parameter_name, name, "/admin/stage~title.json", q)
|
47
47
|
|
48
48
|
# # current
|
49
49
|
# q = build_query("title" => r["id"], "phase" => 2) # 2: current
|
50
|
-
# update_first_result(VERSION_PARAMETER_NAME, "/admin/stage~version.json", q, %w[id])
|
50
|
+
# update_first_result(VERSION_PARAMETER_NAME, "phase=2", "/admin/stage~version.json", q, %w[id])
|
51
51
|
|
52
52
|
# # workspace
|
53
53
|
q = build_query("title" => r["id"], "phase" => 1) # 1: workspace
|
54
|
-
update_first_result(VERSION_PARAMETER_NAME, "/admin/stage~version.json", q, %w[id])
|
54
|
+
update_first_result(VERSION_PARAMETER_NAME, "phase=1", "/admin/stage~version.json", q, %w[id])
|
55
55
|
end
|
56
56
|
|
57
57
|
desc "deselect", I18n.t(:deselect, scope: [:resources, :common, :cmd], res_name: resource_name)
|
@@ -77,7 +77,7 @@ module Magellan
|
|
77
77
|
def switch_version(phase)
|
78
78
|
s = load_selection!(self.class)
|
79
79
|
q = build_query("title" => s["id"], "phase" => phase) # 1: workspace, 2: current, 3: used
|
80
|
-
update_first_result(VERSION_PARAMETER_NAME, "/admin/stage~version.json", q, %w[id])
|
80
|
+
update_first_result(VERSION_PARAMETER_NAME, "phase=#{phase}", "/admin/stage~version.json", q, %w[id])
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
data/lib/magellan/cli/version.rb
CHANGED
@@ -20,7 +20,7 @@ describe Magellan::Cli::Resources::Project do
|
|
20
20
|
|
21
21
|
describe :list do
|
22
22
|
it do
|
23
|
-
expect(httpclient).to receive(:get).with(
|
23
|
+
expect(httpclient).to receive(:get).with(%r{\A#{base_url}/admin/project.json}).and_return(res)
|
24
24
|
expect($stdout).to receive(:puts)
|
25
25
|
cmd.list
|
26
26
|
end
|
@@ -36,4 +36,32 @@ describe Magellan::Cli::Resources::Project do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
describe :delete do
|
40
|
+
before do
|
41
|
+
@name = "dummyproject"
|
42
|
+
end
|
43
|
+
context "organization selected" do
|
44
|
+
before do
|
45
|
+
Magellan::Cli::FileAccess.update_selections(Magellan::Cli::FileAccess.load_selections.merge("magellan_auth_organization" => { id: 1, name: @name}))
|
46
|
+
allow(res).to receive(:body).and_return("")
|
47
|
+
allow(res).to receive(:status).and_return(401)
|
48
|
+
expect(httpclient).to receive(:get).and_return(res)
|
49
|
+
end
|
50
|
+
it "show not found error message" do
|
51
|
+
expect do
|
52
|
+
cmd.delete(@name)
|
53
|
+
end.to raise_error(Magellan::Cli::Resources::NotFound)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
context "organization not selected" do
|
57
|
+
before do
|
58
|
+
Magellan::Cli::FileAccess.update_selections(Magellan::Cli::FileAccess.load_selections.merge("magellan_auth_organization" => nil))
|
59
|
+
end
|
60
|
+
it "show not selected error message" do
|
61
|
+
expect do
|
62
|
+
cmd.delete(@name)
|
63
|
+
end.to raise_error(Magellan::Cli::FileAccess::NotSelected)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
39
67
|
end
|