mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-10-20 10:38:34 +00:00
fix: dont try to unmarshal into JSON if data is empty (#996)
This commit is contained in:
@@ -35,8 +35,10 @@ func runCustomizationPlugins() ([]YAMLPrompt, error) {
|
||||
var r []YAMLPrompt
|
||||
|
||||
bus.Manager.Response(sdk.EventInteractiveInstall, func(p *pluggable.Plugin, resp *pluggable.EventResponse) {
|
||||
err := json.Unmarshal([]byte(resp.Data), &r)
|
||||
if err != nil {
|
||||
if resp.Data == "" {
|
||||
return
|
||||
}
|
||||
if err := json.Unmarshal([]byte(resp.Data), &r); err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
})
|
||||
|
@@ -96,6 +96,9 @@ func Install(sourceImgURL string, dir ...string) error {
|
||||
})
|
||||
|
||||
bus.Manager.Response(events.EventInstall, func(p *pluggable.Plugin, resp *pluggable.EventResponse) {
|
||||
if resp.Data == "" {
|
||||
return
|
||||
}
|
||||
err := json.Unmarshal([]byte(resp.Data), &r)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
@@ -139,6 +139,9 @@ func sharedReset(reboot, unattended, resetOem bool, dir ...string) (c *config.Co
|
||||
// This gets the options from an event that can be sent by anyone.
|
||||
// This should override the default config as it's much more dynamic
|
||||
bus.Manager.Response(sdk.EventBeforeReset, func(p *pluggable.Plugin, r *pluggable.EventResponse) {
|
||||
if r.Data == "" {
|
||||
return
|
||||
}
|
||||
err := json.Unmarshal([]byte(r.Data), &optionsFromEvent)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
|
Reference in New Issue
Block a user