This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can I suggest simply returning an
errors.New("no charts in repository index")
, as the caller of this function will log the error with Fatal:monocular/cmd/chart-repo/sync.go
Line 64 in e19c1b1
The issue with using Fatal here is that it will exit the program here, and that should really be the job of the caller of this function. This function should just return a response and not control the flow of the program.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prydonius Thanks for explaining.
Do you mean to add a test something like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hpandeycodeit I think we can remove the trailing slashes and subpath parts in that, and just return an empty index. We should also call this something like
emptyChartRepoHTTPClient
to make the intent more clear.I'm also not sure if
w.Write(nil)
will be sufficient though, we might need to create a test index file (likemonocular/cmd/chart-repo/testdata/valid-index.yaml
Line 1 in e19c1b1
entries
key that is empty.e.g.:
We would then need a test that is similar to
monocular/cmd/chart-repo/utils_test.go
Line 157 in e19c1b1
netClient
likemonocular/cmd/chart-repo/utils_test.go
Line 202 in e19c1b1
Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prydonius Yes, it does. I have added the test case. Let me know if it looks okay to you.
:)