Skip to content
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

Merged
merged 1 commit into from
Jun 12, 2020

Conversation

DanielSz50
Copy link
Contributor

Summary

  • CreatePost() method is modified so it can take fileID as a new parameter without changing its behavior when no fileID was given.
  • fetchAndUploadBuildLog() method now includes fileID as a parameter in call for CreatePost().

Ticket Link

Fixes #33

@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2020

Codecov Report

Merging #34 into master will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
server/plugin.go 4.74% <0.00%> (-0.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc14b48...4894ed2. Read the comment docs.

@mickmister mickmister added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Jun 8, 2020
Copy link
Contributor

@mickmister mickmister left a 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!

Copy link

@larkox larkox left a 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])
Copy link

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@mickmister mickmister Jun 8, 2020

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?

Copy link
Contributor Author

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.

@mickmister
Copy link
Contributor

mickmister commented Jun 9, 2020

@DanielSz50 In general it's better to incrementally add your commits to the PR instead of rebase/force-pushing for a few reasons:

  • It's easier to review each change after each partial approval, though it is not as big of a deal here since this PR is very small. For larger PRs, the entire PR must be reviewed again, instead of just verifying the requested changes have been fixed.
  • It leaves a good history for each stage that was reviewed.

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.

@hanzei hanzei requested a review from DHaussermann June 9, 2020 15:32
@hanzei hanzei removed the 2: Dev Review Requires review by a core committer label Jun 9, 2020
@DanielSz50
Copy link
Contributor Author

Thanks for the tips, I'm going to keep that in mind while working on PRs in the future.

@mickmister
Copy link
Contributor

@DHaussermann Test steps:

Before this PR:

  • /jenkins get-log (name) should show a link to the file
  • MM admin should be able to download the file
  • non MM admin should not be able to download the file

After the PR:

  • /jenkins get-log (name) should embed the file in the post
  • Both admin and non MM admin should be able download

Copy link

@DHaussermann DHaussermann left a 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!

@DHaussermann DHaussermann added 4: Reviews Complete All reviewers have approved the pull request and removed 3: QA Review Requires review by a QA tester labels Jun 12, 2020
@mickmister mickmister merged commit b55a1b6 into mattermost-community:master Jun 12, 2020
@hanzei hanzei removed the request for review from waseem18 June 15, 2020 09:04
@hanzei hanzei mentioned this pull request Jun 15, 2020
@DanielSz50 DanielSz50 deleted the fix-fileInfo branch July 14, 2020 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Post get-log file as a file attachment rather than a link
6 participants