Make API it's own go module#4537
Conversation
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR splits the in-repo API surface into its own Go module (github.com/kptdev/kpt/api) and updates the main module to consume those API packages from the new module path, aiming to reduce dependency/cycle issues for API consumers and the SDK.
Changes:
- Introduces a new nested Go module under
api/(with its owngo.mod/go.sum) and wires the root module to it viareplace+require. - Rewrites imports across the repo from
github.com/kptdev/kpt/pkg/api/...(andpkg/lib/types) togithub.com/kptdev/kpt/api/...(including movingUniquePath/DisplayPathintoapi/kptfile/v1). - Adds new API packages/files (e.g.,
api/resourcegroup/v1alpha1) and updates generation targets to rungo generatewithin the new module.
Reviewed changes
Copilot reviewed 87 out of 92 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| thirdparty/kyaml/runfn/runfn.go | Switches to API module imports; uses kptfilev1.UniquePath and fnresultv1. |
| thirdparty/kyaml/runfn/runfn_test.go | Updates tests to import API module packages. |
| thirdparty/cmdconfig/commands/runner/runner.go | Updates import to API module kptfile/v1. |
| thirdparty/cmdconfig/commands/cmdtree/tree.go | Updates import to API module kptfile/v1. |
| thirdparty/cmdconfig/commands/cmdtree/cmdtree.go | Updates import to API module kptfile/v1. |
| thirdparty/cmdconfig/commands/cmdsource/cmdsource.go | Uses API module KptFileName constant. |
| thirdparty/cmdconfig/commands/cmdeval/cmdeval.go | Switches function/Kptfile types to API module equivalents. |
| thirdparty/cmdconfig/commands/cmdcat/cmdcat.go | Updates import to API module kptfile/v1. |
| pkg/test/runner/config.go | Replaces types.UniquePath with kptfilev1.UniquePath. |
| pkg/printer/printer.go | Switches options path types to API module path types. |
| pkg/live/rgstream.go | Updates imports to API module kptfile/resourcegroup. |
| pkg/live/rgpath.go | Updates import to API module resourcegroup/v1alpha1. |
| pkg/live/load.go | Updates imports to API module kptfile/resourcegroup. |
| pkg/live/load_test.go | Updates tests to use API module kptfile/resourcegroup types/constants. |
| pkg/lib/util/parse/parse.go | Updates import to API module kptfile/v1. |
| pkg/lib/util/parse/parse_test.go | Updates tests to use API module kptfilev1.Git. |
| pkg/lib/util/man/man.go | Updates import to API module kptfile/v1 types. |
| pkg/lib/util/man/man_test.go | Updates tests to use API module imports. |
| pkg/lib/util/get/get.go | Uses API module UniquePath in error construction and removes types dependency. |
| pkg/lib/util/get/get_test.go | Updates tests to use API module imports. |
| pkg/lib/util/get/example_test.go | Updates example test to use API module imports. |
| pkg/lib/util/fetch/fetch.go | Uses API module UniquePath in error construction and updates imports. |
| pkg/lib/util/fetch/fetch_test.go | Updates tests to use API module imports. |
| pkg/lib/update/update.go | Replaces types.UniquePath with API module kptfilev1.UniquePath across updater errors. |
| pkg/lib/update/update_test.go | Updates tests to use API module imports. |
| pkg/lib/update/resource-merge.go | Replaces types.UniquePath with API module kptfilev1.UniquePath. |
| pkg/lib/update/replace.go | Replaces types.UniquePath with API module kptfilev1.UniquePath. |
| pkg/lib/update/fastforward.go | Replaces types.UniquePath with API module kptfilev1.UniquePath. |
| pkg/lib/update/fastforward_test.go | Updates tests to use API module imports. |
| pkg/lib/update/copy-merge.go | Replaces types.UniquePath with API module kptfilev1.UniquePath. |
| pkg/lib/update/common.go | Replaces types.UniquePath with API module kptfilev1.UniquePath. |
| pkg/lib/pkg/util.go | Updates import to API module kptfile/v1. |
| pkg/lib/pkg/util_test.go | Updates tests to use API module imports. |
| pkg/lib/pkg/pkg.go | Replaces types.UniquePath/DisplayPath with API module equivalents; updates API imports. |
| pkg/lib/pkg/pkg_test.go | Updates tests to use API module imports. |
| pkg/lib/pkg/diff/pkgdiff.go | Updates import to API module kptfile/v1. |
| pkg/lib/pkg/diff/diff.go | Updates import to API module kptfile/v1. |
| pkg/lib/kptops/render.go | Updates renderer result types to API module fnresult/v1. |
| pkg/lib/kptops/render_executor.go | Updates renderer/hydration types to API module fnresult/kptfile and UniquePath. |
| pkg/lib/kptops/render_executor_test.go | Updates tests to use API module imports and UniquePath type. |
| pkg/lib/kptops/pkgupdate.go | Updates import to API module kptfile/v1. |
| pkg/lib/kptops/hook_executor.go | Updates to API module fnresult/kptfile and UniquePath. |
| pkg/lib/kptops/helpers_test.go | Updates tests to use API module imports. |
| pkg/lib/kptops/clone.go | Updates import to API module kptfile/v1. |
| pkg/lib/kptops/clone_test.go | Updates tests to use API module imports. |
| pkg/lib/errors/resolver/pkg.go | Updates import to API module kptfile/v1. |
| pkg/lib/errors/errors.go | Switches error path type to API module kptfilev1.UniquePath. |
| pkg/lib/errors/errors_test.go | Updates tests to use API module UniquePath. |
| pkg/lib/builtins/pkg_context.go | Updates import to API module kptfile/v1. |
| pkg/kptpkg/init.go | Updates import to API module kptfile/v1. |
| pkg/kptfile/kptfileutil/util.go | Switches KptfileError.Path to API module UniquePath and updates imports. |
| pkg/kptfile/kptfileutil/util_test.go | Updates tests to use API module imports. |
| pkg/fn/runtime/utils.go | Updates SaveResults signature and selection context path type to API module types. |
| pkg/fn/runtime/utils_test.go | Updates tests to use API module imports. |
| pkg/fn/runtime/runner.go | Updates runner signatures/fields to API module kptfile/fnresult and UniquePath. |
| pkg/fn/runtime/runner_test.go | Updates tests to use API module imports and UniquePath. |
| pkg/fn/runtime/nodejs.go | Updates function result type to API module fnresult/v1. |
| pkg/fn/runtime/exec.go | Updates function result type to API module fnresult/v1. |
| pkg/fn/runtime/container.go | Updates function result type to API module fnresult/v1. |
| pkg/fn/runtime/container_test.go | Updates tests to use API module fnresult/v1. |
| pkg/fn/render.go | Updates renderer interface to return API module fnresult/v1 list. |
| pkg/fn/multiruntime.go | Updates import to API module kptfile/v1. |
| pkg/fn/eval.go | Updates import to API module kptfile/v1. |
| pkg/fn/eval_test.go | Updates tests to use API module imports. |
| Makefile | Adds go generate execution for the new api/ module. |
| internal/testutil/testutil.go | Updates import to API module kptfile/v1. |
| internal/testutil/setup_manager.go | Updates import to API module kptfile/v1. |
| internal/testutil/pkgbuilder/builder.go | Updates imports to API module kptfile/resourcegroup. |
| internal/docs/generated/pkgdocs/docs.go | Regenerates/updates kpt pkg cat help text. |
| go.sum | Updates dependency checksums for updated module graph (SDK, apimachinery). |
| go.mod | Adds replace/require for github.com/kptdev/kpt/api; updates versions. |
| commands/pkg/update/cmdupdate.go | Updates import to API module kptfile/v1 and uses API UniquePath. |
| commands/pkg/update/cmdupdate_test.go | Updates tests to use API module imports. |
| commands/pkg/get/cmdget.go | Updates import to API module kptfile/v1 and uses API UniquePath. |
| commands/pkg/get/cmdget_test.go | Updates tests to use API module imports. |
| commands/live/status/cmdstatus_test.go | Updates tests to use API module imports. |
| commands/live/migrate/migratecmd.go | Updates imports to API module kptfile/resourcegroup and uses API UniquePath. |
| commands/live/migrate/migratecmd_test.go | Updates tests to use API module resourcegroup. |
| commands/live/init/cmdliveinit.go | Updates imports to API module kptfile/resourcegroup and uses API UniquePath. |
| commands/live/init/cmdliveinit_test.go | Updates tests to use API module imports. |
| commands/live/destroy/cmddestroy_test.go | Updates tests to use API module imports. |
| commands/live/apply/cmdapply_test.go | Updates tests to use API module imports. |
| api/resourcegroup/v1alpha1/types.go | Adds ResourceGroup API types under the new api module. |
| api/kptfile/v1/zz_generated.deepcopy.go | Updates generated deepcopy to import API module fnresult/v1. |
| api/kptfile/v1/validation.go | Moves validation APIs to use in-module UniquePath type (no pkg/lib/types). |
| api/kptfile/v1/validation_test.go | Updates tests to use in-module UniquePath. |
| api/kptfile/v1/types.go | Fixes generator header path and imports API module fnresult/v1. |
| api/kptfile/v1/path.go | Defines UniquePath/DisplayPath in the API module (moved from pkg/lib/types). |
| api/go.sum | Adds dependency checksums for the new api module. |
| api/go.mod | Adds module definition and dependency set for github.com/kptdev/kpt/api. |
| api/fnresult/v1/zz_generated.deepcopy.go | Adds generated deepcopy for fnresult API types. |
| api/fnresult/v1/types.go | Adds/updates fnresult API types and generator header path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 90 out of 94 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
api/kptfile/v1/validation.go:73
- Typo in user-facing validation error: "functon" should be "function" (this string is surfaced when validating Kptfiles).
api/kptfile/v1/validation.go:283 RecognizedKustomizationFileNamesis exported but appears to be used only within this file. If it is not intended as part of the publickptfile/v1API surface, consider making it unexported (or a private const/slice) to avoid committing to this as a supported API.
| @@ -0,0 +1,32 @@ | |||
| module github.com/kptdev/kpt/api | |||
|
|
|||
| go 1.24.0 | |||
There was a problem hiding this comment.
Why are we using an older go version here?
There was a problem hiding this comment.
I think it is best for API modules to use as low of a version as possible so dependents don't have to upgrade unnecessarily.
There was a problem hiding this comment.
But do we then risk pulling in vulnerable indirect dependencies?
Instead of pulling the API into a separate git repository, this PR exposes it from this one as a separate go module.
This is done in order to lessen the dependency requirements of API users as well as remove circular dependencies between this repo and the SDK repo without the need for duplication in SDK.
Also tried to unify the import alias of the API packages across this repo. Had to move
pkg/lib/typesintoapi/kptfile/v1to avoid some dependency conflicts with SDK.We could look into further removing some dependencies, like
sigs.k8s.io/cli-utilsfrom which we import a single const.