nucleus 0.1.0
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 +7 -0
- data/.gitattributes +1 -0
- data/.gitignore +19 -0
- data/.rspec +3 -0
- data/.rubocop.yml +44 -0
- data/.travis.yml +21 -0
- data/CHANGELOG.md +19 -0
- data/CONTRIBUTING.md +13 -0
- data/Gemfile +16 -0
- data/Guardfile +22 -0
- data/LICENSE +21 -0
- data/README.md +675 -0
- data/Rakefile +137 -0
- data/bin/nucleus +91 -0
- data/bin/nucleus.bat +1 -0
- data/config.ru +18 -0
- data/config/adapters/cloud_control.yml +32 -0
- data/config/adapters/cloud_foundry_v2.yml +61 -0
- data/config/adapters/heroku.yml +13 -0
- data/config/adapters/openshift_v2.yml +20 -0
- data/config/nucleus_config.rb +47 -0
- data/lib/nucleus.rb +13 -0
- data/lib/nucleus/adapter_resolver.rb +115 -0
- data/lib/nucleus/adapters/base_adapter.rb +109 -0
- data/lib/nucleus/adapters/buildpack_translator.rb +79 -0
- data/lib/nucleus/adapters/v1/cloud_control/application.rb +108 -0
- data/lib/nucleus/adapters/v1/cloud_control/authentication.rb +27 -0
- data/lib/nucleus/adapters/v1/cloud_control/buildpacks.rb +23 -0
- data/lib/nucleus/adapters/v1/cloud_control/cloud_control.rb +153 -0
- data/lib/nucleus/adapters/v1/cloud_control/data.rb +76 -0
- data/lib/nucleus/adapters/v1/cloud_control/domains.rb +68 -0
- data/lib/nucleus/adapters/v1/cloud_control/lifecycle.rb +27 -0
- data/lib/nucleus/adapters/v1/cloud_control/log_poller.rb +71 -0
- data/lib/nucleus/adapters/v1/cloud_control/logs.rb +103 -0
- data/lib/nucleus/adapters/v1/cloud_control/regions.rb +32 -0
- data/lib/nucleus/adapters/v1/cloud_control/scaling.rb +17 -0
- data/lib/nucleus/adapters/v1/cloud_control/semantic_errors.rb +31 -0
- data/lib/nucleus/adapters/v1/cloud_control/services.rb +162 -0
- data/lib/nucleus/adapters/v1/cloud_control/token.rb +17 -0
- data/lib/nucleus/adapters/v1/cloud_control/vars.rb +88 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/app_states.rb +28 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/application.rb +111 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/authentication.rb +17 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/buildpacks.rb +23 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/cloud_foundry_v2.rb +141 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/data.rb +97 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/domains.rb +149 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/lifecycle.rb +41 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/logs.rb +303 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/regions.rb +33 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/scaling.rb +15 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/semantic_errors.rb +27 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/services.rb +286 -0
- data/lib/nucleus/adapters/v1/cloud_foundry_v2/vars.rb +80 -0
- data/lib/nucleus/adapters/v1/heroku/app_states.rb +57 -0
- data/lib/nucleus/adapters/v1/heroku/application.rb +93 -0
- data/lib/nucleus/adapters/v1/heroku/authentication.rb +27 -0
- data/lib/nucleus/adapters/v1/heroku/buildpacks.rb +27 -0
- data/lib/nucleus/adapters/v1/heroku/data.rb +78 -0
- data/lib/nucleus/adapters/v1/heroku/domains.rb +43 -0
- data/lib/nucleus/adapters/v1/heroku/heroku.rb +146 -0
- data/lib/nucleus/adapters/v1/heroku/lifecycle.rb +51 -0
- data/lib/nucleus/adapters/v1/heroku/logs.rb +108 -0
- data/lib/nucleus/adapters/v1/heroku/regions.rb +42 -0
- data/lib/nucleus/adapters/v1/heroku/scaling.rb +28 -0
- data/lib/nucleus/adapters/v1/heroku/semantic_errors.rb +23 -0
- data/lib/nucleus/adapters/v1/heroku/services.rb +168 -0
- data/lib/nucleus/adapters/v1/heroku/vars.rb +65 -0
- data/lib/nucleus/adapters/v1/openshift_v2/app_states.rb +68 -0
- data/lib/nucleus/adapters/v1/openshift_v2/application.rb +108 -0
- data/lib/nucleus/adapters/v1/openshift_v2/authentication.rb +21 -0
- data/lib/nucleus/adapters/v1/openshift_v2/data.rb +96 -0
- data/lib/nucleus/adapters/v1/openshift_v2/domains.rb +37 -0
- data/lib/nucleus/adapters/v1/openshift_v2/lifecycle.rb +60 -0
- data/lib/nucleus/adapters/v1/openshift_v2/logs.rb +106 -0
- data/lib/nucleus/adapters/v1/openshift_v2/openshift_v2.rb +125 -0
- data/lib/nucleus/adapters/v1/openshift_v2/regions.rb +58 -0
- data/lib/nucleus/adapters/v1/openshift_v2/scaling.rb +39 -0
- data/lib/nucleus/adapters/v1/openshift_v2/semantic_errors.rb +40 -0
- data/lib/nucleus/adapters/v1/openshift_v2/services.rb +173 -0
- data/lib/nucleus/adapters/v1/openshift_v2/vars.rb +49 -0
- data/lib/nucleus/adapters/v1/stub_adapter.rb +464 -0
- data/lib/nucleus/core/adapter_authentication_inductor.rb +62 -0
- data/lib/nucleus/core/adapter_extensions/auth/auth_client.rb +44 -0
- data/lib/nucleus/core/adapter_extensions/auth/authentication_retry_wrapper.rb +79 -0
- data/lib/nucleus/core/adapter_extensions/auth/expiring_token_auth_client.rb +53 -0
- data/lib/nucleus/core/adapter_extensions/auth/http_basic_auth_client.rb +37 -0
- data/lib/nucleus/core/adapter_extensions/auth/o_auth2_auth_client.rb +95 -0
- data/lib/nucleus/core/adapter_extensions/auth/token_auth_client.rb +36 -0
- data/lib/nucleus/core/adapter_extensions/http_client.rb +177 -0
- data/lib/nucleus/core/adapter_extensions/http_tail_client.rb +26 -0
- data/lib/nucleus/core/adapter_extensions/tail_stopper.rb +25 -0
- data/lib/nucleus/core/common/errors/ambiguous_adapter_error.rb +7 -0
- data/lib/nucleus/core/common/errors/file_existence_error.rb +7 -0
- data/lib/nucleus/core/common/errors/startup_error.rb +12 -0
- data/lib/nucleus/core/common/exit_codes.rb +25 -0
- data/lib/nucleus/core/common/files/application_repo_sanitizer.rb +52 -0
- data/lib/nucleus/core/common/files/archive_extractor.rb +112 -0
- data/lib/nucleus/core/common/files/archiver.rb +91 -0
- data/lib/nucleus/core/common/link_generator.rb +46 -0
- data/lib/nucleus/core/common/logging/logging.rb +52 -0
- data/lib/nucleus/core/common/logging/multi_logger.rb +59 -0
- data/lib/nucleus/core/common/logging/request_log_formatter.rb +48 -0
- data/lib/nucleus/core/common/ssh_handler.rb +108 -0
- data/lib/nucleus/core/common/stream_callback.rb +27 -0
- data/lib/nucleus/core/common/thread_config_accessor.rb +85 -0
- data/lib/nucleus/core/common/url_converter.rb +28 -0
- data/lib/nucleus/core/enums/application_states.rb +26 -0
- data/lib/nucleus/core/enums/logfile_types.rb +28 -0
- data/lib/nucleus/core/error_messages.rb +127 -0
- data/lib/nucleus/core/errors/adapter_error.rb +13 -0
- data/lib/nucleus/core/errors/adapter_missing_implementation_error.rb +12 -0
- data/lib/nucleus/core/errors/adapter_request_error.rb +10 -0
- data/lib/nucleus/core/errors/adapter_resource_not_found_error.rb +10 -0
- data/lib/nucleus/core/errors/endpoint_authentication_error.rb +10 -0
- data/lib/nucleus/core/errors/platform_specific_semantic_error.rb +12 -0
- data/lib/nucleus/core/errors/platform_timeout_error.rb +10 -0
- data/lib/nucleus/core/errors/platform_unavailable_error.rb +10 -0
- data/lib/nucleus/core/errors/semantic_adapter_request_error.rb +19 -0
- data/lib/nucleus/core/errors/unknown_adapter_call_error.rb +10 -0
- data/lib/nucleus/core/file_handling/archive_converter.rb +29 -0
- data/lib/nucleus/core/file_handling/file_manager.rb +64 -0
- data/lib/nucleus/core/file_handling/git_deployer.rb +133 -0
- data/lib/nucleus/core/file_handling/git_repo_analyzer.rb +23 -0
- data/lib/nucleus/core/import/adapter_configuration.rb +53 -0
- data/lib/nucleus/core/import/vendor_parser.rb +28 -0
- data/lib/nucleus/core/import/version_detector.rb +18 -0
- data/lib/nucleus/core/models/abstract_model.rb +29 -0
- data/lib/nucleus/core/models/endpoint.rb +30 -0
- data/lib/nucleus/core/models/provider.rb +26 -0
- data/lib/nucleus/core/models/vendor.rb +22 -0
- data/lib/nucleus/ext/kernel.rb +5 -0
- data/lib/nucleus/ext/regexp.rb +49 -0
- data/lib/nucleus/os.rb +15 -0
- data/lib/nucleus/root_dir.rb +13 -0
- data/lib/nucleus/scripts/finalize.rb +8 -0
- data/lib/nucleus/scripts/initialize.rb +9 -0
- data/lib/nucleus/scripts/initialize_config_defaults.rb +26 -0
- data/lib/nucleus/scripts/load.rb +17 -0
- data/lib/nucleus/scripts/load_dependencies.rb +43 -0
- data/lib/nucleus/scripts/setup_config.rb +28 -0
- data/lib/nucleus/scripts/shutdown.rb +11 -0
- data/lib/nucleus/version.rb +3 -0
- data/nucleus.gemspec +88 -0
- data/public/robots.txt +2 -0
- data/public/swagger-ui/css/reset.css +125 -0
- data/public/swagger-ui/css/screen.css +1224 -0
- data/public/swagger-ui/images/apple-touch-icon-114x114.png +0 -0
- data/public/swagger-ui/images/apple-touch-icon-120x120.png +0 -0
- data/public/swagger-ui/images/apple-touch-icon-144x144.png +0 -0
- data/public/swagger-ui/images/apple-touch-icon-152x152.png +0 -0
- data/public/swagger-ui/images/apple-touch-icon-57x57.png +0 -0
- data/public/swagger-ui/images/apple-touch-icon-60x60.png +0 -0
- data/public/swagger-ui/images/apple-touch-icon-72x72.png +0 -0
- data/public/swagger-ui/images/apple-touch-icon-76x76.png +0 -0
- data/public/swagger-ui/images/explorer_icons.png +0 -0
- data/public/swagger-ui/images/favicon-128.png +0 -0
- data/public/swagger-ui/images/favicon-16x16.png +0 -0
- data/public/swagger-ui/images/favicon-196x196.png +0 -0
- data/public/swagger-ui/images/favicon-32x32.png +0 -0
- data/public/swagger-ui/images/favicon-96x96.png +0 -0
- data/public/swagger-ui/images/favicon.ico +0 -0
- data/public/swagger-ui/images/logo_small.png +0 -0
- data/public/swagger-ui/images/mstile-144x144.png +0 -0
- data/public/swagger-ui/images/mstile-150x150.png +0 -0
- data/public/swagger-ui/images/mstile-310x150.png +0 -0
- data/public/swagger-ui/images/mstile-310x310.png +0 -0
- data/public/swagger-ui/images/mstile-70x70.png +0 -0
- data/public/swagger-ui/images/pet_store_api.png +0 -0
- data/public/swagger-ui/images/throbber.gif +0 -0
- data/public/swagger-ui/images/wordnik_api.png +0 -0
- data/public/swagger-ui/index.html +107 -0
- data/public/swagger-ui/lib/backbone-min.js +38 -0
- data/public/swagger-ui/lib/handlebars-1.0.0.js +2278 -0
- data/public/swagger-ui/lib/highlight.7.3.pack.js +1 -0
- data/public/swagger-ui/lib/jquery-1.8.0.min.js +2 -0
- data/public/swagger-ui/lib/jquery.ba-bbq.min.js +18 -0
- data/public/swagger-ui/lib/jquery.slideto.min.js +1 -0
- data/public/swagger-ui/lib/jquery.wiggle.min.js +8 -0
- data/public/swagger-ui/lib/shred.bundle.js +2765 -0
- data/public/swagger-ui/lib/shred/content.js +193 -0
- data/public/swagger-ui/lib/swagger-oauth.js +211 -0
- data/public/swagger-ui/lib/swagger.js +1653 -0
- data/public/swagger-ui/lib/underscore-min.js +32 -0
- data/public/swagger-ui/o2c.html +15 -0
- data/public/swagger-ui/redirect.html +14 -0
- data/public/swagger-ui/swagger-ui.js +2324 -0
- data/public/swagger-ui/swagger-ui.min.js +1 -0
- data/schemas/api.adapter.schema.yml +31 -0
- data/schemas/api.requirements.schema.yml +17 -0
- data/spec/factories/models.rb +61 -0
- data/spec/integration/api/auth_spec.rb +58 -0
- data/spec/integration/api/endpoints_spec.rb +167 -0
- data/spec/integration/api/errors_spec.rb +47 -0
- data/spec/integration/api/providers_spec.rb +157 -0
- data/spec/integration/api/swagger_schema_spec.rb +64 -0
- data/spec/integration/api/vendors_spec.rb +45 -0
- data/spec/integration/integration_spec_helper.rb +27 -0
- data/spec/integration/test_data_generator.rb +55 -0
- data/spec/nucleus_git_key.pem +51 -0
- data/spec/spec_helper.rb +98 -0
- data/spec/support/shared_example_request_types.rb +99 -0
- data/spec/test_suites.rake +31 -0
- data/spec/unit/adapters/archive_converter_spec.rb +25 -0
- data/spec/unit/adapters/file_manager_spec.rb +93 -0
- data/spec/unit/adapters/git_deployer_spec.rb +262 -0
- data/spec/unit/adapters/v1/stub_spec.rb +14 -0
- data/spec/unit/common/helpers/auth_helper_spec.rb +73 -0
- data/spec/unit/common/oauth2_auth_client_spec.rb +108 -0
- data/spec/unit/common/regexp_spec.rb +33 -0
- data/spec/unit/common/request_log_formatter_spec.rb +108 -0
- data/spec/unit/common/thread_config_accessor_spec.rb +97 -0
- data/spec/unit/models/endpoint_spec.rb +83 -0
- data/spec/unit/models/provider_spec.rb +102 -0
- data/spec/unit/models/vendor_spec.rb +100 -0
- data/spec/unit/schemas/adapter_schema_spec.rb +16 -0
- data/spec/unit/schemas/adapter_validation_spec.rb +56 -0
- data/spec/unit/schemas/requirements_schema_spec.rb +16 -0
- data/spec/unit/unit_spec_helper.rb +11 -0
- data/tasks/compatibility.rake +113 -0
- data/tasks/evaluation.rake +162 -0
- data/wiki/adapter_tests.md +99 -0
- data/wiki/implement_new_adapter.md +155 -0
- metadata +836 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Nucleus
|
|
2
|
+
module VersionDetector
|
|
3
|
+
# Get all abstraction layer versions that are included in the project via the adapters.
|
|
4
|
+
# The abstraction layer versions are identified by the presence of a directory below 'adapters/'.
|
|
5
|
+
# An abstraction layer's directory will resolve to its version.
|
|
6
|
+
# Therefore, if there is a directory 'adapters/v3', 'v3' will be on of the returned versions.
|
|
7
|
+
# The method caches its detected versions and returns the previous result if called multiple times.
|
|
8
|
+
#
|
|
9
|
+
# @return [Array<String>] names of the abstraction layer versions
|
|
10
|
+
def self.api_versions
|
|
11
|
+
return @api_versions if @api_versions
|
|
12
|
+
abstraction_layer_api_versions_dir = "#{Nucleus.root}/lib/nucleus/adapters/*"
|
|
13
|
+
@api_versions = Dir.glob(abstraction_layer_api_versions_dir).map do |f|
|
|
14
|
+
File.basename(f) if File.directory?(f)
|
|
15
|
+
end.compact
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Nucleus
|
|
2
|
+
#
|
|
3
|
+
# @author Cedric Roeck (cedric.roeck@gmail.com)
|
|
4
|
+
# @since 0.1.0
|
|
5
|
+
class AbstractModel
|
|
6
|
+
include Kwalify::Util::HashLike
|
|
7
|
+
|
|
8
|
+
attr_accessor :id
|
|
9
|
+
attr_accessor :name
|
|
10
|
+
attr_accessor :created_at
|
|
11
|
+
attr_accessor :updated_at
|
|
12
|
+
|
|
13
|
+
def initialize(hash = nil)
|
|
14
|
+
return if hash.nil?
|
|
15
|
+
@name = hash['name']
|
|
16
|
+
@id = hash['id']
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_s
|
|
20
|
+
return name if self.respond_to?('name')
|
|
21
|
+
return id if id
|
|
22
|
+
super.to_s
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def inspect
|
|
26
|
+
to_s
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Nucleus
|
|
2
|
+
# The {Endpoint} model will initially be imported from +.yaml+ description files and shall be persisted
|
|
3
|
+
# in the {Nucleus::DB::Store store}. The endpoint has the following properties:<br>
|
|
4
|
+
# * id (String)
|
|
5
|
+
# * name (String)
|
|
6
|
+
# * provider (Nucleus::Provider)
|
|
7
|
+
# * url (String)
|
|
8
|
+
# * app_domain (String)
|
|
9
|
+
# * trust (Boolean)
|
|
10
|
+
#
|
|
11
|
+
# @author Cedric Roeck (cedric.roeck@gmail.com)
|
|
12
|
+
# @since 0.1.0
|
|
13
|
+
class Endpoint < Nucleus::AbstractModel
|
|
14
|
+
include Kwalify::Util::HashLike
|
|
15
|
+
|
|
16
|
+
attr_accessor :provider
|
|
17
|
+
attr_accessor :url # str
|
|
18
|
+
attr_accessor :app_domain # str
|
|
19
|
+
attr_accessor :trust # bool
|
|
20
|
+
|
|
21
|
+
def initialize(hash = nil)
|
|
22
|
+
super(hash)
|
|
23
|
+
@trust = false
|
|
24
|
+
return if hash.nil?
|
|
25
|
+
@url = hash['url']
|
|
26
|
+
@app_domain = hash['app_domain']
|
|
27
|
+
@trust = hash['trust'] if hash.key?('trust')
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Nucleus
|
|
2
|
+
# The {Provider} model will initially be imported from +.yaml+ description files and shall be persisted
|
|
3
|
+
# in the {Nucleus::DB::Store store}. The provider has the following properties:<br>
|
|
4
|
+
# * id (String)
|
|
5
|
+
# * name (String)
|
|
6
|
+
# * vendor (Nucleus::Vendor)
|
|
7
|
+
# * endpoints (Array<Nucleus::Endpoint>)
|
|
8
|
+
#
|
|
9
|
+
# @author Cedric Roeck (cedric.roeck@gmail.com)
|
|
10
|
+
# @since 0.1.0
|
|
11
|
+
class Provider < Nucleus::AbstractModel
|
|
12
|
+
include Kwalify::Util::HashLike
|
|
13
|
+
|
|
14
|
+
attr_accessor :vendor
|
|
15
|
+
attr_accessor :endpoints # seq
|
|
16
|
+
|
|
17
|
+
def initialize(hash = nil)
|
|
18
|
+
super(hash)
|
|
19
|
+
@endpoints = []
|
|
20
|
+
return if hash.nil?
|
|
21
|
+
|
|
22
|
+
return unless hash.key?('endpoints')
|
|
23
|
+
@endpoints = hash['endpoints'].map! { |e| e.is_a?(Nucleus::Endpoint) ? e : Nucleus::Endpoint.new(e) }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Nucleus
|
|
2
|
+
# The {Vendor} model will initially be imported from +.yaml+ description files and shall be persisted
|
|
3
|
+
# in the {Nucleus::DB::Store store}. The vendor has the following properties:<br>
|
|
4
|
+
# * id (String)
|
|
5
|
+
# * name (String)
|
|
6
|
+
# * providers (Array<Nucleus::Provider>)
|
|
7
|
+
#
|
|
8
|
+
# @author Cedric Roeck (cedric.roeck@gmail.com)
|
|
9
|
+
# @since 0.1.0
|
|
10
|
+
class Vendor < Nucleus::AbstractModel
|
|
11
|
+
attr_accessor :providers # seq
|
|
12
|
+
|
|
13
|
+
def initialize(hash = nil)
|
|
14
|
+
super(hash)
|
|
15
|
+
@providers = []
|
|
16
|
+
return if hash.nil?
|
|
17
|
+
|
|
18
|
+
return unless hash.key?('providers')
|
|
19
|
+
@providers = hash['providers'].map! { |e| e.is_a?(Nucleus::Provider) ? e : Nucleus::Provider.new(e) }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
class Regexp
|
|
2
|
+
PERFECT_URL_PATTERN = %r{
|
|
3
|
+
\A
|
|
4
|
+
|
|
5
|
+
# protocol identifier
|
|
6
|
+
(?:(?:https?|ftp)://)
|
|
7
|
+
|
|
8
|
+
# user:pass authentication
|
|
9
|
+
(?:\S+(?::\S*)?@)?
|
|
10
|
+
|
|
11
|
+
(?:
|
|
12
|
+
# IP address exclusion
|
|
13
|
+
# private & local networks
|
|
14
|
+
(?!10(?:\.\d{1,3}){3})
|
|
15
|
+
(?!127(?:\.\d{1,3}){3})
|
|
16
|
+
(?!169\.254(?:\.\d{1,3}){2})
|
|
17
|
+
(?!192\.168(?:\.\d{1,3}){2})
|
|
18
|
+
(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})
|
|
19
|
+
|
|
20
|
+
# IP address dotted notation octets
|
|
21
|
+
# excludes loopback network 0.0.0.0
|
|
22
|
+
# excludes reserved space >= 224.0.0.0
|
|
23
|
+
# excludes network & broacast addresses
|
|
24
|
+
# (first & last IP address of each class)
|
|
25
|
+
(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])
|
|
26
|
+
(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}
|
|
27
|
+
(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))
|
|
28
|
+
|
|
|
29
|
+
# host name
|
|
30
|
+
(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)
|
|
31
|
+
|
|
32
|
+
# domain name
|
|
33
|
+
(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*
|
|
34
|
+
|
|
35
|
+
# TLD identifier
|
|
36
|
+
(?:\.(?:[a-z\u00a1-\uffff]{2,}))
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
# port number
|
|
40
|
+
(?::\d{2,5})?
|
|
41
|
+
|
|
42
|
+
# resource path
|
|
43
|
+
(?:/[^\s]*)?
|
|
44
|
+
|
|
45
|
+
\z
|
|
46
|
+
}xi
|
|
47
|
+
|
|
48
|
+
UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
|
|
49
|
+
end
|
data/lib/nucleus/os.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Operating System module to detect the current platform
|
|
2
|
+
# From: http://stackoverflow.com/questions/170956/how-can-i-find-which-operating-system-my-ruby-program-is-running-on
|
|
3
|
+
module OS
|
|
4
|
+
# Is the current platform windows?
|
|
5
|
+
# @return [Boolean] true if on windows, else false
|
|
6
|
+
def self.windows?
|
|
7
|
+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Is the current platform Unix?
|
|
11
|
+
# @return [Boolean] true if on Unix, else false
|
|
12
|
+
def self.unix?
|
|
13
|
+
!OS.windows?
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Nucleus
|
|
2
|
+
# Return the project's root directory.
|
|
3
|
+
# @return [Path] project's root directory
|
|
4
|
+
def self.root
|
|
5
|
+
File.join(__dir__, '..', '..')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# Return the project's main source code directory 'lib/nucleus''.
|
|
9
|
+
# @return [Path] project's main source code directory
|
|
10
|
+
def self.src
|
|
11
|
+
File.join(Nucleus.root, '/lib/nucleus')
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Lock the configuration, so it can't be manipulated
|
|
2
|
+
nucleus_config.lock!
|
|
3
|
+
|
|
4
|
+
puts "Rack environment: #{ENV['RACK_ENV']}" if ENV.key?('RACK_ENV')
|
|
5
|
+
puts 'Configuration locked!'
|
|
6
|
+
|
|
7
|
+
puts 'Initialization complete'
|
|
8
|
+
puts '-----------------------------------------------'
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Check the API versions once and make them available via configatron
|
|
2
|
+
nucleus_config.api.versions = Nucleus::VersionDetector.api_versions
|
|
3
|
+
|
|
4
|
+
# make sure the key is always set
|
|
5
|
+
key_file = nil
|
|
6
|
+
if nucleus_config.ssh.key?(:custom_key) && !nucleus_config.ssh.custom_key.nil?
|
|
7
|
+
puts "Loading custom SSH key #{nucleus_config.ssh.custom_key}"
|
|
8
|
+
# use the custom key file
|
|
9
|
+
key_file = nucleus_config.ssh.custom_key
|
|
10
|
+
|
|
11
|
+
# fail if file does not exist
|
|
12
|
+
unless File.exist?(key_file)
|
|
13
|
+
msg = "Could not find the SSH key: '#{key_file}'"
|
|
14
|
+
STDERR.puts msg
|
|
15
|
+
fail Nucleus::StartupError.new(msg, Nucleus::ExitCodes::INVALID_SSH_KEY_FILE)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
if File.read(key_file).include?('ENCRYPTED')
|
|
19
|
+
msg = "Provided private key '#{key_file}' must not be protected with a passphrase."
|
|
20
|
+
STDERR.puts msg
|
|
21
|
+
fail Nucleus::StartupError.new(msg, Nucleus::ExitCodes::INVALID_SSH_KEY_FILE_PROTECTED)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# now setup the SSHHandler
|
|
26
|
+
nucleus_config.ssh.handler = Nucleus::SSHHandler.new(key_file)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# First, load 3rd party dependencies
|
|
2
|
+
require_relative 'load_dependencies'
|
|
3
|
+
|
|
4
|
+
# require all patched classes
|
|
5
|
+
require_rel '../ext'
|
|
6
|
+
|
|
7
|
+
# OS detection
|
|
8
|
+
require 'nucleus/os'
|
|
9
|
+
|
|
10
|
+
# Root directory convenience module
|
|
11
|
+
require 'nucleus/root_dir'
|
|
12
|
+
|
|
13
|
+
# core
|
|
14
|
+
require_rel '../core'
|
|
15
|
+
|
|
16
|
+
# adapters
|
|
17
|
+
require_rel '../adapters'
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require 'require_all'
|
|
2
|
+
|
|
3
|
+
# actually more native
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require 'find'
|
|
6
|
+
require 'time'
|
|
7
|
+
require 'securerandom'
|
|
8
|
+
require 'logger'
|
|
9
|
+
|
|
10
|
+
# database
|
|
11
|
+
require 'moneta'
|
|
12
|
+
require 'daybreak'
|
|
13
|
+
require 'lmdb'
|
|
14
|
+
|
|
15
|
+
# schema
|
|
16
|
+
require 'kwalify'
|
|
17
|
+
|
|
18
|
+
# serialization
|
|
19
|
+
require 'oj'
|
|
20
|
+
|
|
21
|
+
# SSH keys
|
|
22
|
+
require 'sshkey'
|
|
23
|
+
|
|
24
|
+
# Http clients, ...
|
|
25
|
+
# Currently we need excon AND rest_client, due to excon not supporting multipart requests. See also:
|
|
26
|
+
# https://github.com/excon/excon/issues/353
|
|
27
|
+
require 'excon'
|
|
28
|
+
require 'rest_client'
|
|
29
|
+
# faye is used to fetch logs from cloud foundry, using websocket communication
|
|
30
|
+
require 'faye/websocket'
|
|
31
|
+
require 'protobuf'
|
|
32
|
+
require 'eventmachine'
|
|
33
|
+
require 'em-http'
|
|
34
|
+
|
|
35
|
+
# others
|
|
36
|
+
require 'request_store'
|
|
37
|
+
require 'git'
|
|
38
|
+
require 'mime-types'
|
|
39
|
+
|
|
40
|
+
# require archive dependencies
|
|
41
|
+
require 'zip'
|
|
42
|
+
require 'zlib'
|
|
43
|
+
require 'rubygems/package'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# configuration
|
|
2
|
+
require 'logger'
|
|
3
|
+
require 'configatron/core'
|
|
4
|
+
require 'nucleus/ext/kernel'
|
|
5
|
+
require 'nucleus/os'
|
|
6
|
+
|
|
7
|
+
# import the configuration file that resides in the user's home directory as initial choice
|
|
8
|
+
if OS.windows?
|
|
9
|
+
home_dir_config = File.expand_path(File.join(Dir.home, 'nucleus', 'nucleus_config.rb'))
|
|
10
|
+
else
|
|
11
|
+
home_dir_config = File.expand_path(File.join(Dir.home, '.nucleus', 'nucleus_config.rb'))
|
|
12
|
+
end
|
|
13
|
+
if File.exist?(home_dir_config)
|
|
14
|
+
puts "Applying configuration from: #{home_dir_config}"
|
|
15
|
+
require home_dir_config
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# include the configuration of the project to overwrite the home dir config
|
|
19
|
+
project_dir_config = '../../../config/nucleus_config.rb'
|
|
20
|
+
if File.exist?(File.expand_path(project_dir_config, File.dirname(__FILE__)))
|
|
21
|
+
puts "Applying configuration from: #{File.expand_path(project_dir_config, File.dirname(__FILE__))}"
|
|
22
|
+
require_relative project_dir_config
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# make sure we have a logging directory
|
|
26
|
+
unless nucleus_config.logging.key?(:path)
|
|
27
|
+
nucleus_config.logging.path = File.join(__dir__, '..', '..', '..', 'log')
|
|
28
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Implement shutdown actions, tidy up the DB
|
|
2
|
+
at_exit do
|
|
3
|
+
puts '-----------------------------------------------', ''
|
|
4
|
+
puts 'Cleaning up...'
|
|
5
|
+
|
|
6
|
+
# delete the SSHHandler generated files
|
|
7
|
+
puts '... delete SSH files ...'
|
|
8
|
+
nucleus_config.ssh.handler.cleanup if nucleus_config.key?(:ssh) && nucleus_config.ssh.key?(:handler)
|
|
9
|
+
|
|
10
|
+
puts '... done!'
|
|
11
|
+
end
|
data/nucleus.gemspec
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
|
3
|
+
require 'nucleus/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'nucleus'
|
|
7
|
+
spec.version = Nucleus::VERSION
|
|
8
|
+
spec.authors = ['Stefan Kolb', 'Cedric Röck']
|
|
9
|
+
spec.email = ['stefan.kolb@uni-bamberg.de']
|
|
10
|
+
spec.summary = 'Nucleus unifies core management functions of Platform-as-a-Service (PaaS) systems.'
|
|
11
|
+
spec.description = 'Nucleus is a unified API for deployment and management of '\
|
|
12
|
+
'Platform-as-a-Service (PaaS) systems.'
|
|
13
|
+
spec.homepage = 'https://github.com/stefan-kolb/nucleus'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
spec.executables = 'nucleus'
|
|
16
|
+
spec.require_paths = ['lib']
|
|
17
|
+
spec.required_ruby_version = '>= 2.0'
|
|
18
|
+
|
|
19
|
+
# we ignore the test files and icons as they tremendously increase the gem size (up to 43MB)
|
|
20
|
+
spec.files = `git ls-files -z --exclude-standard`.split("\x0").reject do |f|
|
|
21
|
+
f[%r{^(lib/nucleus_api|spec/adapter|icons)/}]
|
|
22
|
+
end
|
|
23
|
+
# again only unit and integration, but no adapter test files
|
|
24
|
+
spec.test_files = spec.files.grep(%r{^(spec)/})
|
|
25
|
+
|
|
26
|
+
# used as global configuration
|
|
27
|
+
spec.add_runtime_dependency 'configatron', '~> 4.5'
|
|
28
|
+
# DB store (1)
|
|
29
|
+
spec.add_runtime_dependency 'daybreak', '~> 0.3'
|
|
30
|
+
# Required for log tailing against HTTP endpoints
|
|
31
|
+
spec.add_runtime_dependency 'em-http-request', '~> 1.1'
|
|
32
|
+
# Used as main HTTP / REST client
|
|
33
|
+
spec.add_runtime_dependency 'excon', '~> 0.44'
|
|
34
|
+
# Required for log tailing against websockets
|
|
35
|
+
spec.add_runtime_dependency 'faye-websocket', '~> 0.9'
|
|
36
|
+
# Application data handling
|
|
37
|
+
spec.add_runtime_dependency 'git', '~> 1.2'
|
|
38
|
+
# Used to build the API
|
|
39
|
+
spec.add_runtime_dependency 'grape', '~> 0.12'
|
|
40
|
+
spec.add_runtime_dependency 'grape-entity', '~> 0.4', '>= 0.4.5'
|
|
41
|
+
# Used to document the API
|
|
42
|
+
spec.add_runtime_dependency 'grape-swagger', '~> 0.10', '>= 0.10.1'
|
|
43
|
+
# Used to import the vendor, provider & adapter setup from configuration with schema validation
|
|
44
|
+
spec.add_runtime_dependency 'kwalify', '~> 0.7'
|
|
45
|
+
# DB store (2)
|
|
46
|
+
spec.add_runtime_dependency 'lmdb', '~> 0.4'
|
|
47
|
+
# Logging
|
|
48
|
+
spec.add_runtime_dependency 'logger', '~> 1.2'
|
|
49
|
+
# Application archive handling, detect unsupported uploads
|
|
50
|
+
spec.add_runtime_dependency 'mime-types', '~> 2.4'
|
|
51
|
+
# Generic interface for DB store implementations
|
|
52
|
+
spec.add_runtime_dependency 'moneta', '~> 0.8'
|
|
53
|
+
# Openshift logging access and direct Git SSH requests
|
|
54
|
+
spec.add_runtime_dependency 'net-ssh', '~> 3.0'
|
|
55
|
+
# Used for JSON / Hash conversion and test cassette serialization (is way faster than other JSON libs)
|
|
56
|
+
spec.add_runtime_dependency 'oj', '~> 2.12'
|
|
57
|
+
# Required for Cloud Foundry log messages
|
|
58
|
+
spec.add_runtime_dependency 'protobuf', '~> 3.4'
|
|
59
|
+
# To make sure HTTPS is used instead of HTTP
|
|
60
|
+
spec.add_runtime_dependency 'rack-ssl-enforcer', '~> 0.2', '>= 0.2.8'
|
|
61
|
+
# TODO: Should be removed as soon as excon supports multipart requests
|
|
62
|
+
spec.add_runtime_dependency 'rest-client', '~> 1.8'
|
|
63
|
+
# Used to build a streaming API for the log tail action
|
|
64
|
+
spec.add_runtime_dependency 'rack-stream', '= 0.0.5'
|
|
65
|
+
# Save certain information for the current request, e.g. the already loaded adapter
|
|
66
|
+
spec.add_runtime_dependency 'request_store', '~> 1.1'
|
|
67
|
+
# Application setup, require libs
|
|
68
|
+
spec.add_runtime_dependency 'require_all', '~> 1.3'
|
|
69
|
+
# Application data handling
|
|
70
|
+
spec.add_runtime_dependency 'rubyzip', '~> 1.1'
|
|
71
|
+
# Application data handling when using git deployment
|
|
72
|
+
spec.add_runtime_dependency 'sshkey', '~> 1.7'
|
|
73
|
+
# The ONLY supported server ATM
|
|
74
|
+
spec.add_runtime_dependency 'thin', '~> 1.6'
|
|
75
|
+
|
|
76
|
+
spec.add_development_dependency 'bundler'
|
|
77
|
+
spec.add_development_dependency 'guard'
|
|
78
|
+
spec.add_development_dependency 'guard-bundler'
|
|
79
|
+
spec.add_development_dependency 'guard-rack'
|
|
80
|
+
spec.add_development_dependency 'guard-rubocop'
|
|
81
|
+
spec.add_development_dependency 'guard-yard'
|
|
82
|
+
spec.add_development_dependency 'inch', '~> 0.7'
|
|
83
|
+
spec.add_development_dependency 'rake', '~> 10.4'
|
|
84
|
+
spec.add_development_dependency 'rubocop', '~> 0.34'
|
|
85
|
+
spec.add_development_dependency 'vcr', '~> 2.9'
|
|
86
|
+
spec.add_development_dependency 'webmock', '~> 1.20'
|
|
87
|
+
spec.add_development_dependency 'yard', '~> 0.8'
|
|
88
|
+
end
|