-
Notifications
You must be signed in to change notification settings - Fork 25
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
[DO NOT MERGE] feat(cli): add Markdown support for CLI #1356
Open
jasminesun-lw
wants to merge
17
commits into
main
Choose a base branch
from
feature/markdown-support-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
505e777
feat(cli): initial commit of comment markdown
hazedav c6e399c
feat(cli): initial commit of comment markdown
hazedav 819b922
Merge branch 'main' into feature/markdown-support-api
jasminesun-lw a97d4f8
feat(cli): add unit test for feature flag
jasminesun-lw ba5594a
feat(cli): fix test
jasminesun-lw 7a83d42
feat(cli): add negative test
jasminesun-lw ac810ea
feat(cli): update tests
jasminesun-lw bb2e3c4
feat(cli): capitalize formats, update tests
jasminesun-lw 1f1df02
feat(cli): fix panic on comments shorter than title
jasminesun-lw 1f67dc9
feat(cli): fix newline \r\n
jasminesun-lw d5d26ca
feat(cli): fix linting issue
jasminesun-lw 39eb0ab
feat(cli): fix linting problem
jasminesun-lw ffc2655
feat(cli): revert baack to timeline table if on windows
jasminesun-lw 8c6c1a6
chore: Merge branch 'main' into feature/markdown-support-api
jasminesun-lw ba8ac02
feat(cli): update import order
jasminesun-lw 85bf6c2
Merge branch 'main' into feature/markdown-support-api
hazedav 970e0fa
Merge branch 'main' into feature/markdown-support-api
hazedav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
"strconv" | ||
"testing" | ||
|
||
"github.com/lacework/go-sdk/api" | ||
"github.com/lacework/go-sdk/internal/lacework" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAlertComment(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
args []string | ||
commentFlag string | ||
formatFlag string | ||
}{ | ||
{ | ||
name: "Valid Comment with Markdown Format", | ||
args: []string{"12345"}, | ||
commentFlag: "This is a **markdown** comment.", | ||
formatFlag: "Markdown", | ||
}, | ||
{ | ||
name: "Valid Comment with Plain Text Format", | ||
args: []string{"12344"}, | ||
commentFlag: "This is a plain text comment.", | ||
formatFlag: "Plaintext", | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
id, _ := strconv.Atoi(test.args[0]) | ||
fakeServer := lacework.MockServer() | ||
fakeServer.MockAPI( | ||
fmt.Sprintf("Alerts/%d/comment", id), | ||
func(w http.ResponseWriter, r *http.Request) { | ||
assert.Equal(t, "POST", r.Method, "should be a POST method") | ||
fmt.Fprint(w, "{}") | ||
}, | ||
) | ||
defer fakeServer.Close() | ||
|
||
c, err := api.NewClient("test", | ||
api.WithToken("TOKEN"), | ||
api.WithURL(fakeServer.URL()), | ||
) | ||
assert.Nil(t, err) | ||
|
||
_, err = c.V2.Alerts.CommentFromRequest(id, | ||
api.AlertsCommentRequest{Comment: test.commentFlag, Format: test.formatFlag}) | ||
assert.Nil(t, err) | ||
}) | ||
} | ||
} |
This file contains 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 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 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
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.
Are there packages cross platform compatible? Especially for windows?
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.
So
box-cli-maker
seems to render fine in windows command line.go-term-markdown
is another story...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.
For windows me might have to revert back to just showing a table (not sure how tables even look with really long comments today). I'm not aware of any
go+markdown+windows-cli
packages.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.
We can maybe look into this...https://github.com/charmbracelet/glow