Skip to content

Commit

Permalink
noop as resource meta param
Browse files Browse the repository at this point in the history
first part of #21
tested with example/noop1.yaml on CentOS 6
  • Loading branch information
Martin Alfke authored and purpleidea committed Oct 5, 2018
1 parent 0966d9e commit effa92c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
24 changes: 24 additions & 0 deletions examples/noop1.yaml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion pgraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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!
Expand Down
1 change: 1 addition & 0 deletions resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit effa92c

Please sign in to comment.