-
Notifications
You must be signed in to change notification settings - Fork 22
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
Include ID of get-log file in the post #34
Include ID of get-log file in the post #34
Conversation
Codecov Report
@@ Coverage Diff @@
## master #34 +/- ##
=========================================
- Coverage 6.94% 6.93% -0.01%
=========================================
Files 6 6
Lines 734 735 +1
=========================================
Hits 51 51
- Misses 665 666 +1
Partials 18 18
Continue to review full report at Codecov.
|
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.
At first it seemed odd to add the variadic parameter for the fileIDs, but I understand why. All of the other code did not need to be updated, which is 16 calls in total. I think this change is fine until we need to add another parameter to the createPost
function, which may be never.
LGTM, thanks @DanielSz50!
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.
LGTM, just a small question.
@@ -194,6 +194,11 @@ func (p *Plugin) createPost(userID, channelID, message string) { | |||
"attachments": []*model.SlackAttachment{slackAttachment}, | |||
}, | |||
} | |||
|
|||
if fileIds != nil { | |||
post.FileIds = append(post.FileIds, fileIds[0]) |
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.
Does it make sense to consider all the fieldIDs that are delivered, and not only the first one?
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 now, it seems like it's not necessary to consider all fileIDs as only one is being delivered. Keeping it this way might clarify the purpose of including the variadic parameter.
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 was thinking the same, but since there is no code passing more than one at the moment, I think this makes sense to just assume there is at maximum one id present.
But now that I read this code again, I think len(fileIds) > 0
is a more readable way to check the presence of the file ID. Go implicitly checks if it is nil in the process. @DanielSz50 what do you think about making this change?
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 you're right, done.
@DanielSz50 In general it's better to incrementally add your commits to the PR instead of rebase/force-pushing for a few reasons:
Thanks again for this incredibly quick fix! Edit: Also we squash commits when we merge, so there's downside in having several commits in the PR, in that regard. |
Thanks for the tips, I'm going to keep that in mind while working on PRs in the future. |
@DHaussermann Test steps: Before this PR:
After the PR:
|
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.
Tested and passed
/jenkins get log [job name]
now creates a post with a file attachment instead of a link.- File attachment can be downloaded by any user regardless of Mattermost role
- Created minor enhancement suggestion issue to make file names unique Include build number in file name when downloading logs #38
LGTM!
Thanks @DanielSz50 for this fix!
Summary
Ticket Link
Fixes #33