Skip to content

Add ability to build specific docker variants#5338

Merged
blakerouse merged 2 commits intoelastic:mainfrom
blakerouse:package-docker-variant-selection
Aug 28, 2024
Merged

Add ability to build specific docker variants#5338
blakerouse merged 2 commits intoelastic:mainfrom
blakerouse:package-docker-variant-selection

Conversation

@blakerouse
Copy link
Contributor

@blakerouse blakerouse commented Aug 21, 2024

What does this PR do?

Adds ability to adjust package building to build only a subset of docker image variants.

Why is it important?

Helps with developer velocity, where iterating on an image is quicker because you can select only a specific variant to build.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • [ ] I have added tests that prove my fix is effective or that my feature works (dev-tools/ only)
  • [ ] I have added an entry in ./changelog/fragments using the changelog tool (dev-tools/ only)
  • [ ] I have added an integration test or an E2E test (dev-tools/ only)

Disruptive User Impact

None

How to test this PR locally

Build a specific image variant:

PLATFORMS="linux/arm64" PACKAGES="docker" SNAPSHOT="true" EXTERNAL="true" DOCKER_VARIANTS="wolfi" mage package

Build a specific subset variant:

PLATFORMS="linux/arm64" PACKAGES="docker" SNAPSHOT="true" EXTERNAL="true" DOCKER_VARIANTS="basic wolfi cloud" mage package

Build all variants:

PLATFORMS="linux/arm64" PACKAGES="docker" SNAPSHOT="true" EXTERNAL="true" mage package

@blakerouse blakerouse self-assigned this Aug 21, 2024
@blakerouse blakerouse requested a review from a team as a code owner August 21, 2024 16:11
@elasticmachine
Copy link
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@blakerouse blakerouse changed the title Add ability to select docker variant Add ability to build specific docker variants Aug 21, 2024
@elastic-sonarqube
Copy link

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

Copy link
Member

@pchila pchila left a comment

Choose a reason for hiding this comment

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

Just a small suggestion, non-blocking.
Looks good 👍

Comment on lines +136 to +141
for _, v := range SelectedDockerVariants {
if v == docVariant {
return true
}
}
return false
Copy link
Member

Choose a reason for hiding this comment

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

Nit: we can use something more compact:

Suggested change
for _, v := range SelectedDockerVariants {
if v == docVariant {
return true
}
}
return false
return slices.Contains(SelectedDockerVariants, docVariant)

https://pkg.go.dev/slices#Contains

@blakerouse blakerouse merged commit fd477ec into elastic:main Aug 28, 2024
@blakerouse blakerouse deleted the package-docker-variant-selection branch August 28, 2024 14:55
v1v added a commit that referenced this pull request Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants