epc 1.0.4 → 1.0.6
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 +3 -0
- data/lib/epc/client/base_client.rb +2 -1
- data/lib/epc/client/json_client.rb +22 -0
- data/lib/epc/command/archive_command.rb +1 -1
- data/lib/epc/command/attachto_command.rb +1 -1
- data/lib/epc/command/base_command.rb +35 -25
- data/lib/epc/command/build_command.rb +2 -2
- data/lib/epc/command/config/create_config_command.rb +1 -1
- data/lib/epc/command/config/delete_config_command.rb +4 -4
- data/lib/epc/command/config/list_configs_command.rb +1 -1
- data/lib/epc/command/config/update_config_command.rb +3 -3
- data/lib/epc/command/copy_command.rb +1 -1
- data/lib/epc/command/create_command.rb +1 -1
- data/lib/epc/command/delete_command.rb +2 -2
- data/lib/epc/command/deploy_command.rb +4 -3
- data/lib/epc/command/deployment/copy_deployment_command.rb +1 -1
- data/lib/epc/command/deployment/create_deployment_command.rb +3 -3
- data/lib/epc/command/deployment/list_deployments_command.rb +1 -1
- data/lib/epc/command/deployment/show_deployment_command.rb +1 -1
- data/lib/epc/command/deployment/submit_deployment_command.rb +1 -1
- data/lib/epc/command/deployment/update_deployment_command.rb +1 -1
- data/lib/epc/command/deployment/vote_deployment_command.rb +1 -1
- data/lib/epc/command/deploymentstage/list_deploymentstages_command.rb +1 -1
- data/lib/epc/command/detachfrom_command.rb +1 -1
- data/lib/epc/command/group/create_group_command.rb +1 -1
- data/lib/epc/command/group/delete_group_command.rb +1 -1
- data/lib/epc/command/group/list_groups_command.rb +1 -1
- data/lib/epc/command/group/show_group_command.rb +2 -1
- data/lib/epc/command/group/update_group_command.rb +1 -1
- data/lib/epc/command/library/create_library_command.rb +2 -2
- data/lib/epc/command/library/delete_library_command.rb +1 -1
- 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 +1 -1
- data/lib/epc/command/librarylanguage/list_librarylanguages_command.rb +1 -1
- data/lib/epc/command/librarylanguage/update_librarylanguage_command.rb +1 -1
- data/lib/epc/command/libraryset/create_libraryset_command.rb +2 -2
- data/lib/epc/command/libraryset/delete_libraryset_command.rb +1 -1
- data/lib/epc/command/libraryset/list_librarysets_command.rb +1 -1
- data/lib/epc/command/libraryset/show_libraryset_command.rb +1 -1
- data/lib/epc/command/libraryset/update_libraryset_command.rb +3 -3
- data/lib/epc/command/list_command.rb +1 -1
- data/lib/epc/command/objectrole/create_objectrole_command.rb +2 -1
- data/lib/epc/command/objectrole/list_objectroles_command.rb +1 -1
- data/lib/epc/command/objectrole/update_objectrole_command.rb +5 -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 -1
- data/lib/epc/command/plugin/delete_plugin_command.rb +1 -1
- data/lib/epc/command/plugin/list_plugins_command.rb +1 -1
- data/lib/epc/command/plugin/show_plugin_command.rb +1 -1
- data/lib/epc/command/plugin/update_plugin_command.rb +2 -2
- data/lib/epc/command/project/archive_project_command.rb +1 -1
- data/lib/epc/command/project/attachto_project_command.rb +3 -3
- data/lib/epc/command/project/create_project_command.rb +2 -2
- data/lib/epc/command/project/delete_project_command.rb +1 -1
- data/lib/epc/command/project/detachfrom_project_command.rb +4 -4
- data/lib/epc/command/project/list_projects_command.rb +1 -1
- data/lib/epc/command/project/show_project_command.rb +2 -1
- data/lib/epc/command/project/unarchive_project_command.rb +1 -2
- data/lib/epc/command/project/update_project_command.rb +2 -2
- data/lib/epc/command/projecttype/create_projecttype_command.rb +3 -3
- data/lib/epc/command/projecttype/delete_projecttype_command.rb +2 -1
- data/lib/epc/command/projecttype/list_projecttypes_command.rb +1 -1
- data/lib/epc/command/projecttype/show_projecttype_command.rb +2 -1
- data/lib/epc/command/projecttype/update_projecttype_command.rb +4 -3
- data/lib/epc/command/pull_command.rb +12 -10
- data/lib/epc/command/push_command.rb +45 -29
- data/lib/epc/command/role/create_role_command.rb +1 -1
- data/lib/epc/command/role/delete_role_command.rb +2 -1
- data/lib/epc/command/role/list_roles_command.rb +2 -5
- data/lib/epc/command/role/show_role_command.rb +2 -2
- data/lib/epc/command/role/update_role_command.rb +1 -1
- data/lib/epc/command/runtime/create_runtime_command.rb +1 -1
- data/lib/epc/command/runtime/delete_runtime_command.rb +2 -1
- data/lib/epc/command/runtime/list_runtimes_command.rb +1 -1
- data/lib/epc/command/runtime/update_runtime_command.rb +4 -3
- data/lib/epc/command/runtimetype/list_runtimetypes_command.rb +1 -1
- data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +2 -2
- data/lib/epc/command/servicedefinition/delete_servicedefinition_command.rb +1 -1
- data/lib/epc/command/servicedefinition/list_servicedefinitions_command.rb +1 -1
- data/lib/epc/command/servicetype/list_servicetypes_command.rb +1 -1
- data/lib/epc/command/serviceversion/create_serviceversion_command.rb +2 -2
- data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +3 -1
- data/lib/epc/command/serviceversion/list_serviceversions_command.rb +1 -1
- data/lib/epc/command/show_command.rb +1 -1
- data/lib/epc/command/solution/archive_solution_command.rb +1 -1
- data/lib/epc/command/solution/create_solution_command.rb +2 -2
- data/lib/epc/command/solution/delete_solution_command.rb +1 -1
- data/lib/epc/command/solution/list_solutions_command.rb +1 -1
- data/lib/epc/command/solution/show_solution_command.rb +1 -1
- data/lib/epc/command/solution/unarchive_solution_command.rb +1 -1
- data/lib/epc/command/solution/update_solution_command.rb +1 -1
- data/lib/epc/command/submit_command.rb +1 -1
- data/lib/epc/command/unarchive_command.rb +1 -1
- data/lib/epc/command/update_command.rb +1 -1
- data/lib/epc/command/user/create_user_command.rb +1 -1
- data/lib/epc/command/user/delete_user_command.rb +1 -1
- data/lib/epc/command/user/list_users_command.rb +1 -1
- data/lib/epc/command/user/show_user_command.rb +2 -1
- data/lib/epc/command/user/update_user_command.rb +3 -3
- data/lib/epc/command/userproperty/delete_user_property_command.rb +48 -0
- data/lib/epc/command/userproperty/get_user_property_command.rb +61 -0
- data/lib/epc/command/userproperty/list_user_properties_command.rb +1 -1
- data/lib/epc/command/userproperty/set_user_property_command.rb +52 -0
- data/lib/epc/command/vote_command.rb +1 -1
- data/lib/epc/config.rb +12 -0
- data/lib/epc/help.rb +20 -8
- data/lib/epc/runner.rb +22 -11
- data/lib/epc/version.rb +1 -1
- data/test/command/archive_project_command_test.rb +1 -1
- data/test/command/archive_solution_command_test.rb +1 -1
- data/test/command/build_command_test.rb +1 -1
- data/test/command/copy_deployment_command_test.rb +1 -1
- data/test/command/create_config_command_test.rb +1 -1
- data/test/command/create_deployment_command_test.rb +3 -3
- data/test/command/create_group_command_test.rb +1 -1
- data/test/command/create_library_command_test.rb +1 -1
- data/test/command/create_librarylanguage_command_test.rb +2 -2
- data/test/command/create_libraryset_command_test.rb +2 -2
- data/test/command/create_objectrole_command_test.rb +1 -1
- data/test/command/create_project_command_test.rb +2 -2
- data/test/command/create_projecttypes_command_test.rb +33 -0
- data/test/command/create_role_command_test.rb +10 -1
- data/test/command/create_runtime_command_test.rb +1 -1
- data/test/command/create_servicedefinition_command_test.rb +1 -1
- data/test/command/create_serviceversion_command_test.rb +1 -1
- data/test/command/create_solution_command_test.rb +2 -2
- data/test/command/create_user_command_test.rb +1 -1
- data/test/command/delete_config_command_test.rb +3 -3
- data/test/command/delete_library_command_test.rb +1 -1
- data/test/command/delete_librarylanguage_command_test.rb +1 -1
- data/test/command/delete_libraryset_command_test.rb +1 -1
- data/test/command/delete_plugin_command_test.rb +1 -1
- data/test/command/delete_project_command_test.rb +1 -1
- data/test/command/delete_projecttype_command_test.rb +1 -1
- data/test/command/delete_role_command_test.rb +1 -1
- data/test/command/delete_runtime_command_test.rb +1 -1
- data/test/command/delete_servicedefinition_command_test.rb +1 -1
- data/test/command/delete_serviceversion_command_test.rb +1 -1
- data/test/command/delete_solution_command_test.rb +1 -1
- data/test/command/delete_user_command_test.rb +1 -1
- data/test/command/delete_user_property_command_test.rb +60 -0
- data/test/command/deploy_command_test.rb +14 -6
- data/test/command/get_user_property_command_test.rb +58 -0
- data/test/command/list_command_test.rb +28 -0
- data/test/command/list_config_command_test.rb +1 -1
- data/test/command/list_deployments_command_test.rb +1 -1
- data/test/command/list_deploymentstages_command_test.rb +1 -1
- data/test/command/list_libraries_command_test.rb +1 -1
- data/test/command/list_librarylanguages_command_test.rb +1 -1
- data/test/command/list_librarysets_command_test.rb +1 -1
- data/test/command/list_objectroles_command_test.rb +1 -1
- data/test/command/list_permissiongroups_command_test.rb +1 -1
- data/test/command/list_permissions_command_test.rb +1 -1
- data/test/command/list_plugins_command_test.rb +1 -1
- data/test/command/list_projects_command_test.rb +1 -1
- data/test/command/list_projecttypes_command_test.rb +1 -1
- data/test/command/list_roles_command_test.rb +9 -1
- data/test/command/list_runtimes_command_test.rb +1 -1
- data/test/command/list_runtimetypes_command_test.rb +1 -1
- data/test/command/list_service_types_command_test.rb +1 -1
- data/test/command/list_servicedefinitions_command_test.rb +1 -1
- data/test/command/list_serviceversions_command_test.rb +1 -1
- data/test/command/list_solutions_command_test.rb +1 -1
- data/test/command/list_userproperties_command_test.rb +3 -3
- data/test/command/list_users_command_test.rb +1 -1
- data/test/command/pull_command_test.rb +8 -8
- data/test/command/push_command_test.rb +38 -8
- data/test/command/set_user_property_command_test.rb +50 -0
- data/test/command/show_command_test.rb +28 -0
- data/test/command/show_deployment_command_test.rb +1 -1
- data/test/command/show_group_command_test.rb +1 -1
- data/test/command/show_libraryset_command_test.rb +1 -1
- data/test/command/show_plugin_command_test.rb +1 -1
- data/test/command/show_project_command_test.rb +1 -1
- data/test/command/show_projecttype_command_test.rb +1 -1
- data/test/command/show_role_command_test.rb +1 -1
- data/test/command/show_solution_command_test.rb +1 -1
- data/test/command/show_user_command_test.rb +1 -1
- data/test/command/submit_deployment_command_test.rb +1 -1
- data/test/command/unarchive_project_command_test.rb +1 -1
- data/test/command/unarchive_solution_command_test.rb +1 -1
- data/test/command/update_config_command_test.rb +2 -2
- data/test/command/update_deployment_command_test.rb +1 -1
- data/test/command/update_group_command_test.rb +1 -1
- data/test/command/update_librarylanguage_command_test.rb +1 -1
- data/test/command/update_libraryset_command_test.rb +3 -3
- data/test/command/update_plugin_command_test.rb +2 -2
- data/test/command/update_project_command_test.rb +2 -2
- data/test/command/update_solution_command_test.rb +1 -1
- data/test/command/update_user_command_test.rb +2 -2
- data/test/command/vote_deployment_command_test.rb +1 -1
- metadata +38 -23
@@ -8,7 +8,7 @@ module EPC::Command
|
|
8
8
|
status, response, headers = client.get(EPC::Config::ENTITY_PROPERTIES_PATH + "/for/User/#{user_id}")
|
9
9
|
|
10
10
|
if status.failure?
|
11
|
-
|
11
|
+
say_err("Request failed with [#{response[:message]}]")
|
12
12
|
elsif response.empty?
|
13
13
|
say("No properties found for current user.")
|
14
14
|
else
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module EPC::Command
|
2
|
+
class SetUserPropertyCommand < BaseCommand
|
3
|
+
|
4
|
+
def execute(*args)
|
5
|
+
user_id = retrieve_identifier_for("User", EPC::Config.username)
|
6
|
+
|
7
|
+
if @options[:file]
|
8
|
+
return 1 unless set_multiple_properties_for(user_id)
|
9
|
+
else
|
10
|
+
name, value = args[1].split('=') rescue [nil,nil]
|
11
|
+
set_single_property_for(name, user_id)
|
12
|
+
@data = { :name => name, :value => value, :entity_id => user_id, :entity_type => "User"}
|
13
|
+
end
|
14
|
+
|
15
|
+
status, response, headers = client.send(@method, @path, @data)
|
16
|
+
|
17
|
+
if status.failure?
|
18
|
+
say_err("User properties could not be set [#{response[:message]}].")
|
19
|
+
else
|
20
|
+
say("Successfully set the user properties.")
|
21
|
+
end
|
22
|
+
return status
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def set_single_property_for(name, user_id)
|
29
|
+
identified = retrieve_identifier_for("EntityProperty", "#{name}:#{user_id}:User")
|
30
|
+
@path, @method = if identified.present?
|
31
|
+
["#{EPC::Config::ENTITY_PROPERTIES_PATH}/#{identified}", :put]
|
32
|
+
else
|
33
|
+
["#{EPC::Config::ENTITY_PROPERTIES_PATH}", :post]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_multiple_properties_for(user_id)
|
38
|
+
unless File.exists?(@options[:file])
|
39
|
+
say_err("File #{@options[:file]} was not found")
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
@method = :put
|
43
|
+
@path = "#{EPC::Config::ENTITY_PROPERTIES_PATH}/for/User/#{user_id}"
|
44
|
+
@data = {:entity_properties => []}
|
45
|
+
File.open(@options[:file]).each_line do |f|
|
46
|
+
@data[:entity_properties] << JSON.parse(f)
|
47
|
+
end
|
48
|
+
return true
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -2,7 +2,7 @@ module EPC::Command
|
|
2
2
|
class VoteCommand < BaseCommand
|
3
3
|
|
4
4
|
def execute(*args)
|
5
|
-
raise
|
5
|
+
raise InputError, "You need to specify the object for the command" if args.blank?
|
6
6
|
params = resolve_context(args)
|
7
7
|
@klass_name = "EPC::Command::Vote#{@object_type.to_s.gsub("-","").capitalize}Command"
|
8
8
|
command = eval(@klass_name)
|
data/lib/epc/config.rb
CHANGED
@@ -146,6 +146,18 @@ module EPC
|
|
146
146
|
return false
|
147
147
|
end
|
148
148
|
|
149
|
+
def say_err( statement )
|
150
|
+
statement = statement.to_str
|
151
|
+
return unless statement.length > 0
|
152
|
+
|
153
|
+
if statement[-1, 1] == " " or statement[-1, 1] == "\t"
|
154
|
+
STDERR.print(statement)
|
155
|
+
STDERR.flush
|
156
|
+
else
|
157
|
+
STDERR.puts(statement)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
149
161
|
def underscore(camel_cased_word)
|
150
162
|
camel_cased_word.to_s.gsub(/::/, '/').
|
151
163
|
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
data/lib/epc/help.rb
CHANGED
@@ -26,7 +26,7 @@ module EPC
|
|
26
26
|
:list_serviceversions => 'epc list ServiceVersions',
|
27
27
|
:delete_serviceversion => 'epc delete ServiceVersion:service_version_identifier',
|
28
28
|
:create_user => 'epc create user <email> [--name NAME]',
|
29
|
-
:push => 'epc push [
|
29
|
+
:push => 'epc push [Solution:solution_name Project:project_name] [--note NOTE] [--timeout value | --nopoll] [--direct-deploy file]',
|
30
30
|
:pull => 'epc pull [SOLUTION]',
|
31
31
|
:build => 'epc build [project_name=version] [--note NOTE] [--timeout value | --nopoll]',
|
32
32
|
:list_deploymentstages => 'epc list stages',
|
@@ -66,9 +66,9 @@ module EPC
|
|
66
66
|
:list_objectroles => 'epc list ObjectRoles <ObjectType:ObjectId>',
|
67
67
|
:delete_role => 'epc delete Role',
|
68
68
|
:update_role => 'epc update Role:role_identifier [--add-user USER_ID] [--remove-user USER_ID] [--add-grant ObjectType:action:ObjectId] [--remove-grant ObjectType:action:ObjectId> [--file json]',
|
69
|
-
:update_objectrole => 'epc update ObjectRole:ObjectType
|
70
|
-
:create_role => 'epc create
|
71
|
-
:create_objectrole => 'epc create
|
69
|
+
:update_objectrole => 'epc update ObjectRole:ObjectType:ObjectID:role_identifier [--add-user USER_ID] [--remove-user USER_ID] [--add-grant ObjectType:action:ObjectId] [--remove-grant ObjectType:action:ObjectId> [--file json]',
|
70
|
+
:create_role => 'epc create Role <name> [--file json]',
|
71
|
+
:create_objectrole => 'epc create Objectrole <ObjectType:ObjectId> <name>',
|
72
72
|
:show_role => 'epc show Role:role_identifier [users|groups|grants]',
|
73
73
|
:list_users => 'epc list users',
|
74
74
|
:delete_user => 'epc delete User:user_identifier',
|
@@ -97,13 +97,17 @@ module EPC
|
|
97
97
|
:attachto_project => 'epc attach-to Project:project_identifier [Library|LibrarySet|ServiceVersion|Dependency]:[library_identifier|library_set_identifier|service_version_identifier|dependency_identifier]',
|
98
98
|
:detachfrom_project => 'epc detach-from Project:project_identifier [Library|LibrarySet|ServiceVersion|Dependency]:[library_identifier|library_set_identifier|service_version_identifier|dependency_identifier]',
|
99
99
|
:list_runtimetypes => 'epc list RuntimeTypes',
|
100
|
-
:create_runtime => 'epc create Runtime RuntimeType:runtime_type_identifier name target deployment_stage username password [--
|
100
|
+
:create_runtime => 'epc create Runtime RuntimeType:runtime_type_identifier name target deployment_stage username password [--agility-topology id] [--agility-environment id]',
|
101
101
|
:update_runtime => 'epc update Runtime:runtime_identifier attribute=new_value',
|
102
102
|
:delete_runtime => 'epc delete Runtime:runtime_identifier',
|
103
103
|
:create_projecttype => 'epc create ProjectType name runtime framework build-type build-packaging deployable runtime-env-types',
|
104
104
|
:delete_projecttype => 'epc delete ProjectType:project_type_identifier',
|
105
105
|
:update_projecttype => 'epc update ProjectType:project_type_identifier attribute=value',
|
106
|
-
:snapshot => 'epc snapshot project_id:project_version'
|
106
|
+
:snapshot => 'epc snapshot project_id:project_version',
|
107
|
+
:set_userproperty => 'epc set UserProperty [name=value] [--file FILE]',
|
108
|
+
:list_userproperties => 'epc list UserProperties',
|
109
|
+
:get_userproperty => 'epc get UserProperty[:property] [--all] [--file FILE]',
|
110
|
+
:delete_userproperty => 'epc delete UserProperty[:property] [--all] [-y]'
|
107
111
|
}
|
108
112
|
|
109
113
|
def display_usage
|
@@ -131,7 +135,7 @@ module EPC
|
|
131
135
|
private
|
132
136
|
|
133
137
|
def usage
|
134
|
-
"Usage: epc command [<args>] [command_options]\n"
|
138
|
+
"Usage: epc command [<Object>] [<Target>] [<args>] [command_options]\n"
|
135
139
|
end
|
136
140
|
|
137
141
|
def verbose_usage
|
@@ -286,7 +290,15 @@ Currently available epc commands are:
|
|
286
290
|
request password-change Sends a request for a password change to
|
287
291
|
the server. The user will receive an
|
288
292
|
email with the password change token.
|
289
|
-
|
293
|
+
|
294
|
+
User Properties
|
295
|
+
set UserProperty Set one or more user properties for the
|
296
|
+
logged-in user
|
297
|
+
get UserProperty Retrieves one or all user properties
|
298
|
+
for the logged-in user.
|
299
|
+
list UserProperties List user properties for the logged-in user.
|
300
|
+
delete UserProperty Removes one or all user properties
|
301
|
+
for the logged-in user.
|
290
302
|
|
291
303
|
Administration
|
292
304
|
create user Creates a new user account with the target system
|
data/lib/epc/runner.rb
CHANGED
@@ -29,32 +29,39 @@ class EPC::Runner
|
|
29
29
|
code = command_klass.go(*@args)
|
30
30
|
exit translate_exit_code(code)
|
31
31
|
rescue InternalError => ex
|
32
|
-
|
32
|
+
EPC::Config.say_err("An internal error occured. Please contact the AgileMethods support team.")
|
33
33
|
exit 1
|
34
34
|
rescue InputError => ex
|
35
|
-
|
35
|
+
EPC::Config.say_err(ex.to_s)
|
36
36
|
exit 1
|
37
37
|
rescue FatalError => ex
|
38
38
|
command_name = EPC::Config.underscore(command_klass.klass_name.to_s.split("::").last)
|
39
|
-
|
40
|
-
|
39
|
+
help_key = command_name.split("_")
|
40
|
+
if help_key.size > 1
|
41
|
+
help_key = help_key[0...-1].join("_")
|
42
|
+
else
|
43
|
+
help_key = help_key[0]
|
44
|
+
end
|
45
|
+
say("USAGE: " + EPC::Help::COMMAND_USAGES[help_key.to_sym])
|
46
|
+
EPC::Config.say_err(ex.to_s)
|
41
47
|
exit 1
|
42
48
|
rescue ArgumentError => ex
|
43
49
|
command_name = EPC::Config.underscore(command_klass.klass_name.to_s.split("::").last)
|
44
|
-
|
50
|
+
EPC::Config.say_err("Wrong number of attributes for #{command_name}")
|
45
51
|
say("USAGE: " + EPC::Help::COMMAND_USAGES[command_name.split("_")[0...-1].join("_").to_sym])
|
46
52
|
exit 1
|
47
53
|
rescue NameError => ex
|
48
|
-
|
54
|
+
EPC::Config.say_err "No such command"
|
55
|
+
display_verbose_usage
|
49
56
|
exit 1
|
50
57
|
rescue BaseClient::HTTPException => ex
|
51
|
-
|
58
|
+
EPC::Config.say_err(ex.to_s)
|
52
59
|
exit 1
|
53
60
|
rescue BaseClient::BadResponse => ex
|
54
|
-
|
61
|
+
EPC::Config.say_err(ex.to_s)
|
55
62
|
exit 1
|
56
63
|
rescue SocketError => ex
|
57
|
-
|
64
|
+
EPC::Config.say_err(ex.to_s)
|
58
65
|
exit 1
|
59
66
|
end
|
60
67
|
end
|
@@ -141,6 +148,8 @@ class EPC::Runner
|
|
141
148
|
opts.on('--backwards-compatible') { |val| @options[:backwards_compatible] = true}
|
142
149
|
opts.on('--reversible') { |val| @options[:reversible] = true}
|
143
150
|
opts.on('--direct-deploy FILE') { |file| @options[:direct_deploy] = file}
|
151
|
+
opts.on('--all') { |all| @options[:all] = true}
|
152
|
+
opts.on('--debug') { |debug| @options[:debug] = true}
|
144
153
|
|
145
154
|
opts.on('-p NAME') do |name|
|
146
155
|
if @options[:project_name].nil?
|
@@ -178,13 +187,15 @@ class EPC::Runner
|
|
178
187
|
klass_name = "EPC::Command::#{command_name.to_s.capitalize}#{subcommand_name.to_s.capitalize}Command"
|
179
188
|
elsif command_name == "snapshot"
|
180
189
|
klass_name = "EPC::Command::ShowProjectSnapshotCommand"
|
190
|
+
elsif %w(set get).include?(command_name)
|
191
|
+
klass_name = "EPC::Command::#{command_name.to_s.capitalize}UserPropertyCommand"
|
181
192
|
else
|
182
193
|
klass_name = "EPC::Command::#{command_name.to_s.capitalize}Command"
|
183
194
|
end
|
184
195
|
command_klass = eval(klass_name.gsub("-", "")).new(client, @options)
|
185
196
|
end
|
186
197
|
rescue NameError => ex
|
187
|
-
|
198
|
+
EPC::Config.say_err("No such command: #{command_name} #{subcommand_name}")
|
188
199
|
display_verbose_usage
|
189
200
|
exit 1
|
190
201
|
end
|
@@ -194,6 +205,6 @@ class EPC::Runner
|
|
194
205
|
|
195
206
|
def client
|
196
207
|
return @client if @client
|
197
|
-
@client = EPC::Client::JsonClient.new(target_url, caller_id, auth_token)
|
208
|
+
@client = EPC::Client::JsonClient.new(target_url, caller_id, auth_token, @options[:debug])
|
198
209
|
end
|
199
210
|
end
|
data/lib/epc/version.rb
CHANGED
@@ -14,7 +14,7 @@ class ArchiveProjectCommandTest < Test::Unit::TestCase
|
|
14
14
|
@mock_client.expects(:put).with(EPC::Config::PROJECTS_PATH + "/1", {:archived => true}).
|
15
15
|
returns([404, {:message => "Not Found"}, {}])
|
16
16
|
|
17
|
-
@command.expects(:
|
17
|
+
@command.expects(:say_err).with("Project could not be archived. Request failed with: [Not Found]")
|
18
18
|
assert_equal(@command.execute, 404)
|
19
19
|
end
|
20
20
|
|
@@ -14,7 +14,7 @@ class ArchiveSolutionCommandTest < Test::Unit::TestCase
|
|
14
14
|
@mock_client.expects(:put).with(EPC::Config::SOLUTIONS_PATH + "/1", {:archived => true}).
|
15
15
|
returns([404, {:message => "Not Found"}, {}])
|
16
16
|
|
17
|
-
@command.expects(:
|
17
|
+
@command.expects(:say_err).with("Solution could not be archived. Request failed with: [Not Found]")
|
18
18
|
assert_equal(@command.execute, 404)
|
19
19
|
end
|
20
20
|
|
@@ -80,7 +80,7 @@ class BuildCommandTest < Test::Unit::TestCase
|
|
80
80
|
should "return false if the status is not 200" do
|
81
81
|
@mock_client.expects(:post).with("/api/v1/builds", { :project_ids => [7], :project_versions => [], :note => nil }).
|
82
82
|
returns([404, { :message => "Not Found" }, {}])
|
83
|
-
@command.expects(:
|
83
|
+
@command.expects(:say_err).with("Build kickoff failed [Not Found]. Aborting.")
|
84
84
|
|
85
85
|
created, id, built, message = @command.send(:create_build, { 7 => nil })
|
86
86
|
|
@@ -16,7 +16,7 @@ class CopyDeploymentCommandTest < Test::Unit::TestCase
|
|
16
16
|
@mock_client.expects(:post).with(EPC::Config::DEPLOYMENTS_PATH + "/1/copy", :stage_name => "development").
|
17
17
|
returns([404, {:message => "Not Found"}, {}])
|
18
18
|
|
19
|
-
@command.expects(:
|
19
|
+
@command.expects(:say_err).with("Request failed: [Not Found]")
|
20
20
|
assert_equal(@command.execute(["development"]), 404)
|
21
21
|
end
|
22
22
|
|
@@ -27,7 +27,7 @@ class CreateConfigCommandTest < Test::Unit::TestCase
|
|
27
27
|
{:config_values => [{:name => "key1", :value => "value1", :value_type => "text", :configurable_id => 1, :configurable_type => "Project", :required => false, :no_override => nil}]}
|
28
28
|
).returns([400, {:message => "Not Found"}, {}])
|
29
29
|
|
30
|
-
@command.expects(
|
30
|
+
@command.expects(:say_err).with("Request failed with message [Not Found]")
|
31
31
|
assert_equal(@command.execute(["key1=value1"]), 400)
|
32
32
|
end
|
33
33
|
|
@@ -40,7 +40,7 @@ class CreateDeploymentCommandTest < Test::Unit::TestCase
|
|
40
40
|
|
41
41
|
|
42
42
|
@command.expects(:ask_yn).returns("Y")
|
43
|
-
@command.expects(:
|
43
|
+
@command.expects(:say_err).with("Deployment creation failed [Not Found]. Aborting.")
|
44
44
|
|
45
45
|
assert_equal(@command.execute(["Development"]), 404)
|
46
46
|
end
|
@@ -51,7 +51,7 @@ class CreateDeploymentCommandTest < Test::Unit::TestCase
|
|
51
51
|
raises(StandardError.new("failed"))
|
52
52
|
|
53
53
|
@command.expects(:ask_yn).returns("Y")
|
54
|
-
@command.expects(:
|
54
|
+
@command.expects(:say_err).with("Create deployment failed [Exception Caught (StandardError): failed].")
|
55
55
|
|
56
56
|
assert_equal(@command.execute(["Development"]), 1)
|
57
57
|
end
|
@@ -111,7 +111,7 @@ class CreateDeploymentCommandTest < Test::Unit::TestCase
|
|
111
111
|
@mock_client.expects(:post).with("/api/v1/deployments",
|
112
112
|
{ :solution_name => "Test Solution", :stage_name => "dev" }).
|
113
113
|
returns([404, { :message => "Not Found" }, {}])
|
114
|
-
@command.expects(:
|
114
|
+
@command.expects(:say_err).with("Deployment creation failed [Not Found]. Aborting.")
|
115
115
|
|
116
116
|
status, id = @command.send(:create_deployment, "Test Solution", "dev")
|
117
117
|
|
@@ -18,7 +18,7 @@ class CreateGroupCommandTest < Test::Unit::TestCase
|
|
18
18
|
should "fail if status is not 201" do
|
19
19
|
@mock_client.expects(:post).with(EPC::Config::GROUPS_PATH, {:name => "group"}).
|
20
20
|
returns([500, {:message => "System exception"}, {}])
|
21
|
-
@command.expects(:
|
21
|
+
@command.expects(:say_err).with("Failed to create [group] group: [System exception]")
|
22
22
|
assert_equal(@command.execute(["group"]), 500)
|
23
23
|
end
|
24
24
|
|
@@ -34,7 +34,7 @@ class CreateLibraryCommandTest < Test::Unit::TestCase
|
|
34
34
|
should "fail if status is not 200" do
|
35
35
|
@command.expects(:retrieve_identifier_for).returns(1)
|
36
36
|
@mock_client.expects(:post).returns([404, {:message => "Not Found"}, {}])
|
37
|
-
@command.expects(:
|
37
|
+
@command.expects(:say_err).with("Request failed: [Not Found]")
|
38
38
|
|
39
39
|
assert_equal(@command.execute(["lib1", 1, "0.2", "my_grp"]), 404)
|
40
40
|
end
|
@@ -18,7 +18,7 @@ class CreateLibrarylanguageCommandTest < Test::Unit::TestCase
|
|
18
18
|
should "fail if status is not 201" do
|
19
19
|
@mock_client.expects(:post).with(EPC::Config::LIBRARY_LANGUAGES_PATH, {:name => "ruby"}).
|
20
20
|
returns([500, {:message => "System exception"}, {}])
|
21
|
-
@command.expects(:
|
21
|
+
@command.expects(:say_err).with("Failed to create [ruby] language: [System exception]")
|
22
22
|
assert_equal(@command.execute(["ruby"]), 1)
|
23
23
|
end
|
24
24
|
|
@@ -39,7 +39,7 @@ class CreateLibrarylanguageCommandTest < Test::Unit::TestCase
|
|
39
39
|
should "continue with creation even if one request fails" do
|
40
40
|
@mock_client.expects(:post).with(EPC::Config::LIBRARY_LANGUAGES_PATH, {:name => "ruby"}).
|
41
41
|
returns([500, {:message => "System exception"}, {}])
|
42
|
-
@command.expects(:
|
42
|
+
@command.expects(:say_err).with("Failed to create [ruby] language: [System exception]")
|
43
43
|
|
44
44
|
@mock_client.expects(:post).with(EPC::Config::LIBRARY_LANGUAGES_PATH, {:name => "java"}).
|
45
45
|
returns([201, {}, {}])
|
@@ -19,7 +19,7 @@ class CreateLibrarysetCommandTest < Test::Unit::TestCase
|
|
19
19
|
should "fail if status is not 201" do
|
20
20
|
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH, {:name => "rubylibs", :language_id => 1}).
|
21
21
|
returns([500, {:message => "System exception"}, {}])
|
22
|
-
@command.expects(:
|
22
|
+
@command.expects(:say_err).with("Request failed: [System exception]")
|
23
23
|
assert_equal(@command.execute(["rubylibs", "1"]), 500)
|
24
24
|
end
|
25
25
|
|
@@ -52,7 +52,7 @@ class CreateLibrarysetCommandTest < Test::Unit::TestCase
|
|
52
52
|
EPC::Config.expects(:read_content_as_json).with("/path/to/file").returns([{"name" => "lib1", "library_version" => "1", "group" => "grp"}])
|
53
53
|
@command.expects(:retrieve_libraries).with([{:name => "lib1", :library_version => "1", :group => "grp"}]).returns([1])
|
54
54
|
@mock_client.expects(:post).with(EPC::Config::LIBRARY_SETS_PATH + "/1/attach_library", :library_id => 1).returns([404, {:message => "Not Found"}, {}])
|
55
|
-
@command.expects(:
|
55
|
+
@command.expects(:say_err).with("Failed to add [1]: [Not Found]")
|
56
56
|
|
57
57
|
assert_equal(@command.execute(["rubylibs", "1"]), 1)
|
58
58
|
end
|
@@ -20,7 +20,7 @@ class CreateObjectroleCommandTest < Test::Unit::TestCase
|
|
20
20
|
|
21
21
|
should "report reason for request failure" do
|
22
22
|
@mock_client.expects(:post).with(EPC::Config::ROLES_PATH, {:name => "Admin", :owner_id => "1", :owner_type => "Solution"}).returns([500, {:message => "System Exception"}, {}])
|
23
|
-
@command.expects(:
|
23
|
+
@command.expects(:say_err).with("Request failed: [System Exception]")
|
24
24
|
@command.execute(["Admin"])
|
25
25
|
end
|
26
26
|
end
|
@@ -97,7 +97,7 @@ class CreateProjectCommandTest < Test::Unit::TestCase
|
|
97
97
|
returns([400, { :message => "Bad Request" }, {}])
|
98
98
|
|
99
99
|
@command.expects(:ask_yn).returns("Y")
|
100
|
-
@command.expects(:
|
100
|
+
@command.expects(:say_err).with("Project creation failed [Bad Request].")
|
101
101
|
|
102
102
|
assert_equal(@command.execute(["TestProject"]), 400)
|
103
103
|
end
|
@@ -108,7 +108,7 @@ class CreateProjectCommandTest < Test::Unit::TestCase
|
|
108
108
|
raises(StandardError.new("failed"))
|
109
109
|
|
110
110
|
@command.expects(:ask_yn).returns("Y")
|
111
|
-
@command.expects(:
|
111
|
+
@command.expects(:say_err).with("Project creation failed [failed].")
|
112
112
|
|
113
113
|
assert_equal(@command.execute(["TestProject"]), 1)
|
114
114
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CreateProjecttypeCommandTest < Test::Unit::TestCase
|
4
|
+
should_require_login
|
5
|
+
|
6
|
+
context "execute" do
|
7
|
+
setup do
|
8
|
+
@mock_client = mock("Client")
|
9
|
+
@command = EPC::Command::CreateProjecttypeCommand.new(@mock_client)
|
10
|
+
end
|
11
|
+
|
12
|
+
should "fail if mandatory attributes not specified" do
|
13
|
+
assert_raise EPC::Error::FatalError do
|
14
|
+
@command.execute
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
should "request creation of the project types" do
|
19
|
+
@mock_client.expects(:post).with(EPC::Config::PROJECT_TYPES_PATH, {:name => "ruby", :runtime => "project_type_runtime", :framework => "p_type_framework", :build_type => 1, :build_packaging => "b_pack", :deployable => "true", :runtime_env_types => []}).returns([200, {}, {}])
|
20
|
+
@command.expects(:say).with("ProjectType [ruby] created")
|
21
|
+
@command.execute(["ruby", "project_type_runtime", "p_type_framework", 1, "b_pack", "true", ""])
|
22
|
+
end
|
23
|
+
|
24
|
+
should "fail if status is not 201" do
|
25
|
+
@mock_client.expects(:post).with(EPC::Config::PROJECT_TYPES_PATH, {:name => "ruby", :runtime => "project_type_runtime", :framework => "p_type_framework", :build_type => 1, :build_packaging => "b_pack", :deployable => "true", :runtime_env_types => []}).returns([500, {:message => "System Exception"}, {}])
|
26
|
+
@command.expects(:say_err).with("Request failed: [System Exception]")
|
27
|
+
@command.execute(["ruby", "project_type_runtime", "p_type_framework", 1, "b_pack", "true", ""])
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end
|
@@ -24,9 +24,18 @@ class CreateRoleCommandTest < Test::Unit::TestCase
|
|
24
24
|
|
25
25
|
should "report reason for request failure" do
|
26
26
|
@mock_client.expects(:post).with(EPC::Config::ROLES_PATH, {:name => "Admin"}).returns([500, {:message => "System Exception"}, {}])
|
27
|
-
@command.expects(:
|
27
|
+
@command.expects(:say_err).with("Request failed: [System Exception]")
|
28
28
|
@command.execute(["Admin"])
|
29
29
|
end
|
30
|
+
|
31
|
+
context "role creation from file" do
|
32
|
+
should "read file and create roles" do
|
33
|
+
EPC::Config.expects(:read_content_as_json).returns({:name => "role name", :users => {}, :groups => {}, :grants => {}})
|
34
|
+
@command.expects(:create_role).returns([200, 1])
|
35
|
+
@command.expects(:batch_add)
|
36
|
+
assert_equal @command.handle_file_role_creation, 0
|
37
|
+
end
|
38
|
+
end
|
30
39
|
end
|
31
40
|
|
32
41
|
end
|