-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Builder Does Not Support Specifying tcp/Arbitrary IHostService, *Builder classes Cannot Be Extended #185
Comments
@lordmilko Thanks for this really good explained issue. I'll add support for custom |
@lordmilko I've added both ability to add a using(var container = Fd.UseHost().FromUri(Settings.DockerUri, isWindowsHost: true).
.UseContainer().Build())
{
} There are some other parameters for Cheers, |
Thanks @mariotoffia, I also stumbled upon the fact this also appears to be the same issue as described in #105, so potentially this may allow both issues to be closed |
@lordmilko I would say it partially solves #105 since it was derived another issue from that one - issue #160 so it will support docker-compose along with docker contexts. I would like to state that I really like your issue, good explanation so it is crystal clear what you want! - Thanks! :) |
Hi @mariotoffia, Today I noticed you had pushed FluentDocker 2.10.2 with this change last week! I was able to try it out and can confirm everything is working as expected; one curious thing I did note however, I personally found the syntax surrounding the new In the README it states that
While it doesn't provide an example, it seems fairly logical based on this that you can probably do something like: var hostService = new DockerHostService(...);
var container = Fd
.UseHost(hostService)
... But this is incorrect! In fact, the syntax is actually var hostService = new DockerHostService(...);
var container = Fd
.UseHost()
.UseHost(hostService)
... In order to use your custom I think it would probably make more sense as var container = Fd
.UseHost()
.WithHostService(hostService)
... or something, which would be consistent with how you can do .UseImage(...)
.WithName(...)
.WithHostName(...) of course, for me my program is now working without the need for my own custom workaround. Potentially this may be something worth considering however. Thanks for your help! Regards, |
@lordmilko Great suggestion!! - Hmm... yes, kid'a cookie ontop of cookie as we say in sweden :). What do you think about var container = Fd
.UseHost()
.WithCustomHost(hostService)
// or
var container = Fd
.UseHost()
.FromService(hostService)
// or
var container = Fd
.UseHost()
.AsService(hostService) ? Cheers, |
Hi @mariotoffia, I spent a bit of time thinking about this! And I would say
As such, by process of elimination I think |
Neat! :) I'll add it to my todo for the week - I will make this change in hope that not too many have used this particular method since I'm going to do a rename, hence incompatibility is introduced even if the semver do not denote such - hope this is ok for you. Thanks for your help! Cheers, |
done, will come in a release this week |
In my program, users will be able to customize the URI of the docker service they wish to connect to via a config file, thereby allowing users to connect to
tcp://<arbitraryAddress>:2375
without need to specify this as theirDOCKER_HOST
environment variable.At the lowest level, I can easily create an
DockerHostService
that encapsulates this custom Docker URI, however I've found when it comes to using the fluent API, there doesn't appear to be a way to specify either the arbitraryIHostService
I've created, or simply specify atcp://
based one.The
HostBuilder
returned fromnew Builder().UseHost()
only appears to support building three types ofIHostService
objects.UseNative().Build()
.UseSsh(...).Build()
.UseMachine().Build()
I would propose that an additional method should be added, perhaps
UseTcp(...)
,UseUri(...)
orUseHost(IHostService service)
that enables an arbitrary host be used in fluent contexts. Users could theoretically implement such methods themselves if they wanted to by extendingHostBuilder
, however unfortunately it appears that most of the*Builder
classes are actuallysealed
withinternal
constructors, making this a bit more complicated.Fortunately, since
BaseBuilder<T>
simply has aprotected
constructor I was able to effectively workaround this in my application by creating anIBuilder
extension method that returns a customBaseBuilder<IHostService>
, however since I need to re-implementUseContainer
this required the use of reflection since theContainerBuilder
constructor is not public.As such, I would present it could potentially be useful to implement additional methods on
HostBuilder
for utilizing additionalIHostService
types in fluent contexts, and/or unsealing the various*Builder
types that are available so that they can be more easily extended.The text was updated successfully, but these errors were encountered: