Skip to content

Commit 6b00ecd

Browse files
committed
Polishing
This change includes some minor polishing to match project conventions [#472]
1 parent 02ab527 commit 6b00ecd

File tree

5 files changed

+35
-44
lines changed

5 files changed

+35
-44
lines changed

.idea/dictionaries/bhale.xml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/takipi_agent.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
version: 4.+
1919
repository_root: http://get.takipi.com/cloudfoundry
2020
node_name_prefix: node
21-
application_name:
21+
application_name:

lib/java_buildpack/framework/takipi_agent.rb

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,18 @@ def compile
3434

3535
# (see JavaBuildpack::Component::BaseComponent#release)
3636
def release
37-
java_opts = @droplet.java_opts
38-
java_opts.add_agentpath(@droplet.sandbox + 'lib/libTakipiAgent.so')
39-
application_name java_opts
40-
default_env_vars
41-
credentials = @application.services.find_service(FILTER)['credentials']
42-
config_env_vars credentials
37+
@droplet.java_opts
38+
.add_agentpath(agent)
39+
.add_system_property('takipi.name', application_name)
40+
41+
@droplet.environment_variables
42+
.add_environment_variable('LD_LIBRARY_PATH',
43+
"$LD_LIBRARY_PATH:#{qualify_path(lib, @droplet.root)}")
44+
.add_environment_variable('JVM_LIB_FILE', libjvm)
45+
.add_environment_variable('TAKIPI_HOME', @droplet.sandbox)
46+
.add_environment_variable('TAKIPI_MACHINE_NAME', node_name)
47+
48+
config_env_vars @application.services.find_service(FILTER)['credentials']
4349
end
4450

4551
protected
@@ -51,29 +57,20 @@ def supports?
5157

5258
private
5359

60+
COLLECTOR_HOST = 'collector_host'.freeze
61+
5462
FILTER = /takipi/
5563

5664
SECRET_KEY = 'secret_key'.freeze
5765

58-
COLLECTOR_HOST = 'collector_host'.freeze
66+
private_constant :COLLECTOR_HOST, :FILTER, :SECRET_KEY
5967

60-
private_constant :FILTER
61-
62-
def jvm_lib_file
63-
@droplet.java_home.root + 'lib/amd64/server/libjvm.so'
68+
def agent
69+
@droplet.sandbox + 'lib/libTakipiAgent.so'
6470
end
6571

66-
def default_env_vars
67-
env = @droplet.environment_variables
68-
sandbox = @droplet.sandbox
69-
70-
env.add_environment_variable(
71-
'LD_LIBRARY_PATH',
72-
"$LD_LIBRARY_PATH:#{qualify_path(sandbox + 'lib', @droplet.root)}"
73-
)
74-
env.add_environment_variable('JVM_LIB_FILE', jvm_lib_file)
75-
env.add_environment_variable('TAKIPI_HOME', sandbox)
76-
env.add_environment_variable('TAKIPI_MACHINE_NAME', node_name)
72+
def application_name
73+
@configuration['application_name'] || @application.details['application_name']
7774
end
7875

7976
def config_env_vars(credentials)
@@ -89,9 +86,12 @@ def config_env_vars(credentials)
8986
env.add_environment_variable 'TAKIPI_MASTER_PORT', collector_port if collector_port
9087
end
9188

92-
def application_name(java_opts)
93-
app_name = @configuration['application_name'] || @application.details['application_name']
94-
java_opts.add_system_property('takipi.name', app_name)
89+
def lib
90+
@droplet.sandbox + 'lib'
91+
end
92+
93+
def libjvm
94+
@droplet.java_home.root + 'lib/amd64/server/libjvm.so'
9595
end
9696

9797
def node_name

rakelib/versions_task.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def initialize
8181
'redis_store' => 'Redis Session Store',
8282
'spring_auto_reconfiguration' => 'Spring Auto-reconfiguration',
8383
'spring_boot_cli' => 'Spring Boot CLI',
84+
'takipi_agent' => 'Takipi Agent',
8485
'tomcat' => 'Tomcat',
8586
'your_kit_profiler' => 'YourKit Profiler'
8687
}.freeze

spec/java_buildpack/framework/takipi_agent_spec.rb

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@
1616
require 'spec_helper'
1717
require 'component_helper'
1818
require 'java_buildpack/framework/takipi_agent'
19-
require 'java_buildpack/util/find_single_directory'
2019

2120
describe JavaBuildpack::Framework::TakipiAgent do
2221
include_context 'component_helper'
2322

24-
let(:configuration) do
25-
{
26-
'node_name_prefix' => nil
27-
}
28-
end
23+
let(:configuration) { { 'node_name_prefix' => nil } }
2924

3025
it 'does not detect without takipi-n/a service' do
3126
expect(component.detect).to be_nil
@@ -40,6 +35,10 @@
4035
allow(services).to receive(:find_service).and_return('credentials' => credentials)
4136
end
4237

38+
it 'detects with takipi service' do
39+
expect(component.detect).to eq("takipi-agent=#{version}")
40+
end
41+
4342
it 'expands Takipi agent tarball',
4443
cache_fixture: 'stub-takipi-agent.tar.gz' do
4544

@@ -48,14 +47,6 @@
4847
expect(sandbox + 'lib/libTakipiAgent.so').to exist
4948
end
5049

51-
it 'preserves find_single_directory results',
52-
cache_fixture: 'stub-takipi-agent.tar.gz',
53-
app_fixture: 'container_play_2.1_dist' do
54-
component.compile
55-
component.send(:extend, JavaBuildpack::Util)
56-
expect(component.send(:find_single_directory)).not_to be_nil
57-
end
58-
5950
context do
6051
let(:credentials) { { 'collector_host' => 'test-host' } }
6152

@@ -86,10 +77,7 @@
8677

8778
context 'configuration overrides' do
8879

89-
let(:configuration) do
90-
{ 'node_name_prefix' => 'test-name',
91-
'application_name' => 'test-name' }
92-
end
80+
let(:configuration) { { 'node_name_prefix' => 'test-name', 'application_name' => 'test-name' } }
9381

9482
it 'update application name' do
9583
component.release

0 commit comments

Comments
 (0)