Skip to content

Allow to define EPR and Kibana repository URL in elastic-package configuration file#3232

Merged
mrodm merged 21 commits intoelastic:mainfrom
mrodm:command-custom-epr-kibana-urls-config
Jan 29, 2026
Merged

Allow to define EPR and Kibana repository URL in elastic-package configuration file#3232
mrodm merged 21 commits intoelastic:mainfrom
mrodm:command-custom-epr-kibana-urls-config

Conversation

@mrodm
Copy link
Contributor

@mrodm mrodm commented Jan 26, 2026

Follows #3229
Part of #2993

Includes two new configuration into ~/.elastic-package/config.yml to allow overriding the defaults URLs used by elastic-package.

Example:

stack:
    image_ref_overrides: {}
profile:
    current: default

## New configuration fields
package_registry:
  base_url: "https://epr.elastic.co"
status:
  kibana_repository:
    base_url: "https://raw.githubusercontent.com/elastic/kibana"

This PR keeps the same default values:

In the case of the package registry, the value from the configuration file will be taken into consideration for the following commands such as:

  • elastic-package stack up (Serverless and Environment providers)
  • elastic-package stack update (Docker Compose provider)
  • elastic-package status
  • elastic-package test script (stackUp function)

This PR also takes into account the profile setting stack.epr.proxy_to. This configuration, if set, will take precedence to get the value to fill the value for the EPR_PROXY_TO environment variable in the packge-registry Dockerfile.

Author's checklist

  • Test with custom package-registry and kibana URLs in elastic-package status.
  • Test with custom package-registry URLs in elastic-package stack (Serverless provider).
  • Test with custom package-registry URLs in elastic-package stack (Environment provider).
  • Ensure that elastic-package keeps using the default URLs if they are not specified in the config.
  • Update documentation

How to test this PR locally

  • Edit ~/.elastic-package/config.yml including:
package_registry:
  base_url: "https://epr-staging.elastic.co"
status:
  kibana_repository:
    base_url: "https://raw.githubusercontent.com/mrodm/kibana"
  • Run elastic-package status with different parameters:
# It should use the custom EPR URL
go run github.com/elastic/elastic-package -C test/packages/parallel/nginx status -vv

# It should use the custom EPR URL and the custom Kibana Repository URL
# Delete the cache folder to force query to the Github URL
rm -rf ~/.elastic-package/cache/kibana_config
go run github.com/elastic/elastic-package -C test/packages/parallel/nginx status -vv --info kibana.version,serverless.project_types
# Example output:
# TRACE Sending request to Package Registry API: https://epr-staging.elastic.co/search?all=false&experimental=true&package=nginx&prerelease=true
# TRACE Request Serverless Kibana configuration from https://raw.githubusercontent.com/mrodm/kibana/main/config/serverless.oblt.yml
# TRACE Request Serverless Kibana configuration from https://raw.githubusercontent.com/mrodm/kibana/main/config/serverless.security.yml
# TRACE Request Serverless Kibana configuration from https://raw.githubusercontent.com/mrodm/kibana/main/config/serverless.es.yml
# TRACE Sending request to Package Registry API: https://epr-staging.elastic.co/search?all=false&capabilities=apm&capabilities=observability&capabilities=uptime&experimental=true&package=nginx&prerelease=true
# TRACE Sending request to Package Registry API: https://epr-staging.elastic.co/search?all=false&capabilities=security&experimental=true&package=nginx&prerelease=true
# TRACE Sending request to Package Registry API: https://epr-staging.elastic.co/search?all=false&experimental=true&package=nginx&prerelease=true
  • Test for instance with environment provider:
# Once it is started Elasticsearch and Kibana following the previous doc

go run github.com/elastic/elastic-package profiles create environment
go run github.com/elastic/elastic-package profiles use environment

# this command show show that the new EPR URL is being used to get the fleet package
go run github.com/elastic/elastic-package stack up -vv -d --provider environment
# Example output:
# TRACE Sending request to Package Registry API: https://epr-staging.elastic.co/search?all=false&experimental=false&kibana.version=9.2.4&package=fleet_server&prerelease=false
# DEBUG Found fleet_server package - version 1.6.0


