Skip to content

Commit c91a11a

Browse files
authored
Merge pull request #840 from vchrisb/appd_conf_dir
add option to override AppDynamics config from artifact
2 parents fbda426 + 36f9157 commit c91a11a

File tree

4 files changed

+779
-2
lines changed

4 files changed

+779
-2
lines changed

lib/java_buildpack/framework/app_dynamics_agent.rb

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def compile
3939
default_conf_dir = resources_dir + @droplet.component_id + 'defaults'
4040

4141
copy_appd_default_configuration(default_conf_dir)
42-
override_default_config_if_applicable
42+
override_default_config_remote
43+
override_default_config_local
4344
@droplet.copy_resources
4445
end
4546

@@ -169,7 +170,7 @@ def check_if_resource_exists(resource_uri, conf_file)
169170

170171
# Check for configuration files on a remote server. If found, copy to conf dir under each ver* dir
171172
# @return [Void]
172-
def override_default_config_if_applicable
173+
def override_default_config_remote
173174
return unless @application.environment['APPD_CONF_HTTP_URL']
174175

175176
JavaBuildpack::Util::Cache::InternetAvailability.instance.available(
@@ -194,6 +195,27 @@ def override_default_config_if_applicable
194195
end
195196
end
196197
end
198+
199+
# Check for configuration files locally. If found, copy to conf dir under each ver* dir
200+
# @return [Void]
201+
def override_default_config_local
202+
return unless @application.environment['APPD_CONF_DIR']
203+
204+
app_conf_dir = @application.root + @application.environment['APPD_CONF_DIR']
205+
206+
raise "AppDynamics configuration source dir #{app_conf_dir} does not exist" unless Dir.exist?(app_conf_dir)
207+
208+
@logger.info { "Copy override configuration files from #{app_conf_dir}" }
209+
CONFIG_FILES.each do |conf_file|
210+
conf_file_path = app_conf_dir + conf_file
211+
212+
next unless File.file?(conf_file_path)
213+
214+
Dir.glob(@droplet.sandbox + 'ver*') do |target_directory|
215+
FileUtils.cp_r conf_file_path, target_directory + '/conf/' + conf_file
216+
end
217+
end
218+
end
197219
end
198220
end
199221
end

0 commit comments

Comments
 (0)