Skip to content

Make UpstreamLock more generic#4413

Merged
liamfallon merged 4 commits intokptdev:mainfrom
nokia:locator
Mar 4, 2026
Merged

Make UpstreamLock more generic#4413
liamfallon merged 4 commits intokptdev:mainfrom
nokia:locator

Conversation

@mozesl-nokia
Copy link
Copy Markdown
Contributor

@mozesl-nokia mozesl-nokia commented Feb 25, 2026

The gist of this PR is to rename the UpstreamLock type to Locator and add generic locator type.

This is mostly for API consumers, such as Porch, where we currently have no way of expressing in the UpstreamLock that the package comes from a database.

(This renaming is already present in Porch, which duplicates some of the kpt API types, so this is a step towards de-duplicating even further.)

*The big diff is just the yaml/json schema

Copilot AI review requested due to automatic review settings February 25, 2026 10:05
@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 25, 2026

Deploy Preview for kptdocs ready!

Name Link
🔨 Latest commit 232c2ec
🔍 Latest deploy log https://app.netlify.com/projects/kptdocs/deploys/69a1a346ed77510008c382e4
😎 Deploy Preview https://deploy-preview-4413--kptdocs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 25, 2026
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@dosubot
Copy link
Copy Markdown
Contributor

dosubot Bot commented Feb 25, 2026

Related Documentation

1 document(s) may need updating based on files changed in this PR:

kpt

migration /kpt/blob/main/documentation/content/en/installation/migration.md
View Suggested Changes
@@ -105,8 +105,8 @@
 2. `upstream` section, in the `v1alpha1` Kptfile is split into `upstream` and
    `upstreamLock` sections in `v1` Kptfile. `upstream` section can be
    modified by users to declare the desired version of the package,
