diff --git a/internal/resource/document.go b/internal/resource/document.go index 70f21b2..e3a539c 100644 --- a/internal/resource/document.go +++ b/internal/resource/document.go @@ -4,7 +4,7 @@ package resource import ( "encoding/json" -_ "fmt" + "fmt" "gopkg.in/yaml.v3" "io" "log/slog" @@ -122,9 +122,11 @@ func (d *Document) YAML() ([]byte, error) { return yaml.Marshal(d) } -func (d *Document) Diff(with *Document, output io.Writer) (string, error) { +func (d *Document) Diff(with *Document, output io.Writer) (returnOutput string, diffErr error) { defer func() { if r := recover(); r != nil { + returnOutput = "" + diffErr = fmt.Errorf("%s", r) } }() slog.Info("Document.Diff()") diff --git a/internal/resource/resource.go b/internal/resource/resource.go index a674321..f0042b6 100644 --- a/internal/resource/resource.go +++ b/internal/resource/resource.go @@ -64,22 +64,22 @@ func StorageMachine(sub machine.Subscriber) machine.Stater { stater.AddStates("absent", "start_create", "present", "start_delete", "start_read", "start_update") stater.AddTransition("create", "absent", "start_create") if e := stater.AddSubscription("create", sub); e != nil { - + return nil } stater.AddTransition("created", "start_create", "present") stater.AddTransition("read", "*", "start_read") if e := stater.AddSubscription("read", sub); e != nil { - + return nil } stater.AddTransition("state_read", "start_read", "present") stater.AddTransition("update", "*", "start_update") if e := stater.AddSubscription("update", sub); e != nil { - + return nil } stater.AddTransition("updated", "start_update", "present") stater.AddTransition("delete", "*", "start_delete") if e := stater.AddSubscription("delete", sub); e != nil { - + return nil } stater.AddTransition("deleted", "start_delete", "absent") return stater