Skip to content

Commit

Permalink
feat: Add Dotnet support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nandu-pns committed Jun 7, 2023
1 parent e19b1c0 commit 82d7cc8
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 24 deletions.
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,33 @@ end

#### Required

| Name | Default value | Description |
|:-----|:--------------|:------------|
| `default['newrelic_install']['NEW_RELIC_API_KEY']` | `nil` | new relic api key |
| `default['newrelic_install']['NEW_RELIC_ACCOUNT_ID']` | `nil` | new relic account id |
| `default['newrelic_install']['targets']` | [] | agents to be installed, possible values are (`infrastructure-agent-installer`, `logs-integration`, `php-agent-installer`) |
| Name | Default value | Description |
|:------------------------------------------------------|:--------------|:----------------------------------------------------------------------------------------------------------------------------------------------------|
| `default['newrelic_install']['NEW_RELIC_API_KEY']` | `nil` | new relic api key |
| `default['newrelic_install']['NEW_RELIC_ACCOUNT_ID']` | `nil` | new relic account id |
| `default['newrelic_install']['targets']` | [] | agents to be installed, possible values are (`infrastructure-agent-installer`, `logs-integration`, `php-agent-installer`, `dotnet-agent-installer`) |

#### Optional

| Name | Default value | Description |
|:-----|:--------------|:------------|
| `default['newrelic_install']['NEW_RELIC_REGION']` | `US` | new relic regions for your account (`US` or `EU`) |
| `default['newrelic_install']['env']['HTTPS_PROXY']` | `nil` | proxy url if you are behind a firewall |
| `default['newrelic_install']['verbosity']` | `nil` | Verbosity options for the installation (`debug` or `trace`). Writes verbose output to a log file on the host. |
| `default['newrelic_install']['tags']` | `{}` | key value pair tags added through custom attributes |
| `default['newrelic_install']['timeout_seconds']` | `600` | Sets timeout for installation task. |
| Name | Default value | Description |
|:----------------------------------------------------|:--------------|:--------------------------------------------------------------------------------------------------------------|
| `default['newrelic_install']['NEW_RELIC_REGION']` | `US` | new relic regions for your account (`US` or `EU`) |
| `default['newrelic_install']['env']['HTTPS_PROXY']` | `nil` | proxy url if you are behind a firewall |
| `default['newrelic_install']['verbosity']` | `nil` | Verbosity options for the installation (`debug` or `trace`). Writes verbose output to a log file on the host. |
| `default['newrelic_install']['tags']` | `{}` | key value pair tags added through custom attributes |
| `default['newrelic_install']['timeout_seconds']` | `600` | Sets timeout for installation task. |

#### PHP Agent

| Name | Default value | Description |
|:-----|:--------------|:------------|
| `default['newrelic_install']['env']['NEW_RELIC_APPLICATION_NAME']` | `nil` | optional name for your php application |
| Name | Default value | Description |
|:-------------------------------------------------------------------|:--------------|:---------------------------------------|
| `default['newrelic_install']['env']['NEW_RELIC_APPLICATION_NAME']` | `nil` | optional name for your php application |

#### DOTNET Agent

| Name | Default value | Description |
|:-------------------------------------------------------------------|:--------------|:------------------------------------------|
| `default['newrelic_install']['env']['NEW_RELIC_APPLICATION_NAME']` | `nil` | optional name for your dotnet application |

### Testing

Expand Down
8 changes: 8 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
# infrastructure-agent-installer
# logs-integration
# php-agent-installer
# dotnet-agent-installer
default['newrelic_install']['targets'] = []

########
Expand All @@ -43,3 +44,10 @@

# optional name for your php application
default['newrelic_install']['env']['NEW_RELIC_APPLICATION_NAME'] = ''

#############
# DOTNET AGENT #
#############

# optional name for your dotnet application
default['newrelic_install']['env']['NEW_RELIC_APPLICATION_NAME'] = ''
4 changes: 2 additions & 2 deletions resources/newrelic_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ def check_license
end

def check_targets
allowedTargets = Set['infrastructure-agent-installer', 'logs-integration', 'php-agent-installer']
allowedTargetsString = 'infrastructure-agent-installer, logs-integration, php-agent-installer'
allowedTargets = Set['infrastructure-agent-installer', 'logs-integration', 'php-agent-installer', 'dotnet-agent-installer']
allowedTargetsString = 'infrastructure-agent-installer, logs-integration, php-agent-installer, dotnet-agent-installer'
incomingTargets = new_resource.targets.to_set

if incomingTargets.nil? || incomingTargets.empty?
Expand Down
92 changes: 85 additions & 7 deletions spec/unit/resources/newrelic_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
expect(subject).to run_execute('newrelic install').with(env: have_key('NEW_RELIC_CLI_SKIP_CORE'))
end

it 'run bash newrlic install command with infra' do
it 'run bash newrelic install command with infra' do
expect(subject).to run_execute('newrelic install').with(command: include('infrastructure-agent-installer'))
end
end
Expand All @@ -105,15 +105,15 @@
default_attributes['newrelic_install']['NEW_RELIC_REGION'] = 'xxx'
default_attributes['newrelic_install']['targets'] = %w(infrastructure-agent-installer logs-integration php-agent-installer)

