Github user geomacy commented on a diff in the pull request:
https://github.com/apache/brooklyn-client/pull/48#discussion_r113151481
--- Diff: cli/api/catalog/catalog.go ---
@@ -219,20 +219,22 @@ func AddCatalog(network *net.Network, resource
string) (map[string]models.Catalo
urlString := "/v1/catalog"
var entities map[string]models.CatalogEntitySummary
- //Assume application/json. This is correct for http/file resources.
- //Zips will need application/x-zip
- contentType := "application/json"
+ //Force auto-detect by default
+ contentType := "application/octet-stream"
u, err := url.Parse(resource)
if err != nil {
return nil, err
}
//Only deal with the below file types
- if "" != u.Scheme && "file" != u.Scheme && "http" != u.Scheme &&
"https" != u.Scheme{
+ if "" != u.Scheme && "file" != u.Scheme && "http" != u.Scheme &&
"https" != u.Scheme {
return nil, errors.New("Unrecognised protocol scheme: " +
u.Scheme)
}
if "" == u.Scheme || "file" == u.Scheme {
+ if "file" == u.Scheme {
--- End diff --
We need to check that the path is not empty:
```
if "file" == u.Scheme {
if u.Path == "" {
return nil, errors.New("No resource in 'file:'
URL: " + resource)
}
resource = u.Path
}
```
otherwise `br catalog add file://test.zip` will fail with a panic (needs
to be `br catalog add file:///some/path/test.zip`).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---