You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add UpdateSchemas to pkg/project and export the dependency subcommands - #560
An other cli that generates additional schemas of its own wants update-cache to produce them too, wrapping the exported UpdateCacheCmd and appending its own generation step keeps one user-facing command that leaves the project's models complete
Two additions to the embedding surface, one motivation: hosts need the dependency update-cache behavior available as a library.
pkg/project.UpdateSchemas, resolves the project's dependencies and generates language schemas for them and for the project's own APIs into the project's schemas directory, the same work crossplane dependency update-cache does. Options cover the cache directory, git authentication/proxy settings, an optional event channel for progress, and a Refresh toggle (re-resolve and refetch vs. use the cache). The update-cache command now delegates to it, so there is one implementation.
Exported dependency subcommand types (AddCmd, UpdateCacheCmd, CleanCacheCmd), the same treatment the project subcommands received: hosts can mount them in their own kong command trees and wrap them.
Expose resolving a project's dependencies and generating language
schemas for them and the project's own APIs - the work dependency
update-cache does - so hosts can regenerate a project's models without
shelling out. The update-cache command now delegates to it.
Signed-off-by: Christopher Haar <christopher.haar@upbound.io>
Host CLIs embedding the dependency commands can mount them in their own
command trees and wrap them, e.g. update-cache to generate additional
schemas after the update, the same way the project subcommands are
exported.
Signed-off-by: Christopher Haar <christopher.haar@upbound.io>
The project package adds an API for dependency updates and schema generation. Dependency command types become exported. The cache update command delegates dependency refresh and project API schema generation to the new API.
Changes: Dependency commands and schema updates
Layer / File(s)
Summary
Project schema update API pkg/project/project.go
Adds UpdateSchemasOptions and UpdateSchemas. The function configures dependency handling, refreshes or adds dependencies, and generates project API schemas when the API directory exists.
Exported dependency commands and cache update cmd/crossplane/dependency/add.go, cmd/crossplane/dependency/cache.go, cmd/crossplane/dependency/dependency.go, cmd/crossplane/dependency/dependency_test.go
Exports AddCmd, UpdateCacheCmd, and CleanCacheCmd and uses them in Cmd and Git-authentication tests. UpdateCacheCmd calls project.UpdateSchemas with refresh enabled and the cache and Git options.
crossplane/cli#544: Introduces the pkg/project facade and exports project command types, which this change extends with UpdateSchemas and exported dependency command types.
Suggested reviewers:adamwg
Merge Risk: Minimal · up to fa8b4
This change adds a project schema update API and exports the dependency commands, with update-cache delegating to the new API. No concrete behavioral regression was found. The one remaining note is about error wording that was already present before this change.
Pre-merge checks: 6
Check name
Status
Explanation
Title check
The title is 70 characters, under the 72-character limit. It names the two main parts of the changeset: the new pkg/project UpdateSchemas API and the export of the dependency subcommand types. It is d…
Description check
The description explains the motivation (hosts need dependency update-cache behavior as a library). It covers the new pkg/project.UpdateSchemas API, its options, the delegation from update-cache, and …
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Breaking Changes
The check fails only for changes that remove or rename public fields or flags, add required public fields or flags, or remove behavior under apis/** or cmd/**. The PR does none of these. Changed f…
Feature Gate Requirement
Thank you, haarchri, for the clear description and the test coverage. The check fails only when new experimental features that affect apis/**, or that significantly change behavior, ship without a f…
Full details: Title check
Explanation
The title is 70 characters, under the 72-character limit. It names the two main parts of the changeset: the new pkg/project UpdateSchemas API and the export of the dependency subcommand types. It is descriptive and matches the raw summary and objectives.
Full details: Description check
Explanation
The description explains the motivation (hosts need dependency update-cache behavior as a library). It covers the new pkg/project.UpdateSchemas API, its options, the delegation from update-cache, and the exported AddCmd, UpdateCacheCmd, and CleanCacheCmd types. It is related to the changeset, though the 'Fixes #' line is left blank and the checklist is filled in.
Full details: Breaking Changes
Explanation
The check fails only for changes that remove or rename public fields or flags, add required public fields or flags, or remove behavior under apis/** or cmd/**. The PR does none of these. Changed files (from the review range): cmd/crossplane/dependency/{add.go,cache.go,dependency.go,dependency_test.go} and pkg/project/project.go. No apis/** files changed. - Renames:addCmd, updateCacheCmd, and cleanCacheCmd become AddCmd, UpdateCacheCmd, and CleanCacheCmd. These types were unexported before. Exporting them adds to the public surface and removes nothing. - Fields and flags: The struct fields and their kong tags (arg, help, name, short, env, default) are unchanged in all three command types. Cmd keeps the same field names. Only the field types changed, and those types are now exported. - Behavior of update-cache: The logic moved into pkg/project.UpdateSchemas and is equivalent: - Same xpkg client and cache dir resolution. - Same generator filtering from proj.Spec.Schemas.GetLanguages() and cfg.Features. - Same git options. Auth applies only when GitToken is set. Proxy and insecure host key apply under the same conditions as common.GitFlags.ManagerOptions(). - Refresh: true maps to RefreshAll, as before. - Project API schema generation runs under the same condition and sends the same events. - WithProjectFile: The new code passes FileName where the old code passed c.ProjectFile. This does not change update-cache output. RefreshAll uses addDependencyNoWrite, which does not write the project file, so m.projFile is not read on this path. - Removed code: The old cache.go dependency-manager and schema-generation setup was moved, not dropped. I could not read PR labels with the available tools. The label check does not apply here, because no breaking behavior or public-surface break was found.
Full details: Feature Gate Requirement
Explanation
Thank you, haarchri, for the clear description and the test coverage. The check fails only when new experimental features that affect apis/**, or that significantly change behavior, ship without a feature flag. This PR does not meet that condition. Evidence: - The changed files are cmd/crossplane/dependency/{add.go,cache.go,dependency.go,dependency_test.go} and pkg/project/project.go. No file under apis/ changes. - pkg/project.UpdateSchemas moves the existing update-cache logic into a library function. The command now delegates to it with Refresh: true. The same dependency manager, xpkg client, schema-generator filter, Git options, and project API schema step run as before. - The generator filter still reads cfg.Features.GenerateGoModelAccessors and cfg.Features.GenerateGoRuntimeObjects. Existing feature flags therefore still apply to the new path. - The other changes export existing types (AddCmd, UpdateCacheCmd, CleanCacheCmd) and rename receivers. They do not alter command behavior. - The new options and function carry no alpha or beta maturity marker. The diff contains no new feature flag. Notes for follow-up, not failure conditions: - add.go and cache.go now pass FileName to WithProjectFile in the library path, where the command previously passed c.ProjectFile. Please confirm this is intended when a custom -f path is used. - UpdateSchemas adds a public library API. Could you state its maturity level in the docs? Maintainers may want an explicit alpha label if the API can change.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
pkg/project/project.go-242-242: 1
242-242: Minor · Functional Correctness · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Describe the failed user operation in this error.
If the cache directory is not writable, this path reports “cannot create xpkg client”. That wording exposes an internal implementation detail. Please identify schema generation and dependency-cache preparation instead. For a cache-creation failure, include guidance to check directory permissions or select another cache directory. Preserve the underlying error. (raw.githubusercontent.com)
As per path instructions, error messages must “avoid technical jargon” and “include context about what the user was trying to do”.
Reviewing files that changed from the base of the PR and between b0b62c0 and fa8b4c3.
Files selected for processing: 5
cmd/crossplane/dependency/add.go
cmd/crossplane/dependency/cache.go
cmd/crossplane/dependency/dependency.go
cmd/crossplane/dependency/dependency_test.go
pkg/project/project.go
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
❌ Patch coverage is 20.00000% with 48 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.85%. Comparing base (cd703a0) to head (fa8b4c3). ⚠️ Report is 23 commits behind head on main.
🚀 New features to boost your workflow:
❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of your changes
An other cli that generates additional schemas of its own wants update-cache to produce them too, wrapping the exported
UpdateCacheCmdand appending its own generation step keeps one user-facing command that leaves the project's models completeTwo additions to the embedding surface, one motivation: hosts need the dependency update-cache behavior available as a library.
pkg/project.UpdateSchemas, resolves the project's dependencies and generates language schemas for them and for the project's own APIs into the project's schemas directory, the same work crossplane dependency update-cache does. Options cover the cache directory, git authentication/proxy settings, an optional event channel for progress, and a Refresh toggle (re-resolve and refetch vs. use the cache). The update-cache command now delegates to it, so there is one implementation.Fixes #
I have:
./nix.sh flake checkto ensure this PR is ready for review.backport release-x.ylabels to auto-backport this PR.Need help with this checklist? See the cheat sheet.