Skip to content

Add SubpackageDir to API to support clone and upgrade of independent subpackages in a PR#974

Open
liamfallon wants to merge 15 commits into
kptdev:mainfrom
Nordix:add-subpackage-to-api
Open

Add SubpackageDir to API to support clone and upgrade of independent subpackages in a PR#974
liamfallon wants to merge 15 commits into
kptdev:mainfrom
Nordix:add-subpackage-to-api

Conversation

@liamfallon
Copy link
Copy Markdown
Collaborator

Add SubpackageDir to API to support clone and upgrade of independent subpackages in a PR


Description

  • What changed: This PR adds a new SubpackageDir field to the clone and upgrade tasks on the v1alpha1 API and to the Clone and Upgrade source specifications on the v1alpha2 API
  • Why it’s needed: Currently it is not possible to clone a PR into an independent subpackage of another PR or to upgrade an independent subpackage in a PR separately from the overall PR
  • How it works: This PR introduces the API changes. The implementation changes to porchctl and to porch will be implemented in separate PRs.

Related Issue(s)


Type of Change

  • Bug fix
  • New feature
  • Enhancement
  • Refactor
  • Documentation
  • Tests
  • Other: ________

Checklist

  • Code follows project style guidelines
  • Self-reviewed changes
  • Tests added/updated
  • Documentation added/updated
  • All tests and gating checks pass

AI Disclosure

[ ] I have used AI in the creation of this PR.

Copilot AI review requested due to automatic review settings May 7, 2026 15:33
@netlify
Copy link
Copy Markdown

netlify Bot commented May 7, 2026

Deploy Preview for porch ready!

Name Link
🔨 Latest commit 013ddc6
🔍 Latest deploy log https://app.netlify.com/projects/porch/deploys/6a0345edf9627900081ecc81
😎 Deploy Preview https://deploy-preview-974--porch.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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Porch APIs to support targeting an independent subpackage directory during clone/upgrade operations by introducing a SubpackageDir field (v1alpha1 task specs and v1alpha2 source specs), and updates related code/tests to the new v1alpha2 clone source shape.

Changes:

  • Add SubpackageDir to v1alpha1 clone/upgrade task specs and propagate it through conversions/OpenAPI.
  • Introduce a PackageCloneSpec wrapper in v1alpha2 and update callers/tests to use spec.source.cloneFrom.cloneFrom.
  • Update controller/CLI logic and unit/e2e tests to reference the new v1alpha2 clone source structure.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
test/e2e/crd/side_by_side_test.go Update e2e clone source construction to the new v1alpha2 clone spec wrapper.
test/e2e/crd/helpers_test.go Adjust helper to build v1alpha2 clone sources using PackageCloneSpec.
test/e2e/crd/clone_test.go Update clone e2e tests for the new v1alpha2 clone source structure.
pkg/cli/commands/rpkg/upgrade/v1alpha2.go Update upstream-name detection to read from the new clone spec wrapper.
pkg/cli/commands/rpkg/upgrade/v1alpha2_test.go Update tests to build clone sources via PackageCloneSpec.
pkg/cli/commands/rpkg/upgrade/command.go Add a --subpackage-dir flag and runner field (currently miswired).
pkg/cli/commands/rpkg/clone/v1alpha2.go Update clone command to set spec.source.cloneFrom via PackageCloneSpec.
controllers/packagerevisions/pkg/controllers/packagerevision/source.go Update controller source application logic to use spec.source.cloneFrom.cloneFrom.
controllers/packagerevisions/pkg/controllers/packagerevision/source_test.go Update controller tests for the new v1alpha2 clone source structure.
api/porch/v1alpha2/zz_generated.deepcopy.go Add deepcopy support for PackageCloneSpec and update PackageSource clone field.
api/porch/v1alpha2/util.go Update creation-source detection to check the new clone wrapper field.
api/porch/v1alpha2/util_test.go Update util tests to use PackageCloneSpec.
api/porch/v1alpha2/source_types.go Add PackageCloneSpec and SubpackageDir fields (with tag issues).
api/porch/v1alpha2/porch.kpt.dev_packagerevisions.yaml Update CRD schema to reflect nested clone spec and new subpackage dir fields.
api/porch/v1alpha2/packagerevision_types.go Change PackageSource.cloneFrom type to *PackageCloneSpec (schema shape change).
api/porch/v1alpha1/zz_generated.conversion.go Wire SubpackageDir through v1alpha1 <-> internal conversions.
api/porch/v1alpha1/types.go Add SubpackageDir to v1alpha1 clone/upgrade task specs (with tag issues).
api/porch/types.go Add SubpackageDir to internal clone/upgrade task specs (with tag issues).
api/generated/openapi/zz_generated.openapi.go Expose the new fields in generated OpenAPI (currently includes misspelled key).
Comments suppressed due to low confidence (1)

controllers/packagerevisions/pkg/controllers/packagerevision/source.go:131

  • pr.Spec.Source.Clone.CloneFrom may be nil (it is omitempty), and the code dereferences it immediately. This can panic when a PackageRevision is created with source.cloneFrom: {} (or missing cloneFrom inside). Add validation / nil checks and return a clear error when CloneFrom is not set.
