diff --git a/config/components.yml b/config/components.yml index e7e6c39230..fdfc151f54 100644 --- a/config/components.yml +++ b/config/components.yml @@ -51,7 +51,6 @@ frameworks: - "JavaBuildpack::Framework::ContrastSecurityAgent" - "JavaBuildpack::Framework::DatadogJavaagent" - "JavaBuildpack::Framework::Debug" - - "JavaBuildpack::Framework::DynatraceAppmonAgent" - "JavaBuildpack::Framework::DynatraceOneAgent" - "JavaBuildpack::Framework::ElasticApmAgent" - "JavaBuildpack::Framework::GoogleStackdriverDebugger" diff --git a/docs/framework-dynatrace_one_agent.md b/docs/framework-dynatrace_one_agent.md index 08d8739557..cf0d3cfa89 100644 --- a/docs/framework-dynatrace_one_agent.md +++ b/docs/framework-dynatrace_one_agent.md @@ -28,6 +28,7 @@ The credential payload of the service may contain the following entries: | `apitoken` | The token for integrating your Dynatrace environment with Cloud Foundry. You can find it in the deploy Dynatrace section within your environment. | `apiurl` | (Optional) The base URL of the Dynatrace API. If you are using Dynatrace Managed you will need to set this property to `https:///e//api`. If you are using Dynatrace SaaS you don't need to set this property. | `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. +| `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. | `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! ## Configuration diff --git a/lib/java_buildpack/framework/dynatrace_one_agent.rb b/lib/java_buildpack/framework/dynatrace_one_agent.rb index e171e9bda5..baeb939a1a 100644 --- a/lib/java_buildpack/framework/dynatrace_one_agent.rb +++ b/lib/java_buildpack/framework/dynatrace_one_agent.rb @@ -112,12 +112,10 @@ def supports? def agent_download_url download_uri = "#{api_base_url(credentials)}/v1/deployment/installer/agent/unix/paas/latest?include=java" \ - "&bitness=64" \ + '&bitness=64' \ "&Api-Token=#{credentials[APITOKEN]}" - # - # setting networkzone parameter if it's configured - if networkzone? - download_uri += "&networkzone=#{networkzone_value}" + + download_uri += "&networkzone=#{networkzone}" if networkzone? ['latest', download_uri] end @@ -180,6 +178,10 @@ def expand(file) end end + def networkzone + credentials[NETWORKZONE] + end + def networkzone? credentials.key?(NETWORKZONE) end @@ -201,8 +203,6 @@ def unpack_agent(root) FileUtils.mv(root + 'agent', @droplet.sandbox) FileUtils.mv(root + 'manifest.json', @droplet.sandbox) end - end - end end diff --git a/spec/java_buildpack/framework/dynatrace_one_agent_spec.rb b/spec/java_buildpack/framework/dynatrace_one_agent_spec.rb index 9126e2c8ed..4ded98c17a 100644 --- a/spec/java_buildpack/framework/dynatrace_one_agent_spec.rb +++ b/spec/java_buildpack/framework/dynatrace_one_agent_spec.rb @@ -92,6 +92,31 @@ end + context do + + before do + allow(services).to receive(:one_service?).with(/dynatrace/, 'apitoken', 'environmentid').and_return(true) + allow(services).to receive(:find_service).and_return('credentials' => { 'environmentid' => 'test-environmentid', + 'apiurl' => 'test-apiurl', + 'apitoken' => 'test-apitoken', + 'networkzone' => 'test-network-zone' }) + + allow(application_cache).to receive(:get) + .with('test-apiurl/v1/deployment/installer/agent/unix/paas/latest?include=java&bitness=64&' \ + 'Api-Token=test-apitoken&networkzone=test-network-zone') + .and_yield(Pathname.new('spec/fixtures/stub-dynatrace-one-agent.zip').open, false) + end + + it 'downloads Dynatrace agent zip with networkzone', + cache_fixture: 'stub-dynatrace-one-agent.zip' do + + component.compile + + expect(sandbox + 'agent/lib64/liboneagentloader.so').to exist + expect(sandbox + 'manifest.json').to exist + end + end + context do before do