github.com/wmuizelaar/kpt@v0.0.0-20221018115725-bd564717b2ed/site/book/03-packages/05-updating-a-package.md (about)

     1  An independent package records the exact commit where the local fork and the
     2  upstream package diverged. This enables kpt to fetch any update to the upstream
     3  package and merge it with local changes.
     4  
     5  ## Commit your local changes
     6  
     7  Before you update the package, you want to commit your local changes.
     8  
     9  First, to see the changes you've made to the fork of the upstream package:
    10  
    11  ```shell
    12  $ git diff
    13  ```
    14  
    15  If you're happy with the changes, commit them:
    16  
    17  ```shell
    18  $ git add .; git commit -m "My changes"
    19  ```
    20  
    21  ## Update the package
    22  
    23  For example, you can update to version `v0.10` of the `wordpress` package:
    24  
    25  ```shell
    26  $ kpt pkg update wordpress@v0.10
    27  ```
    28  
    29  This is a porcelain for manually updating the `upstream` section in the
    30  `Kptfile` :
    31  
    32  ```yaml
    33  upstream:
    34    type: git
    35    git:
    36      repo: https://github.com/GoogleContainerTools/kpt
    37      directory: /package-examples/wordpress
    38      # Change this from v0.9 to v0.10
    39      ref: v0.10
    40    updateStrategy: resource-merge
    41  ```
    42  
    43  and then running:
    44  
    45  ```shell
    46  $ kpt pkg update wordpress
    47  ```
    48  
    49  The `update` command updates the local `wordpress` package and the dependent
    50  `mysql` package to the upstream version `v0.10` by doing a 3-way merge between:
    51  
    52  1. Original upstream commit
    53  2. New upstream commit
    54  3. Local (edited) package
    55  
    56  Several different strategies are available to handle the merge. By default, the
    57  `resource-merge` strategy is used which performs a structural comparison of the
    58  resource using OpenAPI schema.
    59  
    60  ?> Refer to the [update command reference][update-doc] for usage.
    61  
    62  ## Commit the updated resources
    63  
    64  Once you have successfully updated the package, commit the changes:
    65  
    66  ```shell
    67  $ git add .; git commit -m "Updated wordpress to v0.10"
    68  ```
    69  
    70  [update-doc]: /reference/cli/pkg/update/