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

feat: add support for extra plugins in cluster provider #504

Merged
merged 5 commits into from
Sep 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions clusterplugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (

const clusterProviderCloudConfigFile = "/usr/local/cloud-config/cluster.kairos.yaml"

const EventClusterReset pluggable.EventType = "cluster.reset"

// ClusterProvider returns a yip configuration that configures a Kubernetes engine. The yip config may use any elemental
// stages after initramfs.
type ClusterProvider func(cluster Cluster) yip.YipConfig
Expand Down Expand Up @@ -79,11 +81,16 @@ func (p ClusterPlugin) onBoot(event *pluggable.Event) pluggable.EventResponse {
return response
}

func (p ClusterPlugin) Run() error {
return pluggable.NewPluginFactory(
pluggable.FactoryPlugin{
func (p ClusterPlugin) Run(extraPlugins ...pluggable.FactoryPlugin) error {
plugins := []pluggable.FactoryPlugin{
{
EventType: bus.EventBoot,
PluginHandler: p.onBoot,
},
).Run(pluggable.EventType(os.Args[1]), os.Stdin, os.Stdout)
}
plugins = append(plugins, extraPlugins...)

f := pluggable.NewPluginFactory(plugins...)

return f.Run(pluggable.EventType(os.Args[1]), os.Stdin, os.Stdout)
}