Module: Nucleus::Adapters

Extended by:
Logging
Defined in:
lib/nucleus/adapters/base_adapter.rb,
lib/nucleus/adapters/v1/heroku/data.rb,
lib/nucleus/adapters/v1/heroku/logs.rb,
lib/nucleus/adapters/v1/heroku/vars.rb,
lib/nucleus/adapters/v1/stub_adapter.rb,
lib/nucleus/adapters/v1/heroku/heroku.rb,
lib/nucleus/adapters/v1/heroku/domains.rb,
lib/nucleus/adapters/v1/heroku/regions.rb,
lib/nucleus/adapters/v1/heroku/scaling.rb,
lib/nucleus/adapters/v1/heroku/services.rb,
lib/nucleus/adapters/v1/heroku/lifecycle.rb,
lib/nucleus/adapters/buildpack_translator.rb,
lib/nucleus/adapters/v1/heroku/app_states.rb,
lib/nucleus/adapters/v1/heroku/buildpacks.rb,
lib/nucleus/adapters/v1/openshift_v2/data.rb,
lib/nucleus/adapters/v1/openshift_v2/logs.rb,
lib/nucleus/adapters/v1/openshift_v2/vars.rb,
lib/nucleus/adapters/v1/cloud_control/data.rb,
lib/nucleus/adapters/v1/cloud_control/logs.rb,
lib/nucleus/adapters/v1/cloud_control/vars.rb,
lib/nucleus/adapters/v1/heroku/application.rb,
lib/nucleus/adapters/v1/cloud_control/token.rb,
lib/nucleus/core/file_handling/file_manager.rb,
lib/nucleus/core/file_handling/git_deployer.rb,
lib/nucleus/adapters/v1/openshift_v2/domains.rb,
lib/nucleus/adapters/v1/openshift_v2/regions.rb,
lib/nucleus/adapters/v1/openshift_v2/scaling.rb,
lib/nucleus/adapters/v1/cloud_control/domains.rb,
lib/nucleus/adapters/v1/cloud_control/regions.rb,
lib/nucleus/adapters/v1/cloud_control/scaling.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/data.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/logs.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/vars.rb,
lib/nucleus/adapters/v1/heroku/authentication.rb,
lib/nucleus/adapters/v1/openshift_v2/services.rb,
lib/nucleus/core/import/adapter_configuration.rb,
lib/nucleus/adapters/v1/cloud_control/services.rb,
lib/nucleus/adapters/v1/heroku/semantic_errors.rb,
lib/nucleus/adapters/v1/openshift_v2/lifecycle.rb,
lib/nucleus/adapters/v1/cloud_control/lifecycle.rb,
lib/nucleus/adapters/v1/openshift_v2/app_states.rb,
lib/nucleus/core/adapter_extensions/http_client.rb,
lib/nucleus/adapters/v1/cloud_control/buildpacks.rb,
lib/nucleus/adapters/v1/cloud_control/log_poller.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/domains.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/regions.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/scaling.rb,
lib/nucleus/adapters/v1/openshift_v2/application.rb,
lib/nucleus/core/adapter_extensions/tail_stopper.rb,
lib/nucleus/core/file_handling/archive_converter.rb,
lib/nucleus/core/file_handling/git_repo_analyzer.rb,
lib/nucleus/adapters/v1/cloud_control/application.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/services.rb,
lib/nucleus/adapters/v1/openshift_v2/openshift_v2.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/lifecycle.rb,
lib/nucleus/adapters/v1/cloud_control/cloud_control.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/app_states.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/buildpacks.rb,
lib/nucleus/adapters/v1/openshift_v2/authentication.rb,
lib/nucleus/adapters/v1/cloud_control/authentication.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/application.rb,
lib/nucleus/adapters/v1/openshift_v2/semantic_errors.rb,
lib/nucleus/core/adapter_extensions/auth/auth_client.rb,
lib/nucleus/core/adapter_extensions/http_tail_client.rb,
lib/nucleus/adapters/v1/cloud_control/semantic_errors.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/authentication.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/semantic_errors.rb,
lib/nucleus/adapters/v1/cloud_foundry_v2/cloud_foundry_v2.rb,
lib/nucleus/core/adapter_extensions/auth/token_auth_client.rb,
lib/nucleus/core/adapter_extensions/auth/o_auth2_auth_client.rb,
lib/nucleus/core/adapter_extensions/auth/http_basic_auth_client.rb,
lib/nucleus/core/adapter_extensions/auth/expiring_token_auth_client.rb,
lib/nucleus/core/adapter_extensions/auth/authentication_retry_wrapper.rb

