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

Cannot set custom adapter path through constructor of Robot class #1297

Closed
rqc opened this issue Feb 20, 2017 · 9 comments
Closed

Cannot set custom adapter path through constructor of Robot class #1297

rqc opened this issue Feb 20, 2017 · 9 comments
Labels

Comments

@rqc
Copy link

rqc commented Feb 20, 2017

Hi,

I think there is an error here: https://github.com/github/hubot/blob/498d65611388d2881e6ae24f74bd68a832a24211/src/robot.coffee#L43-L44

Since in the constructor argument for adapterPath is expected to be nil or existing, @adapterPath will never be existing since it is not declared anywhere (the constructor uses adapterPath and not @adapterPath).

@mose
Copy link
Member

mose commented May 12, 2017

You are totally right. But I suspect nobody noticed because in the current state there is no way to set a custom adapterPath without some hacking in hubot launch script. I suspect it may have been put there for some yet-to-come evolution of the code.

@technicalpickles
Copy link
Member

#1191 is a similar question.

I suspect it may have been put there for some yet-to-come evolution of the code.

It was introduced in #1109 which is work towards #858

@technicalpickles
Copy link
Member

Looked a little more closely, and I think it was just an oversight. It'd make sense to do @adapterPath = adapterPath or Path.join __dirname, "adapters"

Some part of me suspects I thought it was using the coffeescriptism of having constructor args like constructor: (@adapterPath), which would automatically set @adapterPath for you.

@rqc
Copy link
Author

rqc commented May 24, 2017

@mose @technicalpickles thanks for looking into this. Would you like me to issue a PR?

@mose
Copy link
Member

mose commented May 24, 2017

Sure, go for it, that should be a simple one :) Thanks!

@technicalpickles
Copy link
Member

I am thinking a bit more about this as I worked on #1366 . According to the docs, it's a String of the path to built-in adapters (defaults to src/adapters). I'm not sure it makes sense to be able to override where builtin adapters are loaded from at a high level, mostly because I would expect making other adapters as new packages. There aren't any public hubot APIs that you can use to override this, so I think that would be pretty unsupported. Even if the adapterPath was set, it would only load the hard-coded set of adapters (HUBOT_DEFAULT_ADAPTERS)

That said, I could imagine some use cases for it. You could override a builtin (ie shell and campfire) adapter with your own in a different directory. You could even just 'override' it but have it do something completely different, without having the overhead of a package, like a new, private adapter.

Right now, I'm kind of inclind to stop exposing adapterPath in general, but I am definitely open to hearing feedback and use cases ✨

@technicalpickles
Copy link
Member

I ended up fixing this in #1366

I am still interested in hearing about use cases, because I suspect that HUBOT_DEFAULT_ADAPTERS will limit how the custom adapterPath can be used.

@rqc
Copy link
Author

rqc commented Jul 10, 2017

@technicalpickles thanks for looking into this. And your ideas about potential use cases is on the right path of our use cases. Let me try to explain:

The main use case here is that we are using Hubot as a package and not as the driver / startup script for my bot. This is because we need to change / override some of that startup behavior for our company bots. Furthermore, we are adding our own default adapters for our bots. The issue arose when we were trying to plugin these custom adapters to our instance of Robot. The fact that it calls loadAdapter() in its constructor, and in turn loadAdapter is constrained by the default adapters and what can be specified in adapterPath and adapter caused some issues in how we created our new bot startup script and also how we tested our bots. We ended up overriding Hubot.Robot constructor and loadAdapter() so that we could instantiate a Robot instance without an Adapter instance and then load an adapter instance with our overridden loadAdapter() method.

In general, the design pattern of having robot include (and load) adapter and havingadapter also include robot has created issues for us in customizing our bots. I think it does not create a clear separation of concerns. If you have any suggestions on this I would be happy to hear them.

Thanks 👍

@stale
Copy link

stale bot commented Oct 8, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 8, 2017
@stale stale bot closed this as completed Oct 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants