Skip to content

Commit ca116a2

Browse files
authored
Merge pull request #72 from aiyengar2/fix_error_on_removed_chart
Fix error message on modifying versions of existing charts and add additional docs
2 parents d37c7d7 + 1f56035 commit ca116a2

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

pkg/validate/validate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type CompareGeneratedAssetsResponse struct {
2929

3030
// PassedValidation returns whether the response seems to indicate that the chart repositories are in sync
3131
func (r CompareGeneratedAssetsResponse) PassedValidation() bool {
32-
return len(r.ModifiedPostRelease) == 0 && len(r.UntrackedInRelease) == 0
32+
return len(r.UntrackedInRelease) == 0 && len(r.RemovedPostRelease) == 0 && len(r.ModifiedPostRelease) == 0
3333
}
3434

3535
// LogDiscrepancies produces logs that can be used to pretty-print why a validation might have failed
@@ -121,7 +121,7 @@ func CompareGeneratedAssets(repoFs billy.Filesystem, u options.UpstreamOptions,
121121
return err
122122
}
123123
if releaseOptions.Contains(chart.Metadata.Name, chart.Metadata.Version) {
124-
// Chart is tracked in release.yaml
124+
// Chart is tracked in release.yaml; this chart was removed intentionally
125125
return nil
126126
}
127127
// Chart was removed from local and is not tracked by release.yaml

templates/template/docs/developing.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ As a result, developers reviewing your chart can see changes made to `packages/`
9898

9999
You are ready to make a PR!
100100

101+
### Known Issue: Making Changes to the Version of an Existing Package
102+
103+
If you are working with a repository using `charts-build-scripts` that uses remote validation (e.g. `validate.url` and `validate.branch` are provided in the `configuration.yaml`) and you are making a change that would modify the version of an existing package (e.g. replacing a version like `0.1.2-rc3` with `0.1.2-rc4`), please see the section `Modifying Chart Versions That Exist In Upstream` within [`docs/validation.md`](docs/validation.md) for how to ensure CI still passes after making your change.
104+
101105
### Versioning Packages
102106

103107
Generally, repositories that are using `charts-build-scripts` use one of the following two types of built-in versioning schemes for packages:

templates/template/docs/validation.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,30 @@ longhorn-crd:
4545
- 100.0.0+up1.1.2
4646
- 100.0.0+up1.2.0
4747
```
48+
49+
### Modifying Chart Versions That Exist In Upstream
50+
51+
One of the caveats with using the `release.yaml` is that **renames are not supported** (e.g. you cannot remove and replace a chart in a single step).
52+
53+
As a result, if you attempt to modify a version of a chart that already exists in upstream, **both the old version and the new version must exist in the release.yaml for CI to pass**. Once the changes have been merged, you can later remove the old version from the release.yaml (usually as part of a release process).
54+
55+
To give a concrete example of such a scenario, let's say that you have currently committed `my-chart` version `0.1.2-rc3`. You then take the following steps:
56+
1. You modify the `package.yaml` to point at a new upstream URL that points to `0.1.2-rc4` and resolve any conflicts with the patch files under `packages/my-chart-package/generated-changes`
57+
2. You run `CHART=my-chart VERSION=0.1.2-rc3 make remove` to delete the older version of the chart
58+
3. You run `make charts` to produce the new assets and charts for `my-chart` version `0.1.2-rc4`.
59+
4. You modify the release.yaml to **replace** `my-chart[0] = 0.1.2-rc3` with `my-chart[0] = 0.1.2-rc4`.
60+
4. You make a PR to your repository.
61+
62+
In this case, CI will fail since you are attempting to remove `0.1.2-rc3` but it is not tracked in the `release.yaml`.
63+
64+
Therefore, the correct resolution would be to leave your `release.yaml` as:
65+
66+
```yaml
67+
...
68+
my-chart:
69+
- 0.1.2-rc3
70+
- 0.1.2-rc4
71+
...
72+
```
73+
74+
That way, both the removal of `0.1.2-rc3` and the addition of `0.1.2-rc4` are accepted. Later, you can remove `0.1.2-rc3` once the PR has been committed.

0 commit comments

Comments
 (0)