diff --git a/internal/resource/container_network.go b/internal/resource/container_network.go index f755a17..fd5bc1c 100644 --- a/internal/resource/container_network.go +++ b/internal/resource/container_network.go @@ -84,16 +84,18 @@ func (n *ContainerNetwork) Notify(m *machine.EventMessage) { case machine.ENTERSTATEEVENT: switch m.Dest { case "start_create": - if e := n.Create(ctx); e != nil { - if triggerErr := n.stater.Trigger("created"); triggerErr != nil { - // transition error + if e := n.Create(ctx); e == nil { + if triggerErr := n.stater.Trigger("created"); triggerErr == nil { + return } - } + } + n.State = "absent" case "present": n.State = "present" } case machine.EXITSTATEEVENT: } + } func (n *ContainerNetwork) URI() string { diff --git a/internal/resource/file.go b/internal/resource/file.go index 9b09ef4..9391e53 100644 --- a/internal/resource/file.go +++ b/internal/resource/file.go @@ -119,11 +119,12 @@ func (f *File) Notify(m *machine.EventMessage) { case machine.ENTERSTATEEVENT: switch m.Dest { case "start_create": - if e := f.Create(ctx); e != nil { - if triggerErr := f.stater.Trigger("created"); triggerErr != nil { - // transition error + if e := f.Create(ctx); e == nil { + if triggerErr := f.stater.Trigger("created"); triggerErr == nil { + return } } + f.State = "absent" case "present": f.State = "present" } diff --git a/internal/resource/http.go b/internal/resource/http.go index cc1a95f..3562746 100644 --- a/internal/resource/http.go +++ b/internal/resource/http.go @@ -70,11 +70,12 @@ func (h *HTTP) Notify(m *machine.EventMessage) { case machine.ENTERSTATEEVENT: switch m.Dest { case "start_create": - if e := h.Create(ctx); e != nil { - if triggerErr := h.stater.Trigger("created"); triggerErr != nil { - // transition error + if e := h.Create(ctx); e == nil { + if triggerErr := h.stater.Trigger("created"); triggerErr == nil { + return } } + h.State = "absent" case "present": h.State = "present" }