mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-08-25 01:59:11 +00:00
feat: add support for extra plugins in cluster provider (#504)
* 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>
This commit is contained in:
parent
bf4c177d3c
commit
541728fa22
@ -13,6 +13,8 @@ import (
|
|||||||
|
|
||||||
const clusterProviderCloudConfigFile = "/usr/local/cloud-config/cluster.kairos.yaml"
|
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
|
// ClusterProvider returns a yip configuration that configures a Kubernetes engine. The yip config may use any elemental
|
||||||
// stages after initramfs.
|
// stages after initramfs.
|
||||||
type ClusterProvider func(cluster Cluster) yip.YipConfig
|
type ClusterProvider func(cluster Cluster) yip.YipConfig
|
||||||
@ -79,11 +81,16 @@ func (p ClusterPlugin) onBoot(event *pluggable.Event) pluggable.EventResponse {
|
|||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p ClusterPlugin) Run() error {
|
func (p ClusterPlugin) Run(extraPlugins ...pluggable.FactoryPlugin) error {
|
||||||
return pluggable.NewPluginFactory(
|
plugins := []pluggable.FactoryPlugin{
|
||||||
pluggable.FactoryPlugin{
|
{
|
||||||
EventType: bus.EventBoot,
|
EventType: bus.EventBoot,
|
||||||
PluginHandler: p.onBoot,
|
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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user