Skip to content

Commit

Permalink
feat: add support for extra plugins in cluster provider (#504)
Browse files Browse the repository at this point in the history
* feat: add support for extra plugins in cluster provider

Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com>

* add cluster reset event

Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com>

---------

Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com>
  • Loading branch information
nianyush authored Sep 27, 2024
1 parent bf4c177 commit 541728f
Showing 1 changed file with 11 additions and 4 deletions.
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)
}

0 comments on commit 541728f

Please sign in to comment.