clever-tools
Advanced tools
Comparing version 2.8.1 to 2.9.0
# clever-tools changelog | ||
## 2.8.1 (2021-01-10) | ||
## 2.9.0 (2022-01-12) | ||
* Add NewRelic support in `clever drains` | ||
## 2.8.1 (2022-01-10) | ||
* Fix `colors` to `1.4.0` | ||
@@ -6,0 +10,0 @@ |
{ | ||
"name": "clever-tools", | ||
"version": "2.8.1", | ||
"version": "2.9.0", | ||
"description": "Command Line Interface for Clever Cloud.", | ||
@@ -5,0 +5,0 @@ "main": "bin/clever.js", |
@@ -323,2 +323,3 @@ # clever-tools | ||
- `DatadogHTTP`: for Datadog endpoint (note that this endpoint needs your Datadog API Key). | ||
- `NewRelicHTTP`: for NewRelic endpoint (note that this endpoint needs your NewRelic API Key). | ||
@@ -341,2 +342,12 @@ #### ElasticSearch logs drains | ||
#### NewRelic logs drains | ||
NewRelic has two zones, EU and US. An account on one zone is not available on the other, make sure to target the good EU or US intake endpoint. | ||
To create a [NewRelic](https://docs.newrelic.com/docs/logs/log-api/introduction-log-api/) drain, you just need to use: | ||
```sh | ||
clever drain create NewRelicHTTP "https://log-api.eu.newrelic.com/log/v1" --api-key <API_KEY> | ||
``` | ||
### Display help | ||
@@ -343,0 +354,0 @@ |
@@ -11,2 +11,3 @@ 'use strict'; | ||
{ id: 'DatadogHTTP' }, | ||
{ id: 'NewRelicHTTP', apiKey: 'MANDATORY' }, | ||
]; | ||
@@ -16,4 +17,4 @@ | ||
if (!authorizeDrainCreation(drainTargetType, drainTargetCredentials)) { | ||
throw new Error("Credentials are: optional for HTTP, mandatory for ElasticSearch and TCPSyslog/UDPSyslog don't need them."); | ||
if (!authorizeDrainCreation(drainTargetType, drainTargetCredentials, drainTargetConfig)) { | ||
throw new Error("Credentials are: optional for HTTP, mandatory for ElasticSearch, NewRelicHTTP and TCPSyslog/UDPSyslog don't need them."); | ||
} | ||
@@ -31,16 +32,33 @@ | ||
} | ||
if (keyExist(drainTargetConfig)) { | ||
body.APIKey = drainTargetConfig.apiKey; | ||
} | ||
return body; | ||
} | ||
function authorizeDrainCreation (drainTargetType, drainTargetCredentials) { | ||
function authorizeDrainCreation (drainTargetType, drainTargetCredentials, drainTargetConfig) { | ||
if (drainTypeExists(drainTargetType)) { | ||
// retrieve creds for drain type ('mandatory', 'optional', undefined) | ||
const status = credentialsStatus(drainTargetType).credentials; | ||
if (status === 'MANDATORY') { | ||
const credStatus = credentialsStatus(drainTargetType).credentials; | ||
const keyStatus = credentialsStatus(drainTargetType).apiKey; | ||
if (credStatus === 'MANDATORY') { | ||
return credentialsExist(drainTargetCredentials); | ||
} | ||
if (status === 'OPTIONAL') { | ||
if (credStatus === 'OPTIONAL') { | ||
return true; | ||
} | ||
return credentialsEmpty(drainTargetCredentials); | ||
if (!credStatus && !keyStatus) { | ||
return credentialsEmpty(drainTargetCredentials); | ||
} | ||
if (keyStatus === 'MANDATORY') { | ||
return keyExist(drainTargetConfig); | ||
} | ||
if (keyStatus === 'OPTIONAL') { | ||
return true; | ||
} | ||
if (!keyStatus) { | ||
return keyEmpty(drainTargetConfig); | ||
} | ||
} | ||
@@ -65,2 +83,10 @@ } | ||
function keyExist ({ apiKey }) { | ||
return apiKey != null; | ||
} | ||
function keyEmpty ({ apiKey }) { | ||
return apiKey == null; | ||
} | ||
function listDrainTypes () { | ||
@@ -67,0 +93,0 @@ return autocomplete.words(DRAIN_TYPES.map((type) => type.id)); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
198937
3806
381
1