fix lint errors
Some checks failed
Lint / golangci-lint (push) Failing after 9m50s
Declarative Tests / test (push) Successful in 1m20s

This commit is contained in:
Matthew Rich 2024-05-14 12:42:28 -07:00
parent 4c1540685d
commit 6df89a7a38
2 changed files with 8 additions and 6 deletions

View File

@ -4,7 +4,7 @@ package resource
import ( import (
"encoding/json" "encoding/json"
_ "fmt" "fmt"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"io" "io"
"log/slog" "log/slog"
@ -122,9 +122,11 @@ func (d *Document) YAML() ([]byte, error) {
return yaml.Marshal(d) 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() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
returnOutput = ""
diffErr = fmt.Errorf("%s", r)
} }
}() }()
slog.Info("Document.Diff()") slog.Info("Document.Diff()")

View File

@ -64,22 +64,22 @@ func StorageMachine(sub machine.Subscriber) machine.Stater {
stater.AddStates("absent", "start_create", "present", "start_delete", "start_read", "start_update") stater.AddStates("absent", "start_create", "present", "start_delete", "start_read", "start_update")
stater.AddTransition("create", "absent", "start_create") stater.AddTransition("create", "absent", "start_create")
if e := stater.AddSubscription("create", sub); e != nil { if e := stater.AddSubscription("create", sub); e != nil {
return nil
} }
stater.AddTransition("created", "start_create", "present") stater.AddTransition("created", "start_create", "present")
stater.AddTransition("read", "*", "start_read") stater.AddTransition("read", "*", "start_read")
if e := stater.AddSubscription("read", sub); e != nil { if e := stater.AddSubscription("read", sub); e != nil {
return nil
} }
stater.AddTransition("state_read", "start_read", "present") stater.AddTransition("state_read", "start_read", "present")
stater.AddTransition("update", "*", "start_update") stater.AddTransition("update", "*", "start_update")
if e := stater.AddSubscription("update", sub); e != nil { if e := stater.AddSubscription("update", sub); e != nil {
return nil
} }
stater.AddTransition("updated", "start_update", "present") stater.AddTransition("updated", "start_update", "present")
stater.AddTransition("delete", "*", "start_delete") stater.AddTransition("delete", "*", "start_delete")
if e := stater.AddSubscription("delete", sub); e != nil { if e := stater.AddSubscription("delete", sub); e != nil {
return nil
} }
stater.AddTransition("deleted", "start_delete", "absent") stater.AddTransition("deleted", "start_delete", "absent")
return stater return stater