it 'run bash newrlic install command with infra' do
it 'run bash newrelic install command with infra' do
expect(subject).to run_execute('newrelic install').with(command: include('infrastructure-agent-installer'))
end

it 'run bash newrlic install command with logs' do
it 'run bash newrelic install command with logs' do
expect(subject).to run_execute('newrelic install').with(command: include('logs-integration'))
end

it 'run bash newrlic install command with php' do
it 'run bash newrelic install command with php' do
expect(subject).to run_execute('newrelic install').with(command: include('php-agent-installer'))
end
end
Expand All @@ -128,15 +128,53 @@
expect(subject).to run_execute('newrelic install').with(env: have_key('NEW_RELIC_CLI_SKIP_CORE'))
end

it 'run bash newrlic install command without infra' do
it 'run bash newrelic install command without infra' do
expect(subject).not_to run_execute('newrelic install').with(command: include('infrastructure-agent-installer'))
end

it 'run bash newrlic install command with php' do
it 'run bash newrelic install command with php' do
expect(subject).to run_execute('newrelic install').with(command: include('-n php-agent-installer'))
end
end

context 'when targets only contains infra, logs and dotnet' do
default_attributes['newrelic_install']['NEW_RELIC_API_KEY'] = 'xxx'
default_attributes['newrelic_install']['NEW_RELIC_ACCOUNT_ID'] = 'xxx'
default_attributes['newrelic_install']['NEW_RELIC_REGION'] = 'xxx'
default_attributes['newrelic_install']['targets'] = %w(infrastructure-agent-installer logs-integration dotnet-agent-installer)

it 'run bash newrelic install command with infra' do
expect(subject).to run_execute('newrelic install').with(command: include('infrastructure-agent-installer'))
end

it 'run bash newrelic install command with logs' do
expect(subject).to run_execute('newrelic install').with(command: include('logs-integration'))
end

it 'run bash newrelic install command with dotnet' do
expect(subject).to run_execute('newrelic install').with(command: include('dotnet-agent-installer'))
end
end

context 'when targets only contains dotnet' do
default_attributes['newrelic_install']['NEW_RELIC_API_KEY'] = 'xxx'
default_attributes['newrelic_install']['NEW_RELIC_ACCOUNT_ID'] = 'xxx'
default_attributes['newrelic_install']['NEW_RELIC_REGION'] = 'xxx'
default_attributes['newrelic_install']['targets'] = ['dotnet-agent-installer']

it 'should execute with target infra and skip core' do
expect(subject).to run_execute('newrelic install').with(env: have_key('NEW_RELIC_CLI_SKIP_CORE'))
end

it 'run bash newrelic install command without infra' do
expect(subject).not_to run_execute('newrelic install').with(command: include('infrastructure-agent-installer'))
end

it 'run bash newrelic install command with dotnet' do
expect(subject).to run_execute('newrelic install').with(command: include('-n dotnet-agent-installer'))
end
end

context 'when execute on windows' do
platform 'windows'
default_attributes['newrelic_install']['NEW_RELIC_API_KEY'] = 'xxx'
Expand All @@ -148,8 +186,48 @@
expect(subject).to run_powershell_script('newrelic install').with(env: have_key('NEW_RELIC_CLI_SKIP_CORE'))
end

it 'run powershell newrlic install command' do
it 'run powershell newrelic install command' do
expect(subject).to run_powershell_script('newrelic install').with(code: include('infrastructure-agent-installer'))
end
end

context 'when execute on windows and targets only contains infra, logs and dotnet' do
platform 'windows'
default_attributes['newrelic_install']['NEW_RELIC_API_KEY'] = 'xxx'
default_attributes['newrelic_install']['NEW_RELIC_ACCOUNT_ID'] = 'xxx'
default_attributes['newrelic_install']['NEW_RELIC_REGION'] = 'xxx'
default_attributes['newrelic_install']['targets'] = %w(infrastructure-agent-installer logs-integration dotnet-agent-installer)

it 'run powershell newrelic install command' do
expect(subject).to run_powershell_script('newrelic install').with(code: include('infrastructure-agent-installer'))
end

it 'run powershell newrelic install command with logs' do
expect(subject).to run_powershell_script('newrelic install').with(code: include('logs-integration'))
end

it 'run powershell newrelic install command with dotnet' do
expect(subject).to run_powershell_script('newrelic install').with(code: include('dotnet-agent-installer'))
end
end

context 'when execute on windows and targets only contains dotnet' do
platform 'windows'
default_attributes['newrelic_install']['NEW_RELIC_API_KEY'] = 'xxx'
default_attributes['newrelic_install']['NEW_RELIC_ACCOUNT_ID'] = 'xxx'
default_attributes['newrelic_install']['NEW_RELIC_REGION'] = 'xxx'
default_attributes['newrelic_install']['targets'] = ['dotnet-agent-installer']

it 'should execute with target infra and skip core' do
expect(subject).to run_powershell_script('newrelic install').with(env: have_key('NEW_RELIC_CLI_SKIP_CORE'))
end

it 'run powershell newrelic install command without infra' do
expect(subject).not_to run_powershell_script('newrelic install').with(code: include('infrastructure-agent-installer'))
end

it 'run powershell newrelic install command with dotnet' do
expect(subject).to run_powershell_script('newrelic install').with(code: include('-n dotnet-agent-installer'))
end
end
end

0 comments on commit 82d7cc8

Please sign in to comment.