From c665902e1904b20e90dd57a2000d5701388d7be2 Mon Sep 17 00:00:00 2001 From: Nianyu Shen Date: Thu, 26 Sep 2024 11:29:23 -0700 Subject: [PATCH 1/2] feat: add support for extra plugins in cluster provider Signed-off-by: Nianyu Shen --- clusterplugin/plugin.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/clusterplugin/plugin.go b/clusterplugin/plugin.go index a3c62cb1..4bba5389 100644 --- a/clusterplugin/plugin.go +++ b/clusterplugin/plugin.go @@ -79,11 +79,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) } From 68e1ddda4d2d3064d09b35339890aa6f6df35468 Mon Sep 17 00:00:00 2001 From: Nianyu Shen Date: Thu, 26 Sep 2024 11:35:10 -0700 Subject: [PATCH 2/2] add cluster reset event Signed-off-by: Nianyu Shen --- clusterplugin/plugin.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/clusterplugin/plugin.go b/clusterplugin/plugin.go index 4bba5389..b95997a3 100644 --- a/clusterplugin/plugin.go +++ b/clusterplugin/plugin.go @@ -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