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

Changes to SinkFlags in order to support plugin event sources #748

Closed
wants to merge 1 commit into from

Conversation

daisy-ycguo
Copy link
Member

@daisy-ycguo daisy-ycguo commented Mar 19, 2020

Description

Make two changes to SinkFlags in order to support other event sources at client-contrib.

Changes

  • Add a public method SinkToDuckV1Beta1 to flags package.
  • Change the parameter in SinkFlags.Add() to flag.FlagSet, similar as AddNamespaceFlags().

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Mar 19, 2020
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 19, 2020
@daisy-ycguo daisy-ycguo changed the title Add a public method SinkToDuckV1Beta1 to flags package [WIP] Changes to SinkFlags in order to support plugin event sources Mar 23, 2020
@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 23, 2020
@daisy-ycguo daisy-ycguo changed the title [WIP] Changes to SinkFlags in order to support plugin event sources Changes to SinkFlags in order to support plugin event sources Mar 23, 2020
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 23, 2020
Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

Sorry, I thought I already sent the review (but probably forgot to push the button).

I don't think that anything from client-contrib must depend on client, as this would also couple the release cycle of otherwise independent plugins to the client release cycle.

Especially when the reuse is only marginally, its better to duplicate for the plugins to make plugins self-contained and independent.

As this, I don't think we should merge this PR.

/hold

@@ -132,3 +134,17 @@ func SinkToString(sink duckv1.Destination) string {
}
return ""
}

// SinkToDuckV1Beta1 converts a Destination from duckv1 to duckv1beta1
func SinkToDuckV1Beta1(destination *duckv1.Destination) *duckv1beta1.Destination {
Copy link
Contributor

Choose a reason for hiding this comment

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

Its not really a Sink but a Destination what you are converting (could be used for other destinations than sinks).

I would it call it ToDuckV1Beta1 as Destination is already clear from the signature, (alternative: DestinationAsDuckV1Beta1 if we want to be more verbose)

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 24, 2020
Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

/ok-to-test

@knative-prow-robot knative-prow-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Mar 24, 2020
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: daisy-ycguo, maximilien

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

The pull request process is described here

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 24, 2020
@knative-metrics-robot
Copy link

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

File Old Coverage New Coverage Delta
pkg/kn/commands/flags/sink.go 57.6% 54.3% -3.3
pkg/kn/commands/source/apiserver/apiserver.go 62.5% 59.1% -3.4

@maximilien
Copy link
Contributor

I don't think that anything from client-contrib must depend on client, as this would also couple the release cycle of otherwise independent plugins to the client release cycle.

While I would agree with the point of having common code in a separate repo, perhaps client-pkg to avoid some of the dependency issues. I also have to question this a bit since part of the charter for kn is to have code that can be reused to create “custom” clients. This has been a goal from the start and we are finally testing this now with plugins.

So while I like the idea of extracting some code for common packages, I also think we need to figure out a way to allow exported types and code to be usable for external components. These “users” would simply vendor the version of the client that they need and periodically update and resolve conflicts.

@rhuss
Copy link
Contributor

rhuss commented Mar 25, 2020

@maximilien I get you point, so let's look for an smaller, not-optimal solution as long as its still hard to introduce new repositories.

If separation of client-internal and exported libraries can not be enforced by using different dependencies (or GitHub repos), we should at least base that separation on Golang package level and maybe even reflect it in the directory structure (e.g. introducing a top-level directory for code that is meant to be reused). Only relying on the golang idiom of uppercase types for exported functionality is not good enough for us (i.e. there are cross-package dependencies whithin the client which are not meant to used outside as the can arbitrarily be changed).

Having this clear seperation even within the knative/client repo has also the benefit that it could be easily moved out into a seperate Github repo later, and we can increase the review standards for those exported code.

The candidates for exported functionalities that I see are:

  • The client services
  • Flag parsing
  • Watch functionality

Anything else ?

So I would suggest to introduce eg. lib directory for this kind of code (I would use pkg but that is already taken).

@daisy-ycguo would this work for you ? If so, I would pick up your PR and include it in a separate PR for setting up this structure.

@maximilien
Copy link
Contributor

The candidates for exported functionalities that I see are:

  • The client services
  • Flag parsing
  • Watch functionality

Good.

Anything else ?

The e2e test infrastructure as well as some parts of the UT code.

Let's start with that and I am sure lots more will come up.

So I would suggest to introduce eg. lib directory for this kind of code (I would use pkg but that is already taken).

Sounds good.

@daisy-ycguo
Copy link
Member Author

I will close this PR since dr.max has tracked it with the issue #763. Thank you for the comments and discussions.

coryrc pushed a commit to coryrc/client that referenced this pull request May 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants