diff --git a/docs/book/src/reference/commands/alpha_update.md b/docs/book/src/reference/commands/alpha_update.md index 304d124b412..b0d79dc54a1 100644 --- a/docs/book/src/reference/commands/alpha_update.md +++ b/docs/book/src/reference/commands/alpha_update.md @@ -2,150 +2,132 @@ ## Overview -The `kubebuilder alpha update` command helps you upgrade your project scaffold to a newer Kubebuilder version or plugin layout automatically. +`kubebuilder alpha update` upgrades your project’s scaffold to a newer scaffold version. -It uses a **3-way merge strategy** to update your project with less manual work. -To achieve that, the command creates the following branches: +It uses a **3-way merge** so you do less manual work. The command creates these branches: -- *Ancestor branch*: clean scaffold using the old version -- *Current branch*: your existing project with your custom code -- *Upgrade branch*: scaffold generated using the new version +- **Ancestor**: clean scaffold from the **old** version +- **Original**: your current project (from your base branch) +- **Upgrade**: clean scaffold from the **new** version +- **Merge**: result of merging **Original** into **Upgrade** (this is where conflicts appear) -Then, it creates a **merge branch** that combines everything. -You can review and test this branch before applying the changes. +You can review and test the merge result before applying it to your main branch. -## When to Use It? +## When to Use It -Use this command when: +Use this command when you: -- You want to upgrade your project to a newer Kubebuilder version or plugin layout -- You prefer to automate the migration instead of updating files manually -- You want to review scaffold changes in a separate Git branch -- You want to focus only on fixing merge conflicts instead of re-applying all your code +- Want to move to a newer Kubebuilder version or plugin layout +- Prefer automation over manual file editing +- Want to review scaffold changes on a separate branch +- Want to focus on resolving merge conflicts (not re-applying your custom code) ## How It Works -The command performs the following steps: +1. **Detect versions** + Reads `--from-version` (or the `PROJECT` file) and `--to-version` (or uses the latest). -1. Downloads the older CLI version (from the `PROJECT` file or `--from-version`) -2. Creates `tmp-kb-update-ancestor` with a clean scaffold using that version -3. Creates `tmp-kb-update-current` and restores your current code on top -4. Creates `tmp-kb-update-upgrade` using the latest scaffold -5. Created `tmp-kb-update-merge` which is a merge of the above branches using the 3-way merge strategy +2. **Create branches & re-scaffold** + - `tmp-ancestor-*`: clean scaffold from **from-version** + - `tmp-original-*`: snapshot of your **from-branch** (e.g., `main`) + - `tmp-upgrade-*`: clean scaffold from **to-version** -You can push the `tmp-kb-update-merge` branch to your remote repository, -review the diff, and test the changes before merging into your main branch. +3. **3-way merge** + Creates `tmp-merge-*` from **Upgrade** and merges **Original** into it. + Runs `make manifests generate fmt vet lint-fix` to normalise outputs. + +Push either `tmp-merge-*` (no squash) to open a PR. ## How to Use It -Run the command from your project directory: +Run from your project root: -```sh +```shell kubebuilder alpha update ``` -If needed, set a specific version or branch: +Pin versions and base branch: -```sh +```shell kubebuilder alpha update \ - --from-version=v4.5.2 \ - --to-version=v4.6.0 \ - --from-branch=main + --from-version v4.5.2 \ + --to-version v4.6.0 \ + --from-branch main ``` +Automation-friendly (proceed even with conflicts): -Force update even with merge conflicts: - -```sh +```shell kubebuilder alpha update --force ``` - - -## Flags - -| Flag | Description | -|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------| -| `--from-version` | **Required for projects initialized with versions earlier than v4.6.0.** Kubebuilder version your project was created with. If unset, uses the `PROJECT` file. | -| `--to-version` | Version to upgrade to. Defaults to the latest version. | -| `--from-branch` | Git branch that contains your current project code. Defaults to `main`. | -| `--force` | Force the update even if conflicts occur. Conflicted files will include conflict markers, and a commit will be created automatically. Ideal for automation (e.g., cronjobs, CI). | -| `-h, --help` | Show help for this command. | - - ## Merge Conflicts with `--force` -When you use the `--force` flag with `kubebuilder alpha update`, Git will complete the merge even if there are conflicts. The resulting commit will include conflict markers like: -``` +When you use `--force`, Git finishes the merge even if there are conflicts. +The commit will include markers like: + +```shell <<<<<<< HEAD Your changes ======= Incoming changes ->>>>>>> branch-name +>>>>>>> tmp-original-… ``` -These conflicts will be committed in the -`tmp-kb-update-merge` branch. -