Skip to content

Separate API types module#1060

Open
mozesl-nokia wants to merge 12 commits into
kptdev:mainfrom
nokia:api-module
Open

Separate API types module#1060
mozesl-nokia wants to merge 12 commits into
kptdev:mainfrom
nokia:api-module

Conversation

@mozesl-nokia

@mozesl-nokia mozesl-nokia commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Title

Separate API types module


Description

  • What changed: Made the api directory a separate go module, copied packagevariant/set and internal api to here.
  • Why it’s needed: So that downstream consumers that only need the API don't need to import the entirety of porch
  • How it works: By api being a separate module, it can be imported independently

Simplified the code generation so it is now done by one go:generate line, but the side effect of that is all the CRDs are now generated into a single directory (I think this is a positive).

This PR also includes using the independent kpt api module, thus the kpt version has been bumped as well.


Related Issue(s)


Type of Change

  • New feature
  • Enhancement
  • Refactor

Checklist

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

Testing Instructions (Optional)

  1. lint, generate, generate-mocks works as expected
  2. setting up the dev env and run-in-kind works
  3. unit tests and e2e passes

Additional Notes (Optional)

  • Known issues: Since we generate informers and such with 1.36.1 code generator, the api module needs 0.36.1 of the k8s api.
  • Further improvements: See if any of the dependencies of the api module can be removed or lowered. Pull a lot of the utility functions centred around around type transformations into the api module.
  • Review notes: A lot of files had imports changed, that is why the changed file number is so high.

AI Disclosure

I have not used AI in the creation of this PR.

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@mozesl-nokia mozesl-nokia requested review from a team and Copilot June 18, 2026 14:42
@netlify

netlify Bot commented Jun 18, 2026

Copy link
Copy Markdown

Deploy Preview for kpt-porch ready!

Name Link
🔨 Latest commit b200864
🔍 Latest deploy log https://app.netlify.com/projects/kpt-porch/deploys/6a3411538cfda800082b7388
😎 Deploy Preview https://deploy-preview-1060--kpt-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.

@dosubot dosubot Bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Jun 18, 2026
@mozesl-nokia mozesl-nokia added enhancement New feature or request dependencies Update project dependencies go Pull requests that update go code labels Jun 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refactors Porch’s API surface so the api/ directory becomes an independently importable Go module, and updates the codebase to consume the standalone github.com/kptdev/kpt/api module. It also streamlines code generation (single go:generate) and centralizes generated CRDs under api/generated/crds.

Changes:

  • Split api/ into its own Go module (github.com/kptdev/porch/api) and adjust build/tidy/lint workflows accordingly.
  • Migrate imports from github.com/kptdev/kpt/pkg/api/... to github.com/kptdev/kpt/api/... across controllers, pkg, func, and tests.
  • Consolidate/move PackageVariant / PackageVariantSet / internal PackageRev APIs into api/porchconfig, and update CRD generation + deployment scripts to use the generated CRD directory.

Reviewed changes

