Skip to content

feat: validate Kptfile Inventory and Upstream - #4736

Open
vishnukothakapu wants to merge 1 commit into
kptdev:mainfrom
vishnukothakapu:feature/kptfile-validation
Open

feat: validate Kptfile Inventory and Upstream#4736
vishnukothakapu wants to merge 1 commit into
kptdev:mainfrom
vishnukothakapu:feature/kptfile-validation

Conversation

@vishnukothakapu

Copy link
Copy Markdown
Contributor

Description

Description of the change
This PR introduces explicit validation for the Inventory and Upstream fields within the Kptfile API.

  • It updates the Kptfile.Validate() method to execute sub-validators for these fields if they are populated.
  • For Inventory, it ensures that Name, Namespace, and InventoryID are present using the existing IsValid() method.
  • For Upstream, it ensures that a valid Type (git or generic) and a valid UpdateStrategy are specified, and strictly enforces that a repository is provided if the origin is git.
  • Includes full unit test coverage for these new validation paths in api/kptfile/v1/validation_test.go.

Motivation for the change
Currently, kpt only validates the Pipeline field of the Kptfile during early parsing, leaving other crucial fields unchecked (as noted by a TODO in the codebase). Hand-editing a Kptfile with malformed Upstream or Inventory data 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

@netlify

netlify Bot commented Sep 6, 2026

Copy link
Copy Markdown

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 8861be2
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6a9dcdd0cde10300087c07f3
😎 Deploy Preview https://deploy-preview-4736--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@vishnukothakapu
vishnukothakapu force-pushed the feature/kptfile-validation branch from 00ff379 to 8861be2 Compare September 6, 2026 20:32
@sonarqubecloud

sonarqubecloud Bot commented Sep 6, 2026

Copy link
Copy Markdown

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.

1 participant