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

Fix plugin inlining that uses client-pkg dependency #1816

Merged
merged 3 commits into from
Jul 18, 2023

Conversation

dsimansk
Copy link
Contributor

Description

Changes

  • Fix plugin inlining that uses client-pkg dependency

This moves the initialization to new client-pkg, otherwise the inlined plugins depending on client-pkg aren't recognized as expected.

/cc @rhuss @vyasgun

Reference

Fixes #

Release Note

Fix plugin inlining that uses client-pkg dependency

@knative-prow knative-prow bot requested review from rhuss and vyasgun May 24, 2023 12:14
@knative-prow knative-prow bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 24, 2023
@codecov
Copy link

codecov bot commented May 24, 2023

Codecov Report

Patch coverage: 66.66% and project coverage change: -0.01 ⚠️

Comparison is base (75d62a3) 79.74% compared to head (bfaf3f9) 79.73%.

❗ Current head bfaf3f9 differs from pull request most recent head 29b7e83. Consider uploading reports for the commit 29b7e83 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1816      +/-   ##
==========================================
- Coverage   79.74%   79.73%   -0.01%     
==========================================
  Files         179      179              
  Lines       13890    13898       +8     
==========================================
+ Hits        11076    11081       +5     
- Misses       2052     2054       +2     
- Partials      762      763       +1     
Impacted Files Coverage Δ
pkg/kn/plugin/manager.go 84.19% <66.66%> (-0.66%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 24, 2023
@rhuss
Copy link
Contributor

rhuss commented May 24, 2023

IIUC this is about moving the pluginmanager to pkg, so that plugins can add themselves to that global plugin array (because now they don't have a dependency to the client anymore, which is what we want).

If this is correct, the chance makes totally sense. However, I would also remove moved parts from the client hier as well.

@dsimansk
Copy link
Contributor Author

IIUC this is about moving the pluginmanager to pkg, so that plugins can add themselves to that global plugin array (because now they don't have a dependency to the client anymore, which is what we want).

If this is correct, the chance makes totally sense. However, I would also remove moved parts from the client hier as well.

Yep, that's exact summary. I'll clean up the moved parts in a big bang sweep. :)

@dsimansk
Copy link
Contributor Author

@rhuss or @vyasgun would be able to take a look pls? I'll rebase the PR though to be mergeable again.

@vyasgun
Copy link
Contributor

vyasgun commented Jun 19, 2023

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jun 19, 2023
@knative-prow knative-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 22, 2023
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 22, 2023
@dsimansk
Copy link
Contributor Author

@vyasgun sorry, rebased now. :)

@vyasgun
Copy link
Contributor

vyasgun commented Jun 22, 2023

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jun 22, 2023
@knative-prow knative-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 23, 2023
@dsimansk
Copy link
Contributor Author

@vyasgun @rhuss if you may pls. I had to rebase due to other fix within e2e tests. Thanks!

@dsimansk
Copy link
Contributor Author

/retest

@vyasgun
Copy link
Contributor

vyasgun commented Jun 29, 2023

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jun 29, 2023
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 29, 2023
@knative-prow knative-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 30, 2023
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 30, 2023
@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 30, 2023
@dsimansk
Copy link
Contributor Author

@vyasgun I went with a different approach, rather make both lists work for a while as a backward compatibility solution.

@rhuss per our chat, that's upstream fix.

cmd/kn/main.go Outdated
Comment on lines 67 to 71
// Merge plugins that implements client-pkg Plugin type to the same manager instance
for _, p := range pkgplugin.InternalPlugins {
pluginManager.AppendPlugin(p)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This part is important!

There're 2 gloabal variables:

  • client InternalPlugins
  • client-pkg InternalPlugins

Depending in the plugin impl both are still valid, either by using new depedency or former on client repo. Therefore there's list merge to a single one that is used onward. I.e. content of client-pkg list is merged into client list.

@dsimansk
Copy link
Contributor Author

dsimansk commented Jul 3, 2023

/retest

cmd/kn/main.go Outdated
@@ -62,6 +64,11 @@ func run(args []string) error {

pluginManager := plugin.NewManager(config.GlobalConfig.PluginsDir(), config.GlobalConfig.LookupPluginsInPath())

// Merge plugins that implements client-pkg Plugin type to the same manager instance
for _, p := range pkgplugin.InternalPlugins {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether we shouldn't put this internally in plugin.NewManager() where it feels more natural to me. It could be a lazy initialization (i.e. do only once regardless how often NewManager() is called). It would also keep main() a bit cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it look better now? Agreed on moving the scope to constructor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rhuss ping if you get to it.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks! (sorry, missed that ping)

/approve
/lgtm

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 13, 2023
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 13, 2023
@knative-prow knative-prow bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 13, 2023
@dsimansk
Copy link
Contributor Author

/retest

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 18, 2023
@knative-prow
Copy link

knative-prow bot commented Jul 18, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dsimansk, rhuss

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 knative-prow bot merged commit e6a60c4 into knative:main Jul 18, 2023
22 checks passed
@dsimansk dsimansk added this to the Knative 1.11 milestone Aug 10, 2023
dsimansk added a commit to dsimansk/client that referenced this pull request Oct 3, 2023
* Fix plugin inlining that uses client-pkg dependency

* Move list merge into plugin manager

* Fix imports formatting
openshift-ci bot pushed a commit to openshift-knative/client that referenced this pull request Oct 3, 2023
)

* Fix plugin inlining that uses client-pkg dependency

* Move list merge into plugin manager

* Fix imports formatting
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. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants