From 6d816a17bcad33738e1b5a00b1b11361c4468eb5 Mon Sep 17 00:00:00 2001 From: Matthew Rich Date: Mon, 13 May 2024 11:07:31 -0700 Subject: [PATCH] fix lint errors --- internal/resource/iptables.go | 7 ++++--- internal/resource/network_route.go | 7 ++++--- internal/resource/package.go | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/internal/resource/iptables.go b/internal/resource/iptables.go index 89104af..1ce7230 100644 --- a/internal/resource/iptables.go +++ b/internal/resource/iptables.go @@ -164,11 +164,12 @@ func (i *Iptable) Notify(m *machine.EventMessage) { case machine.ENTERSTATEEVENT: switch m.Dest { case "start_create": - if e := i.Create(ctx); e != nil { - if triggerErr := i.stater.Trigger("created"); triggerErr != nil { - // transition error + if e := i.Create(ctx); e == nil { + if triggerErr := i.stater.Trigger("created"); triggerErr == nil { + return } } + i.State = "absent" case "present": i.State = "present" } diff --git a/internal/resource/network_route.go b/internal/resource/network_route.go index d1bb95f..8030f8a 100644 --- a/internal/resource/network_route.go +++ b/internal/resource/network_route.go @@ -153,11 +153,12 @@ func (n *NetworkRoute) 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" } diff --git a/internal/resource/package.go b/internal/resource/package.go index 14beda1..299a231 100644 --- a/internal/resource/package.go +++ b/internal/resource/package.go @@ -109,11 +109,12 @@ func (p *Package) Notify(m *machine.EventMessage) { case machine.ENTERSTATEEVENT: switch m.Dest { case "start_create": - if e := p.Create(ctx); e != nil { - if triggerErr := p.stater.Trigger("created"); triggerErr != nil { - // transition error + if e := p.Create(ctx); e == nil { + if triggerErr := p.stater.Trigger("created"); triggerErr == nil { + return } } + p.State = "absent" case "present": p.State = "present" }