From 6bbce039aa6ac7b1fa9ea617663e7ad6b5a5cffa Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Sat, 14 May 2016 21:30:54 +0200 Subject: [PATCH] noop as resource meta param first part of #21 tested with example/noop1.yaml on CentOS 6 --- examples/noop1.yaml | 24 ++++++++++++++++++++++++ pgraph.go | 7 ++++++- resources.go | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 examples/noop1.yaml diff --git a/examples/noop1.yaml b/examples/noop1.yaml new file mode 100644 index 00000000..1a105dc6 --- /dev/null +++ b/examples/noop1.yaml @@ -0,0 +1,24 @@ +--- +graph: mygraph +comment: noop example +resources: + noop: + - name: noop1 + meta: + noop: true + file: + - name: file1 + path: "/tmp/mgmt-hello-noop" + content: | + hello world from @purpleidea + state: exists + meta: + noop: true +edges: +- name: e1 + from: + kind: noop + name: noop1 + to: + kind: file + name: file1 diff --git a/pgraph.go b/pgraph.go index a97bd1b0..6eb98c7e 100644 --- a/pgraph.go +++ b/pgraph.go @@ -729,7 +729,7 @@ func (g *Graph) Process(v *Vertex) { obj.SetState(resStateCheckApply) // if this fails, don't UpdateTimestamp() - checkok, err := obj.CheckApply(true) + checkok, err := obj.CheckApply(!obj.GetMeta().Noop) if checkok && err != nil { // should never return this way log.Fatalf("%v[%v]: CheckApply(): %t, %+v", obj.Kind(), obj.GetName(), checkok, err) } @@ -745,6 +745,11 @@ func (g *Graph) Process(v *Vertex) { } } + // when noop is true we always want to update timestamp + if obj.GetMeta().Noop && err == nil { + ok = true + } + if ok { // update this timestamp *before* we poke or the poked // nodes might fail due to having a too old timestamp! diff --git a/resources.go b/resources.go index b3b57d86..a1d7131f 100644 --- a/resources.go +++ b/resources.go @@ -60,6 +60,7 @@ type AutoEdge interface { type MetaParams struct { AutoEdge bool `yaml:"autoedge"` // metaparam, should we generate auto edges? // XXX should default to true AutoGroup bool `yaml:"autogroup"` // metaparam, should we auto group? // XXX should default to true + Noop bool `yaml:"noop"` } // this interface is everything that is common to all resources