diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c897f6d..ba0dbe06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ ## Changelog +### [13.3.2](https://kaos.sh/ek/13.3.2) + +- `[support/apps]` Added support for Docker, Podman, and LXC +- `[rand]` Removed method `Int` +- `[rand]` Code refactoring + ### [13.3.1](https://kaos.sh/ek/13.3.1) - `[cache]` Added constants with duration diff --git a/cache/fs/fs.go b/cache/fs/fs.go index b2083e7a..549fbc47 100644 --- a/cache/fs/fs.go +++ b/cache/fs/fs.go @@ -271,6 +271,14 @@ func (c Config) Validate() error { // ////////////////////////////////////////////////////////////////////////////////// // +// func encodeItem(item any) ([]byte, error) { +// return nil, nil +// } + +// func decodeItem() ([]byte, error) { +// return nil, nil +// } + // getItemPath returns path to cache item func (c *Cache) getItemPath(key string, temporary bool) string { if temporary { diff --git a/go.mod b/go.mod index 51fab7a0..0852eac9 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,13 @@ module github.com/essentialkaos/ek/v13 -go 1.18 +go 1.21 require ( github.com/essentialkaos/check v1.4.0 github.com/essentialkaos/depsy v1.3.0 github.com/essentialkaos/go-linenoise/v3 v3.6.0 - golang.org/x/crypto v0.25.0 - golang.org/x/sys v0.22.0 + golang.org/x/crypto v0.26.0 + golang.org/x/sys v0.24.0 ) require ( diff --git a/go.sum b/go.sum index b0ed1b35..df0bdc87 100644 --- a/go.sum +++ b/go.sum @@ -13,7 +13,7 @@ github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsK github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/rand/rand.go b/rand/rand.go index 2b2d053f..88a3993a 100644 --- a/rand/rand.go +++ b/rand/rand.go @@ -25,35 +25,29 @@ func String(length int) string { return "" } + rnd := rand.New(rand.NewSource(time.Now().UTC().UnixNano())) symbolsLength := len(symbols) result := make([]byte, length) - rand.Seed(time.Now().UTC().UnixNano()) - for i := 0; i < length; i++ { - result[i] = symbols[rand.Intn(symbolsLength)] + result[i] = symbols[rnd.Intn(symbolsLength)] } return string(result) } -// Int returns random int -func Int(n int) int { - rand.Seed(time.Now().UTC().UnixNano()) - return rand.Intn(n) -} - // Slice returns slice with random chars func Slice(length int) []string { if length == 0 { return []string{} } + rnd := rand.New(rand.NewSource(time.Now().UTC().UnixNano())) symbolsLength := len(symbols) result := make([]string, length) for i := 0; i < length; i++ { - result[i] = string(symbols[rand.Intn(symbolsLength)]) + result[i] = string(symbols[rnd.Intn(symbolsLength)]) } return result diff --git a/rand/rand_test.go b/rand/rand_test.go index 0c0eb000..6dfcd24b 100644 --- a/rand/rand_test.go +++ b/rand/rand_test.go @@ -33,17 +33,6 @@ func (s *RandSuite) TestString(c *C) { c.Assert(len(String(-100)), Equals, 0) } -func (s *RandSuite) TestInt(c *C) { - n := 1000 - k := 0 - - for i := 0; i < 1000; i++ { - k += Int(n) - } - - c.Assert(k/n, Not(Equals), n) -} - func (s *RandSuite) TestSlice(c *C) { t1 := strings.Join(Slice(256), "") t2 := strings.Join(Slice(256), "") diff --git a/support/apps/apps.go b/support/apps/apps.go index 00cf2424..779afa06 100644 --- a/support/apps/apps.go +++ b/support/apps/apps.go @@ -116,6 +116,24 @@ func SVN() support.App { return support.App{"svn", ver} } +// Docker extracts version info from Docker command output +func Docker() support.App { + ver := extractField(execVersionCmd("docker", "--version"), 0, 2) + return support.App{"docker", ver} +} + +// Podman extracts version info from Podman command output +func Podman() support.App { + ver := extractField(execVersionCmd("podman", "--version"), 0, 2) + return support.App{"podman", ver} +} + +// LXC extracts version info from LXC command output +func LXC() support.App { + ver := extractField(execVersionCmd("lxc", "--version"), 0, 0) + return support.App{"lxc", ver} +} + // ////////////////////////////////////////////////////////////////////////////////// // // execVersionCmd execs command and returns output as a string diff --git a/version.go b/version.go index 065e0a4b..feb300e1 100644 --- a/version.go +++ b/version.go @@ -8,4 +8,4 @@ package ek // ////////////////////////////////////////////////////////////////////////////////// // // VERSION is current ek package version -const VERSION = "13.3.1" +const VERSION = "13.3.2"