-
Notifications
You must be signed in to change notification settings - Fork 23
[STORY-2042] log-drains: Add OpenSearch support #1110
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,11 +2,11 @@ package logdrains | |
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "gopkg.in/errgo.v1" | ||
| "strings" | ||
|
|
||
| "github.com/Scalingo/cli/config" | ||
| "github.com/Scalingo/cli/io" | ||
| "github.com/Scalingo/go-utils/errors/v2" | ||
| ) | ||
|
|
||
| type RemoveAddonOpts struct { | ||
|
|
@@ -18,36 +18,41 @@ type RemoveAddonOpts struct { | |
| func Remove(ctx context.Context, app string, opts RemoveAddonOpts) error { | ||
| c, err := config.ScalingoClient(ctx) | ||
| if err != nil { | ||
| return errgo.Notef(err, "fail to get Scalingo client to remove a log drain from the application") | ||
| return errors.Wrap(ctx, err, "get Scalingo client") | ||
| } | ||
|
|
||
| if opts.AddonID != "" { | ||
| // addon only | ||
| err := c.LogDrainAddonRemove(ctx, app, opts.AddonID, opts.URL) | ||
| if err != nil { | ||
| return errgo.Notef(err, "fail to remove the log drain from the addon %s", opts.AddonID) | ||
| return errors.Wrap(ctx, err, "remove log drain from addon "+opts.AddonID) | ||
| } | ||
| io.Status("The log drain", opts.URL, "has been deleted from the addon", opts.AddonID) | ||
| return nil | ||
| } | ||
|
|
||
| err = c.LogDrainRemove(ctx, app, opts.URL) | ||
| if err != nil { | ||
| io.Status("fail to remove the log drain from the application:", app, "\n\t", err) | ||
| } else { | ||
| io.Status("Log drain", opts.URL, "has been deleted from the application", app) | ||
| return errors.Wrap(ctx, err, "remove log drain from application "+app) | ||
| } | ||
| io.Status("Log drain", opts.URL, "has been deleted from the application", app) | ||
|
|
||
| if !opts.OnlyApp { | ||
| addons, err := c.AddonsList(ctx, app) | ||
| if err != nil { | ||
| return errgo.Notef(err, "fail to list addons to remove log drain") | ||
| return errors.Wrap(ctx, err, "list addons to remove log drain") | ||
| } | ||
|
|
||
| for _, addon := range addons { | ||
| err := c.LogDrainAddonRemove(ctx, app, addon.ID, opts.URL) | ||
| if err != nil { | ||
| io.Status("fail to remove the log drain from the addon:", addon.AddonProvider.Name, "\n\t", err) | ||
| // Check if this is a "not found" error, which can happen if the log drain | ||
| // was already removed by the main API call | ||
| if strings.Contains(err.Error(), "not found") { | ||
| io.Status("Log drain", opts.URL, "was already removed from the addon", addon.AddonProvider.Name) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Questions: (Sorry for the late notice) is this message will be logged when an addon never got the log drains? |
||
| } else { | ||
| io.Status("Unable to remove the log drain from the addon:", addon.AddonProvider.Name, "\n\t", err) | ||
curzolapierre marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } else { | ||
| io.Status("Log drain", opts.URL, "has been deleted from the addon", addon.AddonProvider.Name) | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hardcoded sensitive data leaked
Semgrep has detected a leak of sensitive data in this code. This secret data could be used by internal or external malicious actors. We highly recommend you change, reset, or rotate the sensitive data.
A secret is hard-coded in the application. Secrets stored in source code, such as credentials, identifiers, and other types of sensitive data, can be leaked and used by internal or external malicious actors. It is recommended to rotate the secret and retrieve them from a secure secret vault or Hardware Security Module (HSM), alternatively environment variables can be used if allowed by your company policy.
💬 To ignore this, reply with:
•
/fp <comment>for false positive•
/ar <comment>for acceptable risk•
/other <comment>for all other reasonsAlternatively, triage in Semgrep AppSec Platform to ignore the finding created by generic_uri_string.
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.
/fp url example