fabric8 icon indicating copy to clipboard operation
fabric8 copied to clipboard

allow the @ServiceName injection to use http or https as the protocol depending on the service port (80 / 443)?

Open jstrachan opened this issue 9 years ago • 9 comments

so gogs can be configured to use http or https; we've code that would like to use whichever flavour is being used.

https://github.com/fabric8io/fabric8/blob/master/forge/fabric8-forge-core/src/main/java/io/fabric8/forge/rest/main/GitUserHelper.java#L44-44

I added @Protocol("http") as otherwise this results in URLs of the form: "tcp://foo.bar" which don't work too well in browsers.

What would be nice is if we know its either http or https then use one of those protocols and pick the right protocol based on the port number (e.g. if 443 then use https otherwise default to http).

I kinda hoped the env vars could expose the protocol; but seems to always be "TCP". e.g.:

            "GOGS_HTTP_SERVICE_PORT_443_TCP_PROTO=tcp",

Ah - looks like we're not setting the protocol string on the gogs service; lets try that and see if it helps...

jstrachan avatar Apr 24 '15 07:04 jstrachan

am patching the mvn plugin to allow fabric8.service.protocol to be used...

jstrachan avatar Apr 24 '15 07:04 jstrachan

Service protocol can only be tcp or UDP AFAIK. This is for the kube proxy to set up port listeners.

On 08:23, Fri, 24 Apr 2015 James Strachan [email protected] wrote:

am patching the mvn plugin to allow fabric8.service.protocol to be used...

— Reply to this email directly or view it on GitHub https://github.com/fabric8io/fabric8/issues/3808#issuecomment-95832611.

jimmidyson avatar Apr 24 '15 07:04 jimmidyson

ah crap! :(

jstrachan avatar Apr 24 '15 07:04 jstrachan

OK maybe we need a @HttpProtocol annotation for the CDI stuff; to pick the most suitable http protocol for injecting URLs?

jstrachan avatar Apr 24 '15 07:04 jstrachan

Perhaps a bit more generic, can imagine ssh, ftp, git, etc all being options? Defaulting to http seems sane though.

On Fri, 24 Apr 2015 at 08:25 James Strachan [email protected] wrote:

OK maybe we need a @HttpProtocol annotation for the CDI stuff; to pick the most suitable http protocol for injecting URLs?

— Reply to this email directly or view it on GitHub https://github.com/fabric8io/fabric8/issues/3808#issuecomment-95833277.

jimmidyson avatar Apr 24 '15 08:04 jimmidyson

Yeah, maybe a @ProtocolFromPort that uses the actual port number of the service to determine 80 = http, 443 = https etc?

jstrachan avatar Apr 24 '15 08:04 jstrachan

If a service exposes ssh and http this could be confusing ;). Maybe we need to use a @HttpProtocol annotation to pick https if possible or http if not for the protocol?

jstrachan avatar Apr 24 '15 10:04 jstrachan

For specific protocols, like ssh, folks can use @Protocol("ssh") its only for things like http/https that a service may or may not be configured to use https; so if not fall back to http (e.g. for gogs).

jstrachan avatar Apr 24 '15 10:04 jstrachan

I think that we should just add an option to the existing annotation Protocol annotation and if explicitly set, we should attempt a "port to protocol" conversion.

iocanel avatar Apr 27 '15 15:04 iocanel