Skip to content

Commit

Permalink
Add download and path urls (#174)
Browse files Browse the repository at this point in the history
At the moment, only the `/search` endpoint contains the download url. This is now also added to the package info. In addition a field `path` is added which is the path to the package info. This should help with breaking changes in the future so EPM can rely on this information to find the info about a package instead of having to hard code it.
  • Loading branch information
ruflin authored Dec 3, 2019
1 parent 13ad34b commit 490ed41
Show file tree
Hide file tree
Showing 15 changed files with 46 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Add missing assets from datasets. [#146](https://github.com/elastic/integrations-registry/pull/146)
* Add `format_version` to define the package format.
* Add dataset array to package info endpoint. [#162](https://github.com/elastic/integrations-registry/pull/162)
* Add path field to search and package info endpoint. [#174](https://github.com/elastic/integrations-registry/pull/174)
* Add download field to package info endpoint. [#174](https://github.com/elastic/integrations-registry/pull/174)

### Deprecated

Expand Down
4 changes: 3 additions & 1 deletion docs/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@
"type": "logs",
"ingest_pipeline": "pipeline-entry"
}
]
],
"download": "/package/example-1.0.0.tar.gz",
"path": "/package/example-1.0.0"
}
1 change: 1 addition & 0 deletions docs/api/search-category-logs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "This is the example integration",
"download": "/package/example-1.0.0.tar.gz",
"name": "example",
"path": "/package/example-1.0.0",
"title": "Example Integration",
"type": "integration",
"version": "1.0.0"
Expand Down
2 changes: 2 additions & 0 deletions docs/api/search-category-metrics.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "This is the example integration",
"download": "/package/example-1.0.0.tar.gz",
"name": "example",
"path": "/package/example-1.0.0",
"title": "Example Integration",
"type": "integration",
"version": "1.0.0"
Expand All @@ -11,6 +12,7 @@
"description": "This is the foo integration",
"download": "/package/foo-1.0.0.tar.gz",
"name": "foo",
"path": "/package/foo-1.0.0",
"title": "Foo",
"type": "solution",
"version": "1.0.0"
Expand Down
1 change: 1 addition & 0 deletions docs/api/search-kibana652.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "This is the example integration.",
"download": "/package/example-0.0.2.tar.gz",
"name": "example",
"path": "/package/example-0.0.2",
"title": "Example",
"type": "integration",
"version": "0.0.2"
Expand Down
2 changes: 2 additions & 0 deletions docs/api/search-kibana721.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "This is the example integration",
"download": "/package/example-1.0.0.tar.gz",
"name": "example",
"path": "/package/example-1.0.0",
"title": "Example Integration",
"type": "integration",
"version": "1.0.0"
Expand All @@ -11,6 +12,7 @@
"description": "This is the foo integration",
"download": "/package/foo-1.0.0.tar.gz",
"name": "foo",
"path": "/package/foo-1.0.0",
"title": "Foo",
"type": "solution",
"version": "1.0.0"
Expand Down
2 changes: 2 additions & 0 deletions docs/api/search-package-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "This is the example integration.",
"download": "/package/example-0.0.2.tar.gz",
"name": "example",
"path": "/package/example-0.0.2",
"title": "Example",
"type": "integration",
"version": "0.0.2"
Expand All @@ -11,6 +12,7 @@
"description": "This is the example integration",
"download": "/package/example-1.0.0.tar.gz",
"name": "example",
"path": "/package/example-1.0.0",
"title": "Example Integration",
"type": "integration",
"version": "1.0.0"
Expand Down
3 changes: 3 additions & 0 deletions docs/api/search-package-internal.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "This is the example integration",
"download": "/package/example-1.0.0.tar.gz",
"name": "example",
"path": "/package/example-1.0.0",
"title": "Example Integration",
"type": "integration",
"version": "1.0.0"
Expand All @@ -11,6 +12,7 @@
"description": "This is the foo integration",
"download": "/package/foo-1.0.0.tar.gz",
"name": "foo",
"path": "/package/foo-1.0.0",
"title": "Foo",
"type": "solution",
"version": "1.0.0"
Expand All @@ -20,6 +22,7 @@
"download": "/package/internal-1.2.0.tar.gz",
"internal": true,
"name": "internal",
"path": "/package/internal-1.2.0",
"title": "Internal",
"type": "integration",
"version": "1.2.0"
Expand Down
2 changes: 2 additions & 0 deletions docs/api/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "This is the example integration",
"download": "/package/example-1.0.0.tar.gz",
"name": "example",
"path": "/package/example-1.0.0",
"title": "Example Integration",
"type": "integration",
"version": "1.0.0"
Expand All @@ -11,6 +12,7 @@
"description": "This is the foo integration",
"download": "/package/foo-1.0.0.tar.gz",
"name": "foo",
"path": "/package/foo-1.0.0",
"title": "Foo",
"type": "solution",
"version": "1.0.0"
Expand Down
3 changes: 2 additions & 1 deletion search.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ func getPackageOutput(packagesList map[string]map[string]util.Package) ([]byte,
"description": m.Description,
"version": m.Version,
"type": m.Type,
"download": "/package/" + m.Name + "-" + m.Version + ".tar.gz",
"download": m.GetDownloadPath(),
"path": m.GetUrlPath(),
}
if m.Title != nil {
data["title"] = *m.Title
Expand Down
4 changes: 3 additions & 1 deletion testdata/public/package/example-0.0.2/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@
"/package/example-0.0.2/kibana/visualization/80844540-5c97-11e9-8477-077ec9664dbd.json",
"/package/example-0.0.2/kibana/visualization/ab48c3f0-5ca6-11e9-8477-077ec9664dbd.json"
],
"format_version": "1.0.0"
"format_version": "1.0.0",
"download": "/package/example-0.0.2.tar.gz",
"path": "/package/example-0.0.2"
}
4 changes: 3 additions & 1 deletion testdata/public/package/example-1.0.0/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@
"type": "logs",
"ingest_pipeline": "pipeline-entry"
}
]
],
"download": "/package/example-1.0.0.tar.gz",
"path": "/package/example-1.0.0"
}
4 changes: 3 additions & 1 deletion testdata/public/package/foo-1.0.0/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
"assets": [
"/package/foo-1.0.0/manifest.yml"
],
"format_version": "1.0.0"
"format_version": "1.0.0",
"download": "/package/foo-1.0.0.tar.gz",
"path": "/package/foo-1.0.0"
}
4 changes: 3 additions & 1 deletion testdata/public/package/internal-1.2.0/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
"/package/internal-1.2.0/manifest.yml"
],
"internal": true,
"format_version": "1.0.0"
"format_version": "1.0.0",
"download": "/package/internal-1.2.0.tar.gz",
"path": "/package/internal-1.2.0"
}
14 changes: 14 additions & 0 deletions util/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ type Package struct {
Internal bool `config:"internal,omitempty" json:"internal,omitempty"`
FormatVersion string `config:"format_version" json:"format_version"`
DataSets []*DataSet `config:"datasets,omitempty" json:"datasets,omitempty"`
Download string `json:"download"`
Path string `json:"path"`
}

type Requirement struct {
Expand Down Expand Up @@ -136,6 +138,10 @@ func NewPackage(basePath, packageName string) (*Package, error) {
p.Readme = &readmePathShort
}

// Assign download path to be part of the output
p.Download = p.GetDownloadPath()
p.Path = p.GetUrlPath()

return p, nil
}

Expand Down Expand Up @@ -320,3 +326,11 @@ func (p *Package) LoadDataSets(packagePath string) error {
func (p *Package) GetPath() string {
return p.Name + "-" + p.Version
}

func (p *Package) GetDownloadPath() string {
return "/package/" + p.Name + "-" + p.Version + ".tar.gz"
}

func (p *Package) GetUrlPath() string {
return "/package/" + p.Name + "-" + p.Version
}

0 comments on commit 490ed41

Please sign in to comment.