-
Notifications
You must be signed in to change notification settings - Fork 702
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
Get package details prototype #2915
Get package details prototype #2915
Conversation
|
||
message GetPackageMetaResponse { | ||
message PackageMeta { | ||
string readme = 1; |
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 was thinking about this field - Helm charts have a readme, but a more general option might be longDescription
, noting that it can be markdown, but we can discuss that in the design doc soon.
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.
Michael, this is not ready for review in any shape. Its a draft just to see what it costs to make the "electrons flow". When I am ready for review the interface will be much more generic and not look like that. So no need to worry
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.
Ah sorry... I thought you'd created a draft PR because it wasn't ready for review but wanted some feedback (something I often do). No probs, I'll not look at something until you request it :)
|
||
log.Infof("created chart: [%v]", newChart) | ||
|
||
return nil, status.Errorf(codes.Unimplemented, "not implemented yet") |
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.
Guessing you plan at this point to wait for the chart to reconcile before returning the metadata, though I don't see it on the CR (https://fluxcd.io/docs/components/source/helmcharts/#specification) so we'd need to parse the chart itself, right? (which is cached by fluxv2?)
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.
please hold comments until I mark it ready for review :-)
I marked it ready for review. To be clear on what this is - just a prototype piece of |
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.
Nice work Greg. I'm OK if you want to land this as is, slight preference for at least using the endpoint name that we're going to move to, but you may have reasons to prefer to land and continue. A few comments in line.
) | ||
|
||
// these should really be constants, rather than global vars | ||
// but alas, go does not allow const structs (why???) |
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.
Because an instance of a struct is not a compile-time object, therefore, not really constant. I assume the reason for that is for the speed of the compiler (it does not need to check whether code is updating things that are declared as constants).
I'd personally prefer not to set a precedent of using global vars at all, and instead just instantiate the GroupVersionResource using the const strings that you already have.
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.
ok, sounds good. I'll change this.
FWIW, there was a lot of debate on the subject of const structs in go. What I got from it, it is technically possible just requires a lot of work, and there wasn't enough "bang for the buck" (literally an expression someone at google used) to make it happen. bleh
@@ -172,6 +201,130 @@ func (s *Server) GetAvailablePackages(ctx context.Context, request *corev1.GetAv | |||
}, nil | |||
} | |||
|
|||
// GetPackageMeta streams the package metadata based on the request. | |||
func (s *Server) GetPackageMeta(ctx context.Context, request *corev1.GetPackageMetaRequest) (*corev1.GetPackageMetaResponse, 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 is what you were referring to, that I should ignore? As in, this will later be changed to GetAvailablePackageDetail
or something? If so, why not just add it as we plan it to be (just this one call)?
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.
yeah, this will happen, don't worry about that
return nil, err | ||
} | ||
|
||
resourceIfc := client.Resource(chartsResource).Namespace("default") |
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.
Why is the namespace hard-coded here? Fine if it's just for demoning right now.
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.
just a placeholder, like I said, a lot of refactoring to be done
return nil, err | ||
} | ||
|
||
// TODO it'd be better if we could filter on server-side |
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.
You should be able to use the metav1.ListOptions{}
above to specify filtering using the FieldSelector
. More info at https://kubernetes.io/docs/concepts/overview/working-with-objects/field-selectors/ . You may even be able to specify that the pull should be complete to be included (ie. that status conditions ready is true), not sure, but that'd be nice.
Again, at this point it's fine if you just want to update your comment to link to that and do it in a later PR.
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.
As I remember I did try a few things here. The problem is the set of supported fields in FieldSelector is very small. things like spec.chart are certainly not supported. see kubernetes/client-go#713 and https://github.com/flant/shell-operator/blob/8fa3c3b8cfeb1ddb37b070b7a871561fdffe788b/HOOKS.md#fieldselector. Nevertheless, I made a TODO comment here just as you suggested to see if I can improve later
} | ||
|
||
func waitUntilChartPullComplete(watcher watch.Interface) (*string, error) { | ||
ch := watcher.ResultChan() |
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.
Nice - great use of both channel and the watcher to handle the async request. Note that this effectively makes pullChartTarball
a blocking call, which is fine in it's current use (where it's only called in a context of one chart). Not for now, but in the future you might instead want to consider something like passing a results channel (of string urls) to pullChartTarball, so it returns immediately and you wait on the results channel at the call-site, which would mean you could call it for 20 different charts and just wait for the results to come in whatever order they happen to take, rather than serially.
// | ||
// TODO the semantics of this really should be do we need to keep polling or not | ||
// | ||
func isChartPullComplete(unstructuredChart *unstructured.Unstructured) (bool, 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.
As above, hopefully this fn isn't required if we can only list charts that we know are ready.
@@ -0,0 +1,134 @@ | |||
/* |
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.
Is the functionality in this utils file already available in the existing codebase? If so, I'd be keen to import and re-use that?
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.
yeah, kind of, but its private to asset-syncer. now. Needs to be re-packaged for re-used. I will put a TODO item to see if I can clean it up
@@ -22,6 +22,11 @@ service PackagesService { | |||
get: "/core/packages/v1alpha1/packagerepositories" | |||
}; | |||
} | |||
rpc GetPackageMeta(kubeappsapis.core.packages.v1alpha1.GetPackageMetaRequest) returns (kubeappsapis.core.packages.v1alpha1.GetPackageMetaResponse) { |
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 we just use GetInstalledPackageDetails
? Fine if not, we'll be updating it soon.
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.
one thing at a time :-). It will probably be in my next PR
Description of the change
A prototype for fluxv2 plugin's feature that returns package details
Benefits
Possible drawbacks
Applicable issues
[kubeapps-apis] Investigate provision of chart Readme and values #2864
Additional information