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

[kubeapps-apis] Add direct-helm GetAvailablePackageDetail #3034

Conversation

antgamdia
Copy link
Contributor

Description of the change

This PR just implements the GetAvailablePackageDetail method in the direct-helm plugin.

Benefits

We will have a brand new GetAvailablePackageDetail operation up and running.

Possible drawbacks

N/A

Applicable issues

Additional information

(Draft until we merge the other PRs so that it becomes easier to review; didn't want to push to the repo)

@antgamdia antgamdia changed the title 2993 helm plugin get available package detail [kubeapps-apis] Add direct-helm GetAvailablePackageDetail Jun 23, 2021
@antgamdia antgamdia marked this pull request as draft June 23, 2021 20:32
@absoludity
Copy link
Contributor

(Draft until we merge the other PRs so that it becomes easier to review; didn't want to push to the repo)

You can target your other branch in situations like this, so reviews can go ahead with just the relevant diff. It's a bit of a pain, but works OK. When the preceding branch lands, GH will automatically update the target of this PR back to the main branch, but you still often need to rebase, removing the extra commits.

Conflicts:
	cmd/assetsvc/handler.go
	cmd/assetsvc/handler_test.go
	cmd/assetsvc/main.go
	cmd/assetsvc/pkg/assetsvc_utils/postgresql_utils.go
	cmd/assetsvc/pkg/assetsvc_utils/postgresql_utils_test.go
	cmd/assetsvc/pkg/assetsvc_utils/utils.go
	cmd/assetsvc/pkg/utils/postgresql_utils.go
	cmd/assetsvc/pkg/utils/postgresql_utils_test.go
	cmd/assetsvc/pkg/utils/utils.go
	cmd/assetsvc/postgres_db_test.go
	cmd/assetsvc/postgresql_utils.go
	cmd/assetsvc/postgresql_utils_test.go
	cmd/assetsvc/utils.go
	cmd/kubeapps-apis/gen/core/packages/v1alpha1/packages.pb.go
	cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server.go
@antgamdia antgamdia force-pushed the 2993-helmPlugin-GetAvailablePackageDetail branch from d1ad0b0 to d278b12 Compare June 25, 2021 14:52
Conflicts:
	cmd/kubeapps-apis/docs/kubeapps-apis.swagger.json
	cmd/kubeapps-apis/gen/core/packages/v1alpha1/packages.pb.go
	cmd/kubeapps-apis/gen/plugins/helm/packages/v1alpha1/helm.pb.gw.go
	cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server.go
	cmd/kubeapps-apis/plugins/helm/packages/v1alpha1/server_test.go
	cmd/kubeapps-apis/proto/kubeappsapis/core/packages/v1alpha1/packages.proto
@antgamdia antgamdia marked this pull request as ready for review June 29, 2021 16:31
Copy link
Contributor

@absoludity absoludity left a comment

Choose a reason for hiding this comment

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

Excellent, thanks Antonio. A couple of points about required vs optional fields to see what you think, but otherwise +1

Comment on lines +222 to +236
// After requesting a specific namespace, we have to ensure the user can actually access to it
// If checking the global namespace, allow access always
hasAccess := namespace == s.globalPackagingNamespace
if !hasAccess {
var err error
// If checking another namespace, check if the user has access (ie, "get secrets in this ns")
hasAccess, err = s.hasAccessToNamespace(ctx, namespace)
if err != nil {
return nil, status.Errorf(codes.Internal, "Unable to check if the user has access to the namespace: %s", err)
}
if !hasAccess {
// If the user has not access, return a unauthenticated response, otherwise, continue
return nil, status.Errorf(codes.Unauthenticated, "The current user has no access to the namespace %q", namespace)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this now be dry'd up if it's the same in both this function and the summaries one?


if chart.Description == "" {
return nil, status.Errorf(codes.Internal, "required field .Description not found on helm package: %v", chart)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the description required? It's listed as optional at https://helm.sh/docs/topics/charts/#the-chartyaml-file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot to verify it! Last week I thought: ok, let's put every param as mandatory and later on I'll look them up in the helm code or website... but...ouch, I never did.
Thanks for the pointer!

return nil, status.Errorf(codes.Internal, "required field .Description not found on helm package: %v", chart)
}
pkg.ShortDescription = chart.Description
pkg.LongDescription = chart.Description
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should just leave LongDescription blank for helm charts, which only have a single description field in the Chart.yaml? If we copy it like this, a client would display both, I'd think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that makes sense. I just set both so that we can decide later. But, we better avoid duplicated fields :P

pkg.Name = chart.Name
pkg.DisplayName = chart.Name

if chart.Icon == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

pkg.ShortDescription = chart.Description
pkg.LongDescription = chart.Description

if chart.Maintainers == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

}
pkg.PkgVersion = chart.ChartVersions[0].Version

if chart.ChartVersions[0].AppVersion == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

AppVersion is also optional at https://helm.sh/docs/topics/charts/#the-chartyaml-file so I assume it can be optional in our cache.

}
pkg.AppVersion = chart.ChartVersions[0].AppVersion

if chart.ChartVersions[0].Readme == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

}
pkg.DefaultValues = chart.ChartVersions[0].Values

if chart.ChartVersions[0].Schema == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

name: "it returns internal error if chart is invalid",
chart: &models.Chart{Name: "foo"},
statusCode: codes.Internal,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess you could add failing tests here to show that it should succeed without certain fields (ie. readme, icon, maintainers) then fix it for them to pass :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TDD is great for these fixes :P Added a TestIsValidChart test suite

@absoludity
Copy link
Contributor

Great, good to go when the conflict is resolved.

@antgamdia antgamdia merged commit 76b5a5b into vmware-tanzu:master Jul 1, 2021
@antgamdia antgamdia deleted the 2993-helmPlugin-GetAvailablePackageDetail branch July 1, 2021 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants