Tool to help creating distributions of packages#1335
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
mrodm
left a comment
There was a problem hiding this comment.
Just take a quick look to this approach, and it looks nice!
This is a tool quite flexible allowing to set different queries to get the desired packages for different scenarios.
For instance it looks easy to create a distribution with just the packages available for Kibana 9.1.0.
The only consideration that I see is that it requires to know how the /search API works along with its query parameters. It will be needed to review the documentation to ensure that there is nothing missing.
01055ed to
973d306
Compare
|
Branch updated, and opening for review. We were missing the scripts and docs to make this tool useful, but we have found that it is already being used by some users. @fred-maussion is using it, and prepared a PR based on this one with the scripts he is using. It can be found in #1554 So I think we can review and merge this one, and keep iterating on it on follow ups. |
cmd/distribution/main.go
Outdated
| baseURL, err := url.Parse(basePath) | ||
| if err != nil { | ||
| // This should not happen because JoinPath already parses the url. | ||
| panic("invalid url") |
There was a problem hiding this comment.
can we use fmt.Fatalf and attach the error?
cmd/distribution/main.go
Outdated
| os.Exit(status) | ||
| } | ||
|
|
||
| type config struct { |
There was a problem hiding this comment.
can we move this config code into its own internal or to a file under main pkg (like download file) ?
| "sync" | ||
| ) | ||
|
|
||
| type taskPool struct { |
There was a problem hiding this comment.
can we use the internal/workers pkg instead of duplicating the code?
There was a problem hiding this comment.
can we organize the yml files under an examples folder or testdata?
There was a problem hiding this comment.
why do we need a copy of Makefile from root here?
There was a problem hiding this comment.
To have the same release targets, though I could remove it as this is not used by now...
…sert in the project
| close(p.pool) | ||
| p.wg.Wait() | ||
| close(p.errC) | ||
| return errors.Join(p.errors...) |
There was a problem hiding this comment.
There was a race condition here, there could be error that haven't been appended yet at this point. Fixed by directly appending the error instead of using a channel.
💚 Build Succeeded
History
cc @jsoriano |
|
This PR adds some reference documentation in https://github.com/elastic/package-registry/blob/main/cmd/distribution/README.md There is also an open follow up PR by @fred-maussion that helps making the tool easier to use, including more docs: #1554 |
|
@theletterf I think we should be documenting this tool in our public docs as well. I tried to look around but couldn't find any references. We do have a section on using elastic-package itself. We also have section on EPR and folks building their own containers. Not sure where the best place would be. |
|
Sounds good. @jsoriano could you open an issue for this in docs-content? |
The tool makes queries to package registry to discover and download packages.
Users provide a configuration file that includes the set of queries to perform, each query receives parameters that map with query parameters. A matrix can be defined with parameters that should be included in all queries.
Actions can be also defined for each package.
Some small examples:
Download all available packages for 9.1.0, with format versions between 2.3 and 3.4.
Download all available packages for 9.1.0, with format versions between 2.3 and 3.4, including prereleases
A couple of more complex examples can be found in the PR:
lite.ymldownloads the latest version of the packages included in the lite distribution, for each one of the given versions of kibana.sample.ymldownloads the latest version of all packages, including their prereleases.