Copilot reviewed 108 out of 119 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
test/mockery/mocks/porch/pkg/repository/mock_PackageRevision.go Update kptfile import path to kpt/api.
test/mockery/mocks/porch/pkg/repository/mock_PackageContent.go Update kptfile import path to kpt/api.
test/mockery/mocks/porch/pkg/repository/mock_ExternalPackageFetcher.go Update kptfile import path to kpt/api.
test/e2e/suiteutils/suite.go Update kptfile import and scheme registration for moved APIs.
test/e2e/suiteutils/suite_utils.go Update kptfile import and switch to porchconfig API types for PV/PkgRev usage.
test/e2e/api/rpkg_subpkg_test.go Update kptfile import path to kpt/api.
test/e2e/api/rpkg_init_test.go Update kptfile import path to kpt/api.
test/e2e/api/rpkg_edit_test.go Update kptfile import path to kpt/api.
test/e2e/api/rpkg_clone_test.go Update kptfile import path to kpt/api.
test/e2e/api/render_failure_test.go Update kptfile import path to kpt/api.
test/disaster/api/environment/packagevariantsets/packagevariantsets.go Switch PVSet API import to porchconfig v1alpha2.
test/disaster/api/environment/packagevariants/packagevariants.go Switch PV API import to porchconfig v1alpha1.
scripts/generate-api.sh Run codegen from api/ module root and emit to api/generated.
scripts/create-deployment-blueprint.sh Copy CRDs from api/generated/crds instead of legacy locations.
pkg/task/upgrade_test.go Update kptfile import path to kpt/api.
pkg/task/simpleruntime_test.go Update kptfile import path to kpt/api.
pkg/task/render.go Update fnresult import path to kpt/api.
pkg/task/render_test.go Update kptfile import path to kpt/api.
pkg/task/patch_test.go Update kptfile import path to kpt/api.
pkg/task/generictaskhandler.go Update kptfile import path to kpt/api.
pkg/task/generictaskhandler_test.go Update kptfile import path to kpt/api.
pkg/task/edit_test.go Update kptfile import path to kpt/api.
pkg/task/clone.go Update kptfile import path to kpt/api.
pkg/task/clone_test.go Update kptfile import path to kpt/api.
pkg/repository/util.go Update kptfile import path to kpt/api.
pkg/repository/util_test.go Update kptfile import path to kpt/api.
pkg/repository/repository.go Update kptfile import path to kpt/api.
pkg/repository/repository_test.go Update kptfile import path to kpt/api.
pkg/repository/content.go Update kptfile import path to kpt/api.
pkg/registry/porch/packagerevision_test.go Update kptfile import path to kpt/api.
pkg/externalrepo/oci/oci.go Update kptfile import path to kpt/api.
pkg/externalrepo/git/package.go Update kptfile import path to kpt/api.
pkg/externalrepo/git/package_test.go Update kptfile import path to kpt/api.
pkg/externalrepo/git/git.go Update kptfile import path to kpt/api.
pkg/externalrepo/fake/repository.go Update kptfile import path to kpt/api.
pkg/externalrepo/fake/packagerevision.go Update kptfile import path to kpt/api.
pkg/engine/pushpr.go Update kptfile import path to kpt/api.
pkg/engine/pushpr_test.go Update kptfile import path to kpt/api.
pkg/engine/grpcruntime.go Update kptfile import path to kpt/api.
pkg/engine/grpcruntime_test.go Update kptfile import path to kpt/api.
pkg/engine/engine_test.go Update kptfile import path to kpt/api.
pkg/engine/builtinruntime.go Update kptfile import path to kpt/api.
pkg/engine/builtinruntime_test.go Update kptfile import path to kpt/api.
pkg/cli/commands/rpkg/util/common.go Update kptfile import path to kpt/api.
pkg/cli/commands/rpkg/upgrade/command.go Update kptfile import path to kpt/api.
pkg/cli/commands/rpkg/pull/command.go Update kptfile import path to kpt/api.
pkg/cli/commands/rpkg/get/command.go Update kptfile import path to kpt/api.
pkg/cache/dbcache/dbreposync_test.go Update kptfile import path to kpt/api.
pkg/cache/dbcache/dbrepository.go Update kptfile import path to kpt/api.
pkg/cache/dbcache/dbpackagerevisionsql.go Update kptfile import path to kpt/api.
pkg/cache/dbcache/dbpackagerevision.go Update kptfile import path to kpt/api.
pkg/cache/crcache/meta/store.go Switch internal PackageRev usage to porchconfig API types.
pkg/cache/crcache/meta/store_test.go Update test types from internalapi to porchconfig PackageRev.
pkg/cache/contentcache/wrappers.go Update kptfile import path to kpt/api.
pkg/cache/contentcache/wrappers_test.go Update kptfile import path to kpt/api.
pkg/cache/contentcache/externalfetcher.go Update kptfile import path to kpt/api.
pkg/apiserver/apiserver.go Update scheme types and switch internal PackageRev type to porchconfig.
make/go.mk Add api-module sub-make targets; adjust lint/fix/vet/fmt/tidy flow.
make/build.mk Limit API module generation loop to api/; make tidy run api tidy too.
internal/api/porchinternal/v1alpha1/zz_generated.deepcopy.go Remove internal API deepcopy output (types moved).
go.sum Bump kpt version; add kpt/api and module split sums.
go.mod Add replace+require for github.com/kptdev/porch/api; add kpt/api.
func/internal/executableevaluator.go Update kptfile import path to kpt/api.
func/internal/executableevaluator_test.go Update kptfile import path to kpt/api.
func/Dockerfile-wrapperserver Reorder/collapse grpc-health-probe install and improve build caching.
func/Dockerfile Reorder/collapse grpc-health-probe install and improve build caching.
controllers/repositories/pkg/controllers/repository/repository_controller.go Bump controller-gen version for RBAC generation.
controllers/repositories/pkg/controllers/repository/pkgrevsync_test.go Update kptfile import path to kpt/api.
controllers/packagevariantsets/pkg/controllers/packagevariantset/validate.go Switch PV/PVSet API imports to porchconfig module.
controllers/packagevariantsets/pkg/controllers/packagevariantset/validate_test.go Switch PVSet API imports to porchconfig module.
controllers/packagevariantsets/pkg/controllers/packagevariantset/render.go Switch PV/PVSet API imports to porchconfig module + update kptfile import.
controllers/packagevariantsets/pkg/controllers/packagevariantset/render_test.go Switch PV/PVSet API imports to porchconfig module + update kptfile import.
controllers/packagevariantsets/pkg/controllers/packagevariantset/packagevariantset_controller.go Rewire controller to use porchconfig v1alpha2 PVSet and v1alpha1 PV types.
controllers/packagevariantsets/pkg/controllers/packagevariantset/packagevariantset_controller_test.go Update tests to use porchconfig PV/PVSet types.
controllers/packagevariantsets/pkg/controllers/packagevariantset/fake_client.go Switch PV API import to porchconfig module.
controllers/packagevariantsets/api/v1alpha2/groupversion_info.go Remove old controller-local PVSet API types.
controllers/packagevariantsets/api/v1alpha1/zz_generated.deepcopy.go Remove old controller-local PVSet API deepcopies.
controllers/packagevariantsets/api/v1alpha1/groupversion_info.go Remove old controller-local PVSet API groupversion.
controllers/packagevariants/pkg/controllers/packagevariant/packagevariant_controller.go Switch PV type usage to porchconfig and update kptfile import.
controllers/packagevariants/pkg/controllers/packagevariant/packagevariant_controller-with-workspacename_test.go Switch PV API import to porchconfig module.
controllers/packagevariants/pkg/controllers/packagevariant/packagevariant_controller_test.go Switch PV API import to porchconfig module.
controllers/packagevariants/pkg/controllers/packagevariant/injection.go Switch PV API import to porchconfig module + update kptfile import.
controllers/packagevariants/pkg/controllers/packagevariant/injection-with-workspacename_test.go Switch PV API import to porchconfig module + update kptfile import.
controllers/packagevariants/pkg/controllers/packagevariant/injection_test.go Switch PV API import to porchconfig module + update kptfile import.
controllers/packagevariants/api/v1alpha1/zz_generated.deepcopy.go Remove old controller-local PV API deepcopies.
controllers/packagevariants/api/v1alpha1/groupversion_info.go Remove old controller-local PV API groupversion.
controllers/packagerevisions/pkg/controllers/packagerevision/status.go Update kptfile import path to kpt/api.
controllers/packagerevisions/pkg/controllers/packagerevision/status_test.go Update kptfile import path to kpt/api.
controllers/packagerevisions/pkg/controllers/packagerevision/source.go Update kptfile import path to kpt/api.
controllers/packagerevisions/pkg/controllers/packagerevision/source_test.go Update kptfile import path to kpt/api.
controllers/packagerevisions/pkg/controllers/packagerevision/render.go Update fnresult/kptfile imports to kpt/api.
controllers/packagerevisions/pkg/controllers/packagerevision/packagerevision_controller.go Bump controller-gen version for RBAC generation.
controllers/packagerevisions/pkg/controllers/packagerevision/packagerevision_controller_test.go Update kptfile import path to kpt/api.
controllers/main.go Bump controller-gen version and update scheme registration for moved APIs.
controllers/Dockerfile Remove separate go mod download step (build caching changes).
build/Dockerfile Remove separate go mod download step (build caching changes).
api/porchconfig/v1alpha2/zz_generated.deepcopy.go Update deepcopy imports after moving PV types into porchconfig.
api/porchconfig/v1alpha2/packagevariantset_types.go Update PVSet types to use new module paths and shared v1alpha1 types.
api/porchconfig/v1alpha2/groupversion_info.go Define lightweight TypeInfo registration for v1alpha2 PVSet.
api/porchconfig/v1alpha1/zz_generated.deepcopy.go Add deepcopies for moved PV/PVSet and new PackageRev types.
api/porchconfig/v1alpha1/packagevariantset_types.go Update PVSet v1alpha1 types; align policy types with porchconfig.
api/porchconfig/v1alpha1/packagevariant_types.go Update kptfile import path to kpt/api.
api/porchconfig/v1alpha1/packagerev.go Add new porchconfig PackageRev CRD type.
api/porchconfig/v1alpha1/groupversion_info.go Register added porchconfig types (PackageRev, PV, PVSet) in scheme.
api/porchconfig/doc.go Add groupName doc for porchconfig API group.
api/porch/v1alpha2/kptdata_conversion.go Update kptfile import path to kpt/api.
api/porch/v1alpha2/kptdata_conversion_test.go Update kptfile import path to kpt/api.
api/porch/v1alpha2/groupversion_info.go Remove old controller-gen directives (generation centralized).
api/Makefile Add module-local fmt/vet/fix/tidy/lint targets.
api/go.sum Add sums for the new api module.
api/go.mod Introduce standalone github.com/kptdev/porch/api module definition.
api/generated/crds/porch.kpt.dev_packagerevisions.yaml Regenerate CRD with newer controller-gen version.
api/generated/crds/config.porch.kpt.dev_servicetemplates.yaml Regenerate CRD with newer controller-gen version.
api/generated/crds/config.porch.kpt.dev_repositories.yaml Regenerate CRD with newer controller-gen version.
api/generated/crds/config.porch.kpt.dev_packagevariantsets.yaml Regenerate CRD with newer controller-gen version.
api/generated/crds/config.porch.kpt.dev_packagevariants.yaml Regenerate CRD with newer controller-gen version.
api/generated/crds/config.porch.kpt.dev_packagerevs.yaml Add/regenerate PackageRev CRD (new type) with license header + version update.
api/generated/crds/config.porch.kpt.dev_functionconfigs.yaml Regenerate CRD with newer controller-gen version.
api/doc.go Centralize controller-gen directives for generating api module CRDs.
Files not reviewed (1)
  • api/porchconfig/v1alpha1/zz_generated.deepcopy.go: Generated file
