Skip to content

Commit

Permalink
Merge pull request #22 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 1.5.0
  • Loading branch information
andyone authored Oct 19, 2019
2 parents a546d38 + e1a51cf commit 9885f72
Show file tree
Hide file tree
Showing 19 changed files with 71 additions and 69 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ before_install:
- ./shellcheck-latest/shellcheck --version
- ./hadolint --version
- make deps deps-test
- go get -v github.com/mattn/goveralls
- npm install -g codeclimate-test-reporter

script:
- make all
- go test -covermode=count ./parser ./recipe -coverprofile=coverage.out
- goveralls -service travis-ci -repotoken $COVERALLS_TOKEN -coverprofile coverage.out
- codeclimate-test-reporter < coverage.out
- bash -c 'shopt -s globstar; ./shellcheck-latest/shellcheck bibop-docker'
- bash -c 'shopt -s globstar; ./shellcheck-latest/shellcheck bibop-entrypoint'
Expand Down
12 changes: 6 additions & 6 deletions COOKBOOK.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* [`output-trim`](#output-trim)
* [Filesystem](#filesystem)
* [`chdir`](#chdir)
* [`perms`](#perms)
* [`mode`](#mode)
* [`owner`](#owner)
* [`exist`](#exist)
* [`readable`](#readable)
Expand Down Expand Up @@ -225,7 +225,7 @@ command "postgres:echo 'ABCD'" "Simple echo command as postgres user"
command "-" "Check configuration files"
exist "/etc/myapp.conf"
owner "/etc/myapp.conf" "root"
perms "/etc/myapp.conf" 644
mode "/etc/myapp.conf" 644
```

Expand Down Expand Up @@ -487,11 +487,11 @@ command "-" "Check environment"

<br/>

##### `perms`
##### `mode`

Checks file or directory permissions.
Checks file or directory mode bits.

**Syntax:** `perms <path> <mode>`
**Syntax:** `mode <path> <mode>`

**Arguments:**

Expand All @@ -504,7 +504,7 @@ Checks file or directory permissions.

```yang
command "-" "Check environment"
perms "/home/user/file.log" 644
mode "/home/user/file.log" 644
```

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################

# This Makefile generated by GoMakeGen 1.1.0 using next command:
# This Makefile generated by GoMakeGen 1.2.0 using next command:
# gomakegen .
#
# More info: https://kaos.sh/gomakegen
Expand All @@ -27,7 +27,7 @@ git-config: ## Configure git redirects for stable import path services
git config --global http.https://pkg.re.followRedirects true

deps: git-config ## Download dependencies
go get -d -v pkg.re/essentialkaos/ek.v10
go get -d -v pkg.re/essentialkaos/ek.v11

deps-test: git-config ## Download dependencies for tests
go get -d -v pkg.re/check.v1
Expand All @@ -50,6 +50,6 @@ help: ## Show this info
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[33m%-12s\033[0m %s\n", $$1, $$2}'
@echo -e ''
@echo -e '\033[90mGenerated by GoMakeGen 1.1.0\033[0m\n'
@echo -e '\033[90mGenerated by GoMakeGen 1.2.0\033[0m\n'

################################################################################
2 changes: 1 addition & 1 deletion action/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"hash/crc32"
"os"

"pkg.re/essentialkaos/ek.v10/fsutil"
"pkg.re/essentialkaos/ek.v11/fsutil"

"github.com/essentialkaos/bibop/recipe"
)
Expand Down
2 changes: 1 addition & 1 deletion action/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"syscall"
"time"

"pkg.re/essentialkaos/ek.v10/mathutil"
"pkg.re/essentialkaos/ek.v11/mathutil"

"github.com/essentialkaos/bibop/recipe"
)
Expand Down
26 changes: 13 additions & 13 deletions action/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"os"
"strconv"

"pkg.re/essentialkaos/ek.v10/fsutil"
"pkg.re/essentialkaos/ek.v10/hash"
"pkg.re/essentialkaos/ek.v10/strutil"
"pkg.re/essentialkaos/ek.v10/system"
"pkg.re/essentialkaos/ek.v11/fsutil"
"pkg.re/essentialkaos/ek.v11/hash"
"pkg.re/essentialkaos/ek.v11/strutil"
"pkg.re/essentialkaos/ek.v11/system"

"github.com/essentialkaos/bibop/recipe"
)
Expand All @@ -41,28 +41,28 @@ func Chdir(action *recipe.Action) error {
return nil
}

// Perms is action processor for "perms"
func Perms(action *recipe.Action) error {
// Mode is action processor for "mode"
func Mode(action *recipe.Action) error {
file, err := action.GetS(0)

if err != nil {
return err
}

perms, err := action.GetS(1)
mode, err := action.GetS(1)

if err != nil {
return err
}

filePerms := fsutil.GetPerms(file)
filePermsStr := strconv.FormatUint(uint64(filePerms), 8)
fileMode := fsutil.GetMode(file)
fileModeStr := strconv.FormatUint(uint64(fileMode), 8)

switch {
case !action.Negative && perms != filePermsStr:
return fmt.Errorf("File %s has invalid permissions (%s ≠ %s)", file, filePermsStr, perms)
case action.Negative && perms == filePermsStr:
return fmt.Errorf("File %s has invalid permissions (%s)", file, filePermsStr)
case !action.Negative && mode != fileModeStr:
return fmt.Errorf("File %s has invalid mode (%s ≠ %s)", file, fileModeStr, mode)
case action.Negative && mode == fileModeStr:
return fmt.Errorf("File %s has invalid mode (%s)", file, fileModeStr)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions action/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"fmt"
"strings"

"pkg.re/essentialkaos/ek.v10/req"
"pkg.re/essentialkaos/ek.v10/strutil"
"pkg.re/essentialkaos/ek.v11/req"
"pkg.re/essentialkaos/ek.v11/strutil"

"github.com/essentialkaos/bibop/recipe"
)
Expand Down
2 changes: 1 addition & 1 deletion action/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"strings"
"time"

"pkg.re/essentialkaos/ek.v10/mathutil"
"pkg.re/essentialkaos/ek.v11/mathutil"

"github.com/essentialkaos/bibop/output"
"github.com/essentialkaos/bibop/recipe"
Expand Down
4 changes: 2 additions & 2 deletions action/libs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"path/filepath"
"strings"

"pkg.re/essentialkaos/ek.v10/fsutil"
"pkg.re/essentialkaos/ek.v10/strutil"
"pkg.re/essentialkaos/ek.v11/fsutil"
"pkg.re/essentialkaos/ek.v11/strutil"

"github.com/essentialkaos/bibop/recipe"
)
Expand Down
2 changes: 1 addition & 1 deletion action/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package action
import (
"fmt"

"pkg.re/essentialkaos/ek.v10/initsystem"
"pkg.re/essentialkaos/ek.v11/initsystem"

"github.com/essentialkaos/bibop/recipe"
)
Expand Down
6 changes: 3 additions & 3 deletions action/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import (
"strings"
"time"

"pkg.re/essentialkaos/ek.v10/env"
"pkg.re/essentialkaos/ek.v10/fsutil"
"pkg.re/essentialkaos/ek.v10/mathutil"
"pkg.re/essentialkaos/ek.v11/env"
"pkg.re/essentialkaos/ek.v11/fsutil"
"pkg.re/essentialkaos/ek.v11/mathutil"

"github.com/essentialkaos/bibop/recipe"
)
Expand Down
2 changes: 1 addition & 1 deletion action/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package action
import (
"fmt"

"pkg.re/essentialkaos/ek.v10/system"
"pkg.re/essentialkaos/ek.v11/system"

"github.com/essentialkaos/bibop/recipe"
)
Expand Down
22 changes: 11 additions & 11 deletions cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ import (
"os"
"path/filepath"

"pkg.re/essentialkaos/ek.v10/fmtc"
"pkg.re/essentialkaos/ek.v10/fmtutil"
"pkg.re/essentialkaos/ek.v10/fsutil"
"pkg.re/essentialkaos/ek.v10/options"
"pkg.re/essentialkaos/ek.v10/strutil"
"pkg.re/essentialkaos/ek.v10/usage"
"pkg.re/essentialkaos/ek.v10/usage/completion/bash"
"pkg.re/essentialkaos/ek.v10/usage/completion/fish"
"pkg.re/essentialkaos/ek.v10/usage/completion/zsh"
"pkg.re/essentialkaos/ek.v10/usage/update"
"pkg.re/essentialkaos/ek.v11/fmtc"
"pkg.re/essentialkaos/ek.v11/fmtutil"
"pkg.re/essentialkaos/ek.v11/fsutil"
"pkg.re/essentialkaos/ek.v11/options"
"pkg.re/essentialkaos/ek.v11/strutil"
"pkg.re/essentialkaos/ek.v11/usage"
"pkg.re/essentialkaos/ek.v11/usage/completion/bash"
"pkg.re/essentialkaos/ek.v11/usage/completion/fish"
"pkg.re/essentialkaos/ek.v11/usage/completion/zsh"
"pkg.re/essentialkaos/ek.v11/usage/update"

"github.com/essentialkaos/bibop/cli/executor"
"github.com/essentialkaos/bibop/parser"
Expand All @@ -33,7 +33,7 @@ import (
// Application info
const (
APP = "bibop"
VER = "1.4.1"
VER = "1.5.0"
DESC = "Utility for testing command-line tools"
)

Expand Down
24 changes: 12 additions & 12 deletions cli/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ import (
"strings"
"time"

"pkg.re/essentialkaos/ek.v10/errutil"
"pkg.re/essentialkaos/ek.v10/fmtc"
"pkg.re/essentialkaos/ek.v10/fmtutil"
"pkg.re/essentialkaos/ek.v10/fsutil"
"pkg.re/essentialkaos/ek.v10/log"
"pkg.re/essentialkaos/ek.v10/passwd"
"pkg.re/essentialkaos/ek.v10/sliceutil"
"pkg.re/essentialkaos/ek.v10/strutil"
"pkg.re/essentialkaos/ek.v10/system"
"pkg.re/essentialkaos/ek.v10/terminal/window"
"pkg.re/essentialkaos/ek.v10/tmp"
"pkg.re/essentialkaos/ek.v11/errutil"
"pkg.re/essentialkaos/ek.v11/fmtc"
"pkg.re/essentialkaos/ek.v11/fmtutil"
"pkg.re/essentialkaos/ek.v11/fsutil"
"pkg.re/essentialkaos/ek.v11/log"
"pkg.re/essentialkaos/ek.v11/passwd"
"pkg.re/essentialkaos/ek.v11/sliceutil"
"pkg.re/essentialkaos/ek.v11/strutil"
"pkg.re/essentialkaos/ek.v11/system"
"pkg.re/essentialkaos/ek.v11/terminal/window"
"pkg.re/essentialkaos/ek.v11/tmp"

"github.com/essentialkaos/bibop/action"
"github.com/essentialkaos/bibop/output"
Expand Down Expand Up @@ -69,7 +69,7 @@ type ValidationConfig struct {
var handlers = map[string]action.Handler{
recipe.ACTION_WAIT: action.Wait,
recipe.ACTION_CHDIR: action.Chdir,
recipe.ACTION_PERMS: action.Perms,
recipe.ACTION_MODE: action.Mode,
recipe.ACTION_OWNER: action.Owner,
recipe.ACTION_EXIST: action.Exist,
recipe.ACTION_READABLE: action.Readable,
Expand Down
8 changes: 4 additions & 4 deletions cli/executor/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"regexp"
"strings"

"pkg.re/essentialkaos/ek.v10/fsutil"
"pkg.re/essentialkaos/ek.v10/sliceutil"
"pkg.re/essentialkaos/ek.v10/strutil"
"pkg.re/essentialkaos/ek.v10/system"
"pkg.re/essentialkaos/ek.v11/fsutil"
"pkg.re/essentialkaos/ek.v11/sliceutil"
"pkg.re/essentialkaos/ek.v11/strutil"
"pkg.re/essentialkaos/ek.v11/system"

"github.com/essentialkaos/bibop/recipe"
)
Expand Down
4 changes: 2 additions & 2 deletions parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"regexp"
"strings"

"pkg.re/essentialkaos/ek.v10/fsutil"
"pkg.re/essentialkaos/ek.v10/strutil"
"pkg.re/essentialkaos/ek.v11/fsutil"
"pkg.re/essentialkaos/ek.v11/strutil"

"github.com/essentialkaos/bibop/recipe"
)
Expand Down
2 changes: 1 addition & 1 deletion recipe/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strconv"
"strings"

"pkg.re/essentialkaos/ek.v10/strutil"
"pkg.re/essentialkaos/ek.v11/strutil"
)

// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
6 changes: 3 additions & 3 deletions recipe/runtime_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"strconv"
"time"

"pkg.re/essentialkaos/ek.v10/fsutil"
"pkg.re/essentialkaos/ek.v10/netutil"
"pkg.re/essentialkaos/ek.v10/system"
"pkg.re/essentialkaos/ek.v11/fsutil"
"pkg.re/essentialkaos/ek.v11/netutil"
"pkg.re/essentialkaos/ek.v11/system"
)

// ////////////////////////////////////////////////////////////////////////////////// //
Expand Down
4 changes: 2 additions & 2 deletions recipe/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
ACTION_OUTPUT_TRIM = "output-trim"
ACTION_PRINT = "print"
ACTION_CHDIR = "chdir"
ACTION_PERMS = "perms"
ACTION_MODE = "mode"
ACTION_OWNER = "owner"
ACTION_EXIST = "exist"
ACTION_READABLE = "readable"
Expand Down Expand Up @@ -109,7 +109,7 @@ var Tokens = []TokenInfo{
{ACTION_PRINT, 1, 1, false, false},

{ACTION_CHDIR, 1, 1, false, false},
{ACTION_PERMS, 2, 2, false, true},
{ACTION_MODE, 2, 2, false, true},
{ACTION_OWNER, 2, 2, false, true},
{ACTION_EXIST, 1, 1, false, true},
{ACTION_READABLE, 2, 2, false, true},
Expand Down

0 comments on commit 9885f72

Please sign in to comment.