Overview

The Adapters module combines all application logic to communicate with the different vendor platforms and created the unified API.

Defined Under Namespace

Modules: ArchiveConverter, AuthenticationRetryWrapper, BuildpackTranslator, FileManager, GitRepoAnalyzer, HttpClient, HttpTailClient, V1 Classes: AuthClient, BaseAdapter, ExpiringTokenAuthClient, GitDeployer, HttpBasicAuthClient, OAuth2AuthClient, TailStopper, TokenAuthClient

Class Method Summary collapse

Methods included from Logging

configure_logger_for, log, logger_for

Class Method Details

.adapter_clazz(adapter_config, api_version) ⇒ String

Get the clazz to the adapter file that matches the adapter_config and api_version.

Parameters:

  • adapter_config (String)

    adapter configuration that indicates the adapter’s name

  • api_version (String)

    API version to load the adapter for

Returns:

  • (String)

    clazz name of the adapter



25
26
27
28
29
30
31
# File 'lib/nucleus/core/import/adapter_configuration.rb', line 25

def self.adapter_clazz(adapter_config, api_version)
  adapter_file = adapter_file(adapter_config, api_version)
  return if adapter_file.nil?
  # transform path to clazz and load an instance
  adapter_clazz = "Nucleus::Adapters::#{api_version.upcase}::#{File.basename(adapter_file, '.rb').capitalize}"
  adapter_clazz.camelize.split('::').inject(Object) { |a, e| a.const_get e }
end

.adapter_file(adapter_config, api_version) ⇒ String

Get the path to the adapter’s class file by translation from the adapter configuration’s name. If the adapter configuration is called ‘abc-vendor.yml’, then the adapter’s source file must be found below app/adapters/#{api_version}/ with the name abc-vendor_adapter.rb.

Parameters:

  • adapter_config (String)

    adapter configuration that indicates the adapter’s name

  • api_version (String)

    API version to load the adapter for

Returns:

  • (String)

    path to the adapter’s class file

Raises:



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/nucleus/core/import/adapter_configuration.rb', line 41

def self.adapter_file(adapter_config, api_version)
  log.debug "... trying to resolve adapter for config #{adapter_config} and API #{api_version}..."
  adapter_name = File.basename(adapter_config).sub(/.[^.]+\z/, '.rb')
  file_search_path = "#{Nucleus.root}/lib/nucleus/adapters/#{api_version}/*/#{adapter_name}"
  adapter_file = Dir.glob(file_search_path)
  fail AmbiguousAdapterError, "More than 1 adapter file found for #{adapter_name}" unless adapter_file.size <= 1

  return if adapter_file.empty?
  log.debug "... found '#{adapter_file.first}'"
  adapter_file.first
end

.configuration_filesArray<File>

Get all adapter configuration files that are included in the application. The config files must be located at the config/adapters directory.

Returns:

  • (Array<File>)

    all adapter configuration files



9
10
11
12
13
14
15
16
17
18
# File 'lib/nucleus/core/import/adapter_configuration.rb', line 9

def self.configuration_files
  return @configuration_files if @configuration_files
  adapter_dir = "#{Nucleus.root}/config/adapters"
  files = Dir[File.join(adapter_dir, '*.yml')] | Dir[File.join(adapter_dir, '*.yaml')]
  files = files.flatten.compact
  files.collect! { |file| File.expand_path(file) }
  log.debug "... found #{files.size} adapter config file(s)"
  @configuration_files = files
  @configuration_files
end