go run github.com/elastic/elastic-package stack down -v

@mrodm mrodm self-assigned this Jan 26, 2026
@mrodm
Copy link
Contributor Author

mrodm commented Jan 27, 2026

Missing to add a new profile setting stack.epr.base_url to be able to override the package registry URL used in those commands using profile (e.g. elastic-package stack)

@mrodm mrodm marked this pull request as ready for review January 27, 2026 10:52
@mrodm mrodm requested a review from a team January 27, 2026 10:53
profile:
current: default
schema_urls:
ecs_base: https://raw.githubusercontent.com/elastic/ecs
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: just thinking now, should this be ecs_base_url ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it would not be needed since this field is under the key schema_urls that already refers to URLs.

}
p.elasticsearch = elasticsearch

p.registry = registry.NewClient(appConfig.PackageRegistryBaseURL())
Copy link
Contributor

Choose a reason for hiding this comment

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

could we benefit of passing just the url as a string? instead of the struct for appConfig, given that we only need one of its params

Profile *profile.Profile
Printer Printer
Profile *profile.Profile
AppConfig *install.ApplicationConfiguration
Copy link
Contributor

Choose a reason for hiding this comment

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

currently we use this AppConfig to provide the registryURL, could we just pass along the string url, and change it into a struct if we need future options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This value could depend on the specific use case.
For instance, for stack commands the registry URL value will depend on where it is used:

To write the value of EPR_PROXY_TO variable, this value depends on the stack.epr.proxy_to setting from the profile or the value in the configuration file.

However other usages in stack commands will depend on another profile setting stack.epr.base_url and the value in the configuration file. This will be required when doing elastic-package stack up in Serverless or Environment providers.

This last scenario described can be observed in the changes applied in #3235

So, maybe we need to keep both the profile and the configuration.

Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

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

Looks good, thanks, added some small suggestions.

cmd/status.go Outdated
}

func getPackageStatus(packageName string, options registry.SearchOptions) (*status.PackageStatus, error) {
func getPackageStatus(packageName string, options registry.SearchOptions, registryClient *registry.Client) (*status.PackageStatus, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit. I would place the client as first parameter, here and in the other methods where this is added.

Suggested change
func getPackageStatus(packageName string, options registry.SearchOptions, registryClient *registry.Client) (*status.PackageStatus, error) {
func getPackageStatus(registryClient *registry.Client, packageName string, options registry.SearchOptions) (*status.PackageStatus, error) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! I've applied these changes in 9108ad8

Comment on lines +192 to +198
if ac == nil {
return "https://raw.githubusercontent.com/elastic/kibana"
}
if ac.c.Status.KibanaRepository.BaseURL != "" {
return ac.c.Status.KibanaRepository.BaseURL
}
return defaultKibanaRepositoryBaseURL
Copy link
Member

Choose a reason for hiding this comment

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

Or:

Suggested change
if ac == nil {
return "https://raw.githubusercontent.com/elastic/kibana"
}
if ac.c.Status.KibanaRepository.BaseURL != "" {
return ac.c.Status.KibanaRepository.BaseURL
}
return defaultKibanaRepositoryBaseURL
if ac == nil || ac.c.Status.KibanaRepository.BaseURL == "" {
return defaultKibanaRepositoryBaseURL
}
return ac.c.Status.KibanaRepository.BaseURL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Applied these changes here 112327b

require.NoError(t, err)
}

config, err := Configuration()
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we could have a method that initializes the configuration from a given directory, so we don't need to set ELASTIC_PACKAGE_DATA_HOME.

Suggested change
config, err := Configuration()
config, err := configurationFromDir(tmpDir)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added change for this test 61bb121

@elasticmachine
Copy link
Collaborator

elasticmachine commented Jan 29, 2026

💛 Build succeeded, but was flaky

Failed CI Steps

History

cc @mrodm

@mrodm mrodm merged commit f9bca8d into elastic:main Jan 29, 2026
3 checks passed
@mrodm mrodm deleted the command-custom-epr-kibana-urls-config branch January 29, 2026 10:00
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.

4 participants