This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathglobal_instrumentation_builder.rb
63 lines (56 loc) · 2.6 KB
/
global_instrumentation_builder.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require './src/common/install/definitions/install_definition'
require './src/install/install_definitions/builder'
require "./src/common/logger/logger_factory"
module Install
module InstallDefinitions
class GlobalInstrumentationBuilder < Builder
def initialize(context, provisioned_resources)
super(context, provisioned_resources)
end
def build_install_definitions()
install_definitions = []
global_instrumentors = get_global_instrumentors()
Common::Logger::LoggerFactory.get_logger().debug("GlobalInstrumentationBuilder for #{global_instrumentors.length} global instrumentors")
global_instrumentors.each do |global_instrumentor|
Common::Logger::LoggerFactory.get_logger().debug("GlobalInstrumentationBuilder building definitions for global #{global_instrumentor.get_id()}")
instrumentor_install_definition = assemble_install_definition(global_instrumentor)
install_definitions.push(instrumentor_install_definition)
end
return install_definitions
end
private
def assemble_install_definition(instrumentor, params = {})
global_id = instrumentor.get_id()
roles_path = get_roles_path(instrumentor)
yaml_output_path = get_yaml_output_path(instrumentor)
action_vars_lambda = lambda { return get_action_vars(instrumentor, params) }
# Don't forget to pass the global instrumentationn to the install definition
return Common::Install::Definitions::InstallDefinition.new(global_id, nil, get_erb_input_path(), yaml_output_path, roles_path, action_vars_lambda)
end
def get_action_vars(instrumentor, params = {})
tags = @context.get_tags_provider().get_global_tags().to_json()
deployment_name = get_deployment_name()
vars = {}
vars["version"] = instrumentor.get_version()
vars["deployment_name"] = deployment_name
vars["deployment_path"] = get_deployment_path()
vars["tags"] = tags
credential = get_instrumentor_credential(instrumentor)
unless (credential.nil?)
vars = vars.merge(credential.to_h())
end
credential = get_instrumentor_provider_credential(instrumentor)
unless (credential.nil?)
vars = vars.merge(credential.to_h())
end
vars = vars.merge(params)
instrumentor_params = instrumentor.get_params().get_all()
vars = vars.merge(instrumentor_params)
return vars
end
def get_yaml_output_path(instrumentor)
return "#{get_deployment_name()}/global/#{instrumentor.get_id()}"
end
end
end
end