Skip to content

Conversation

@AustinAbro321
Copy link
Member

@AustinAbro321 AustinAbro321 commented Oct 23, 2025

Commands that do not have an impact on the cluster such as inspect do not implement the version check. Additionally, Publish is very generic and not effected by the actual layout.

This removed .build.LastNonBreakingChange which was set but not used

This is what the error message will look like to the user. I created got this by manually setting .build.VersionRequirements then creating and deploying that package

image

Related Issue

Fixes #4256

Checklist before merging

Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
@netlify
Copy link

netlify bot commented Oct 23, 2025

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 58e082e
🔍 Latest deploy log https://app.netlify.com/projects/zarf-docs/deploys/69037969dc7df50008257924

@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 54.33071% with 58 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/internal/packager/requirements/requirements.go 60.65% 19 Missing and 5 partials ⚠️
src/cmd/dev.go 25.00% 6 Missing ⚠️
src/pkg/packager/deploy.go 0.00% 5 Missing ⚠️
src/pkg/packager/dev.go 0.00% 5 Missing ⚠️
src/pkg/packager/inspect.go 0.00% 5 Missing ⚠️
src/pkg/packager/load/import.go 28.57% 5 Missing ⚠️
src/pkg/packager/remove.go 0.00% 5 Missing ⚠️
src/cmd/package.go 75.00% 3 Missing ⚠️
Files with missing lines Coverage Δ
src/api/v1alpha1/package.go 32.55% <ø> (ø)
src/internal/pkgcfg/pkgcfg.go 67.37% <ø> (-0.68%) ⬇️
src/pkg/packager/create.go 56.32% <100.00%> (+0.50%) ⬆️
src/pkg/packager/find_images.go 55.93% <100.00%> (+0.13%) ⬆️
src/pkg/packager/lint.go 65.38% <100.00%> (+1.38%) ⬆️
src/pkg/packager/load/load.go 37.22% <100.00%> (ø)
src/pkg/packager/publish.go 63.92% <100.00%> (+0.22%) ⬆️
src/cmd/package.go 40.60% <75.00%> (+0.28%) ⬆️
src/pkg/packager/deploy.go 0.00% <0.00%> (ø)
src/pkg/packager/dev.go 0.00% <0.00%> (ø)
... and 5 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

AustinAbro321 and others added 4 commits October 23, 2025 11:34
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
@AustinAbro321 AustinAbro321 changed the title feat: add check version requirement check feat: add check version requirement Oct 23, 2025
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
@AustinAbro321 AustinAbro321 marked this pull request as ready for review October 23, 2025 18:08
@AustinAbro321 AustinAbro321 requested review from a team as code owners October 23, 2025 18:08
// List of migrations tracked in the zarf.yaml build data.
const (
// This should be updated when a breaking change is introduced to the Zarf package structure. See: https://github.com/zarf-dev/zarf/releases/tag/v0.27.0
LastNonBreakingVersion = "v0.27.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

CurrentVersion string
}

func (e *VersionRequirementsError) Error() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Non-blocking, more of a discussion item. There's an alternative path for this where we use a NewVersionRequirementsError(...) VersionRequirementsError constructor function, and calculate all of the necessary fields upfront. Then the error method can assemble the message string from the pre-calculated fields. I expect that this approach would be a bit more readable, but it is otherwise equivalent.

Copy link
Member Author

@AustinAbro321 AustinAbro321 Oct 24, 2025

Choose a reason for hiding this comment

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

Not sure if this is what you mean but I moved the logic to determine the highest required version out of the error message, which I agree is better

Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
@brandtkeller brandtkeller moved this to PR Review in Zarf Oct 24, 2025
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Copy link
Member

@brandtkeller brandtkeller left a comment

Choose a reason for hiding this comment

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

Approach is generally straight-forward. One minor comment for build data.

Signed-off-by: Austin Abro <austinabro321@gmail.com>
Signed-off-by: Austin Abro <austinabro321@gmail.com>
Copy link
Member

@brandtkeller brandtkeller left a comment

Choose a reason for hiding this comment

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

Few questions for my own education.

// SPDX-FileCopyrightText: 2021-Present The Zarf Authors

// Package requirements validates that Zarf meets the version requirements defined by the package
package requirements
Copy link
Member

Choose a reason for hiding this comment

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

Couple Questions:

  1. Do we have a expected example of how to utilize these when necessary?
  2. Are we using build data as state to manage collecting these requirements throughout the create lifecycle?
  3. Should we add documentation to support more of a user-facing warning "skipping the version check may introduce...." .

Copy link
Member Author

@AustinAbro321 AustinAbro321 Oct 30, 2025

Choose a reason for hiding this comment

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

  1. I see the setting of the data as something that will be done at create time in the recordPackageMetadata function. For instance, you may have a block like this:
	var versionRequirements []v1alpha1.VersionRequirement
	for _, comp := range pkg.Components {
		for _, v := range comp.Charts {
			if v.Version == "" {
				versionRequirements = append(versionRequirements, v1alpha1.VersionRequirement{
					Version: "v0.65.0",
					Reason:  "the internal file structure of charts has changed in the v1beta1 schema. Zarf is backwards compatible with these changes from v0.65.0+",
				})
				break
			}
		}
	}
	pkg.Build.VersionRequirements = versionRequirements
  1. I think this will be defined by whats in the package / general changes to Zarf, so we can always set it towards the end of create
  2. I think so, especially when we have real use cases in the defined. Interested in your thoughts on how that might be structured.

Copy link
Member Author

@AustinAbro321 AustinAbro321 Oct 30, 2025

Choose a reason for hiding this comment

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

Let me know if there's a better place to document this example, for now, I linked this block to issue #2245. As that's the first use case I can think of

Signed-off-by: Austin Abro <austinabro321@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: PR Review

Development

Successfully merging this pull request may close these issues.

Add VersionRequirements at build time to prevent operations on incompatible versions

4 participants