nucleus 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +9 -0
- data/README.md +43 -72
- data/lib/nucleus/adapter_resolver.rb +3 -3
- data/lib/nucleus/adapters/base_adapter.rb +109 -109
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/application.rb +111 -111
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/cloud_foundry_v2.rb +141 -141
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/data.rb +97 -97
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/domains.rb +5 -5
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/lifecycle.rb +41 -41
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/logs.rb +6 -6
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/regions.rb +33 -33
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/services.rb +6 -6
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/vars.rb +80 -80
- data/lib/nucleus/adapters/v1/heroku/app_states.rb +57 -57
- data/lib/nucleus/adapters/v1/heroku/data.rb +78 -78
- data/lib/nucleus/adapters/v1/heroku/heroku.rb +146 -146
- data/lib/nucleus/adapters/v1/heroku/lifecycle.rb +51 -51
- data/lib/nucleus/adapters/v1/heroku/logs.rb +2 -2
- data/lib/nucleus/adapters/v1/heroku/regions.rb +42 -42
- data/lib/nucleus/adapters/v1/heroku/services.rb +168 -168
- data/lib/nucleus/adapters/v1/heroku/vars.rb +65 -65
- data/lib/nucleus/adapters/v1/openshift_v2/app_states.rb +68 -68
- data/lib/nucleus/adapters/v1/openshift_v2/application.rb +1 -1
- data/lib/nucleus/adapters/v1/openshift_v2/data.rb +96 -96
- data/lib/nucleus/adapters/v1/openshift_v2/lifecycle.rb +60 -60
- data/lib/nucleus/adapters/v1/openshift_v2/logs.rb +106 -106
- data/lib/nucleus/adapters/v1/openshift_v2/openshift_v2.rb +125 -125
- data/lib/nucleus/adapters/v1/openshift_v2/regions.rb +58 -58
- data/lib/nucleus/adapters/v1/openshift_v2/services.rb +173 -173
- data/lib/nucleus/adapters/v1/openshift_v2/vars.rb +49 -49
- data/lib/nucleus/adapters/v1/stub_adapter.rb +464 -464
- data/lib/nucleus/core/adapter_extensions/auth/auth_client.rb +44 -44
- data/lib/nucleus/core/adapter_extensions/auth/expiring_token_auth_client.rb +53 -53
- data/lib/nucleus/core/adapter_extensions/auth/http_basic_auth_client.rb +3 -3
- data/lib/nucleus/core/adapter_extensions/auth/o_auth2_auth_client.rb +95 -95
- data/lib/nucleus/core/adapter_extensions/auth/token_auth_client.rb +36 -36
- data/lib/nucleus/core/adapter_extensions/http_client.rb +5 -5
- data/lib/nucleus/core/common/files/archive_extractor.rb +1 -1
- data/lib/nucleus/core/common/files/archiver.rb +2 -2
- data/lib/nucleus/core/file_handling/file_manager.rb +64 -64
- data/lib/nucleus/core/file_handling/git_deployer.rb +133 -133
- data/lib/nucleus/core/import/adapter_configuration.rb +53 -53
- data/lib/nucleus/scripts/initialize_config_defaults.rb +26 -26
- data/lib/nucleus/version.rb +1 -1
- data/nucleus.gemspec +2 -2
- data/spec/integration/api/auth_spec.rb +3 -3
- data/spec/spec_helper.rb +98 -98
- data/spec/test_suites.rake +1 -1
- data/spec/unit/adapters/git_deployer_spec.rb +262 -262
- data/spec/unit/common/helpers/auth_helper_spec.rb +1 -1
- data/tasks/evaluation.rake +1 -1
- data/wiki/adapter_tests.md +0 -7
- data/wiki/implement_new_adapter.md +1 -1
- metadata +4 -20
- data/config/adapters/cloud_control.yml +0 -32
- data/lib/nucleus/adapters/v1/cloud_control/application.rb +0 -108
- data/lib/nucleus/adapters/v1/cloud_control/authentication.rb +0 -27
- data/lib/nucleus/adapters/v1/cloud_control/buildpacks.rb +0 -23
- data/lib/nucleus/adapters/v1/cloud_control/cloud_control.rb +0 -153
- data/lib/nucleus/adapters/v1/cloud_control/data.rb +0 -76
- data/lib/nucleus/adapters/v1/cloud_control/domains.rb +0 -68
- data/lib/nucleus/adapters/v1/cloud_control/lifecycle.rb +0 -27
- data/lib/nucleus/adapters/v1/cloud_control/log_poller.rb +0 -71
- data/lib/nucleus/adapters/v1/cloud_control/logs.rb +0 -103
- data/lib/nucleus/adapters/v1/cloud_control/regions.rb +0 -32
- data/lib/nucleus/adapters/v1/cloud_control/scaling.rb +0 -17
- data/lib/nucleus/adapters/v1/cloud_control/semantic_errors.rb +0 -31
- data/lib/nucleus/adapters/v1/cloud_control/services.rb +0 -162
- data/lib/nucleus/adapters/v1/cloud_control/token.rb +0 -17
- data/lib/nucleus/adapters/v1/cloud_control/vars.rb +0 -88
@@ -1,17 +0,0 @@
|
|
1
|
-
module Nucleus
|
2
|
-
module Adapters
|
3
|
-
module V1
|
4
|
-
class CloudControl < Stub
|
5
|
-
# cloud control specific token, which requires a specific +cc_auth_token+ value in the +Authorization+ header.
|
6
|
-
class Token < Nucleus::Adapters::ExpiringTokenAuthClient
|
7
|
-
# @see Nucleus::Adapters::ExpiringTokenAuthClient#auth_header
|
8
|
-
def auth_header
|
9
|
-
# call super for error checks, but ignore returned header
|
10
|
-
super
|
11
|
-
{ 'Authorization' => "cc_auth_token=\"#{api_token}\"" }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
module Nucleus
|
2
|
-
module Adapters
|
3
|
-
module V1
|
4
|
-
class CloudControl < Stub
|
5
|
-
# cloud control, CRUD operations for the application's environment variable object,
|
6
|
-
# which is referred to as +config addon+ on the platform.
|
7
|
-
module Vars
|
8
|
-
# @see Stub#env_vars
|
9
|
-
def env_vars(application_id)
|
10
|
-
cc_vars = cc_vars(application_id)
|
11
|
-
cc_vars.collect do |key, value|
|
12
|
-
{ id: key, key: key, value: value }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
# @see Stub#env_var
|
17
|
-
def env_var(application_id, env_var_key)
|
18
|
-
cc_vars = cc_vars(application_id)
|
19
|
-
fail Errors::AdapterResourceNotFoundError,
|
20
|
-
"Env. var key '#{env_var_key}' does not exist" unless env_var?(application_id, env_var_key, cc_vars)
|
21
|
-
{ id: env_var_key, key: env_var_key, value: cc_vars[env_var_key.to_sym] }
|
22
|
-
end
|
23
|
-
|
24
|
-
# @see Stub#create_env_var
|
25
|
-
def create_env_var(application_id, env_var)
|
26
|
-
cc_vars = cc_vars(application_id)
|
27
|
-
fail Errors::SemanticAdapterRequestError,
|
28
|
-
"Env. var key '#{env_var[:key]}' already taken" if env_var?(application_id, env_var[:key], cc_vars)
|
29
|
-
set_var(application_id, env_var[:key], env_var[:value])
|
30
|
-
end
|
31
|
-
|
32
|
-
# @see Stub#update_env_var
|
33
|
-
def update_env_var(application_id, env_var_key, env_var)
|
34
|
-
cc_vars = cc_vars(application_id)
|
35
|
-
fail Errors::AdapterResourceNotFoundError,
|
36
|
-
"Env. var key '#{env_var_key}' does not exist" unless env_var?(application_id, env_var_key, cc_vars)
|
37
|
-
set_var(application_id, env_var_key, env_var[:value])
|
38
|
-
end
|
39
|
-
|
40
|
-
# @see Stub#delete_env_var
|
41
|
-
def delete_env_var(application_id, env_var_key)
|
42
|
-
cc_vars = cc_vars(application_id)
|
43
|
-
fail Errors::AdapterResourceNotFoundError,
|
44
|
-
"Env. var key '#{env_var_key}' does not exist" unless env_var?(application_id, env_var_key, cc_vars)
|
45
|
-
set_var(application_id, env_var_key, nil)
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def cc_vars(application_id)
|
51
|
-
cc_vars_response = get("app/#{application_id}/deployment/#{NUCLEUS_DEPLOYMENT}/addon/config.free")
|
52
|
-
cc_vars_response.body[:settings][:CONFIG_VARS]
|
53
|
-
end
|
54
|
-
|
55
|
-
# Set the variable value (create or update)
|
56
|
-
# @param [String] application_id id of the cloud control application
|
57
|
-
# @param [Symbol] key variable key name
|
58
|
-
# @param [String, Integer, Float, Double] value value to apply to the variable
|
59
|
-
# @return [Hash] Nucleus representation of the modified variable
|
60
|
-
def set_var(application_id, key, value)
|
61
|
-
settings = if value.nil?
|
62
|
-
# delete the var, set to 'null'
|
63
|
-
"{\"#{key}\":null}"
|
64
|
-
else
|
65
|
-
"{\"#{key}\":\"#{value}\"}"
|
66
|
-
end
|
67
|
-
response = put("/app/#{application_id}/deployment/#{NUCLEUS_DEPLOYMENT}/addon/config.free",
|
68
|
-
body: { addon: 'config.free',
|
69
|
-
settings: settings,
|
70
|
-
force: true })
|
71
|
-
all_vars = response.body[:settings][:CONFIG_VARS]
|
72
|
-
{ id: key, key: key, value: all_vars[key.to_sym] }
|
73
|
-
end
|
74
|
-
|
75
|
-
# Checks if a variable with the env_var_key already exists.
|
76
|
-
# @param [String] application_id id of the cloud control application
|
77
|
-
# @param [Symbol] env_var_key key name that shall be checked for existence
|
78
|
-
# @param [Hash] all_vars collection of currently existing variables for the application
|
79
|
-
# @return [Boolean] true if there is a variable with the env_var_key, otherwise false
|
80
|
-
def env_var?(application_id, env_var_key, all_vars = nil)
|
81
|
-
all_vars = cc_vars(application_id) if all_vars.nil?
|
82
|
-
all_vars.key? env_var_key.to_sym
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|