func (r *PackageRevisionReconciler) clonePackage(ctx context.Context, pr *porchv1alpha2.PackageRevision) (map[string]string, error) {
	cloneFrom := pr.Spec.Source.Clone.CloneFrom

	if cloneFrom.UpstreamRef != nil {
		return r.cloneFromUpstreamRef(ctx, pr, cloneFrom.UpstreamRef)
	}
	if cloneFrom.Git != nil {
		return r.cloneFromGit(ctx, pr, cloneFrom.Git)
	}
	return nil, fmt.Errorf("clone source must specify either upstreamRef or git")

Comment thread pkg/cli/commands/rpkg/upgrade/command.go Outdated
Comment thread pkg/cli/commands/rpkg/upgrade/v1alpha2.go Outdated
Comment thread api/porch/v1alpha2/source_types.go
Comment thread api/porch/v1alpha2/source_types.go
Comment thread api/porch/v1alpha1/types.go
Comment thread api/porch/v1alpha1/types.go Outdated
Comment thread api/porch/types.go
Comment thread api/porch/types.go Outdated
Comment thread api/porch/v1alpha2/packagerevision_types.go Outdated
Comment thread controllers/packagerevisions/pkg/controllers/packagerevision/source.go Outdated
Copilot AI review requested due to automatic review settings May 7, 2026 15:55
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.

Comment thread api/porch/v1alpha2/packagerevision_types.go Outdated
Comment thread api/porch/v1alpha2/source_types.go Outdated
Copilot AI review requested due to automatic review settings May 8, 2026 14:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@liamfallon liamfallon force-pushed the add-subpackage-to-api branch from 5524a78 to 67a7487 Compare May 11, 2026 10:46
Copilot AI review requested due to automatic review settings May 11, 2026 16:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 4 comments.

Comment thread api/porch/v1alpha2/packagerevision_types.go Outdated
Comment thread api/porch/v1alpha2/packagerevision_types.go Outdated
Comment thread api/porch/v1alpha2/porch.kpt.dev_packagerevisions.yaml Outdated
Comment thread api/porch/v1alpha2/porch.kpt.dev_packagerevisions.yaml
Copilot AI review requested due to automatic review settings May 11, 2026 16:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.

Comment thread api/porch/v1alpha2/source_types.go Outdated
Comment thread api/porch/v1alpha2/packagerevision_types.go Outdated
Comment thread api/porch/v1alpha2/porch.kpt.dev_packagerevisions.yaml
Comment thread controllers/packagerevisions/pkg/controllers/packagerevision/source.go Outdated
Comment thread controllers/packagerevisions/pkg/controllers/packagerevision/source.go Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 18 changed files in this pull request and generated 2 comments.

Files not reviewed (2)
  • api/porch/v1alpha1/zz_generated.conversion.go: Language not supported
  • api/porch/v1alpha2/zz_generated.deepcopy.go: Language not supported

Comment thread api/porch/v1alpha2/source_types.go Outdated
Comment thread api/porch/v1alpha2/packagerevision_types.go
@liamfallon liamfallon force-pushed the add-subpackage-to-api branch from ff45d38 to 6ad0ecf Compare May 12, 2026 12:41
Copilot AI review requested due to automatic review settings May 12, 2026 13:35
@liamfallon liamfallon force-pushed the add-subpackage-to-api branch from 33a961e to a7e6659 Compare May 12, 2026 13:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 22 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • api/porch/v1alpha1/zz_generated.conversion.go: Language not supported
  • api/porch/v1alpha2/zz_generated.deepcopy.go: Language not supported

Comment thread controllers/packagerevisions/pkg/controllers/packagerevision/source.go Outdated
@sonarqubecloud
Copy link
Copy Markdown

Copilot AI review requested due to automatic review settings May 13, 2026 05:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 22 changed files in this pull request and generated 2 comments.

Files not reviewed (2)
  • api/porch/v1alpha1/zz_generated.conversion.go: Language not supported
  • api/porch/v1alpha2/zz_generated.deepcopy.go: Language not supported

Comment thread api/porch/v1alpha2/packagerevision_types.go
Comment thread api/porch/v1alpha2/packagerevision_types.go
Copilot AI review requested due to automatic review settings May 13, 2026 15:38
@liamfallon liamfallon force-pushed the add-subpackage-to-api branch from 8079aeb to dc7c72c Compare May 13, 2026 15:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 22 changed files in this pull request and generated 1 comment.

Files not reviewed (2)
  • api/porch/v1alpha1/zz_generated.conversion.go: Language not supported
  • api/porch/v1alpha2/zz_generated.deepcopy.go: Language not supported

Comment thread api/porch/v1alpha2/porch.kpt.dev_packagerevisions.yaml
Copilot AI review requested due to automatic review settings May 15, 2026 20:01
@liamfallon liamfallon force-pushed the add-subpackage-to-api branch from afb4bb0 to e6ae265 Compare May 15, 2026 20:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 19 out of 22 changed files in this pull request and generated no new comments.

Files not reviewed (2)
  • api/porch/v1alpha1/zz_generated.conversion.go: Language not supported
  • api/porch/v1alpha2/zz_generated.deepcopy.go: Language not supported

liamfallon added 15 commits May 15, 2026 22:07
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
Signed-off-by: liamfallon <liam.fallon@est.tech>
@liamfallon liamfallon force-pushed the add-subpackage-to-api branch from e6ae265 to 50c9952 Compare May 15, 2026 21:07
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.

Add support to the Porch APIs for independent subpackages

2 participants