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
Use LINK_PORT
variable if it's set
#1370
Conversation
This brings PORT up to parity with SCHEME, PATH, USERNAME, and PASSWORD.
Current coverage is 29.05% (diff: 0.00%)@@ master #1370 diff @@
==========================================
Files 137 137
Lines 12900 12913 +13
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
Hits 3752 3752
- Misses 8750 8763 +13
Partials 398 398
|
Came across these |
My main question is around what needs to be done in release.go.
|
Confirmed that this change works locally: docker-compose.yml: worker:
build: .
command: /app/bin/worker
environment:
- ...
links:
- broker
broker:
image: rabbitmq:3.6
environment:
- LINK_SCHEME=amqp
- LINK_PORT=5672
ports:
- 5672
|
Seems good. Yes, we should do it for production also, that would be here: https://github.com/convox/rack/blob/master/api/models/release.go#L489 |
@ddollar Thanks. I took a look at adding it there, but wasn't sure what to do for converting an environment variable (string) into a It's a little less clear to me how this would be used on a rack (as I'd expect the only option is to go through the service's ELB, which already has the exposed ports defined. |
I'm assuming this LINK_PORT defines which port shows up by default in the full link _URL ? |
Perhaps loop through |
@ddollar I'll give that a shot, thanks! |
i, _ := strconv.Atoi(other.Exports["LINK_PORT"]) | ||
if err != nil { | ||
// handle error | ||
fmt.Println(err) |
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.
Golang noobie.. not sure what to do here in case of an error converting LINK_PORT
to an int
.
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.
return nil, err
if i == p.Container { | ||
port = p | ||
} | ||
} |
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.
Anything we should do if they've set LINK_PORT
but it doesn't match any of the exposed ports?
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.
That should be an error.
* If `LINK_PORT` not set, default to first port immediately * Return error if `LINK_PORT` can't be converted to integer * Return error if `LINK_PORT` set to non-existant port
@@ -18,7 +19,7 @@ import ( | |||
"github.com/aws/aws-sdk-go/service/iam" | |||
"github.com/convox/rack/api/crypt" | |||
"github.com/convox/rack/api/structs" | |||
"github.com/convox/rack/manifest" | |||
mp "github.com/convox/rack/manifest" |
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.
Had to do this as I wasn't able to refer to manifest.Port
in my code otherwise (there's a local variable also called manifest
already). Open on suggestions for a better way to handle this (or better name for it - mp
stands for manifest package).
I updated other the other references that I found as well.
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.
So let's go the other way with this to avoid surprises around the namespace. Perhaps name the variable m
down in the function and let this be manifest
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.
Can do, thanks!
@@ -18,7 +19,7 @@ import ( | |||
"github.com/aws/aws-sdk-go/service/iam" | |||
"github.com/convox/rack/api/crypt" | |||
"github.com/convox/rack/api/structs" | |||
"github.com/convox/rack/manifest" | |||
mp "github.com/convox/rack/manifest" |
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.
So let's go the other way with this to avoid surprises around the namespace. Perhaps name the variable m
down in the function and let this be manifest
* Imported package is back to `manifest` * Manifest arg to `resolveLinks` is now `m` * Pointer to manifest is now `mp`
func (r *Release) resolveLinks(app App, manifest *manifest.Manifest) (*manifest.Manifest, error) { | ||
m := *manifest | ||
func (r *Release) resolveLinks(app App, m *manifest.Manifest) (*manifest.Manifest, error) { | ||
mp := *m |
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.
Ran into one more existing variable name conflict here - renamed the pointer to the manifest from m
to mp
and updated other references.
Updated docs here: https://github.com/convox/site/pull/340 |
@MiguelMoll Not sure if you saw this one, @ddollar mentioned that it could make it into the next release potentially? |
@mwarkentin Getting the release ready 👍 Could you update this branch with master? Then we'll be ready to go. |
@MiguelMoll Updated, thanks! |
@MiguelMoll Thanks! |
This brings PORT up to parity with SCHEME, PATH, USERNAME, and PASSWORD.
Use Case
We are trying to use the official
rabbitmq
image for local development.EXPOSE
s multiple portsdocker inspect
LINK_*
environment variables can be usedTODO