Move more code out of internal#4515
Conversation
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
…l/update/merge3 Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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>
|
I think is enough for this batch. Wanted to move |
There was a problem hiding this comment.
Pull request overview
This PR is a follow-up to #4490 that continues the effort to expose internal kpt utilities under pkg/lib/ (and pkg/printer) so that they can be consumed by external projects such as Porch. It is largely a mechanical relocation of packages from internal/ to public locations, with a few merges (e.g., internal/util/render + internal/hook → pkg/lib/kptops) and renames (executor.go → render_executor.go / hook_executor.go).
Changes:
- Moved a large number of
internal/...packages topkg/lib/...andpkg/printer/..., updating imports across the codebase. - Consolidated previously split packages (e.g.,
internal/util/update+internal/utils/update/merge3→pkg/lib/update, and render/hook executors intopkg/lib/kptops). - Renamed
internal/util/printerutilinto the existingpkg/printerpackage, removing intra-package import cycles by inliningFromContextOrDie.
Reviewed changes
Copilot reviewed 90 out of 146 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| thirdparty/kyaml/runfn/runfn.go | Switch to pkg/lib/types, pkg/lib/pkg, and pkg/printer.PrintFnResultInfo. |
| thirdparty/cmdconfig/commands/cmdtree/cmdtree.go | Replace argutil with pkg/lib/util/args (alias argsutil). |
| thirdparty/cmdconfig/commands/cmdsource/cmdsource.go | Update to pkg/lib/pkg and pkg/lib/util/args. |
| thirdparty/cmdconfig/commands/cmdeval/cmdeval.go | Update to pkg/lib/util/args and pkg/lib/util/path; introduces duplicate import of path. |
| pkg/test/runner/config.go | Switch internal/types to pkg/lib/types. |
| pkg/printer/util.go | Move printerutil into the printer package; drop self-import. |
| pkg/printer/table/printer.go | Switch to genericiooptions from deprecated genericclioptions.IOStreams. |
| pkg/printer/table/collector.go | New file moved from internal/alpha/printers/table; carries over some dead/copy-paste comments. |
| pkg/printer/printer.go | Imports updated to pkg/lib/pkg and pkg/lib/types. |
| pkg/printer/printer_test.go | Test import updated to pkg/lib/pkg. |
| pkg/printer/fake/fake.go | Import updated to pkg/lib/pkg. |
| pkg/live/rgpath.go | Switch to pkg/lib/util/path. |
| pkg/live/load.go | Switch to pkg/lib/pkg, pkg/lib/util/path, and pkg/lib/util/strings. |
| pkg/lib/util/strings/strings.go | New file moved from internal/util/strings. |
| pkg/lib/util/strings/strings_test.go | Test moved alongside the source. |
Comments suppressed due to low confidence (4)
pkg/lib/pkg/util.go:16
- The package doc comment still refers to the old name "Package pkgutil" after the move/rename to
pkg/lib/pkg. Update the comment to match the new package name to avoid misleading readers and tooling likego doc.
pkg/lib/util/git/git.go:56 - Changing
AbsPathfrom a value receiver to a pointer receiver is an API-visible change forRepoSpec. Callers that hold a non-addressableRepoSpecvalue (e.g., returned from a function and used inline, or stored in an interface) will no longer compile or will not pick up the method via the value's method set when the value is used through interfaces. Since this type is now underpkg/liband intended for external consumption, this is a potentially breaking change that should be called out, or kept as a value receiver for consistency with otherRepoSpecmethods.
pkg/lib/update/resource-merge.go:135 - The local variable
diffshadows the importeddiffpackage within this function, which makes the code harder to read and brittle to future edits that might want to call anotherdiff.*function below this line. Consider renaming the local variable (e.g.,diffResult).
pkg/lib/update/update_test.go:33 - Using
update2as an import alias to disambiguate from anotherupdatesymbol is unidiomatic. Prefer a descriptive alias (e.g.,updatepkg) so it's clear what the package is at the call sites.
💡 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>
Follow up to #4490
Currently moved:
internal/types->pkg/lib/types(this is a revert)internal/pkg->pkg/lib/pkginternal/alpha/printers/table->pkg/printer/tableinternal/builtins/pkg_context.go->pkg/lib/builtins/pkg_context.go(builtins already existed here)internal/util/update/->pkg/lib/update(merged the two packages)internal/utils/update/merge3->pkg/lib/update/merge3internal/util/mergeinternal/util/render->pkg/lib/kptops(renamedexecutor.gotorender_executor.go)internal/util/diff->pkg/lib/pkg/diffinternal/util/pkgutil->pkg/lib/pkginternal/util/attribution->pkg/lib/util/attributioninternal/util/stack->pkg/lib/util/stackinternal/util/strings->pkg/lib/util/stringsinternal/util/printerutil->pkg/printerinternal/util/argutil->pkg/lib/util/argsinternal/util/fetch->pkg/lib/util/fetchinternal/util/get->pkg/lib/util/getinternal/util/git->pkg/lib/util/gitinternal/util/man->pkg/lib/util/maninternal/util/pathutil->pkg/lib/util/pathinternal/hook->pkg/lib/kptops(renamedexecutor.gotohook_executor.go)