Skip to content

Commit fd50c13

Browse files
author
Daniel Mikusa
authored
Polishing after #893 (#894)
- Remove DynatraceAppmonAgent from the component list. This was missed when AppMon Agent was removed. - Fixes syntax error with missing `end` block - Fixes Rubocop violation for single line if blocks, use `cmd if expr` syntax intead - Adds referenced but missing method to pull the networkzone property from credentials - Adds docs for the networkzone property - Adds a unit test to validate that networkzone is passed in the URL when present in the binding
1 parent 5483a87 commit fd50c13

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

config/components.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ frameworks:
5151
- "JavaBuildpack::Framework::ContrastSecurityAgent"
5252
- "JavaBuildpack::Framework::DatadogJavaagent"
5353
- "JavaBuildpack::Framework::Debug"
54-
- "JavaBuildpack::Framework::DynatraceAppmonAgent"
5554
- "JavaBuildpack::Framework::DynatraceOneAgent"
5655
- "JavaBuildpack::Framework::ElasticApmAgent"
5756
- "JavaBuildpack::Framework::GoogleStackdriverDebugger"

docs/framework-dynatrace_one_agent.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The credential payload of the service may contain the following entries:
2828
| `apitoken` | The token for integrating your Dynatrace environment with Cloud Foundry. You can find it in the deploy Dynatrace section within your environment.
2929
| `apiurl` | (Optional) The base URL of the Dynatrace API. If you are using Dynatrace Managed you will need to set this property to `https://<your-managed-server-url>/e/<environmentId>/api`. If you are using Dynatrace SaaS you don't need to set this property.
3030
| `environmentid` | Your Dynatrace environment ID is the unique identifier of your Dynatrace environment. You can find it in the deploy Dynatrace section within your environment.
31+
| `networkzone` | (Optional) Network zones are Dynatrace entities that represent your network structure. They help you to route the traffic efficiently, avoiding unnecessary traffic across data centers and network regions. Enter the network zone you wish to pass to the server during the OneAgent Download.
3132
| `skiperrors` | (Optional) The errors during agent download are skipped and the injection is disabled. Use this option at your own risk. Possible values are 'true' and 'false'. This option is disabled by default!
3233

3334
## Configuration

lib/java_buildpack/framework/dynatrace_one_agent.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,10 @@ def supports?
112112

113113
def agent_download_url
114114
download_uri = "#{api_base_url(credentials)}/v1/deployment/installer/agent/unix/paas/latest?include=java" \
115-
"&bitness=64" \
115+
'&bitness=64' \
116116
"&Api-Token=#{credentials[APITOKEN]}"
117-
#
118-
# setting networkzone parameter if it's configured
119-
if networkzone?
120-
download_uri += "&networkzone=#{networkzone_value}"
117+
118+
download_uri += "&networkzone=#{networkzone}" if networkzone?
121119

122120
['latest', download_uri]
123121
end
@@ -180,6 +178,10 @@ def expand(file)
180178
end
181179
end
182180

181+
def networkzone
182+
credentials[NETWORKZONE]
183+
end
184+
183185
def networkzone?
184186
credentials.key?(NETWORKZONE)
185187
end
@@ -201,8 +203,6 @@ def unpack_agent(root)
201203
FileUtils.mv(root + 'agent', @droplet.sandbox)
202204
FileUtils.mv(root + 'manifest.json', @droplet.sandbox)
203205
end
204-
205206
end
206-
207207
end
208208
end

spec/java_buildpack/framework/dynatrace_one_agent_spec.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,31 @@
9292

9393
end
9494

95+
context do
96+
97+
before do
98+
allow(services).to receive(:one_service?).with(/dynatrace/, 'apitoken', 'environmentid').and_return(true)
99+
allow(services).to receive(:find_service).and_return('credentials' => { 'environmentid' => 'test-environmentid',
100+
'apiurl' => 'test-apiurl',
101+
'apitoken' => 'test-apitoken',
102+
'networkzone' => 'test-network-zone' })
103+
104+
allow(application_cache).to receive(:get)
105+
.with('test-apiurl/v1/deployment/installer/agent/unix/paas/latest?include=java&bitness=64&' \
106+
'Api-Token=test-apitoken&networkzone=test-network-zone')
107+
.and_yield(Pathname.new('spec/fixtures/stub-dynatrace-one-agent.zip').open, false)
108+
end
109+
110+
it 'downloads Dynatrace agent zip with networkzone',
111+
cache_fixture: 'stub-dynatrace-one-agent.zip' do
112+
113+
component.compile
114+
115+
expect(sandbox + 'agent/lib64/liboneagentloader.so').to exist
116+
expect(sandbox + 'manifest.json').to exist
117+
end
118+
end
119+
95120
context do
96121

97122
before do

0 commit comments

Comments
 (0)