Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added handler for OCI Artifacts not supporting the plus sign (+) #23

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions internal/manifest/charts.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ func (m *Manifests) prepareChart(ctx context.Context, repo string, reference str
m.log.Printf("searching index for %s with reference %s\n", chart, reference)
chartVer, err := index.Get(chart, reference)
if err != nil {
if strings.Contains(reference, "_") {
reference = strings.ReplaceAll(reference, "_", "+")
}
chartVer, err = index.Get(chart, reference)
}
if err != nil {

return &errors.RegError{
Status: http.StatusNotFound,
Code: "NOT FOUND",
Expand Down
15 changes: 11 additions & 4 deletions internal/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,18 @@ func (m *Manifests) Handle(resp http.ResponseWriter, req *http.Request) error {
}
ma, ok = m.manifests[repo][target]
if !ok {
// check if chart was just remapped to an _ before failing
if target != "" && strings.Contains(target, "_") {
target = strings.ReplaceAll(target, "_", "+")
}
ma, ok = m.manifests[repo][target]
// we failed
return &errors.RegError{
Status: http.StatusNotFound,
Code: "NOT FOUND",
Message: "Chart prepare error",
if !ok {
return &errors.RegError{
Status: http.StatusNotFound,
Code: "NOT FOUND",
Message: "Chart prepare error",
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure consistent handling between GET and HEAD methods.

The underscore to plus sign conversion is only implemented in the HEAD method. Consider applying the same logic to the GET method for consistency.

Would you like me to provide the implementation for the GET method as well?

Comment on lines +207 to +211
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Enhance error message for better debugging.

The current error message "Chart prepare error" is not descriptive enough. It should indicate the attempted conversion and actual values.

-						Message: "Chart prepare error",
+						Message: fmt.Sprintf("Chart not found for repository %q with tag %q (attempted underscore to plus conversion)", repo, target),

Committable suggestion was skipped due to low confidence.

}
}
}
Expand Down
Loading