Skip to content

Tool to help creating distributions of packages#1335

Merged
jsoriano merged 29 commits intoelastic:mainfrom
jsoriano:cmd-distribution-scripts
Feb 11, 2026
Merged

Tool to help creating distributions of packages#1335
jsoriano merged 29 commits intoelastic:mainfrom
jsoriano:cmd-distribution-scripts

Conversation

@jsoriano
Copy link
Copy Markdown
Member

@jsoriano jsoriano commented Jul 5, 2025

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.

actions:
  - download:
      destination: ./build/distribution
queries:
  - kibana.version: 9.1.0
    spec.min: 2.3
    spec.max: 3.4

Download all available packages for 9.1.0, with format versions between 2.3 and 3.4, including prereleases

actions:
  - download:
      destination: ./build/distribution
matrix:
  - {}
  - prerelease: true
queries:
  - kibana.version: 9.1.0
    spec.min: 2.3
    spec.max: 3.4

A couple of more complex examples can be found in the PR:

  • lite.yml downloads the latest version of the packages included in the lite distribution, for each one of the given versions of kibana.
  • sample.yml downloads the latest version of all packages, including their prereleases.

@jsoriano jsoriano self-assigned this Jul 5, 2025
@prodsecmachine
Copy link
Copy Markdown

prodsecmachine commented Jul 5, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jsoriano jsoriano force-pushed the cmd-distribution-scripts branch from 01055ed to 973d306 Compare January 20, 2026 11:06
@jsoriano
Copy link
Copy Markdown
Member Author

jsoriano commented Feb 9, 2026

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.

@jsoriano jsoriano marked this pull request as ready for review February 9, 2026 17:18
@jsoriano jsoriano requested a review from a team as a code owner February 9, 2026 17:18
baseURL, err := url.Parse(basePath)
if err != nil {
// This should not happen because JoinPath already parses the url.
panic("invalid url")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use fmt.Fatalf and attach the error?

os.Exit(status)
}

type config struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this config code into its own internal or to a file under main pkg (like download file) ?

"sync"
)

type taskPool struct {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use the internal/workers pkg instead of duplicating the code?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we organize the yml files under an examples folder or testdata?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need a copy of Makefile from root here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To have the same release targets, though I could remove it as this is not used by now...

close(p.pool)
p.wg.Wait()
close(p.errC)
return errors.Join(p.errors...)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jsoriano jsoriano requested a review from mrodm February 10, 2026 15:16
@elasticmachine
Copy link
Copy Markdown

💚 Build Succeeded

History

cc @jsoriano

Copy link
Copy Markdown
Contributor

@mrodm mrodm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jsoriano jsoriano merged commit 500b635 into elastic:main Feb 11, 2026
5 checks passed
@jsoriano jsoriano deleted the cmd-distribution-scripts branch February 11, 2026 19:04
@nimarezainia
Copy link
Copy Markdown

@jsoriano @mrodm was this tool and options documented?

@jsoriano
Copy link
Copy Markdown
Member Author

@jsoriano @mrodm was this tool and options documented?

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

@nimarezainia
Copy link
Copy Markdown

@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.

@theletterf
Copy link
Copy Markdown
Member

Sounds good. @jsoriano could you open an issue for this in docs-content?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants