Skip to content

Commit fdab0a3

Browse files
DMevadanebhale
authored andcommitted
Introscope Agent Manager Credential Property
This change adds an additional, optional, agent manager credential property for the Introscope framework. This property is passed via the service credential payload. [resolves cloudfoundry#559]
1 parent 4446775 commit fdab0a3

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

docs/framework-introscope_agent.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ The credential payload of the service may contain the following entries:
2323

2424
| Name | Description
2525
| ---- | -----------
26-
| `agent-name` | (Optional) The name that should be given to this instance of the Introscope agent
26+
| `agent_name` | (Optional) The name that should be given to this instance of the Introscope agent
27+
| `credential`| (Optional) The credential that is used to connect to the Enterprise Manager server
2728
| `url` | The url of the Introscope Enterprise Manager server
2829

29-
30-
To provide more complex values such as the `agent-name`, using the interactive mode when creating a user-provided service will manage the character escaping automatically. For example, the default `agent-name` could be set with a value of `agent-$(expr "$VCAP_APPLICATION" : '.*application_name[": ]*\([[:word:]]*\).*')` to calculate a value from the Cloud Foundry application name.
30+
To provide more complex values such as the `agent_name`, using the interactive mode when creating a user-provided service will manage the character escaping automatically. For example, the default `agent_name` could be set with a value of `agent-$(expr "$VCAP_APPLICATION" : '.*application_name[": ]*\([[:word:]]*\).*')` to calculate a value from the Cloud Foundry application name.
3131

3232
## Configuration
3333
For general information on configuring the buildpack, including how to specify configuration values through environment variables, refer to [Configuration and Extension][].

lib/java_buildpack/framework/introscope_agent.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def release
4444
.add_system_property('com.wily.introscope.agent.agentName', agent_name(credentials))
4545
.add_system_property('introscope.agent.defaultProcessName', default_process_name)
4646

47+
java_opts.add_system_property('agentManager.credential', credential(credentials)) if credential(credentials)
4748
add_url(credentials, java_opts)
4849
end
4950

@@ -92,7 +93,7 @@ def parse_url(url)
9293
end
9394

9495
def agent_name(credentials)
95-
credentials['agent-name'] || @configuration['default_agent_name']
96+
credentials['agent_name'] || @configuration['default_agent_name']
9697
end
9798

9899
def agent_profile
@@ -119,6 +120,10 @@ def protocol_mapping(protocol)
119120
def url(credentials)
120121
credentials['url']
121122
end
123+
124+
def credential(credentials)
125+
credentials['credential']
126+
end
122127
end
123128
end
124129
end

spec/java_buildpack/framework/introscope_agent_spec.rb

+28-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
end
5757

5858
context do
59-
let(:credentials) { { 'agent-name' => 'another-test-agent-name', 'url' => 'default-host:5001' } }
59+
let(:credentials) { { 'agent_name' => 'another-test-agent-name', 'url' => 'default-host:5001' } }
6060

61-
it 'adds agent-name from credentials to JAVA_OPTS if specified' do
61+
it 'adds agent_name from credentials to JAVA_OPTS if specified' do
6262
component.release
6363

6464
expect(java_opts).to include('-Dcom.wily.introscope.agent.agentName=another-test-agent-name')
@@ -157,5 +157,31 @@
157157
'\'.*application_name[": ]*\\([A-Za-z0-9_-]*\\).*\')')
158158
end
159159
end
160+
161+
context do
162+
let(:credentials) { { 'url' => 'https://test-host-name:8444', 'credential' => 'test-credential-cccf-88-ae' } }
163+
164+
it 'sets the url and also the agent manager credential' do
165+
component.release
166+
167+
expect(java_opts).to include('-javaagent:$PWD/.java-buildpack/introscope_agent/Agent.jar')
168+
expect(java_opts).to include('-Dcom.wily.introscope.agentProfile=$PWD/.java-buildpack/introscope_agent/core' \
169+
'/config/IntroscopeAgent.profile')
170+
expect(java_opts).to include('-Dintroscope.agent.defaultProcessName=test-application-name')
171+
expect(java_opts).to include('-Dintroscope.agent.hostName=test-application-uri-0')
172+
173+
expect(java_opts).to include('-DagentManager.url.1=https://test-host-name:8444')
174+
expect(java_opts).to include('-Dintroscope.agent.enterprisemanager.transport.tcp.host.DEFAULT=test-host-name')
175+
expect(java_opts).to include('-Dintroscope.agent.enterprisemanager.transport.tcp.port.DEFAULT=8444')
176+
expect(java_opts).to include('-Dintroscope.agent.enterprisemanager.transport.tcp.socketfactory.DEFAULT=' \
177+
'com.wily.isengard.postofficehub.link.net.HttpsTunnelingSocketFactory')
178+
179+
expect(java_opts).to include('-Dcom.wily.introscope.agent.agentName=$(expr "$VCAP_APPLICATION" : ' \
180+
'\'.*application_name[": ]*\\([A-Za-z0-9_-]*\\).*\')')
181+
expect(java_opts).to include('-DagentManager.credential=test-credential-cccf-88-ae')
182+
183+
end
184+
end
185+
160186
end
161187
end

0 commit comments

Comments
 (0)