feat: validate Kptfile Inventory and Upstream - #4736
Open
vishnukothakapu wants to merge 1 commit into
Open
Conversation
vishnukothakapu
requested review from
efiacor,
kispaljr,
liamfallon and
mozesl-nokia
as code owners
September 6, 2026 18:57
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Signed-off-by: Vishnu Kothakapu <[email protected]>
vishnukothakapu
force-pushed
the
feature/kptfile-validation
branch
from
September 6, 2026 20:32
00ff379 to
8861be2
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Description of the change
This PR introduces explicit validation for the
InventoryandUpstreamfields within theKptfileAPI.Kptfile.Validate()method to execute sub-validators for these fields if they are populated.Inventory, it ensures thatName,Namespace, andInventoryIDare present using the existingIsValid()method.Upstream, it ensures that a validType(gitorgeneric) and a validUpdateStrategyare specified, and strictly enforces that a repository is provided if the origin isgit.api/kptfile/v1/validation_test.go.Motivation for the change
Currently,
kptonly validates thePipelinefield of theKptfileduring early parsing, leaving other crucial fields unchecked (as noted by aTODOin the codebase). Hand-editing aKptfilewith malformedUpstreamorInventorydata can lead to unexpected and confusing runtime errors much later in the command execution cycle.By shifting this validation to the earliest possible point (the core
Validate()method), we significantly improve the developer experience by catching malformed configurations immediately.Fixes #4735