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

Add plugin registry #5467

Merged
merged 4 commits into from
Jan 7, 2025
Merged

Add plugin registry #5467

merged 4 commits into from
Jan 7, 2025

Conversation

ffjlabo
Copy link
Member

@ffjlabo ffjlabo commented Jan 7, 2025

What this PR does:

I added the package pkg/plugin/registry.
This package is responsible for finding which plugin is used to deploy the app.

I implemented the two use-cases as methods for now.

  1. GetPluginClientsByAppConfig: Get the plugin client based on the app config
  2. GetPluginClientByStageName: Get the plugin client based on the stage name

These will be used in the controller, scheduler, planner like this↓ (draft implementation)
add-plugin-registry...use-plugin-registry

Why we need it:

We need to find the plugin for the app to deploy, detect the diff, and get the live state from the plugin.

At first, we added the plugin name to the model.Application on the PR #5457.
However, users should update the app to change its available plugins on the Web UI when they want to use another plugin. It takes more time for users.

So, we decided to determine the plugin used to deploy an app from the app config.

Which issue(s) this PR fixes:

Part of #5259

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

Signed-off-by: Yoshiki Fujikane <[email protected]>
Copy link

codecov bot commented Jan 7, 2025

Codecov Report

Attention: Patch coverage is 65.51724% with 20 lines in your changes missing coverage. Please review.

Project coverage is 26.19%. Comparing base (602bf8c) to head (58f6e2a).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
pkg/plugin/registry/registry.go 65.51% 20 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5467      +/-   ##
==========================================
+ Coverage   26.15%   26.19%   +0.04%     
==========================================
  Files         457      458       +1     
  Lines       49111    49169      +58     
==========================================
+ Hits        12843    12881      +38     
- Misses      35246    35266      +20     
  Partials     1022     1022              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ffjlabo ffjlabo marked this pull request as ready for review January 7, 2025 05:15
Warashi
Warashi previously approved these changes Jan 7, 2025
Copy link
Contributor

@Warashi Warashi left a comment

Choose a reason for hiding this comment

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

LGTM

[IMO]
We have 2 kinds of packages under pkgs/plugin, but it's confusing. So we may have to separate them.

  1. packages mainly used by the plugins
  2. packages mainly used by the piped, and it operates about the plugins

Let's discuss and do it on another PR.

plugin, ok := pr.stageBasedPlugins[stage.Name.String()]
if ok {
plugins = append(plugins, plugin)
}
Copy link
Member

Choose a reason for hiding this comment

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

[ASK]
What if not ok? I think it should return an error.

Suggested change
}
}else{
return nil, fmt.Errorf("no plugin found for the stage %s", stage.Name.String())
}

instead of the following:

	if len(plugins) == 0 {
		return nil, fmt.Errorf("no plugin found for each stages")
	}

The same in getPluginClientsByNames().

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, thanks.
I fixed to return when the plugin couldn't find by the given identity (such as stage name or plugin name)
58f6e2a

}

func TestPluginRegistry_GetPluginClientsByAppConfig(t *testing.T) {
tests := []struct {
Copy link
Member

Choose a reason for hiding this comment

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

[ASK] Is it possible to add t.Parallel()?

Also in t.Run(tt.name, func(t *testing.T) {.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, added on 1e1bd50

Signed-off-by: Yoshiki Fujikane <[email protected]>
…y (stage name and plugin name)

Signed-off-by: Yoshiki Fujikane <[email protected]>
@ffjlabo ffjlabo enabled auto-merge (squash) January 7, 2025 06:48
@ffjlabo ffjlabo requested review from t-kikuc and Warashi January 7, 2025 06:48
@ffjlabo
Copy link
Member Author

ffjlabo commented Jan 7, 2025

@Warashi Sorry, plz re-approve 🙏

Copy link
Member

@t-kikuc t-kikuc left a comment

Choose a reason for hiding this comment

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

Thank you!

@ffjlabo ffjlabo merged commit 7e0adab into master Jan 7, 2025
18 checks passed
@ffjlabo ffjlabo deleted the add-plugin-registry branch January 7, 2025 07:24
@github-actions github-actions bot mentioned this pull request Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants