Skip to content

Commit

Permalink
[#3620] Append scheme to the URL to parse correctly
Browse files Browse the repository at this point in the history
### What is the feature/fix?

The std url package does not parse correctly if missing http(s)://

### Add screenshot or video (optional)

```
$ ./convox resources proxy postgres
proxying localhost:5432 to dev-v2-efsresource-httpd-resourcepostgres-n0w2v7qwskwy.c5mts8687wtb.us-east-2.rds.amazonaws.com:5432
$ ./convox resources proxy memcached
proxying localhost:11211 to dev-ca-j1jlewp39pdr.rctvfw.cfg.use2.cache.amazonaws.com:11211
```

### Does it has a breaking change?

No

### How to use/test it?

Install the version (to be created), deploy an app with Memcached resource, and run `convox resources proxy memcached`.

### Checklist
- [ ] New coverage tests
- [ ] Unit tests passing
- [ ] E2E tests passing
- [ ] E2E downgrade/update test passing
- [ ] Documentation updated
- [ ] No warnings or errors on Deepsource/Codecov
  • Loading branch information
Twsouza committed Dec 13, 2022
1 parent b33b4f3 commit 4b76c3b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/cli/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ func ResourcesProxy(rack sdk.Interface, c *stdcli.Context) error {
return fmt.Errorf("no url for resource: %s", r.Name)
}

u, err := url.Parse(r.Url)
resourceUrl := r.Url
if !strings.HasPrefix(r.Url, "http") {
resourceUrl = fmt.Sprintf("http://%s", r.Url)
}

u, err := url.Parse(resourceUrl)
if err != nil {
return err
}
Expand Down Expand Up @@ -504,7 +509,12 @@ func RackResourcesProxy(rack sdk.Interface, c *stdcli.Context) error {
return fmt.Errorf("no url for resource: %s", r.Name)
}

u, err := url.Parse(r.Url)
resourceUrl := r.Url
if !strings.HasPrefix(r.Url, "http") {
resourceUrl = fmt.Sprintf("http://%s", r.Url)
}

u, err := url.Parse(resourceUrl)
if err != nil {
return err
}
Expand Down

0 comments on commit 4b76c3b

Please sign in to comment.