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

Multi product architecture #3309

Merged
merged 51 commits into from Jul 15, 2022

Conversation

wiggin77
Copy link
Member

@wiggin77 wiggin77 commented Jul 1, 2022

Summary

This PR provides support for compiling Boards directly into the Mattermost suite server. This required a major refactoring of the mattermost-plugin package. Plugin builds and stand-alone continue to be supported.

Notable changes:

  • a ServicesAPI interface replaces the PluginAPI to allow for implementations coming from pluginAPI and suite server.
  • a new product package provides a place to register Boards as a suite product and handles life-cycle events
  • a new boards package replaces much of the mattermost-plugin logic, allowing this to be shared between plugin and product
  • Boards now uses module workspaces; run make setup-go-work or place a go.work in the repo root containing:
go 1.18

use ./mattermost-plugin
use ./server
use ../mattermost-server
  • go.mod should no longer use replace to import mattermost-server/v6

Ticket Link

https://community.mattermost.com/boards/workspace/qgsck6cts3fwpqwyjiupjm5cde/b4ctmm917q3rzdfi451qtuxjzcw/150d1464-6d59-4c39-810f-ee201439dbaf/cfs87fp368fbwmc45wnuzcadaqe

@wiggin77 wiggin77 requested a review from a team as a code owner July 1, 2022 19:38
@wiggin77 wiggin77 requested review from sbishel and harshilsharma63 and removed request for a team July 1, 2022 19:38
@wiggin77 wiggin77 marked this pull request as draft July 1, 2022 19:38
@wiggin77 wiggin77 marked this pull request as ready for review July 6, 2022 16:52
@wiggin77 wiggin77 added the 2: Dev Review Requires review by a core committer label Jul 6, 2022
@wiggin77 wiggin77 added this to the v7.3 milestone Jul 6, 2022
@wiggin77 wiggin77 requested a review from sbishel July 6, 2022 17:03
Copy link
Member

@jespino jespino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a big change and I haven't look into each detail here, but looks good to me.

One tiny concern is we still have everything under the mattermost-plugin directory, so... plugin code, and product code are not clearly separated in that sense, but because the plugin code is expected to dissapear eventually, and even if that is not the case, I wouldn't add that changes to this PR, this PR is ready to merge (from my point of view).

@mgdelacroix mgdelacroix added the Do Not Merge Should not be merged until this label is removed label Jul 12, 2022
Copy link
Member

@mgdelacroix mgdelacroix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terrific job! 🚀

}

// Ensure the adapter implements ServicesAPI.
var _ model.ServicesAPI = &serviceAPIAdapter{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

p.SetAPI(api)
p.server = th.Server
p.wsPluginAdapter = &FakePluginAdapter{}
ctrl := gomock.NewController(t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're missing a ctrl.Finish() here or the expectations will not get checked

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the comments for NewController it says that Finish does not need to be called.

// NewController returns a new Controller. It is the preferred way to create a
// Controller.
//
// New in go1.14+, if you are passing a *testing.T into this function you no
// longer need to call ctrl.Finish() in your test methods.

https://github.com/golang/mock/blob/73266f9366fcf2ccef0b880618e5a9266e4136f4/gomock/controller.go#L87

tearDown := func() {
os.Setenv("FOCALBOARD_UNIT_TESTING", origUnitTesting)
}

ctrl := gomock.NewController(t)
defer ctrl.Finish()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but the ctrl.Finish() should get executed as part of the teardown

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it to the teardown, but I think it may be redundant.

"errors"
"net/http"

mm_model "github.com/mattermost/mattermost-server/v6/model"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not for this PR, but we're referring to the Mattermost Model as both mm_model and mmModel. We should pick one and standardize

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -649,7 +649,8 @@ func TestNotifyPortalAdminsUpgradeRequest(t *testing.T) {
defer tearDown()

t.Run("should send message", func(t *testing.T) {
pluginAPI := &plugintest.API{}
ctrl := gomock.NewController(t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ctrl := gomock.NewController(t)
ctrl := gomock.NewController(t)
defer ctrl.Finish()

@@ -691,17 +692,18 @@ func TestNotifyPortalAdminsUpgradeRequest(t *testing.T) {
})

t.Run("no sys admins found", func(t *testing.T) {
pluginAPI := &plugintest.API{}
ctrl := gomock.NewController(t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ctrl := gomock.NewController(t)
ctrl := gomock.NewController(t)
defer ctrl.Finish()

@@ -714,7 +716,8 @@ func TestNotifyPortalAdminsUpgradeRequest(t *testing.T) {
})

t.Run("iterate multiple pages", func(t *testing.T) {
pluginAPI := &plugintest.API{}
ctrl := gomock.NewController(t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ctrl := gomock.NewController(t)
ctrl := gomock.NewController(t)
defer ctrl.Finish()

Comment on lines 26 to 32
type NotSupportedError struct {
msg string
}

func (pe NotSupportedError) Error() string {
return pe.msg
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is being used right now, and duplicates the one on store.go

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@wiggin77
Copy link
Member Author

Thanks for reviewing @mgdelacroix. I've addressed the issued your raised, except the mock controller finish calls. I don't think they are needed anymore (since Go v1.14).

Copy link
Member

@mgdelacroix mgdelacroix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for applying the changes!! LGTM and merging right away!

As per the Finish() comments, you're totally right, they're not needed on our current version of Go. We still need to fix the test helpers in which we're calling defer ctrl.Finish() on the setup, but nothing concerning this PR. Will update the code debt card to add your findings

@mgdelacroix mgdelacroix added 3: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core committer Do Not Merge Should not be merged until this label is removed labels Jul 15, 2022
@mgdelacroix mgdelacroix merged commit 605c007 into mattermost:main Jul 15, 2022
mgdelacroix added a commit that referenced this pull request Jul 15, 2022
mgdelacroix added a commit that referenced this pull request Jul 15, 2022
@mgdelacroix
Copy link
Member

I merged the PR before the branch cut, so it's now reverted on main. Will merge it again after the release cut

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3: Reviews Complete All reviewers have approved the pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants