-
Notifications
You must be signed in to change notification settings - Fork 707
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
Remove unused code + refactor after Kubeops removal #5442
Conversation
Signed-off-by: Rafa Castelblanque <[email protected]>
✅ Deploy Preview for kubeapps-dev canceled.
|
Signed-off-by: Rafa Castelblanque <[email protected]>
Signed-off-by: Rafa Castelblanque <[email protected]>
Signed-off-by: Rafa Castelblanque <[email protected]>
Signed-off-by: Rafa Castelblanque <[email protected]>
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.
Sorry, I did check this PR but I though I +1ed it 😅
Thanks for the effort in refactoring and moving/deleting the code, really important to keep our codebase tidy up!
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.
LGTM! I've added several suggestions, most of them probably not directly related to the scope of this PR, as they likely refer to moved code, and anyway, none of them is blocking. So feel free to ignore them.
} | ||
|
||
// getOCIAppRepositoryTag Gets a tag for the given repo URL & name | ||
func getOCIAppRepositoryTag(cli httpclient.Client, repoURL string, repoName string) (string, error) { |
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.
I think this function has too many responsibilities: it parses/constructs the URL, performs the HTTP request and validates the response, and unmarshal/parses the HTTP response body to get and return the tag. In order to get a shorter function and follow SOLID and clean code principles, I would split it into several auxiliary functions, each with a single responsibility.
} | ||
|
||
// getOCIAppRepositoryMediaType Gets manifests config.MediaType for the given repo URL & Name | ||
func getOCIAppRepositoryMediaType(cli httpclient.Client, repoURL string, repoName string, tagVersion string) (string, error) { |
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.
Here I see more or less the same as in my previous comment. I think that we could have some kind of generic getURL(repoURL, repoName, extraPathSegments... string)
to take care of the different URLs generation.
if err != nil { | ||
t.Fatalf("%+v", err) | ||
} |
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.
I would opt for stretchr/testify
functions like require.NotNil
for this kind of assertions, as it lead to more readable and maintainable tests.
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.
Agree, it is a cleaner way.
Most part of the code is not new, so we have the traditional way of checking :)
t.Fatalf("%+v", err) | ||
} | ||
|
||
testCases := []struct { |
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.
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.
That looks like a good improvement to me, we could start doing it!
if err != nil { | ||
t.Errorf("Unexpected error %v", err) | ||
} | ||
|
||
if got, want := fakeClient.request, tc.httpValidator.Req; !cmp.Equal(want, got, cmpOpts...) { | ||
t.Errorf("mismatch (-want +got):\n%s", cmp.Diff(want, got, cmpOpts...)) | ||
} | ||
|
||
if got, want := response, tc.expectedResponse; !cmp.Equal(want, got) { | ||
t.Errorf("mismatch (-want +got):\n%s", cmp.Diff(want, got)) | ||
} |
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.
The same here about using testify library assertions.
if ch == nil { | ||
t.Errorf("got: nil, want: non-nil") | ||
} else if got, want := ch.Name(), "nginx"; got != want { | ||
t.Errorf("got: %q, want: %q", got, want) | ||
} |
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.
Again, I think that testify's assertions would make this block much easier to understand:
require.NotNil(t, ch)
require.Equal(t, "nginx", ch.Name())
if got, want := len(requests), expectedLen; got != want { | ||
t.Fatalf("got: %d, want %d", got, want) | ||
} |
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.
The same about using require.Equal()
cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/utils/chart-client_test.go
Outdated
Show resolved
Hide resolved
cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/utils/chart-client_test.go
Outdated
Show resolved
Hide resolved
chartURLs []string | ||
index *repo.IndexFile | ||
userAgent string | ||
// TODO(absoludity): perhaps switch to use httptest instead of our own fake? |
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.
I think this would be a good idea 🙂
…lient_test.go Co-authored-by: Jesús Miguel Benito Calzada <[email protected]> Signed-off-by: Rafa Castelblanque <[email protected]>
…lient_test.go Co-authored-by: Jesús Miguel Benito Calzada <[email protected]> Signed-off-by: Rafa Castelblanque <[email protected]>
@beni0888 Thanks for the thorough review. Some comments I haven't changed because it is actually previously existing code and didn't want to mess with it too much given how big the PR is already. |
Bumps [axios](https://github.com/axios/axios) from 1.2.2 to 1.2.3. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/axios/axios/releases">axios's releases</a>.</em></p> <blockquote> <h2>1.2.3</h2> <h2>Release notes:</h2> <h3>Bug Fixes</h3> <ul> <li><strong>types:</strong> fixed AxiosRequestConfig header interface by refactoring it to RawAxiosRequestConfig; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5420">#5420</a>) (<a href="https://github.com/axios/axios/commit/08119634a22f1d5b19f5c9ea0adccb6d3eebc3bc">0811963</a>)</li> </ul> <h3>Contributors to this release</h3> <ul> <li><img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=16" alt="avatar" /> <a href="https://github.com/DigitalBrainJS" title="+938/-442 ([#5456](axios/axios#5456) [#5455](axios/axios#5455) [#5453](axios/axios#5453) [#5451](axios/axios#5451) [#5449](axios/axios#5449) [#5447](axios/axios#5447) [#5446](axios/axios#5446) [#5443](axios/axios#5443) [#5442](axios/axios#5442) [#5439](axios/axios#5439) [#5420](axios/axios#5420) )">Dmitriy Mozgovoy</a></li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/axios/axios/blob/v1.x/CHANGELOG.md">axios's changelog</a>.</em></p> <blockquote> <h2><a href="https://github.com/axios/axios/compare/1.2.2...1.2.3">1.2.3</a> (2023-01-10)</h2> <h3>Bug Fixes</h3> <ul> <li><strong>types:</strong> fixed AxiosRequestConfig header interface by refactoring it to RawAxiosRequestConfig; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5420">#5420</a>) (<a href="https://github.com/axios/axios/commit/08119634a22f1d5b19f5c9ea0adccb6d3eebc3bc">0811963</a>)</li> </ul> <h3>Contributors to this release</h3> <ul> <li><img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=16" alt="avatar" /> <a href="https://github.com/DigitalBrainJS" title="+938/-442 ([#5456](axios/axios#5456) [#5455](axios/axios#5455) [#5453](axios/axios#5453) [#5451](axios/axios#5451) [#5449](axios/axios#5449) [#5447](axios/axios#5447) [#5446](axios/axios#5446) [#5443](axios/axios#5443) [#5442](axios/axios#5442) [#5439](axios/axios#5439) [#5420](axios/axios#5420) )">Dmitriy Mozgovoy</a></li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/axios/axios/commit/557ed0a7489b1bf62296ea34568eeea8975ff4f9"><code>557ed0a</code></a> chore(ci): fixed publish action; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5470">#5470</a>)</li> <li><a href="https://github.com/axios/axios/commit/484e0b6ed24745df9cadaacc0fbf129114e70d00"><code>484e0b6</code></a> chore(release): v1.2.3 (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5459">#5459</a>)</li> <li><a href="https://github.com/axios/axios/commit/d83316db4a242252db3a2ed7728cb43f8f8f4189"><code>d83316d</code></a> chore(ci): enabled npm publishing; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5460">#5460</a>)</li> <li><a href="https://github.com/axios/axios/commit/d750901deda2994a2d89643e8f18723cfb6b2732"><code>d750901</code></a> chore(ci): added an action to make GitHub & NPM releases when merging a relea...</li> <li><a href="https://github.com/axios/axios/commit/477c71427dc1d03e0f3dced0d65bd7c1b99fd900"><code>477c714</code></a> chore(ci): fixed error in generating changelog with unnecessary spaces; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5455">#5455</a>)</li> <li><a href="https://github.com/axios/axios/commit/e2a1e280f6dfbb4f11ad541dec9541cdbf760ab1"><code>e2a1e28</code></a> chore(ci): improved contributors & PRs sections generator; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5453">#5453</a>)</li> <li><a href="https://github.com/axios/axios/commit/18772ed8fdcd0768a9b520737d81283c04a273f8"><code>18772ed</code></a> chore(ci): improved logging; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5451">#5451</a>)</li> <li><a href="https://github.com/axios/axios/commit/259f5f5aaadfcaf7f3a3fe462d8b0dbbc8004962"><code>259f5f5</code></a> chore(ci): added step of generating a list of contributors for CHANELOG.md; (...</li> <li><a href="https://github.com/axios/axios/commit/d33a3deb82b808f109b598abbf39fd2a1f8da998"><code>d33a3de</code></a> chore(ci): added commit message config; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5447">#5447</a>)</li> <li><a href="https://github.com/axios/axios/commit/ebb9e814436d2f6c7cc65ffecb6ff013539ce961"><code>ebb9e81</code></a> chore(deps): bump json5 from 1.0.1 to 1.0.2 (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5438">#5438</a>)</li> <li>Additional commits viewable in <a href="https://github.com/axios/axios/compare/1.2.2...v1.2.3">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=axios&package-manager=npm_and_yarn&previous-version=1.2.2&new-version=1.2.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [axios](https://github.com/axios/axios) from 1.2.2 to 1.2.3. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/axios/axios/releases">axios's releases</a>.</em></p> <blockquote> <h2>1.2.3</h2> <h2>Release notes:</h2> <h3>Bug Fixes</h3> <ul> <li><strong>types:</strong> fixed AxiosRequestConfig header interface by refactoring it to RawAxiosRequestConfig; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5420">#5420</a>) (<a href="https://github.com/axios/axios/commit/08119634a22f1d5b19f5c9ea0adccb6d3eebc3bc">0811963</a>)</li> </ul> <h3>Contributors to this release</h3> <ul> <li><img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=16" alt="avatar" /> <a href="https://github.com/DigitalBrainJS" title="+938/-442 ([#5456](axios/axios#5456) [#5455](axios/axios#5455) [#5453](axios/axios#5453) [#5451](axios/axios#5451) [#5449](axios/axios#5449) [#5447](axios/axios#5447) [#5446](axios/axios#5446) [#5443](axios/axios#5443) [#5442](axios/axios#5442) [#5439](axios/axios#5439) [#5420](axios/axios#5420) )">Dmitriy Mozgovoy</a></li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/axios/axios/blob/v1.x/CHANGELOG.md">axios's changelog</a>.</em></p> <blockquote> <h2><a href="https://github.com/axios/axios/compare/1.2.2...1.2.3">1.2.3</a> (2023-01-10)</h2> <h3>Bug Fixes</h3> <ul> <li><strong>types:</strong> fixed AxiosRequestConfig header interface by refactoring it to RawAxiosRequestConfig; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5420">#5420</a>) (<a href="https://github.com/axios/axios/commit/08119634a22f1d5b19f5c9ea0adccb6d3eebc3bc">0811963</a>)</li> </ul> <h3>Contributors to this release</h3> <ul> <li><img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=16" alt="avatar" /> <a href="https://github.com/DigitalBrainJS" title="+938/-442 ([#5456](axios/axios#5456) [#5455](axios/axios#5455) [#5453](axios/axios#5453) [#5451](axios/axios#5451) [#5449](axios/axios#5449) [#5447](axios/axios#5447) [#5446](axios/axios#5446) [#5443](axios/axios#5443) [#5442](axios/axios#5442) [#5439](axios/axios#5439) [#5420](axios/axios#5420) )">Dmitriy Mozgovoy</a></li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="https://github.com/axios/axios/commit/557ed0a7489b1bf62296ea34568eeea8975ff4f9"><code>557ed0a</code></a> chore(ci): fixed publish action; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5470">#5470</a>)</li> <li><a href="https://github.com/axios/axios/commit/484e0b6ed24745df9cadaacc0fbf129114e70d00"><code>484e0b6</code></a> chore(release): v1.2.3 (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5459">#5459</a>)</li> <li><a href="https://github.com/axios/axios/commit/d83316db4a242252db3a2ed7728cb43f8f8f4189"><code>d83316d</code></a> chore(ci): enabled npm publishing; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5460">#5460</a>)</li> <li><a href="https://github.com/axios/axios/commit/d750901deda2994a2d89643e8f18723cfb6b2732"><code>d750901</code></a> chore(ci): added an action to make GitHub & NPM releases when merging a relea...</li> <li><a href="https://github.com/axios/axios/commit/477c71427dc1d03e0f3dced0d65bd7c1b99fd900"><code>477c714</code></a> chore(ci): fixed error in generating changelog with unnecessary spaces; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5455">#5455</a>)</li> <li><a href="https://github.com/axios/axios/commit/e2a1e280f6dfbb4f11ad541dec9541cdbf760ab1"><code>e2a1e28</code></a> chore(ci): improved contributors & PRs sections generator; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5453">#5453</a>)</li> <li><a href="https://github.com/axios/axios/commit/18772ed8fdcd0768a9b520737d81283c04a273f8"><code>18772ed</code></a> chore(ci): improved logging; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5451">#5451</a>)</li> <li><a href="https://github.com/axios/axios/commit/259f5f5aaadfcaf7f3a3fe462d8b0dbbc8004962"><code>259f5f5</code></a> chore(ci): added step of generating a list of contributors for CHANELOG.md; (...</li> <li><a href="https://github.com/axios/axios/commit/d33a3deb82b808f109b598abbf39fd2a1f8da998"><code>d33a3de</code></a> chore(ci): added commit message config; (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5447">#5447</a>)</li> <li><a href="https://github.com/axios/axios/commit/ebb9e814436d2f6c7cc65ffecb6ff013539ce961"><code>ebb9e81</code></a> chore(deps): bump json5 from 1.0.1 to 1.0.2 (<a href="https://github-redirect.dependabot.com/axios/axios/issues/5438">#5438</a>)</li> <li>Additional commits viewable in <a href="https://github.com/axios/axios/compare/1.2.2...v1.2.3">compare view</a></li> </ul> </details> <br /> [![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=axios&package-manager=npm_and_yarn&previous-version=1.2.2&new-version=1.2.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Rafa Castelblanque [email protected]
Description of the change
After removing
kubeops
#5253, there was a lot of old useless backend code left in the Go modules.This PR removes unused duplicate code related mainly to
kubeops
and pre-plugins age.Also refactors some pieces, code under
/pkg
that is directly related to helm plugin only.Benefits
Simpler and cleaner code base.
Possible drawbacks
N/A
Applicable issues