Comments suppressed due to low confidence (1)

pkg/apiserver/apiserver.go:186

  • buildCompleteScheme adds configapi types twice, and the second error message still refers to "internalapi" even though configapi is being added. This makes failures misleading and the extra AddToScheme call is unnecessary.

Comment thread test/e2e/suiteutils/suite.go
Comment thread controllers/main.go
Comment thread api/doc.go
Comment thread make/go.mk Outdated
Comment thread api/Makefile Outdated
Comment thread api/Makefile
Comment thread scripts/generate-api.sh Outdated
Comment thread scripts/generate-api.sh
Comment thread test/e2e/suiteutils/suite_utils.go
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
64.7% Coverage on New Code (required ≥ 80%)
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Comment thread api/porchconfig/v1alpha1/groupversion_info.go
Comment thread api/doc.go
Comment thread api/go.mod
Comment thread build/Dockerfile
Comment thread make/build.mk
Comment thread pkg/apiserver/apiserver.go
Comment thread go.mod
@mozesl-nokia mozesl-nokia requested a review from efiacor June 22, 2026 07:33

@efiacor efiacor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good overall. Would be nice to get a few more human reviews on it.

@dosubot dosubot Bot added the lgtm #ededed label Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Update project dependencies enhancement New feature or request go Pull requests that update go code lgtm #ededed size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move Porch API types to their own module

3 participants