Skip to content

Conversation

@savitaashture
Copy link
Contributor

Background:
as per the comments 1 and 2 usage of PodSpecable duck type helps to reduce lot of duplicate code

Issue:
To use duck type for Deployment, DaemonSet, StatefulSet etc... Selector field is mandatory and which is missing in WithPod and also GetGroupVersionKind implementation

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Feb 4, 2020
@knative-prow-robot knative-prow-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 4, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: savitaashture
To complete the pull request process, please assign mattmoor
You can assign the PR to them by writing /assign @mattmoor in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

// WithPodSpec is the shell around the PodSpecable within WithPod.
type WithPodSpec struct {
Template PodSpecable `json:"template,omitempty"`
Selector *metav1.LabelSelector `json:"selector"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This would break compatibility with our own PodSpecables, like Service and Configuration.

Copy link
Contributor Author

@savitaashture savitaashture Feb 4, 2020

Choose a reason for hiding this comment

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

If that's the case then do we need to write new one because for controllers selector is mandatory

Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment on the PR. I think we shouldn't actually reserialize from the PodSpecable as that's a lossy conversion (as you noticed).

Instead, we should only override the relevant part of the unstructured that's been updated and part of PodSpecable

}

// GetGroupVersionKind returns a GroupVersionKind.
func (*WithPod) GetGroupVersionKind() schema.GroupVersionKind {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this is the right thing to do here as WithPod doesn't really exist. Should this read the actual GroupVersionKind from the typeMeta?

@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-pkg-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
apis/duck/v1/podspec_types.go 100.0% 75.0% -25.0

@savitaashture
Copy link
Contributor Author

savitaashture commented Feb 5, 2020

closing PR because it may break compatibility with PodSpecables by adding selector support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Indicates the PR's author has signed the CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants