fix lint errors
This commit is contained in:
parent
e3881c7df2
commit
77be7652a5
@ -24,7 +24,7 @@ type CommandArg string
|
|||||||
type Command struct {
|
type Command struct {
|
||||||
Path string `json:"path" yaml:"path"`
|
Path string `json:"path" yaml:"path"`
|
||||||
Args []CommandArg `json:"args" yaml:"args"`
|
Args []CommandArg `json:"args" yaml:"args"`
|
||||||
Split bool `json:"split" yaml:"split`
|
Split bool `json:"split" yaml:"split"`
|
||||||
Executor CommandExecutor `json:"-" yaml:"-"`
|
Executor CommandExecutor `json:"-" yaml:"-"`
|
||||||
Extractor CommandExtractAttributes `json:"-" yaml:"-"`
|
Extractor CommandExtractAttributes `json:"-" yaml:"-"`
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,9 @@ func (n *ContainerNetwork) Notify(m *machine.EventMessage) {
|
|||||||
switch m.Dest {
|
switch m.Dest {
|
||||||
case "start_create":
|
case "start_create":
|
||||||
if e := n.Create(ctx); e != nil {
|
if e := n.Create(ctx); e != nil {
|
||||||
n.stater.Trigger("created")
|
if triggerErr := n.stater.Trigger("created"); triggerErr != nil {
|
||||||
|
// transition error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "present":
|
case "present":
|
||||||
n.State = "present"
|
n.State = "present"
|
||||||
|
@ -129,6 +129,7 @@ func TestDeclarationTransition(t *testing.T) {
|
|||||||
assert.Nil(t, e)
|
assert.Nil(t, e)
|
||||||
assert.Equal(t, TypeName("file"), resourceDeclaration.Type)
|
assert.Equal(t, TypeName("file"), resourceDeclaration.Type)
|
||||||
assert.Equal(t, fileName, resourceDeclaration.Attributes.(*File).Path)
|
assert.Equal(t, fileName, resourceDeclaration.Attributes.(*File).Path)
|
||||||
resourceDeclaration.Apply()
|
err := esourceDeclaration.Apply()
|
||||||
|
assert.Nil(t, err)
|
||||||
assert.FileExists(t, fileName)
|
assert.FileExists(t, fileName)
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,9 @@ func (f *File) Notify(m *machine.EventMessage) {
|
|||||||
switch m.Dest {
|
switch m.Dest {
|
||||||
case "start_create":
|
case "start_create":
|
||||||
if e := f.Create(ctx); e != nil {
|
if e := f.Create(ctx); e != nil {
|
||||||
f.stater.Trigger("created")
|
if triggerErr := f.stater.Trigger("created"); triggerErr != nil {
|
||||||
|
// transition error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "present":
|
case "present":
|
||||||
f.State = "present"
|
f.State = "present"
|
||||||
|
@ -71,7 +71,9 @@ func (h *HTTP) Notify(m *machine.EventMessage) {
|
|||||||
switch m.Dest {
|
switch m.Dest {
|
||||||
case "start_create":
|
case "start_create":
|
||||||
if e := h.Create(ctx); e != nil {
|
if e := h.Create(ctx); e != nil {
|
||||||
h.stater.Trigger("created")
|
if triggerErr := h.stater.Trigger("created"); triggerErr != nil {
|
||||||
|
// transition error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "present":
|
case "present":
|
||||||
h.State = "present"
|
h.State = "present"
|
||||||
|
@ -165,7 +165,9 @@ func (i *Iptable) Notify(m *machine.EventMessage) {
|
|||||||
switch m.Dest {
|
switch m.Dest {
|
||||||
case "start_create":
|
case "start_create":
|
||||||
if e := i.Create(ctx); e != nil {
|
if e := i.Create(ctx); e != nil {
|
||||||
i.stater.Trigger("created")
|
if triggerErr := i.stater.Trigger("created"); triggerErr != nil {
|
||||||
|
// transition error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "present":
|
case "present":
|
||||||
i.State = "present"
|
i.State = "present"
|
||||||
|
@ -154,7 +154,9 @@ func (n *NetworkRoute) Notify(m *machine.EventMessage) {
|
|||||||
switch m.Dest {
|
switch m.Dest {
|
||||||
case "start_create":
|
case "start_create":
|
||||||
if e := n.Create(ctx); e != nil {
|
if e := n.Create(ctx); e != nil {
|
||||||
n.stater.Trigger("created")
|
if triggerErr := n.stater.Trigger("created"); triggerErr != nil {
|
||||||
|
// transition error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "present":
|
case "present":
|
||||||
n.State = "present"
|
n.State = "present"
|
||||||
|
@ -110,7 +110,9 @@ func (p *Package) Notify(m *machine.EventMessage) {
|
|||||||
switch m.Dest {
|
switch m.Dest {
|
||||||
case "start_create":
|
case "start_create":
|
||||||
if e := p.Create(ctx); e != nil {
|
if e := p.Create(ctx); e != nil {
|
||||||
p.stater.Trigger("created")
|
if triggerErr := p.stater.Trigger("created"); triggerErr != nil {
|
||||||
|
// transition error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "present":
|
case "present":
|
||||||
p.State = "present"
|
p.State = "present"
|
||||||
|
@ -63,16 +63,24 @@ func StorageMachine(sub machine.Subscriber) machine.Stater {
|
|||||||
stater := machine.New("absent")
|
stater := machine.New("absent")
|
||||||
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")
|
||||||
stater.AddSubscription("create", sub)
|
if e := stater.AddSubscription("create", sub); e != nil {
|
||||||
|
|
||||||
|
}
|
||||||
stater.AddTransition("created", "start_create", "present")
|
stater.AddTransition("created", "start_create", "present")
|
||||||
stater.AddTransition("read", "*", "start_read")
|
stater.AddTransition("read", "*", "start_read")
|
||||||
stater.AddSubscription("read", sub)
|
if e := stater.AddSubscription("read", sub); e != 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")
|
||||||
stater.AddSubscription("update", sub)
|
if e := stater.AddSubscription("update", sub); e != nil {
|
||||||
|
|
||||||
|
}
|
||||||
stater.AddTransition("updated", "start_update", "present")
|
stater.AddTransition("updated", "start_update", "present")
|
||||||
stater.AddTransition("delete", "*", "start_delete")
|
stater.AddTransition("delete", "*", "start_delete")
|
||||||
stater.AddSubscription("delete", sub)
|
if e := stater.AddSubscription("delete", sub); e != nil {
|
||||||
|
|
||||||
|
}
|
||||||
stater.AddTransition("deleted", "start_delete", "absent")
|
stater.AddTransition("deleted", "start_delete", "absent")
|
||||||
return stater
|
return stater
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,9 @@ func (u *User) Notify(m *machine.EventMessage) {
|
|||||||
switch m.Dest {
|
switch m.Dest {
|
||||||
case "start_create":
|
case "start_create":
|
||||||
if e := u.Create(ctx); e != nil {
|
if e := u.Create(ctx); e != nil {
|
||||||
u.stater.Trigger("created")
|
if triggerErr := u.stater.Trigger("created"); triggerErr != nil {
|
||||||
|
// transition error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "present":
|
case "present":
|
||||||
u.State = "present"
|
u.State = "present"
|
||||||
|
@ -44,7 +44,9 @@ func NewFileDocTarget(u *url.URL, format string, gzip bool, fileUri bool) DocTar
|
|||||||
} else {
|
} else {
|
||||||
t.Path = filepath.Join(u.Hostname(), u.Path)
|
t.Path = filepath.Join(u.Hostname(), u.Path)
|
||||||
}
|
}
|
||||||
t.Open()
|
if e := t.Open(); e != nil {
|
||||||
|
// open target
|
||||||
|
}
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +69,9 @@ func init() {
|
|||||||
t.Format = FormatJson
|
t.Format = FormatJson
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.Open()
|
if e := t.Open(); e != nil {
|
||||||
|
// open target
|
||||||
|
}
|
||||||
return t
|
return t
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -34,7 +34,9 @@ func init() {
|
|||||||
TargetTypes.Register([]string{"tar"}, func(u *url.URL) DocTarget {
|
TargetTypes.Register([]string{"tar"}, func(u *url.URL) DocTarget {
|
||||||
t := NewTar()
|
t := NewTar()
|
||||||
t.Path,_ = filepath.Abs(filepath.Join(u.Hostname(), u.Path))
|
t.Path,_ = filepath.Abs(filepath.Join(u.Hostname(), u.Path))
|
||||||
t.Open()
|
if e := t.Open(); e != nil {
|
||||||
|
|
||||||
|
}
|
||||||
return t
|
return t
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -47,7 +49,9 @@ func init() {
|
|||||||
t.Path = filepath.Join(u.Hostname(), u.Path)
|
t.Path = filepath.Join(u.Hostname(), u.Path)
|
||||||
}
|
}
|
||||||
t.Gzip = true
|
t.Gzip = true
|
||||||
t.Open()
|
if e := t.Open(); e != nil {
|
||||||
|
|
||||||
|
}
|
||||||
return t
|
return t
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user