-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CLI command to set log-forwarding config #225
base: epic/log-forwarding
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,250 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class should be changed to set-log-forwarding-newrelic-.test.js as it is testing newrelic
}); | ||
|
||
// For MVP, only New Relic is supported | ||
const destinations = ['newrelic']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an enum for the destination and make it so that we can extend this functionality for other destinations like splunk
// For MVP, only New Relic is supported | ||
const destinations = ['newrelic']; | ||
|
||
let meshId = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to set meshid to null and as a variable as you are getting the meshid in line 52. Changing it to a const
is better practice
if (shouldContinue) { | ||
try { | ||
await setLogForwarding(imsOrgCode, projectId, workspaceId, { | ||
destination: 'newrelic', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the enum instead
|
||
if (shouldContinue) { | ||
try { | ||
await setLogForwarding(imsOrgCode, projectId, workspaceId, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should make this code extensible so that we can support other destinations besides newrelic
.
|
||
return { | ||
success: true, | ||
destination: 'newrelic', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the enum
this.log('Log forwarding details set successfully.'); | ||
|
||
return { | ||
success: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this success variable used?
} catch (error) { | ||
this.log(error.message); | ||
this.error( | ||
`Failed to set log forwarding details. Please try again. RequestId: ${global.requestId}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if this fails, we should provide a descriptive message of why it failed or else the user may find it confusing why it failed
|
||
if (licenseKey.length !== 40) { | ||
this.error( | ||
`License key has wrong format. Expected: 40 characters (received: ${licenseKey.length})`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`License key has wrong format. Expected: 40 characters (received: ${licenseKey.length})`, | |
`The license key is in the wrong format. Expected: 40 characters (received: ${licenseKey.length})`, |
}, | ||
}); | ||
|
||
this.log('Log forwarding details set successfully.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.log('Log forwarding details set successfully.'); | |
this.log('Log forwarding successful.'); |
} catch (error) { | ||
this.log(error.message); | ||
this.error( | ||
`Failed to set log forwarding details. Please try again. RequestId: ${global.requestId}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`Failed to set log forwarding details. Please try again. RequestId: ${global.requestId}`, | |
`Failed to set log forwarding details. Try again. RequestId: ${global.requestId}`, |
SetLogForwardingCommand.description = `Set log forwarding destination for API mesh. | ||
- Select a log forwarding destination: Choose from available options ( example : newrelic). | ||
- Enter the base URI: Provide the URI for the log forwarding service. Ensure it includes the protocol ( example : \`https://\`). | ||
- Enter the license key: Provide the license key for authentication with the log forwarding service. The key must be 40 characters long.`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SetLogForwardingCommand.description = `Set log forwarding destination for API mesh. | |
- Select a log forwarding destination: Choose from available options ( example : newrelic). | |
- Enter the base URI: Provide the URI for the log forwarding service. Ensure it includes the protocol ( example : \`https://\`). | |
- Enter the license key: Provide the license key for authentication with the log forwarding service. The key must be 40 characters long.`; | |
SetLogForwardingCommand.description = `Sets the log forwarding destination for API mesh. | |
- Select a log forwarding destination: Choose from available options ( example : newrelic). | |
- Enter the base URI: Provide the URI for the log forwarding service. Ensure it includes the protocol ( example : \`https://www.adobe.com\`). | |
- Enter the license key: Provide the license key for authentication with the log forwarding service. The key must be 40 characters long.`; |
This PR closes https://jira.corp.adobe.com/browse/CEXT-4231
Description
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: