fix lint errors
This commit is contained in:
parent
068252570e
commit
cf97af96b3
@ -66,8 +66,7 @@ func (d *Declaration) Resource() Resource {
|
|||||||
|
|
||||||
func (d *Declaration) Apply() error {
|
func (d *Declaration) Apply() error {
|
||||||
stater := d.Attributes.StateMachine()
|
stater := d.Attributes.StateMachine()
|
||||||
stater.Trigger(d.Transition)
|
return stater.Trigger(d.Transition)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Declaration) SetURI(uri string) error {
|
func (d *Declaration) SetURI(uri string) error {
|
||||||
|
@ -218,10 +218,7 @@ resources:
|
|||||||
assert.Nil(t, e)
|
assert.Nil(t, e)
|
||||||
|
|
||||||
resources := d.Filter(func(d *Declaration) bool {
|
resources := d.Filter(func(d *Declaration) bool {
|
||||||
if d.Type == "file" {
|
return d.Type == "file"
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
})
|
})
|
||||||
assert.Equal(t, 2, len(resources))
|
assert.Equal(t, 2, len(resources))
|
||||||
}
|
}
|
||||||
|
@ -256,10 +256,7 @@ func (f *ResourceFileInfo) ModTime() time.Time {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *ResourceFileInfo) IsDir() bool {
|
func (f *ResourceFileInfo) IsDir() bool {
|
||||||
if f.resource.FileType == DirectoryFile {
|
return f.resource.FileType == DirectoryFile
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *ResourceFileInfo) Sys() any {
|
func (f *ResourceFileInfo) Sys() any {
|
||||||
|
@ -32,7 +32,7 @@ func TestNewFileNormalized(t *testing.T) {
|
|||||||
absFilePath,_ := filepath.Abs(file)
|
absFilePath,_ := filepath.Abs(file)
|
||||||
f := NewNormalizedFile()
|
f := NewNormalizedFile()
|
||||||
assert.NotNil(t, f)
|
assert.NotNil(t, f)
|
||||||
f.SetURI("file://" + file)
|
assert.Nil(t, f.SetURI("file://" + file))
|
||||||
|
|
||||||
assert.NotEqual(t, file, f.Path)
|
assert.NotEqual(t, file, f.Path)
|
||||||
assert.Equal(t, absFilePath, f.Path)
|
assert.Equal(t, absFilePath, f.Path)
|
||||||
@ -290,7 +290,8 @@ func TestFileResourceFileInfo(t *testing.T) {
|
|||||||
f.State = "present"
|
f.State = "present"
|
||||||
assert.Nil(t, f.Apply())
|
assert.Nil(t, f.Apply())
|
||||||
|
|
||||||
f.Read(context.Background())
|
_, readErr := f.Read(context.Background())
|
||||||
|
assert.Nil(t, readErr)
|
||||||
|
|
||||||
fi := f.FileInfo()
|
fi := f.FileInfo()
|
||||||
assert.Equal(t, os.FileMode(0600), fi.Mode().Perm())
|
assert.Equal(t, os.FileMode(0600), fi.Mode().Perm())
|
||||||
@ -309,7 +310,8 @@ func TestFileClone(t *testing.T) {
|
|||||||
f.State = "present"
|
f.State = "present"
|
||||||
assert.Nil(t, f.Apply())
|
assert.Nil(t, f.Apply())
|
||||||
|
|
||||||
f.Read(ctx)
|
_, readErr := f.Read(ctx)
|
||||||
|
assert.Nil(t, readErr)
|
||||||
|
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
|
||||||
@ -319,7 +321,9 @@ func TestFileClone(t *testing.T) {
|
|||||||
clone.Path = testCloneFile
|
clone.Path = testCloneFile
|
||||||
assert.Nil(t, clone.Apply())
|
assert.Nil(t, clone.Apply())
|
||||||
|
|
||||||
f.Read(ctx)
|
_, readErr := f.Read(ctx)
|
||||||
|
assert.Nil(t, readErr)
|
||||||
|
|
||||||
clone.Read(ctx)
|
clone.Read(ctx)
|
||||||
|
|
||||||
fmt.Printf("file %#v\nclone %#v\n", f, clone)
|
fmt.Printf("file %#v\nclone %#v\n", f, clone)
|
||||||
|
@ -228,7 +228,6 @@ func (u *UserType) NewCRUD() (create *Command, read *Command, update *Command, d
|
|||||||
}
|
}
|
||||||
return NewUserAddCreateCommand(), NewUserReadCommand(), NewUserUpdateCommand(), NewUserDelDeleteCommand()
|
return NewUserAddCreateCommand(), NewUserReadCommand(), NewUserUpdateCommand(), NewUserDelDeleteCommand()
|
||||||
}
|
}
|
||||||
return nil, nil, nil, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserType) UnmarshalValue(value string) error {
|
func (u *UserType) UnmarshalValue(value string) error {
|
||||||
@ -271,12 +270,14 @@ func NewUserAddCreateCommand() *Command {
|
|||||||
}
|
}
|
||||||
c.Extractor = func(out []byte, target any) error {
|
c.Extractor = func(out []byte, target any) error {
|
||||||
return nil
|
return nil
|
||||||
|
/*
|
||||||
for _,line := range strings.Split(string(out), "\n") {
|
for _,line := range strings.Split(string(out), "\n") {
|
||||||
if line == "iptables: Chain already exists." {
|
if line == "iptables: Chain already exists." {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Errorf(string(out))
|
return fmt.Errorf(string(out))
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
@ -295,12 +296,14 @@ func NewAddUserCreateCommand() *Command {
|
|||||||
}
|
}
|
||||||
c.Extractor = func(out []byte, target any) error {
|
c.Extractor = func(out []byte, target any) error {
|
||||||
return nil
|
return nil
|
||||||
|
/*
|
||||||
for _,line := range strings.Split(string(out), "\n") {
|
for _,line := range strings.Split(string(out), "\n") {
|
||||||
if line == "iptables: Chain already exists." {
|
if line == "iptables: Chain already exists." {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Errorf(string(out))
|
return fmt.Errorf(string(out))
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
@ -73,10 +73,7 @@ func (t *Tar) EmitResources(documents []*resource.Document, filter resource.Reso
|
|||||||
|
|
||||||
for _,document := range documents {
|
for _,document := range documents {
|
||||||
for _,res := range document.Filter(func(d *resource.Declaration) bool {
|
for _,res := range document.Filter(func(d *resource.Declaration) bool {
|
||||||
if d.Type == "file" {
|
return d.Type == "file"
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}) {
|
}) {
|
||||||
var f *resource.File = res.Attributes.(*resource.File)
|
var f *resource.File = res.Attributes.(*resource.File)
|
||||||
slog.Info("Tar.EmitResources", "file", f)
|
slog.Info("Tar.EmitResources", "file", f)
|
||||||
|
Loading…
Reference in New Issue
Block a user