From b40723b0b8d482140c5152b22233c1b62ec7838d Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Mon, 11 Mar 2024 23:19:13 +0100 Subject: chore(variables): support integer interpolation for all values --- pkg/permissions.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'pkg/permissions.go') diff --git a/pkg/permissions.go b/pkg/permissions.go index 2bd73a9..3710e68 100644 --- a/pkg/permissions.go +++ b/pkg/permissions.go @@ -37,14 +37,9 @@ func (p *Permissions) resolve(filename string) (Status, error) { } } } - m, ok := p.mode.(*IntValue) - if !ok { - if i, err := strconv.Atoi(p.mode.String()); err != nil { - return BROKEN, err - } else { - m = &IntValue{i} - p.mode = m - } + m, err := p.mode.Int() + if err != nil { + return BROKEN, err } u, ok := p.user.(*IntValue) if !ok { @@ -63,9 +58,9 @@ func (p *Permissions) resolve(filename string) (Status, error) { if fileInfo, err := os.Lstat(filename); err != nil { return BROKEN, err } else { - gv := g.Int() - mv := fs.FileMode(m.Int()) - uv := u.Int() + gv, _ := g.Int() + mv := fs.FileMode(m) + uv, _ := u.Int() if fileInfo.Mode() != mv { if err := os.Chmod(filename, mv); err != nil { return BROKEN, err @@ -82,8 +77,6 @@ func (p *Permissions) resolve(filename string) (Status, error) { } else { return BROKEN, errors.New("Unsupported operating system") } - _ = gv - _ = uv } return status, nil } -- cgit v1.2.3