The repo package is internally versioned at v1. Repos were designed
to be versioned. This change moves it to a versioned directory the
same way other packages are now being handled.
Signed-off-by: Matt Farina <matt.farina@suse.com>
A few things are added here:
1. The cache is made to be more generic as a content based cache.
It could be used for other things such as plugins
2. Flags were added to specify the content cache locaiton rather
than rely on the repository cache. Keeping the 2 the same
hid bugs and errors.
3. Tests were added and updated to ensure the cache is used and
tested
Signed-off-by: Matt Farina <matt.farina@suse.com>
The previous cache was based on chart name and version. If 2 charts
with different content had the same name and version they would collide.
Helm did not trust the cache because of this and always downloaded
content. It was a short lived cache.
This commit introduces a content based cache which is based on the
content rather than file name. Charts with the same name but different
content are no longer an issue.
While the system assumes a file based interface, the cache system
is pluggable. In the future, it should return bytes for the content
instead of paths to it. That would requie a larger change for Helm 5
or later.
Signed-off-by: Matt Farina <matt.farina@suse.com>
The test was failing intermittently because Go's map iteration order
is randomized (see `range repos` in `findChartUrl`).
When looking up the `baz` chart with repository URL http://example.com/helm,
two repositories match due to trailing slash equivalence:
- testing-relative (URL: http://example.com/helm) - contains baz chart GOOD
- testing-relative-trailing-slash (URL: http://example.com/helm/) - does not contain baz chart.. NOT GOOD
The urlutil.Equal() function treats these URLs as equivalent, but
depending on which repository the random map iterator encounters
first, the test would either pass or fail with "entry not found".
So I changed the third test case from baz to foo chart, since foo exists
in both matching repositories. This eliminates the race condition while
preserving all test expectations and logic.
`findChartURL()` iterates over a map without deterministic
ordering, causing the first-match-wins behavior to be non-deterministic
when multiple repositories match the same URL pattern.
Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
There used to be two implemenations for concatenating the repo URL with
the chart URI / URL. In case the chart specified an absolute URI, one of
the implementations performed an incorrect concatenation between the
two, resulting in a URL which looks like <repo-URL><absolute-chart-URI>.
This commit removes the faulty implementation and uses the other correct
one instead.
Signed-off-by: Omri Steiner <omri@steiners.co.il>
This change moves the code, updates the import locations, and
adds a doc.go file to document what the v2 package is for.
This is part of HIP 20 for v3 charts
Signed-off-by: Matt Farina <matt.farina@suse.com>
chartutil was originally created to operate on protobufs which are
no longer part of Helm. The util package makes more sense to be
part of the chart package.
This change is part of the HIP 20 to create v3 charts and
explicitly call out v2 charts. The changes for this are in smaller
bite size changes.
Signed-off-by: Matt Farina <matt.farina@suse.com>
Since Helm is going through breaking changes with Helm v4, the version path to
Helm needs to be updated.
Signed-off-by: Matt Farina <matt.farina@suse.com>
- replace os.IsNotExist with errors.Is and fs.ErrNotExist
- use %w directive
Signed-off-by: Justen Stall <39888103+justenstall@users.noreply.github.com>
The change in #11726 caused a regression where `helm dependency udpate`
stopped working. The format of the internal representation of the data
changed causing errors of "non-absolute URLs should be in form of
repo_name/path_to_chart". See #13324 for more details.
Since this change is in released Helm and it's a regression, reverting
the original change was the fastest and safest route to deliver a
fix as quickly as possible.
Closes#13324
Signed-off-by: Matt Farina <matt.farina@suse.com>
Noteis:
1. This moves golangci scanning to a GitHub action. This will
enable inline pointers to issues in the PR where linting fails.
2. Go 1.21 is specified in the go.mod because Kubernetes libs
require it.
3. The lint issues were removed. Some were fixed while others
were handled by skipping linting or using _ as an argument.
Many of these can be refactored later for better cleanup.
Signed-off-by: Matt Farina <matt.farina@suse.com>
This commit replaces `ensure.TempDir` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.
Prior to this commit, temporary directory created using `ensure.TempDir`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}
is also tedious, but `t.TempDir` handles this for us nicely.
Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>