epc 1.0.3 → 1.0.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.
- data/lib/epc.rb +25 -5
- data/lib/epc/client/json_client.rb +4 -4
- data/lib/epc/command/archive_command.rb +7 -6
- data/lib/epc/command/attachto_command.rb +13 -0
- data/lib/epc/command/base_command.rb +120 -29
- data/lib/epc/command/config/create_config_command.rb +7 -11
- data/lib/epc/command/config/delete_config_command.rb +5 -5
- data/lib/epc/command/config/list_configs_command.rb +5 -5
- data/lib/epc/command/config/update_config_command.rb +11 -10
- data/lib/epc/command/copy_command.rb +14 -0
- data/lib/epc/command/create_command.rb +9 -5
- data/lib/epc/command/delete_command.rb +9 -9
- data/lib/epc/command/{copy_deployment_command.rb → deployment/copy_deployment_command.rb} +6 -5
- data/lib/epc/command/deployment/create_deployment_command.rb +15 -15
- data/lib/epc/command/deployment/list_deployments_command.rb +2 -4
- data/lib/epc/command/deployment/show_deployment_command.rb +5 -7
- data/lib/epc/command/deployment/submit_deployment_command.rb +15 -0
- data/lib/epc/command/deployment/update_deployment_command.rb +5 -14
- data/lib/epc/command/deployment/vote_deployment_command.rb +23 -0
- data/lib/epc/command/deploymentstage/list_deploymentstages_command.rb +1 -1
- data/lib/epc/command/detachfrom_command.rb +13 -0
- data/lib/epc/command/group/create_group_command.rb +3 -3
- data/lib/epc/command/group/delete_group_command.rb +4 -5
- data/lib/epc/command/group/show_group_command.rb +2 -3
- data/lib/epc/command/group/update_group_command.rb +9 -7
- data/lib/epc/command/library/create_library_command.rb +1 -2
- data/lib/epc/command/library/delete_library_command.rb +4 -5
- data/lib/epc/command/library/list_libraries_command.rb +1 -1
- data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +1 -1
- data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +3 -5
- data/lib/epc/command/librarylanguage/list_librarylanguages_command.rb +1 -1
- data/lib/epc/command/librarylanguage/update_librarylanguage_command.rb +4 -5
- data/lib/epc/command/libraryset/create_libraryset_command.rb +5 -4
- data/lib/epc/command/libraryset/delete_libraryset_command.rb +4 -6
- data/lib/epc/command/libraryset/list_librarysets_command.rb +2 -2
- data/lib/epc/command/libraryset/show_libraryset_command.rb +3 -3
- data/lib/epc/command/libraryset/update_libraryset_command.rb +4 -3
- data/lib/epc/command/list_command.rb +10 -14
- data/lib/epc/command/list_objecttypes_command.rb +1 -1
- data/lib/epc/command/objectrole/create_objectrole_command.rb +4 -5
- data/lib/epc/command/objectrole/list_objectroles_command.rb +3 -8
- data/lib/epc/command/objectrole/update_objectrole_command.rb +3 -1
- data/lib/epc/command/permission/list_permissions_command.rb +1 -1
- data/lib/epc/command/permissiongroup/list_permissiongroups_command.rb +1 -1
- data/lib/epc/command/plugin/create_plugin_command.rb +1 -2
- data/lib/epc/command/plugin/delete_plugin_command.rb +4 -6
- data/lib/epc/command/plugin/list_plugins_command.rb +1 -1
- data/lib/epc/command/plugin/show_plugin_command.rb +2 -5
- data/lib/epc/command/plugin/update_plugin_command.rb +2 -6
- data/lib/epc/command/project/archive_project_command.rb +3 -12
- data/lib/epc/command/project/attachto_project_command.rb +133 -0
- data/lib/epc/command/project/create_project_command.rb +6 -6
- data/lib/epc/command/project/delete_project_command.rb +3 -24
- data/lib/epc/command/project/detachfrom_project_command.rb +66 -0
- data/lib/epc/command/project/list_projects_command.rb +12 -7
- data/lib/epc/command/project/show_project_command.rb +26 -25
- data/lib/epc/command/project/show_project_snapshot_command.rb +41 -0
- data/lib/epc/command/project/unarchive_project_command.rb +3 -10
- data/lib/epc/command/project/update_project_command.rb +5 -18
- data/lib/epc/command/projecttype/create_projecttype_command.rb +37 -0
- data/lib/epc/command/projecttype/delete_projecttype_command.rb +24 -0
- data/lib/epc/command/projecttype/list_projecttypes_command.rb +1 -1
- data/lib/epc/command/projecttype/show_projecttype_command.rb +2 -4
- data/lib/epc/command/projecttype/update_projecttype_command.rb +61 -0
- data/lib/epc/command/push_command.rb +14 -8
- data/lib/epc/command/role/create_role_command.rb +26 -3
- data/lib/epc/command/role/delete_role_command.rb +3 -5
- data/lib/epc/command/role/list_roles_command.rb +7 -3
- data/lib/epc/command/role/show_role_command.rb +8 -5
- data/lib/epc/command/role/update_role_command.rb +14 -66
- data/lib/epc/command/runtime/create_runtime_command.rb +34 -0
- data/lib/epc/command/runtime/delete_runtime_command.rb +24 -0
- data/lib/epc/command/runtime/list_runtimes_command.rb +2 -2
- data/lib/epc/command/runtime/update_runtime_command.rb +49 -0
- data/lib/epc/command/runtimetype/list_runtimetypes_command.rb +17 -0
- data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +5 -6
- data/lib/epc/command/servicedefinition/delete_servicedefinition_command.rb +18 -0
- data/lib/epc/command/servicedefinition/list_servicedefinitions_command.rb +2 -2
- data/lib/epc/command/servicetype/list_servicetypes_command.rb +1 -1
- data/lib/epc/command/serviceversion/create_serviceversion_command.rb +8 -12
- data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +3 -5
- data/lib/epc/command/serviceversion/list_serviceversions_command.rb +8 -1
- data/lib/epc/command/show_command.rb +8 -9
- data/lib/epc/command/show_metrics_command.rb +3 -3
- data/lib/epc/command/solution/archive_solution_command.rb +3 -10
- data/lib/epc/command/solution/create_solution_command.rb +2 -2
- data/lib/epc/command/solution/delete_solution_command.rb +3 -7
- data/lib/epc/command/solution/list_solutions_command.rb +11 -3
- data/lib/epc/command/solution/show_solution_command.rb +4 -6
- data/lib/epc/command/solution/unarchive_solution_command.rb +3 -8
- data/lib/epc/command/solution/update_solution_command.rb +4 -6
- data/lib/epc/command/submit_command.rb +16 -0
- data/lib/epc/command/unarchive_command.rb +7 -6
- data/lib/epc/command/update_command.rb +9 -8
- data/lib/epc/command/user/create_user_command.rb +2 -3
- data/lib/epc/command/user/delete_user_command.rb +3 -5
- data/lib/epc/command/user/list_users_command.rb +1 -1
- data/lib/epc/command/user/show_user_command.rb +2 -4
- data/lib/epc/command/user/update_user_command.rb +3 -14
- data/lib/epc/command/userproperty/list_user_properties_command.rb +23 -0
- data/lib/epc/command/vote_command.rb +16 -0
- data/lib/epc/config.rb +7 -1
- data/lib/epc/help.rb +51 -48
- data/lib/epc/modules/config.rb +39 -0
- data/lib/epc/modules/role.rb +133 -0
- data/lib/epc/runner.rb +23 -12
- data/lib/epc/version.rb +1 -1
- data/test/command/archive_project_command_test.rb +2 -13
- data/test/command/archive_solution_command_test.rb +4 -14
- data/test/command/copy_deployment_command_test.rb +4 -8
- data/test/command/create_config_command_test.rb +23 -23
- data/test/command/create_deployment_command_test.rb +33 -32
- data/test/command/create_group_command_test.rb +2 -2
- data/test/command/create_library_command_test.rb +6 -6
- data/test/command/create_librarylanguage_command_test.rb +3 -3
- data/test/command/create_libraryset_command_test.rb +6 -26
- data/test/command/create_objectrole_command_test.rb +4 -13
- data/test/command/create_project_command_test.rb +27 -13
- data/test/command/create_role_command_test.rb +3 -2
- data/test/command/create_runtime_command_test.rb +37 -0
- data/test/command/create_servicedefinition_command_test.rb +4 -17
- data/test/command/create_serviceversion_command_test.rb +8 -22
- data/test/command/create_solution_command_test.rb +5 -5
- data/test/command/create_user_command_test.rb +4 -4
- data/test/command/delete_config_command_test.rb +8 -15
- data/test/command/delete_library_command_test.rb +3 -4
- data/test/command/delete_librarylanguage_command_test.rb +3 -4
- data/test/command/delete_libraryset_command_test.rb +3 -4
- data/test/command/delete_plugin_command_test.rb +3 -4
- data/test/command/delete_project_command_test.rb +2 -10
- data/test/command/delete_projecttype_command_test.rb +31 -0
- data/test/command/delete_role_command_test.rb +5 -14
- data/test/command/delete_runtime_command_test.rb +31 -0
- data/test/command/delete_servicedefinition_command_test.rb +31 -0
- data/test/command/delete_serviceversion_command_test.rb +3 -2
- data/test/command/delete_solution_command_test.rb +3 -16
- data/test/command/delete_user_command_test.rb +3 -3
- data/test/command/list_config_command_test.rb +1 -0
- data/test/command/list_deployments_command_test.rb +11 -41
- data/test/command/list_objectroles_command_test.rb +4 -14
- data/test/command/list_projects_command_test.rb +0 -14
- data/test/command/list_roles_command_test.rb +3 -1
- data/test/command/list_runtimes_command_test.rb +2 -3
- data/test/command/list_runtimetypes_command_test.rb +29 -0
- data/test/command/list_userproperties_command_test.rb +33 -0
- data/test/command/push_command_test.rb +9 -1
- data/test/command/show_deployment_command_test.rb +36 -0
- data/test/command/show_group_command_test.rb +2 -1
- data/test/command/show_libraryset_command_test.rb +5 -3
- data/test/command/show_metrics_command_test.rb +4 -4
- data/test/command/show_plugin_command_test.rb +4 -4
- data/test/command/show_project_command_test.rb +5 -17
- data/test/command/show_project_snapshot_test.rb +33 -0
- data/test/command/show_projecttype_command_test.rb +5 -11
- data/test/command/show_role_command_test.rb +5 -12
- data/test/command/show_solution_command_test.rb +2 -15
- data/test/command/show_user_command_test.rb +4 -3
- data/test/command/submit_deployment_command_test.rb +4 -11
- data/test/command/unarchive_project_command_test.rb +2 -14
- data/test/command/unarchive_solution_command_test.rb +6 -16
- data/test/command/update_config_command_test.rb +14 -3
- data/test/command/update_deployment_command_test.rb +12 -26
- data/test/command/update_group_command_test.rb +2 -10
- data/test/command/update_librarylanguage_command_test.rb +5 -3
- data/test/command/update_libraryset_command_test.rb +4 -2
- data/test/command/update_plugin_command_test.rb +5 -4
- data/test/command/update_project_command_test.rb +6 -20
- data/test/command/update_role_command_test.rb +11 -8
- data/test/command/update_solution_command_test.rb +6 -12
- data/test/command/update_user_command_test.rb +3 -19
- data/test/command/vote_deployment_command_test.rb +2 -6
- metadata +66 -63
- data/lib/epc/command/attach_library_command.rb +0 -82
- data/lib/epc/command/attach_libraryset_command.rb +0 -31
- data/lib/epc/command/attach_runtime_command.rb +0 -26
- data/lib/epc/command/bind_service_command.rb +0 -35
- data/lib/epc/command/create_dependency_command.rb +0 -43
- data/lib/epc/command/dependency/delete_dependency_command.rb +0 -38
- data/lib/epc/command/detach_library_command.rb +0 -35
- data/lib/epc/command/detach_libraryset_command.rb +0 -8
- data/lib/epc/command/list_versions_command.rb +0 -38
- data/lib/epc/command/submit_deployment_command.rb +0 -19
- data/lib/epc/command/unbind_service_command.rb +0 -42
- data/lib/epc/command/undefine_service_command.rb +0 -33
- data/lib/epc/command/update_rolepermissions_command.rb +0 -83
- data/lib/epc/command/vote_deployment_command.rb +0 -29
- data/test/command/attach_library_command_test.rb +0 -124
- data/test/command/attach_libraryset_command_test.rb +0 -49
- data/test/command/attach_runtime_command_test.rb +0 -44
- data/test/command/bind_service_command_test.rb +0 -46
- data/test/command/create_dependency_command_test.rb +0 -55
- data/test/command/create_plugin_command_test.rb +0 -44
- data/test/command/delete_dependency_command_test.rb +0 -42
- data/test/command/detach_library_command_test.rb +0 -53
- data/test/command/unbind_service_command_test.rb +0 -48
- data/test/command/undefine_service_command_test.rb +0 -49
@@ -1,17 +1,10 @@
|
|
1
1
|
module EPC::Command
|
2
2
|
class UnarchiveProjectCommand < UnarchiveCommand
|
3
3
|
|
4
|
-
def execute(
|
5
|
-
|
4
|
+
def execute(params = [])
|
5
|
+
require_object
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
solution_id, solution_name = infer_solution_context(solution_name, path, {:get_solution_name => true})
|
10
|
-
project_id, project_name = infer_project_context(project_name, path, solution_id, {:get_solution_name => true})
|
11
|
-
|
12
|
-
raise FatalError, "Project could not be inferred." if project_id.nil?
|
13
|
-
|
14
|
-
status, response, message = client.put(EPC::Config::PROJECTS_PATH + "/#{project_id}", {:archived => false})
|
7
|
+
status, response, message = client.put(EPC::Config::PROJECTS_PATH + "/#{object_id}", {:archived => false})
|
15
8
|
if status.successful?
|
16
9
|
say("Project has been unarchived.")
|
17
10
|
else
|
@@ -2,23 +2,9 @@ module EPC::Command
|
|
2
2
|
class UpdateProjectCommand < BaseCommand
|
3
3
|
UPDATABLE_ATTRIBUTES = ["project_name", "project_type"]
|
4
4
|
|
5
|
-
def execute(
|
6
|
-
|
7
|
-
path = File.expand_path(
|
8
|
-
|
9
|
-
ids = project.split(":") rescue [nil, nil]
|
10
|
-
|
11
|
-
if ids.size == 1
|
12
|
-
project_name = ids[0]
|
13
|
-
solution_name = nil
|
14
|
-
elsif ids.size == 2
|
15
|
-
solution_name, project_name = ids
|
16
|
-
end
|
17
|
-
|
18
|
-
solution_id, solution_name = infer_solution_context(solution_name, path, :get_solution_name => true)
|
19
|
-
project_id, project_name = infer_project_context(project_name, path, solution_id, {:get_project_name => true})
|
20
|
-
|
21
|
-
raise FatalError, "Project could not be inferred" if project_id.nil? || project_id == 0
|
5
|
+
def execute(args)
|
6
|
+
require_object
|
7
|
+
path = File.expand_path(".")
|
22
8
|
|
23
9
|
args_hash = {}
|
24
10
|
args.each do |arg|
|
@@ -39,7 +25,7 @@ module EPC::Command
|
|
39
25
|
end
|
40
26
|
end
|
41
27
|
unless args_hash.empty?
|
42
|
-
status, response, message = client.put(EPC::Config::PROJECTS_PATH + "/#{
|
28
|
+
status, response, message = client.put(EPC::Config::PROJECTS_PATH + "/#{object_id}", args_hash)
|
43
29
|
if status.failure?
|
44
30
|
say("Update failed with: [#{response[:message]}]")
|
45
31
|
else
|
@@ -47,6 +33,7 @@ module EPC::Command
|
|
47
33
|
end
|
48
34
|
return status
|
49
35
|
else
|
36
|
+
say("You must specify an attribute to be updated: [#{UPDATABLE_ATTRIBUTES.join(",")}]")
|
50
37
|
say(EPC::Help::COMMAND_USAGES[:update_project])
|
51
38
|
return 1
|
52
39
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class CreateProjecttypeCommand < CreateCommand
|
3
|
+
|
4
|
+
def execute(args = [])
|
5
|
+
# raise FatalError, "You need to specify all mandatory parameters" if args.size < 5
|
6
|
+
|
7
|
+
params = {}
|
8
|
+
params[:name] = args[0]
|
9
|
+
params[:runtime] = args[1]
|
10
|
+
params[:framework] = args[2]
|
11
|
+
params[:build_type] = args[3]
|
12
|
+
params[:build_packaging] = args[4]
|
13
|
+
params[:deployable] = args[5]
|
14
|
+
|
15
|
+
begin
|
16
|
+
params[:runtime_env_types] = []
|
17
|
+
args[6].split(",").each do |rti|
|
18
|
+
params[:runtime_env_types] << {:id => retrieve_identifier_for("RuntimeEnvType", rti)}
|
19
|
+
end
|
20
|
+
rescue Exception => ex
|
21
|
+
say("Unable to parse runtime-env-types parameter")
|
22
|
+
return 1
|
23
|
+
end
|
24
|
+
|
25
|
+
status, response, headers = client.post(EPC::Config::PROJECT_TYPES_PATH, params)
|
26
|
+
|
27
|
+
if status.successful?
|
28
|
+
say("ProjectType [#{args[0]}] created")
|
29
|
+
else
|
30
|
+
say("Request failed: [#{response[:message]}]")
|
31
|
+
end
|
32
|
+
|
33
|
+
return status
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class DeleteProjecttypeCommand < DeleteCommand
|
3
|
+
|
4
|
+
def execute(args = [])
|
5
|
+
|
6
|
+
proceed = ask_yn("Are you sure you want to delete the [#{object_id}] ProjectType? [Yn] ")
|
7
|
+
if proceed.upcase == 'N'
|
8
|
+
return 1
|
9
|
+
end
|
10
|
+
|
11
|
+
status, response, headers = client.delete(EPC::Config::PROJECT_TYPES_PATH + "/#{object_id}")
|
12
|
+
|
13
|
+
if status.successful?
|
14
|
+
say("Project type deleted")
|
15
|
+
else
|
16
|
+
say("Request failed: [#{response[:message]}]")
|
17
|
+
end
|
18
|
+
|
19
|
+
return status
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -1,11 +1,9 @@
|
|
1
1
|
module EPC::Command
|
2
2
|
class ShowProjecttypeCommand < BaseCommand
|
3
3
|
|
4
|
-
def execute(
|
4
|
+
def execute(args = [])
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
status, response, headers = client.get(EPC::Config::PROJECT_TYPES_PATH + "/#{project_type_id}")
|
6
|
+
status, response, headers = client.get(EPC::Config::PROJECT_TYPES_PATH + "/#{object_id}")
|
9
7
|
|
10
8
|
if status.failure?
|
11
9
|
say("Request failed: [#{response[:message]}]")
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class UpdateProjecttypeCommand < UpdateCommand
|
3
|
+
|
4
|
+
UPDATABLE_ATTRIBUTES = ["name", "runtime", "framework", "build_type", "build_packaging", "deployable", "runtime_env_types"]
|
5
|
+
|
6
|
+
def execute(args)
|
7
|
+
|
8
|
+
raise FatalError, "You need to specify at least one attribute to update.\nUpdatable attributes are: [#{UPDATABLE_ATTRIBUTES.join(', ')}]" if args.size < 1
|
9
|
+
params = {}
|
10
|
+
|
11
|
+
args.each do |arg|
|
12
|
+
key, val = arg.split("=")
|
13
|
+
next if key.blank?
|
14
|
+
if key == :runtime_env_types
|
15
|
+
begin
|
16
|
+
params[:runtime_env_types] = []
|
17
|
+
args[6].split(",").each do |rti|
|
18
|
+
params[:runtime_env_types] << {:id => retrieve_identifier_for("RuntimeEnvType", rti)}
|
19
|
+
end
|
20
|
+
rescue Exception => ex
|
21
|
+
say("Unable to parse runtime-env-types parameter")
|
22
|
+
return 1
|
23
|
+
end
|
24
|
+
else
|
25
|
+
params[key] = val
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
params.each do |attr, val|
|
30
|
+
unless UPDATABLE_ATTRIBUTES.include?(attr)
|
31
|
+
params.delete(attr)
|
32
|
+
say("Cannot update #{attr}. Updatable attributes are: [#{UPDATABLE_ATTRIBUTES.join(', ')}]")
|
33
|
+
next
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
raise InputError, "You need to specify at least one attribute to update" if params.blank?
|
38
|
+
|
39
|
+
status, response, headers = client.get(EPC::Config::PROJECT_TYPES_PATH + "/#{object_id}")
|
40
|
+
|
41
|
+
unless status.successful?
|
42
|
+
say("Request failed: [#{response[:message]}]")
|
43
|
+
return 1
|
44
|
+
end
|
45
|
+
|
46
|
+
type_attrs = response.merge(params.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo})
|
47
|
+
|
48
|
+
status, response, headers = client.put(EPC::Config::PROJECT_TYPES_PATH + "/#{object_id}", type_attrs)
|
49
|
+
|
50
|
+
if status.successful?
|
51
|
+
say("Project type updated")
|
52
|
+
else
|
53
|
+
say("Request failed: [#{response[:message]}]")
|
54
|
+
end
|
55
|
+
|
56
|
+
return status
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -58,12 +58,12 @@ module EPC::Command
|
|
58
58
|
project_id, project_name = infer_project_context(nil, path, solution_id, {:get_project_name => true})
|
59
59
|
say("\nPushing #{project_name}...")
|
60
60
|
begin
|
61
|
-
zip_path = zip_source(path)
|
62
|
-
|
61
|
+
zip_path = @options[:direct_deploy].present? ? @options[:direct_deploy] : zip_source(path)
|
62
|
+
raise FatalError, "File missing: #{zip_path}" unless zip_path && File.exists?(zip_path)
|
63
63
|
sha1 = sha1(zip_path)
|
64
|
-
status, url, signature, id = create_push(project_name, solution_name, sha1, @options[:note])
|
64
|
+
status, url, signature, id = create_push(project_name, solution_name, sha1, @options[:note], @options[:direct_deploy])
|
65
65
|
if status.successful?
|
66
|
-
pushed = push_zip(zip_path, url, signature)
|
66
|
+
pushed = push_zip(zip_path, url, signature, @options[:direct_deploy])
|
67
67
|
resp = confirm_push(id)
|
68
68
|
if resp[:build_id].present? && !@options[:skip_build]
|
69
69
|
poll_for_build_status(resp[:build_id]) unless @options[:no_poll].present?
|
@@ -87,9 +87,10 @@ module EPC::Command
|
|
87
87
|
|
88
88
|
private
|
89
89
|
|
90
|
-
def create_push(project_name, solution_name, sha1, note = nil)
|
90
|
+
def create_push(project_name, solution_name, sha1, note = nil, direct_deploy=nil)
|
91
91
|
status, response, headers = client.post("#{EPC::Config::PUSHES_PATH}",
|
92
|
-
{ :project_name => project_name, :solution_name => solution_name,
|
92
|
+
{ :project_name => project_name, :solution_name => solution_name,
|
93
|
+
:sha1 => sha1, :note => note, :direct_deploy => direct_deploy})
|
93
94
|
if status.successful?
|
94
95
|
say("Successfully created a push with [#{target_url}]")
|
95
96
|
return status, response[:url], response[:signature], response[:id]
|
@@ -156,7 +157,7 @@ module EPC::Command
|
|
156
157
|
return full_paths, relative_paths
|
157
158
|
end
|
158
159
|
|
159
|
-
def push_zip(zip_path, url, signature)
|
160
|
+
def push_zip(zip_path, url, signature, direct_deploy=nil)
|
160
161
|
# create API returns a URL that includes protocol://host/solution_name/project_name/version
|
161
162
|
|
162
163
|
status, response, headers = http_client.post(url,
|
@@ -168,7 +169,7 @@ module EPC::Command
|
|
168
169
|
raise BasicError, "Failed to push the zip file to the build area [status = #{status}]. Aborting push command."
|
169
170
|
end
|
170
171
|
|
171
|
-
ensure File.delete zip_path if File.exists?
|
172
|
+
ensure File.delete zip_path if direct_deploy.nil? && File.exists?(zip_path)
|
172
173
|
end
|
173
174
|
|
174
175
|
def check_push_directory(path)
|
@@ -186,8 +187,13 @@ module EPC::Command
|
|
186
187
|
if project_type == "Java Web Archive" || project_type == "Java Library"
|
187
188
|
src_path = File.join(path, "src")
|
188
189
|
raise BasicError, "#{path} does not include a src directory" if !File.exists?(src_path) && !File.directory?(src_path)
|
190
|
+
source_path = src_path
|
191
|
+
else
|
192
|
+
source_path = path
|
189
193
|
end
|
190
194
|
|
195
|
+
raise BasicError, "The directory you are pushing is empty" if Dir.glob(File.join(source_path,'*')).blank?
|
196
|
+
|
191
197
|
return true
|
192
198
|
end
|
193
199
|
end
|
@@ -1,9 +1,18 @@
|
|
1
1
|
module EPC::Command
|
2
2
|
class CreateRoleCommand < BaseCommand
|
3
|
-
def execute(*params)
|
4
|
-
role = params[1]
|
5
|
-
raise FatalError, "You must specify a role name" if role.blank?
|
6
3
|
|
4
|
+
def execute(args = [])
|
5
|
+
role = args[0]
|
6
|
+
|
7
|
+
if @options[:file].present?
|
8
|
+
return handle_file_role_creation
|
9
|
+
else
|
10
|
+
return create_role(role)[0]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_role(role)
|
15
|
+
raise FatalError, "You must specify a role name" if role.blank?
|
7
16
|
status, response, headers = client.post(EPC::Config::ROLES_PATH, {:name => role})
|
8
17
|
|
9
18
|
if status.successful?
|
@@ -11,7 +20,21 @@ module EPC::Command
|
|
11
20
|
else
|
12
21
|
say("Request failed: [#{response[:message]}]")
|
13
22
|
end
|
23
|
+
return status, response[:id]
|
24
|
+
end
|
25
|
+
|
26
|
+
def handle_file_role_creation
|
27
|
+
contents = EPC::Config.read_content_as_json(@options[:file])
|
28
|
+
role = contents["name"]
|
29
|
+
status, role_id = create_role(role)
|
30
|
+
|
31
|
+
return 1 unless status.successful?
|
32
|
+
|
33
|
+
batch_add(role_id,contents)
|
34
|
+
|
35
|
+
return 0
|
14
36
|
|
15
37
|
end
|
38
|
+
|
16
39
|
end
|
17
40
|
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module EPC::Command
|
2
2
|
class DeleteRoleCommand < DeleteCommand
|
3
3
|
|
4
|
-
def execute(
|
4
|
+
def execute(args = [])
|
5
5
|
|
6
|
-
proceed = ask_yn("Are you sure you want to delete the [#{
|
6
|
+
proceed = ask_yn("Are you sure you want to delete the [#{object_id}] role? [Yn] ")
|
7
7
|
if proceed.upcase == "N"
|
8
8
|
return 1
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
status, response, headers = client.delete(EPC::Config::ROLES_PATH + "/#{role_id}/system/true")
|
11
|
+
status, response, headers = client.delete(EPC::Config::ROLES_PATH + "/#{object_id}/system/true")
|
14
12
|
|
15
13
|
if status.successful?
|
16
14
|
say("Role deleted")
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module EPC::Command
|
2
2
|
class ListRolesCommand < BaseCommand
|
3
|
-
def execute(
|
3
|
+
def execute(args = [])
|
4
|
+
|
5
|
+
if has_target?
|
6
|
+
if target_type.downcase != "user"
|
7
|
+
say("Target type must be User")
|
8
|
+
return 1
|
9
|
+
end
|
4
10
|
|
5
|
-
if target.present?
|
6
|
-
target_type, target_id = target.split(":")
|
7
11
|
status, response, headers = client.get(EPC::Config::USERS_PATH + "/#{target_id}?include=roles")
|
8
12
|
response = response[:roles]
|
9
13
|
else
|
@@ -1,22 +1,25 @@
|
|
1
1
|
module EPC::Command
|
2
2
|
class ShowRoleCommand < ShowCommand
|
3
3
|
|
4
|
-
def execute(
|
4
|
+
def execute(args = [])
|
5
5
|
@showable_translations = {
|
6
6
|
:groups => :user_groups
|
7
7
|
}
|
8
8
|
|
9
|
-
|
9
|
+
@showables = args.map(&:to_sym) rescue []
|
10
10
|
|
11
|
-
status, response, headers = client.get(EPC::Config::ROLES_PATH + "/#{
|
12
|
-
|
13
|
-
@showables = args[1..-1].map(&:to_sym) rescue []
|
11
|
+
status, response, headers = client.get(EPC::Config::ROLES_PATH + "/#{object_id}?include=users,user_groups,grants")
|
14
12
|
|
15
13
|
unless status.successful?
|
16
14
|
say("Request failed: [#{response[:message]}]")
|
17
15
|
return 1
|
18
16
|
end
|
19
17
|
|
18
|
+
if @options[:json].present?
|
19
|
+
say response.to_json
|
20
|
+
return 0
|
21
|
+
end
|
22
|
+
|
20
23
|
role_table = EPC::TabularOutputter.new([response], [:id, :name])
|
21
24
|
users_table = EPC::TabularOutputter.new(response[:users], [:id, :name])
|
22
25
|
user_groups_table = EPC::TabularOutputter.new(response[:user_groups], [:id, :name])
|
@@ -1,94 +1,42 @@
|
|
1
1
|
module EPC::Command
|
2
2
|
class UpdateRoleCommand < UpdateCommand
|
3
3
|
|
4
|
-
required_options :add_user, :remove_user, :add_group, :remove_group, :add_grant, :remove_grant, :mode => :any?, :message => "You must specify a user/group/grant to added or removed"
|
4
|
+
required_options :add_user, :remove_user, :add_group, :remove_group, :add_grant, :remove_grant, :file, :mode => :any?, :message => "You must specify a user/group/grant to added or removed"
|
5
5
|
|
6
|
-
def execute(
|
7
|
-
role_id =
|
6
|
+
def execute(args = [])
|
7
|
+
role_id = object_id
|
8
8
|
|
9
|
-
if @options[:
|
10
|
-
|
11
|
-
|
12
|
-
params << {:member_id => user_id.to_i, :member_type => "User"}
|
13
|
-
|
14
|
-
status, response, headers = client.put(EPC::Config::ROLES_PATH + "/#{role_id}/assign_members", {:role_memberships => params})
|
15
|
-
say("User added to role") if status.successful?
|
9
|
+
if @options[:file].present?
|
10
|
+
data = EPC::Config.read_content_as_json(@options[:file])
|
11
|
+
batch_add(object_id, data)
|
16
12
|
end
|
17
13
|
|
14
|
+
if @options[:add_user].present?
|
15
|
+
status = add_user(role_id, @options[:add_user])
|
16
|
+
end
|
18
17
|
|
19
18
|
if @options[:remove_user].present?
|
20
|
-
|
21
|
-
status, response, headers = client.delete(EPC::Config::ROLES_PATH + "/#{role_id}/remove_member", {:member_id => @options[:remove_user], :member_type => "User"})
|
22
|
-
say("User removed from role") if status.successful?
|
19
|
+
status = remove_user(role_id, @options[:remove_user])
|
23
20
|
end
|
24
21
|
|
25
22
|
if @options[:add_group].present?
|
26
|
-
|
27
|
-
params = []
|
28
|
-
params << {:member_id => group_id.to_i, :member_type => "UserGroup"}
|
29
|
-
|
30
|
-
status, response, headers = client.put(EPC::Config::ROLES_PATH + "/#{role_id}/assign_members", {:role_memberships => params})
|
31
|
-
say("UserGroup added to role") if status.successful?
|
23
|
+
status = add_group(role_id, @options[:add_group])
|
32
24
|
end
|
33
25
|
|
34
26
|
|
35
27
|
if @options[:remove_group].present?
|
36
|
-
|
37
|
-
status, response, headers = client.delete(EPC::Config::ROLES_PATH + "/#{role_id}/remove_member", {:member_id => group_id, :member_type => "UserGroup"})
|
38
|
-
say("UserGroup removed from role") if status.successful?
|
28
|
+
status = remove_group(role_id, @options[:remove_group])
|
39
29
|
end
|
40
30
|
|
41
|
-
|
42
|
-
|
43
31
|
if @options[:add_grant].present?
|
44
|
-
|
45
|
-
raise FatalError, "Grant incorrectly specified" if secured_type.blank? || action.blank?
|
46
|
-
|
47
|
-
params = {}
|
48
|
-
params[:grant_action] = action
|
49
|
-
params[:permitted_type] = "Role"
|
50
|
-
params[:permitted_id] = role_id.to_i
|
51
|
-
params[:secured_type] = secured_type
|
52
|
-
params[:secured_id] = secured_id if secured_id.present?
|
53
|
-
|
54
|
-
|
55
|
-
status, response, headers = client.post(EPC::Config::GRANTS_PATH, params)
|
56
|
-
|
57
|
-
if status.successful?
|
58
|
-
say("Role permission updated")
|
59
|
-
end
|
32
|
+
status = add_grant(role_id, @options[:add_grant])
|
60
33
|
end
|
61
34
|
|
62
35
|
|
63
36
|
if @options[:remove_grant].present?
|
64
|
-
|
65
|
-
status, response, headers = client.get(EPC::Config::ROLES_PATH + "/#{role_id}/grants")
|
66
|
-
|
67
|
-
if status.successful?
|
68
|
-
grant_id = response.detect do |g|
|
69
|
-
found = (g[:action] == action)
|
70
|
-
found = found && (g[:secured_type].to_s == secured_type)
|
71
|
-
if secured_id.blank?
|
72
|
-
found = found && g[:secured_id].blank?
|
73
|
-
else
|
74
|
-
found = found && (g[:secured_id].to_s == secured_id)
|
75
|
-
end
|
76
|
-
found
|
77
|
-
end[:id] rescue nil
|
78
|
-
|
79
|
-
raise FatalError, "Permission couldn't be determined" if grant_id.blank?
|
80
|
-
|
81
|
-
status, response, headers = client.delete(EPC::Config::GRANTS_PATH + "/#{grant_id}")
|
82
|
-
|
83
|
-
if status.successful?
|
84
|
-
say("Role permission deleted")
|
85
|
-
end
|
86
|
-
end
|
37
|
+
status = remove_grant(role_id, @options[:remove_grant])
|
87
38
|
end
|
88
39
|
|
89
|
-
|
90
|
-
|
91
|
-
say("Request failed: [#{response[:message]}]") unless status.successful?
|
92
40
|
return status
|
93
41
|
end
|
94
42
|
end
|