-   `upstreamLock` is the resolved package state and should not be modified by
-   users.
+   `upstreamLock` is the resolved package state (stored in the `Locator` type) and should not be modified by
+   users. The `Locator` type supports both Git origins and generic storage backends.
 3. The `OpenAPI` section in `v1alpha1` Kptfile is deprecated.
    [Details below](#changes-to-setters).
 4. `dependencies` section in `v1alpha1` Kptfile is deprecated.
@@ -244,7 +244,7 @@
 1. Best effort is made by the function to transform the `packageMetaData`
    section to the `info` section.
 2. `upstream` section, in the `v1alpha1` Kptfile is converted to `upstream` and
-   `upstreamLock` sections in `v1` version of Kptfile.
+   `upstreamLock` sections in `v1` version of Kptfile. The `upstreamLock` field uses the `Locator` type, which supports both Git and generic storage backends.
 3. `dependencies` section is removed from Kptfile.
 4. Starlark functions section is removed from Kptfile.
 5. `Setters` and `substitutions` are converted to new and simple setter

[Accept] [Decline]

Note: You must be authenticated to accept/decline updates.

How did I do? Any feedback?  Join Discord

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 updates the kpt Kptfile API to make the “where this package came from” metadata more generic by renaming the UpstreamLock type to Locator and introducing a new generic locator form for non-git storage backends.

Changes:

  • Rename kptfile/v1.UpstreamLock (type) to kptfile/v1.Locator and update call sites/tests accordingly.
  • Add GenericOrigin and GenericLock to represent packages stored in generic/custom storage (e.g., a DB).
  • Update helpers/utilities that populate or normalize the upstream lock data to use the renamed type.

Reviewed changes

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

Show a summary per file
File Description
pkg/api/kptfile/v1/types.go Renames the lock type to Locator and adds GenericOrigin / GenericLock.
pkg/kptfile/kptfileutil/util.go Writes UpstreamLock using the new Locator type.
pkg/lib/kptops/clone.go Updates helper APIs to accept/normalize Locator instead of UpstreamLock.
pkg/lib/kptops/clone_test.go Adjusts tests to construct Locator instead of UpstreamLock.
pkg/lib/kptops/pkgupdate.go Updates commented references from UpstreamLock to Locator.
internal/util/diff/pkgdiff.go Updates diff-ignore logic to use Locator.
internal/util/get/get_test.go Updates tests to construct Locator instead of UpstreamLock.
internal/util/fetch/fetch_test.go Updates tests to construct Locator instead of UpstreamLock.
internal/testutil/testutil.go Updates upstreamLock defaulting logic to use Locator.
internal/testutil/setup_manager.go Updates test expectations to use Locator.
internal/testutil/pkgbuilder/builder.go Builds Kptfiles with Locator for upstreamLock.
commands/pkg/get/cmdget_test.go Updates tests to construct Locator instead of UpstreamLock.
commands/pkg/update/cmdupdate_test.go Updates tests to construct Locator instead of UpstreamLock.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/api/kptfile/v1/types.go
Comment thread pkg/lib/kptops/pkgupdate.go Outdated
Comment thread internal/testutil/testutil.go Outdated
Comment thread pkg/lib/kptops/clone.go Outdated
Comment thread pkg/api/kptfile/v1/types.go
@mozesl-nokia mozesl-nokia added the go Pull requests that update Go code label Feb 25, 2026
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 February 25, 2026 14:30
@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Feb 25, 2026
@mozesl-nokia
Copy link
Copy Markdown
Contributor Author

@liamfallon @efiacor @kispaljr Should we consider unifying the Upstream and Locator types?

From what I can see Upstream is meant for input ("user-specified locator") and UpstreamLock was meant to be generated by kpt ("resolved locator"), but would it not make sense to just have Locator with either a filled or unfilled git.commit field?

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 17 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/api/kptfile/v1/types.go Outdated
Comment thread documentation/content/en/reference/schema/kptfile/kptfile.json Outdated
Comment thread documentation/content/en/reference/schema/kptfile/kptfile.yaml Outdated
Comment thread scripts/generate-schema.sh Outdated
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@efiacor
Copy link
Copy Markdown
Contributor

efiacor commented Mar 3, 2026

@liamfallon @efiacor @kispaljr Should we consider unifying the Upstream and Locator types?

From what I can see Upstream is meant for input ("user-specified locator") and UpstreamLock was meant to be generated by kpt ("resolved locator"), but would it not make sense to just have Locator with either a filled or unfilled git.commit field?

I'd err towards keeping them separate for now. How would the new Type be structured? Could we ensure the commit field is valid and protected?

@dosubot dosubot Bot added the lgtm label Mar 4, 2026
@liamfallon liamfallon merged commit 48a6439 into kptdev:main Mar 4, 2026
15 checks passed
ciaranjohnston pushed a commit that referenced this pull request Mar 4, 2026
* rename UpstreamLock type to Locator, add generic locator type

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>

* add deprecated type alias

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>

* fix additional copilot comments, fix schema generation

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>

* strip kubebuilder annos

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>
liamfallon pushed a commit that referenced this pull request Mar 5, 2026
* Updated location of configmap-v1.json to a reachable destination

Signed-off-by: Ciaran Johnston <ciaran.johnston@ericsson.com>

* Adding new logo (#4416)

* Adding new logo

Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>

---------

Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Adding links to the Dosu space

Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>

* Update README.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>

* Make `UpstreamLock` more generic (#4413)

* rename UpstreamLock type to Locator, add generic locator type

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>

* add deprecated type alias

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>

* fix additional copilot comments, fix schema generation

Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>

* strip kubebuilder annos

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>

* updated the curl command to fail on HTTP errors (-f) as well as to quote the output directory to avoid word-splitting

Signed-off-by: Ciaran Johnston <ciaran.johnston@ericsson.com>

---------

Signed-off-by: Ciaran Johnston <ciaran.johnston@ericsson.com>
Signed-off-by: Gergely Csatari <gergely.csatari@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Co-authored-by: Gergely Csatari <gergely.csatari@nokia.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: mozesl-nokia <laszlo.mozes@nokia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/porch go Pull requests that update Go code lgtm size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants