-
Notifications
You must be signed in to change notification settings - Fork 127
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
MM-17818 Adding automatic registration of autolinks for JIRA projects. #453
Conversation
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 the biggest 2 changes I request are:
- move the link (struct) creation to the Instance interface
- consider adding Jira server link support (@DHaussermann or @jfrerich can provide the info on the URL structure)
and naming nits, as usual
server/plugin.go
Outdated
continue | ||
} | ||
|
||
if err := p.InstallAutolinkForCloudInstance(jci); err != nil { |
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.
1/5 s/Install/Configure/; 0/5 s/InstallAutolinkForCloudInstance/configureCloud/
OT: IMO reading a function name, one should need to switch to a "parsing" mode, names should read naturally, with the emphasis on the client (caller). I started thinking using this pattern more, to keep the names cleaner. Also helps keepinf the vocabulary consistent. 1/5 we should rename Link
to Autolink
in the autolink plugin itself before too long.
type autolinkAPI struct {}
func (*autolink) Configure(...link.Link) {...}
...
autolink := NewAutolinkAPI()
err = autolink.Configure(ji.Autolinks()...)
(OT: I recently learned that it's ok to use a _
or even nothing for the receiver! )
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.
It seems like an "Install" to me since we are sending data to a separate system?
reading a function name, one should need to switch to a "parsing" mode, names should read naturally, with the emphasis on the client (caller)
+1000 You read code way more then you write it.
1/5 we should rename Link to Autolink
Ya I struggled with the name there. I think you are right it should be Autolink. Will 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.
autolink.Install(...*autolink.Autolink)
wfm
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.
0/5 To me, install has the connotation of "install and enable the plugin as needed" which is not true, but I can see your POV as well. Maybe autolink.Add(links)
?
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.
@levb Switched to using a new autolink client to address this feedback.
RE: Consider starting a separate versioned package for all |
@levb How will gomod help? Nothing can be picked up until it's merged. Yes. Circular dependencies will have to be avoided. In this case it's fine because autolink should know nothing about any other plugin. But I did factor out the link stuff into a separate package anyway. Separate versioned package is probably overkill in this situation, but I could see it being useful in the future. |
You can use the commit on the feature branch as a dependency, e.g. with Sure, if there are following commits that break the API there is an problem. |
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.
Awesome job @crspeller! Just some nits on error messages
Co-Authored-By: Michael Kochell <mjkochell@gmail.com>
go.mod
Outdated
@@ -8,9 +8,12 @@ require ( | |||
github.com/dghubble/oauth1 v0.5.0 | |||
github.com/dgrijalva/jwt-go v3.2.0+incompatible | |||
github.com/google/uuid v1.1.1 | |||
github.com/mattermost/mattermost-plugin-autolink v0.0.0-00010101000000-000000000000 |
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 should start defining proper versions in our go.mod
's?
Ready to un-draft this, or wait for the other PRs? @crspeller I guess CI is failing... |
Will un-draft when the other PR is merged and I have updated this 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.
I am having issues building this locally even after getting the branch for the corresponding functionality in the other repo.
Please merge and I will test from master and create follow-up issues as needed.
Just for tracking - I created a follow up ticket for registering automatically: #472 |
} | ||
|
||
client := autolinkclient.NewClientPlugin(p.API) | ||
if err := client.Add(installList...); err != nil { |
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.
@crspeller Is the code checking anywhere if the autolink plugin is enabled and running? Or does this line just fail if autolink is not running?
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.
Yup it just fails. No need to check as checking is probably just as expensive as just trying and failing.
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.
/giphy fire and forget :)
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'm not sure if it's about cost. This code is only executed once on startup.
My concerns are mostly that admins might be confused on the log warning.
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 agree with @hanzei. Maybe we can add something to the error that says "Make sure the autolink plugin is installed in order to auto-create links to your Jira issues."
Adds automatic registration of autolinks of JIRA projects converting JIRA tags like MM-1234 to clickable links and pasted links to clickable tags. These are the same links used on community.
This PR requires: mattermost-community/mattermost-plugin-autolink#85
Some notes to be fixed before merge or in follow up PRs: