Skip to content

Make API it's own go module#4537

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

Make API it's own go module#4537
mozesl-nokia wants to merge 3 commits into
kptdev:mainfrom
nokia:api-module

Conversation

@mozesl-nokia
Copy link
Copy Markdown
Contributor

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/types into api/kptfile/v1 to avoid some dependency conflicts with SDK.

We could look into further removing some dependencies, like sigs.k8s.io/cli-utils from which we import a single const.

Copilot AI review requested due to automatic review settings May 21, 2026 15:40
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label May 21, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 21, 2026

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 45dc843
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/6a102c2040fe2f0008950038
😎 Deploy Preview https://deploy-preview-4537--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.

@dosubot dosubot Bot added the go Pull requests that update Go code label May 21, 2026
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 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 own go.mod/go.sum) and wires the root module to it via replace + require.
  • Rewrites imports across the repo from github.com/kptdev/kpt/pkg/api/... (and pkg/lib/types) to github.com/kptdev/kpt/api/... (including moving UniquePath/DisplayPath into api/kptfile/v1).
  • Adds new API packages/files (e.g., api/resourcegroup/v1alpha1) and updates generation targets to run go generate within 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.

Comment thread Makefile
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>
Copilot AI review requested due to automatic review settings May 22, 2026 10:11
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
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 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
  • RecognizedKustomizationFileNames is exported but appears to be used only within this file. If it is not intended as part of the public kptfile/v1 API surface, consider making it unexported (or a private const/slice) to avoid committing to this as a supported API.

Comment thread api/go.mod
@@ -0,0 +1,32 @@
module github.com/kptdev/kpt/api

go 1.24.0
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.

Why are we using an older go version here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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.

But do we then risk pulling in vulnerable indirect dependencies?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants